KiCad PCB EDA Suite
Loading...
Searching...
No Matches
BITMAP_BUTTON Class Reference

A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn. More...

#include <bitmap_button.h>

Inheritance diagram for BITMAP_BUTTON:

Public Member Functions

 BITMAP_BUTTON (wxWindow *aParent, wxWindowID aId, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, int aStyles=wxBORDER_NONE|wxTAB_TRAVERSAL)
 
 BITMAP_BUTTON (wxWindow *aParent, wxWindowID aId, const wxBitmap &aDummyBitmap, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, int aStyles=wxBORDER_NONE|wxTAB_TRAVERSAL)
 
 ~BITMAP_BUTTON ()
 
void SetPadding (int aPadding)
 Set the amount of padding present on each side of the bitmap.
 
void SetBitmap (const wxBitmapBundle &aBmp)
 Set the bitmap shown when the button is enabled.
 
void SetDisabledBitmap (const wxBitmapBundle &aBmp)
 Set the bitmap shown when the button is disabled.
 
bool Enable (bool aEnable=true) override
 Enable the button.
 
void SetIsCheckButton ()
 Setup the control as a two-state button (checked or unchecked).
 
void SetIsRadioButton ()
 
void Check (bool aCheck=true)
 Check the control.
 
bool IsChecked () const
 
void SetIsSeparator ()
 Render button as a toolbar separator.
 
void AcceptDragInAsClick (bool aAcceptDragIn=true)
 Accept mouse-up as click even if mouse-down happened outside of the control.
 
void SetShowBadge (bool aShowBadge)
 
void SetBadgeText (const wxString &aText)
 
void SetBadgeColors (const wxColor &aBadgeColor, const wxColor &aBadgeTextColor)
 
void SetBitmapCentered (bool aCentered=true)
 
void SetIsToolbarButton (bool aIsToolbar=true)
 
bool IsToolbarButton () const
 

Protected Member Functions

void setupEvents ()
 
void OnMouseLeave (wxEvent &aEvent)
 
void OnMouseEnter (wxEvent &aEvent)
 
void OnKillFocus (wxEvent &aEvent)
 
void OnSetFocus (wxEvent &aEvent)
 
void OnLeftButtonUp (wxMouseEvent &aEvent)
 
void OnLeftButtonDown (wxMouseEvent &aEvent)
 
void OnPaint (wxPaintEvent &aEvent)
 
void OnDPIChanged (wxDPIChangedEvent &aEvent)
 
virtual wxSize DoGetBestSize () const override
 
void setFlag (int aFlag)
 
void clearFlag (int aFlag)
 
bool hasFlag (int aFlag) const
 
void invalidateBestSize ()
 

Private Attributes

wxBitmapBundle m_normalBitmap
 
wxBitmapBundle m_disabledBitmap
 
bool m_isRadioButton
 
bool m_showBadge
 
wxString m_badgeText
 
wxColor m_badgeColor
 
wxColor m_badgeTextColor
 
wxFont m_badgeFont
 
int m_buttonState
 
int m_padding
 
wxSize m_unadjustedMinSize
 
bool m_isToolbarButton
 Accept mouse-up as click even if mouse-down happened outside of the control.
 
bool m_acceptDraggedInClicks
 Draws bitmap centered in the control.
 
bool m_centerBitmap
 

Detailed Description

A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.

Specifically:

  • It has no border
  • It has a rectangle highlight when the mouse is hovering/pressed
  • It has the ability to be checked/toggled

Definition at line 41 of file bitmap_button.h.

Constructor & Destructor Documentation

◆ BITMAP_BUTTON() [1/2]

BITMAP_BUTTON::BITMAP_BUTTON ( wxWindow *  aParent,
wxWindowID  aId,
const wxPoint &  aPos = wxDefaultPosition,
const wxSize &  aSize = wxDefaultSize,
int  aStyles = wxBORDER_NONE | wxTAB_TRAVERSAL 
)

Definition at line 37 of file bitmap_button.cpp.

References m_badgeFont, and setupEvents().

◆ BITMAP_BUTTON() [2/2]

BITMAP_BUTTON::BITMAP_BUTTON ( wxWindow *  aParent,
wxWindowID  aId,
const wxBitmap &  aDummyBitmap,
const wxPoint &  aPos = wxDefaultPosition,
const wxSize &  aSize = wxDefaultSize,
int  aStyles = wxBORDER_NONE | wxTAB_TRAVERSAL 
)

Definition at line 56 of file bitmap_button.cpp.

References m_badgeFont, and setupEvents().

