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. More...
 
void SetBitmap (const wxBitmap &aBmp)
 Set the bitmap shown when the button is enabled. More...
 
void SetDisabledBitmap (const wxBitmap &aBmp)
 Set the bitmap shown when the button is disabled. More...
 
bool Enable (bool aEnable=true) override
 Enable the button. More...
 
void SetIsCheckButton ()
 Setup the control as a two-state button (checked or unchecked). More...
 
void SetIsRadioButton ()
 
void Check (bool aCheck=true)
 Check the control. More...
 
bool IsChecked () const
 
void SetIsSeparator ()
 Render button as a toolbar separator. More...
 
void AcceptDragInAsClick (bool aAcceptDragIn=true)
 Accept mouse-up as click even if mouse-down happened outside of the control. More...
 
void SetShowBadge (bool aShowBadge)
 
void SetBadgeText (const wxString &aText)
 
void SetBadgeColors (const wxColor &aBadgeColor, const wxColor &aBadgeTextColor)
 

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

wxBitmap m_normalBitmap
 
wxBitmap 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
 Accept mouse-up as click even if mouse-down happened outside of the control. More...
 
bool m_acceptDraggedInClicks
 

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 40 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 35 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 55 of file bitmap_button.cpp.

References m_padding, and setupEvents().

◆ ~BITMAP_BUTTON()

BITMAP_BUTTON::~BITMAP_BUTTON ( )

Definition at line 83 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 110 of file bitmap_button.cpp.

References m_acceptDraggedInClicks.

Referenced by ACTION_TOOLBAR_PALETTE::AddAction().

◆ Check()

◆ clearFlag()

void BITMAP_BUTTON::clearFlag ( int  aFlag)
inlineprotected

Definition at line 134 of file bitmap_button.h.

References m_buttonState.

Referenced by Check(), Enable(), OnKillFocus(), OnLeftButtonDown(), OnLeftButtonUp(), and OnMouseLeave().

◆ Enable()

◆ hasFlag()

bool BITMAP_BUTTON::hasFlag ( int  aFlag) const
inlineprotected

◆ IsChecked()

◆ OnKillFocus()

void BITMAP_BUTTON::OnKillFocus ( wxEvent &  aEvent)
protected

Definition at line 140 of file bitmap_button.cpp.

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

Referenced by setupEvents().

◆ OnLeftButtonDown()

void BITMAP_BUTTON::OnLeftButtonDown ( wxMouseEvent &  aEvent)
protected

Definition at line 189 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 167 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 128 of file bitmap_button.cpp.

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

Referenced by setupEvents().

◆ OnMouseLeave()

void BITMAP_BUTTON::OnMouseLeave ( wxEvent &  aEvent)
protected

Definition at line 116 of file bitmap_button.cpp.

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

Referenced by setupEvents().

◆ OnPaint()

void BITMAP_BUTTON::OnPaint ( wxPaintEvent &  aEvent)
protected

◆ OnSetFocus()

void BITMAP_BUTTON::OnSetFocus ( wxEvent &  aEvent)
protected

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

References m_badgeColor, and m_badgeTextColor.

◆ SetBadgeText()

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

Definition at line 110 of file bitmap_button.h.

References m_badgeText.

Referenced by KICAD_MANAGER_FRAME::updatePcmButtonBadge().

◆ SetBitmap()

◆ SetDisabledBitmap()

void BITMAP_BUTTON::SetDisabledBitmap ( const wxBitmap &  aBmp)

Set the bitmap shown when the button is disabled.

Parameters
aBmpis the disabled bitmap.

Definition at line 104 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()

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

References m_padding, and m_unadjustedMinSize.

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

◆ SetShowBadge()

void BITMAP_BUTTON::SetShowBadge ( bool  aShowBadge)
inline

Definition at line 108 of file bitmap_button.h.

References m_showBadge.

Referenced by KICAD_MANAGER_FRAME::updatePcmButtonBadge().

◆ setupEvents()

void BITMAP_BUTTON::setupEvents ( )
protected

Member Data Documentation

◆ m_acceptDraggedInClicks

bool BITMAP_BUTTON::m_acceptDraggedInClicks
private

Definition at line 159 of file bitmap_button.h.

Referenced by AcceptDragInAsClick(), and OnLeftButtonUp().

◆ m_badgeColor

wxColor BITMAP_BUTTON::m_badgeColor
private

Definition at line 151 of file bitmap_button.h.

Referenced by OnPaint(), and SetBadgeColors().

◆ m_badgeFont

wxFont BITMAP_BUTTON::m_badgeFont
private

Definition at line 153 of file bitmap_button.h.

Referenced by BITMAP_BUTTON(), and OnPaint().

◆ m_badgeText

wxString BITMAP_BUTTON::m_badgeText
private

Definition at line 150 of file bitmap_button.h.

Referenced by OnPaint(), and SetBadgeText().

◆ m_badgeTextColor

wxColor BITMAP_BUTTON::m_badgeTextColor
private

Definition at line 152 of file bitmap_button.h.

Referenced by OnPaint(), and SetBadgeColors().

◆ m_buttonState

int BITMAP_BUTTON::m_buttonState
private

Definition at line 154 of file bitmap_button.h.

Referenced by clearFlag(), hasFlag(), and setFlag().

◆ m_disabledBitmap

wxBitmap BITMAP_BUTTON::m_disabledBitmap
private

Definition at line 146 of file bitmap_button.h.

Referenced by OnPaint(), and SetDisabledBitmap().

◆ m_isRadioButton

bool BITMAP_BUTTON::m_isRadioButton
private

Definition at line 148 of file bitmap_button.h.

Referenced by OnLeftButtonDown(), and SetIsRadioButton().

◆ m_normalBitmap

wxBitmap BITMAP_BUTTON::m_normalBitmap
private

Definition at line 145 of file bitmap_button.h.

Referenced by OnPaint(), and SetBitmap().

◆ m_padding

int BITMAP_BUTTON::m_padding
private

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

Referenced by OnPaint(), and SetShowBadge().

◆ m_unadjustedMinSize

wxSize BITMAP_BUTTON::m_unadjustedMinSize
private

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

Definition at line 156 of file bitmap_button.h.

Referenced by SetBitmap(), and SetPadding().


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