30#include <wx/dcclient.h>
31#include <wx/renderer.h>
32#include <wx/settings.h>
34#define wxCONTROL_SEPARATOR wxCONTROL_SPECIAL
38 const wxSize& aSize,
int aStyles ) :
39 wxPanel( aParent, aId, aPos, aSize, aStyles ),
40 m_isRadioButton( false ),
42 m_badgeColor( wxColor( 210, 0, 0 ) ),
43 m_badgeTextColor( wxColor( wxT(
"white" ) ) ),
46 m_isToolbarButton( false ),
47 m_acceptDraggedInClicks( false ),
48 m_centerBitmap( true )
57 const wxPoint& aPos,
const wxSize& aSize,
int aStyles ) :
58 wxPanel( aParent, aId, aPos, aSize, aStyles ),
59 m_isRadioButton( false ),
61 m_badgeColor( wxColor( 210, 0, 0 ) ),
62 m_badgeTextColor( wxColor( wxT(
"white" ) ) ),
65 m_isToolbarButton( false ),
66 m_acceptDraggedInClicks( false ),
67 m_centerBitmap( true )
115 InvalidateBestSize();
164 if(
hasFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED ) )
166 clearFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED );
176 if( !
hasFlag( wxCONTROL_CURRENT ) )
188 if(
hasFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED | wxCONTROL_SELECTED ) )
190 clearFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED | wxCONTROL_SELECTED );
200 if( !
hasFlag( wxCONTROL_CHECKABLE ) )
202 if( !
hasFlag( wxCONTROL_FOCUSED ) )
217 if( !
hasFlag( wxCONTROL_DISABLED )
220 GetEventHandler()->CallAfter( [
this]()
222 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
223 evt.SetEventObject(
this );
224 GetEventHandler()->ProcessEvent( evt );
237 if(
hasFlag( wxCONTROL_CHECKABLE ) )
243 GetEventHandler()->CallAfter(
246 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
247 evt.SetEventObject(
this );
249 GetEventHandler()->ProcessEvent( evt );
256 GetEventHandler()->CallAfter(
259 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
260 evt.SetEventObject(
this );
262 GetEventHandler()->ProcessEvent( evt );
279 wxSize newBmSize =
m_normalBitmap.GetPreferredBitmapSizeFor(
this );
294 wxColor highlightColor = wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT );
297 wxRect rect( wxPoint( 0, 0 ), GetSize() );
298 wxPaintDC dc(
this );
302 dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) ) );
303 dc.DrawLine( wxPoint( GetSize().x / 2, 0 ), wxPoint( GetSize().x / 2, GetSize().y ) );
308 if( !
hasFlag( wxCONTROL_DISABLED ) )
310 if(
hasFlag( wxCONTROL_PRESSED ) )
312 dc.SetPen( wxPen( highlightColor ) );
313 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 20 : 150 ) ) );
314 dc.DrawRectangle( rect );
316 else if(
hasFlag( wxCONTROL_CURRENT | wxCONTROL_FOCUSED ) )
318 dc.SetPen( wxPen( highlightColor ) );
319 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 40 : 170 ) ) );
322 if(
hasFlag( wxCONTROL_CHECKED ) )
323 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 50 : 180 ) ) );
325 dc.DrawRectangle( rect );
327 else if(
hasFlag( wxCONTROL_CHECKED ) )
329 dc.SetPen( wxPen( highlightColor ) );
330 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 40 : 170 ) ) );
331 dc.DrawRectangle( rect );
345 bmSize = wxSize( size, size );
346 bmpImg = bmp.GetBitmap( bmSize *
scale );
350 bmpImg.SetScaleFactor(
scale );
352 else if( bmp.IsOk() )
355 bmSize = bmpImg.GetLogicalSize();
360 drawBmpPos.x = ( rect.width - bmSize.x ) / 2;
361 drawBmpPos.y = ( rect.height - bmSize.y ) / 2;
366 dc.DrawBitmap( bmpImg, drawBmpPos,
true );
373 wxSize text_padding( 3, 1 );
378 wxSize box_size = dc.GetTextExtent(
m_badgeText ) + text_padding;
379 wxSize box_offset = box_size;
386 dc.DrawRoundedRectangle( rect.GetRightBottom() - box_offset, box_size, -0.25 );
389 dc.DrawText(
m_badgeText, rect.GetRightBottom() - box_offset + ( text_padding / 2 ) );
397 if( aEnable !=
hasFlag( wxCONTROL_DISABLED ) )
400 wxPanel::Enable( aEnable );
402 if( aEnable &&
hasFlag( wxCONTROL_DISABLED ) )
408 if( !aEnable && !
hasFlag( wxCONTROL_DISABLED ) )
420 setFlag( wxCONTROL_CHECKABLE );
426 setFlag( wxCONTROL_CHECKABLE );
441 wxASSERT_MSG(
hasFlag( wxCONTROL_CHECKABLE ), wxS(
"Button is not a checkButton." ) );
443 if( aCheck && !
hasFlag( wxCONTROL_CHECKED ) )
449 if( !aCheck &&
hasFlag( wxCONTROL_CHECKED ) )
459 wxASSERT_MSG(
hasFlag( wxCONTROL_CHECKABLE ), wxS(
"Button is not a checkButton." ) );
461 return hasFlag( wxCONTROL_CHECKED );
virtual COMMON_SETTINGS * GetCommonSettings() const
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
PGM_BASE & Pgm()
The global Program "get" accessor.