◆ ~BITMAP_BUTTON()

BITMAP_BUTTON::~BITMAP_BUTTON ( )

Member Function Documentation

◆ AcceptDragInAsClick()

void BITMAP_BUTTON::AcceptDragInAsClick ( bool  aAcceptDragIn = true)

Accept mouse-up as click even if mouse-down happened outside of the control.

Parameters
aAcceptDragInis true to allow drag in, false to ignore lone mouse-up events

Definition at line 156 of file bitmap_button.cpp.

References m_acceptDraggedInClicks.

Referenced by ACTION_TOOLBAR_PALETTE::AddAction().

◆ Check()

◆ clearFlag()

void BITMAP_BUTTON::clearFlag ( int  aFlag)
inlineprotected

◆ DoGetBestSize()

wxSize BITMAP_BUTTON::DoGetBestSize ( ) const
overrideprotectedvirtual

Definition at line 101 of file bitmap_button.cpp.

References hasFlag(), m_padding, m_unadjustedMinSize, and wxCONTROL_SEPARATOR.

◆ Enable()

◆ hasFlag()

bool BITMAP_BUTTON::hasFlag ( int  aFlag) const
inlineprotected

◆ invalidateBestSize()

void BITMAP_BUTTON::invalidateBestSize ( )
protected

Definition at line 110 of file bitmap_button.cpp.

Referenced by OnDPIChanged(), SetBitmap(), SetIsSeparator(), and SetPadding().

◆ IsChecked()

◆ IsToolbarButton()

bool BITMAP_BUTTON::IsToolbarButton ( ) const
inline

Definition at line 125 of file bitmap_button.h.

◆ OnDPIChanged()

void BITMAP_BUTTON::OnDPIChanged ( wxDPIChangedEvent &  aEvent)
protected

Definition at line 277 of file bitmap_button.cpp.

References invalidateBestSize(), m_normalBitmap, and m_unadjustedMinSize.

Referenced by setupEvents(), and ~BITMAP_BUTTON().

◆ OnKillFocus()

void BITMAP_BUTTON::OnKillFocus ( wxEvent &  aEvent)
protected

Definition at line 186 of file bitmap_button.cpp.

References clearFlag(), hasFlag(), and Refresh().

Referenced by setupEvents(), and ~BITMAP_BUTTON().

◆ OnLeftButtonDown()

void BITMAP_BUTTON::OnLeftButtonDown ( wxMouseEvent &  aEvent)
protected

Definition at line 235 of file bitmap_button.cpp.

References clearFlag(), hasFlag(), m_isRadioButton, Refresh(), and setFlag().

Referenced by setupEvents(), and ~BITMAP_BUTTON().

◆ OnLeftButtonUp()

void BITMAP_BUTTON::OnLeftButtonUp ( wxMouseEvent &  aEvent)
protected

Definition at line 213 of file bitmap_button.cpp.

References clearFlag(), hasFlag(), m_acceptDraggedInClicks, and Refresh().

Referenced by setupEvents(), and ~BITMAP_BUTTON().

◆ OnMouseEnter()

void BITMAP_BUTTON::OnMouseEnter ( wxEvent &  aEvent)
protected

Definition at line 174 of file bitmap_button.cpp.

References hasFlag(), Refresh(), and setFlag().

Referenced by setupEvents(), and ~BITMAP_BUTTON().

◆ OnMouseLeave()

void BITMAP_BUTTON::OnMouseLeave ( wxEvent &  aEvent)
protected

Definition at line 162 of file bitmap_button.cpp.

References clearFlag(), hasFlag(), and Refresh().

Referenced by setupEvents(), and ~BITMAP_BUTTON().

◆ OnPaint()

◆ OnSetFocus()

void BITMAP_BUTTON::OnSetFocus ( wxEvent &  aEvent)
protected

Definition at line 198 of file bitmap_button.cpp.

References hasFlag(), Refresh(), and setFlag().

Referenced by setupEvents(), and ~BITMAP_BUTTON().

◆ SetBadgeColors()

void BITMAP_BUTTON::SetBadgeColors ( const wxColor &  aBadgeColor,
const wxColor &  aBadgeTextColor 
)
inline

Definition at line 113 of file bitmap_button.h.

◆ SetBadgeText()

void BITMAP_BUTTON::SetBadgeText ( const wxString &  aText)
inline

◆ SetBitmap()

◆ SetBitmapCentered()

void BITMAP_BUTTON::SetBitmapCentered ( bool  aCentered = true)
inline

Definition at line 119 of file bitmap_button.h.

