28#include <wx/dcclient.h>
29#include <wx/renderer.h>
30#include <wx/settings.h>
32#define wxCONTROL_SEPARATOR wxCONTROL_SPECIAL
36 const wxSize& aSize,
int aStyles ) :
37 wxPanel( aParent, aId, aPos, aSize, aStyles ),
38 m_isRadioButton( false ),
40 m_badgeColor( wxColor( 210, 0, 0 ) ),
41 m_badgeTextColor( wxColor( wxT(
"white" ) ) ),
44 m_acceptDraggedInClicks( false )
46 if( aSize == wxDefaultSize )
56 const wxPoint& aPos,
const wxSize& aSize,
int aStyles ) :
57 wxPanel( aParent, aId, aPos, aSize, aStyles ),
58 m_isRadioButton( false ),
62 m_acceptDraggedInClicks( false )
64 if( aSize == wxDefaultSize )
123 if(
hasFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED ) )
125 clearFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED );
135 if( !
hasFlag( wxCONTROL_CURRENT ) )
147 if(
hasFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED ) )
149 clearFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED );
159 if( !
hasFlag( wxCONTROL_CHECKABLE ) )
161 if( !
hasFlag( wxCONTROL_FOCUSED ) )
176 if( !
hasFlag( wxCONTROL_DISABLED )
179 GetEventHandler()->CallAfter( [=]()
181 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
182 evt.SetEventObject(
this );
183 GetEventHandler()->ProcessEvent( evt );
196 if(
hasFlag( wxCONTROL_CHECKABLE ) )
202 GetEventHandler()->CallAfter(
205 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
206 evt.SetEventObject(
this );
208 GetEventHandler()->ProcessEvent( evt );
215 GetEventHandler()->CallAfter(
218 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
219 evt.SetEventObject(
this );
221 GetEventHandler()->ProcessEvent( evt );
239 wxColor highlightColor = wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT );
242 wxRect rect( wxPoint( 0, 0 ), GetSize() );
243 wxPaintDC dc(
this );
247 dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) ) );
248 dc.DrawLine( wxPoint( GetSize().x / 2, 0 ), wxPoint( GetSize().x / 2, GetSize().y ) );
253 if( !
hasFlag( wxCONTROL_DISABLED ) )
255 if(
hasFlag( wxCONTROL_PRESSED ) )
257 dc.SetPen( wxPen( highlightColor ) );
258 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 20 : 150 ) ) );
259 dc.DrawRectangle( rect );
261 else if(
hasFlag( wxCONTROL_CURRENT | wxCONTROL_FOCUSED ) )
263 dc.SetPen( wxPen( highlightColor ) );
264 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 40 : 170 ) ) );
267 if(
hasFlag( wxCONTROL_CHECKED ) )
268 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 50 : 180 ) ) );
270 dc.DrawRectangle( rect );
272 else if(
hasFlag( wxCONTROL_CHECKED ) )
274 dc.SetPen( wxPen( highlightColor ) );
275 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 40 : 170 ) ) );
276 dc.DrawRectangle( rect );
291 wxSize box_size = dc.GetTextExtent(
m_badgeText ) + wxSize( 6, 2 );
293 wxSize text_offset = box_offset - wxSize( 3, 1 );
297 dc.DrawRoundedRectangle( rect.GetRightBottom() - box_offset, box_size, -0.25 );
300 dc.DrawText(
m_badgeText, rect.GetRightBottom() - text_offset );
308 if( aEnable !=
hasFlag( wxCONTROL_DISABLED ) )
311 wxPanel::Enable( aEnable );
313 if( aEnable &&
hasFlag( wxCONTROL_DISABLED ) )
319 if( !aEnable && !
hasFlag( wxCONTROL_DISABLED ) )
331 setFlag( wxCONTROL_CHECKABLE );
337 setFlag( wxCONTROL_CHECKABLE );
345 SetMinSize( wxSize(
m_padding * 2, wxButton::GetDefaultSize().y ) );
351 wxASSERT_MSG(
hasFlag( wxCONTROL_CHECKABLE ), wxS(
"Button is not a checkButton." ) );
353 if( aCheck && !
hasFlag( wxCONTROL_CHECKED ) )
359 if( !aCheck &&
hasFlag( wxCONTROL_CHECKED ) )
369 wxASSERT_MSG(
hasFlag( wxCONTROL_CHECKABLE ), wxS(
"Button is not a checkButton." ) );
371 return hasFlag( wxCONTROL_CHECKED );
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...