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 )
107 InvalidateBestSize();
156 if(
hasFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED ) )
158 clearFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED );
168 if( !
hasFlag( wxCONTROL_CURRENT ) )
180 if(
hasFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED | wxCONTROL_SELECTED ) )
182 clearFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED | wxCONTROL_SELECTED );
192 if( !
hasFlag( wxCONTROL_CHECKABLE ) )
194 if( !
hasFlag( wxCONTROL_FOCUSED ) )
209 if( !
hasFlag( wxCONTROL_DISABLED )
212 GetEventHandler()->CallAfter( [
this]()
214 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
215 evt.SetEventObject(
this );
216 GetEventHandler()->ProcessEvent( evt );
229 if(
hasFlag( wxCONTROL_CHECKABLE ) )
235 GetEventHandler()->CallAfter(
238 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
239 evt.SetEventObject(
this );
241 GetEventHandler()->ProcessEvent( evt );
248 GetEventHandler()->CallAfter(
251 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
252 evt.SetEventObject(
this );
254 GetEventHandler()->ProcessEvent( evt );
271 wxSize newBmSize =
m_normalBitmap.GetPreferredBitmapSizeFor(
this );
286 wxColor highlightColor = wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT );
289 wxRect rect( wxPoint( 0, 0 ), GetSize() );
290 wxPaintDC dc(
this );
294 dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) ) );
295 dc.DrawLine( wxPoint( GetSize().x / 2, 0 ), wxPoint( GetSize().x / 2, GetSize().y ) );
300 if( !
hasFlag( wxCONTROL_DISABLED ) )
302 if(
hasFlag( wxCONTROL_PRESSED ) )
304 dc.SetPen( wxPen( highlightColor ) );
305 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 20 : 150 ) ) );
306 dc.DrawRectangle( rect );
308 else if(
hasFlag( wxCONTROL_CURRENT | wxCONTROL_FOCUSED ) )
310 dc.SetPen( wxPen( highlightColor ) );
311 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 40 : 170 ) ) );
314 if(
hasFlag( wxCONTROL_CHECKED ) )
315 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 50 : 180 ) ) );
317 dc.DrawRectangle( rect );
319 else if(
hasFlag( wxCONTROL_CHECKED ) )
321 dc.SetPen( wxPen( highlightColor ) );
322 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 40 : 170 ) ) );
323 dc.DrawRectangle( rect );
337 bmSize = wxSize( size, size );
338 bmpImg = bmp.GetBitmap( bmSize *
scale );
342 bmpImg.SetScaleFactor(
scale );
344 else if( bmp.IsOk() )
347 bmSize = bmpImg.GetLogicalSize();
352 drawBmpPos.x = ( rect.width - bmSize.x ) / 2;
353 drawBmpPos.y = ( rect.height - bmSize.y ) / 2;
358 dc.DrawBitmap( bmpImg, drawBmpPos,
true );
365 wxSize text_padding( 3, 1 );
370 wxSize box_size = dc.GetTextExtent(
m_badgeText ) + text_padding;
371 wxSize box_offset = box_size;
378 dc.DrawRoundedRectangle( rect.GetRightBottom() - box_offset, box_size, -0.25 );
381 dc.DrawText(
m_badgeText, rect.GetRightBottom() - box_offset + ( text_padding / 2 ) );
389 if( aEnable !=
hasFlag( wxCONTROL_DISABLED ) )
392 wxPanel::Enable( aEnable );
394 if( aEnable &&
hasFlag( wxCONTROL_DISABLED ) )
400 if( !aEnable && !
hasFlag( wxCONTROL_DISABLED ) )
412 setFlag( wxCONTROL_CHECKABLE );
418 setFlag( wxCONTROL_CHECKABLE );
433 wxASSERT_MSG(
hasFlag( wxCONTROL_CHECKABLE ), wxS(
"Button is not a checkButton." ) );
435 if( aCheck && !
hasFlag( wxCONTROL_CHECKED ) )
441 if( !aCheck &&
hasFlag( wxCONTROL_CHECKED ) )
451 wxASSERT_MSG(
hasFlag( wxCONTROL_CHECKABLE ), wxS(
"Button is not a checkButton." ) );
453 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.