Referenced by ACTION_TOOLBAR_PALETTE::AddAction(), and KISTATUSBAR::KISTATUSBAR().

◆ SetDisabledBitmap()

void BITMAP_BUTTON::SetDisabledBitmap ( const wxBitmapBundle &  aBmp)

Set the bitmap shown when the button is disabled.

Parameters
aBmpis the disabled bitmap.

Definition at line 150 of file bitmap_button.cpp.

References m_disabledBitmap.

Referenced by ACTION_TOOLBAR_PALETTE::AddAction(), and PANEL_KICAD_LAUNCHER::CreateLaunchers().

◆ setFlag()

void BITMAP_BUTTON::setFlag ( int  aFlag)
inlineprotected

◆ SetIsCheckButton()

◆ SetIsRadioButton()

◆ SetIsSeparator()

◆ SetIsToolbarButton()

void BITMAP_BUTTON::SetIsToolbarButton ( bool  aIsToolbar = true)
inline

Definition at line 124 of file bitmap_button.h.

Referenced by ACTION_TOOLBAR_PALETTE::AddAction().

◆ SetPadding()

void BITMAP_BUTTON::SetPadding ( int  aPadding)

Set the amount of padding present on each side of the bitmap.

Parameters
aPaddingis the amount in px of padding for each side.

Definition at line 119 of file bitmap_button.cpp.

References invalidateBestSize(), and m_padding.

Referenced by ACTION_TOOLBAR_PALETTE::AddAction(), APPEARANCE_CONTROLS::APPEARANCE_CONTROLS(), PANEL_KICAD_LAUNCHER::CreateLaunchers(), KISTATUSBAR::KISTATUSBAR(), and NET_INSPECTOR_PANEL::NET_INSPECTOR_PANEL().

◆ SetShowBadge()

void BITMAP_BUTTON::SetShowBadge ( bool  aShowBadge)
inline

◆ setupEvents()

void BITMAP_BUTTON::setupEvents ( )
protected

Member Data Documentation

◆ m_acceptDraggedInClicks

bool BITMAP_BUTTON::m_acceptDraggedInClicks
private

Draws bitmap centered in the control.

Definition at line 174 of file bitmap_button.h.

Referenced by AcceptDragInAsClick(), and OnLeftButtonUp().

◆ m_badgeColor

wxColor BITMAP_BUTTON::m_badgeColor
private

Definition at line 165 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_badgeFont

wxFont BITMAP_BUTTON::m_badgeFont
private

Definition at line 167 of file bitmap_button.h.

Referenced by BITMAP_BUTTON(), and OnPaint().

◆ m_badgeText

wxString BITMAP_BUTTON::m_badgeText
private

Definition at line 164 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_badgeTextColor

wxColor BITMAP_BUTTON::m_badgeTextColor
private

Definition at line 166 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_buttonState

int BITMAP_BUTTON::m_buttonState
private

Definition at line 168 of file bitmap_button.h.

◆ m_centerBitmap

bool BITMAP_BUTTON::m_centerBitmap
private

Definition at line 177 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_disabledBitmap

wxBitmapBundle BITMAP_BUTTON::m_disabledBitmap
private

Definition at line 160 of file bitmap_button.h.

Referenced by OnPaint(), and SetDisabledBitmap().

◆ m_isRadioButton

bool BITMAP_BUTTON::m_isRadioButton
private

Definition at line 162 of file bitmap_button.h.

Referenced by OnLeftButtonDown(), and SetIsRadioButton().

◆ m_isToolbarButton

bool BITMAP_BUTTON::m_isToolbarButton
private

Accept mouse-up as click even if mouse-down happened outside of the control.

Definition at line 171 of file bitmap_button.h.

Referenced by OnPaint(), and SetBitmap().

◆ m_normalBitmap

wxBitmapBundle BITMAP_BUTTON::m_normalBitmap
private

Definition at line 159 of file bitmap_button.h.

Referenced by OnDPIChanged(), OnPaint(), and SetBitmap().

◆ m_padding

int BITMAP_BUTTON::m_padding
private

Definition at line 169 of file bitmap_button.h.

Referenced by DoGetBestSize(), OnPaint(), and SetPadding().

◆ m_showBadge

bool BITMAP_BUTTON::m_showBadge
private

Definition at line 163 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_unadjustedMinSize

wxSize BITMAP_BUTTON::m_unadjustedMinSize
private

Definition at line 170 of file bitmap_button.h.

Referenced by DoGetBestSize(), OnDPIChanged(), OnPaint(), and SetBitmap().


The documentation for this class was generated from the following files: