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 setFlag (int aFlag)
 
void clearFlag (int aFlag)
 
bool hasFlag (int aFlag) const
 

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, m_padding, 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 59 of file bitmap_button.cpp.

References m_badgeFont, m_padding, and setupEvents().

◆ ~BITMAP_BUTTON()

BITMAP_BUTTON::~BITMAP_BUTTON ( )

Definition at line 93 of file bitmap_button.cpp.

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 135 of file bitmap_button.cpp.

References m_acceptDraggedInClicks.

Referenced by ACTION_TOOLBAR_PALETTE::AddAction().

◆ Check()

◆ clearFlag()

void BITMAP_BUTTON::clearFlag ( int  aFlag)
inlineprotected

◆ Enable()

◆ hasFlag()

bool BITMAP_BUTTON::hasFlag ( int  aFlag) const
inlineprotected

◆ IsChecked()

◆ IsToolbarButton()

bool BITMAP_BUTTON::IsToolbarButton ( ) const
inline

Definition at line 125 of file bitmap_button.h.

◆ OnKillFocus()

void BITMAP_BUTTON::OnKillFocus ( wxEvent &  aEvent)
protected

Definition at line 165 of file bitmap_button.cpp.

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

Referenced by setupEvents().

◆ OnLeftButtonDown()

void BITMAP_BUTTON::OnLeftButtonDown ( wxMouseEvent &  aEvent)
protected

Definition at line 214 of file bitmap_button.cpp.

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

Referenced by setupEvents().

◆ OnLeftButtonUp()

void BITMAP_BUTTON::OnLeftButtonUp ( wxMouseEvent &  aEvent)
protected

Definition at line 192 of file bitmap_button.cpp.

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

Referenced by setupEvents().

◆ OnMouseEnter()

void BITMAP_BUTTON::OnMouseEnter ( wxEvent &  aEvent)
protected

Definition at line 153 of file bitmap_button.cpp.

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

Referenced by setupEvents().

◆ OnMouseLeave()

void BITMAP_BUTTON::OnMouseLeave ( wxEvent &  aEvent)
protected

Definition at line 141 of file bitmap_button.cpp.

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

Referenced by setupEvents().

◆ OnPaint()

◆ OnSetFocus()

void BITMAP_BUTTON::OnSetFocus ( wxEvent &  aEvent)
protected

Definition at line 177 of file bitmap_button.cpp.

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

Referenced by setupEvents().

◆ 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 129 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 98 of file bitmap_button.cpp.

References m_padding, and m_unadjustedMinSize.

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 169 of file bitmap_button.h.

Referenced by AcceptDragInAsClick(), and OnLeftButtonUp().

◆ m_badgeColor

wxColor BITMAP_BUTTON::m_badgeColor
private

Definition at line 160 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_badgeFont

wxFont BITMAP_BUTTON::m_badgeFont
private

Definition at line 162 of file bitmap_button.h.

Referenced by BITMAP_BUTTON(), and OnPaint().

◆ m_badgeText

wxString BITMAP_BUTTON::m_badgeText
private

Definition at line 159 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_badgeTextColor

wxColor BITMAP_BUTTON::m_badgeTextColor
private

Definition at line 161 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_buttonState

int BITMAP_BUTTON::m_buttonState
private

Definition at line 163 of file bitmap_button.h.

◆ m_centerBitmap

bool BITMAP_BUTTON::m_centerBitmap
private

Definition at line 172 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_disabledBitmap

wxBitmapBundle BITMAP_BUTTON::m_disabledBitmap
private

Definition at line 155 of file bitmap_button.h.

Referenced by OnPaint(), and SetDisabledBitmap().

◆ m_isRadioButton

bool BITMAP_BUTTON::m_isRadioButton
private

Definition at line 157 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 166 of file bitmap_button.h.

Referenced by OnPaint(), and SetBitmap().

◆ m_normalBitmap

wxBitmapBundle BITMAP_BUTTON::m_normalBitmap
private

Definition at line 154 of file bitmap_button.h.

Referenced by OnPaint(), and SetBitmap().

◆ m_padding

int BITMAP_BUTTON::m_padding
private

Definition at line 164 of file bitmap_button.h.

Referenced by BITMAP_BUTTON(), OnPaint(), SetBitmap(), SetIsSeparator(), and SetPadding().

◆ m_showBadge

bool BITMAP_BUTTON::m_showBadge
private

Definition at line 158 of file bitmap_button.h.

Referenced by OnPaint().

◆ m_unadjustedMinSize

wxSize BITMAP_BUTTON::m_unadjustedMinSize
private

Definition at line 165 of file bitmap_button.h.

Referenced by SetBitmap(), and SetPadding().


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