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( false )
50 if( aSize == wxDefaultSize )
60 const wxPoint& aPos,
const wxSize& aSize,
int aStyles ) :
61 wxPanel( aParent, aId, aPos, aSize, aStyles ),
62 m_isRadioButton( false ),
64 m_badgeColor( wxColor( 210, 0, 0 ) ),
65 m_badgeTextColor( wxColor( wxT(
"white" ) ) ),
68 m_isToolbarButton( false ),
69 m_acceptDraggedInClicks( false ),
70 m_centerBitmap( false )
72 if( aSize == wxDefaultSize )
143 if(
hasFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED ) )
145 clearFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED );
155 if( !
hasFlag( wxCONTROL_CURRENT ) )
167 if(
hasFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED | wxCONTROL_SELECTED ) )
169 clearFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED | wxCONTROL_SELECTED );
179 if( !
hasFlag( wxCONTROL_CHECKABLE ) )
181 if( !
hasFlag( wxCONTROL_FOCUSED ) )
196 if( !
hasFlag( wxCONTROL_DISABLED )
199 GetEventHandler()->CallAfter( [=]()
201 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
202 evt.SetEventObject(
this );
203 GetEventHandler()->ProcessEvent( evt );
216 if(
hasFlag( wxCONTROL_CHECKABLE ) )
222 GetEventHandler()->CallAfter(
225 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
226 evt.SetEventObject(
this );
228 GetEventHandler()->ProcessEvent( evt );
235 GetEventHandler()->CallAfter(
238 wxCommandEvent evt( wxEVT_BUTTON, GetId() );
239 evt.SetEventObject(
this );
241 GetEventHandler()->ProcessEvent( evt );
259 wxColor highlightColor = wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT );
262 wxRect rect( wxPoint( 0, 0 ), GetSize() );
263 wxPaintDC dc(
this );
267 dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) ) );
268 dc.DrawLine( wxPoint( GetSize().x / 2, 0 ), wxPoint( GetSize().x / 2, GetSize().y ) );
273 if( !
hasFlag( wxCONTROL_DISABLED ) )
275 if(
hasFlag( wxCONTROL_PRESSED ) )
277 dc.SetPen( wxPen( highlightColor ) );
278 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 20 : 150 ) ) );
279 dc.DrawRectangle( rect );
281 else if(
hasFlag( wxCONTROL_CURRENT | wxCONTROL_FOCUSED ) )
283 dc.SetPen( wxPen( highlightColor ) );
284 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 40 : 170 ) ) );
287 if(
hasFlag( wxCONTROL_CHECKED ) )
288 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 50 : 180 ) ) );
290 dc.DrawRectangle( rect );
292 else if(
hasFlag( wxCONTROL_CHECKED ) )
294 dc.SetPen( wxPen( highlightColor ) );
295 dc.SetBrush( wxBrush( highlightColor.ChangeLightness( darkMode ? 40 : 170 ) ) );
296 dc.DrawRectangle( rect );
310 size =
Pgm().GetCommonSettings()->m_Appearance.toolbar_icon_size;
311 bmSize = wxSize( size, size );
312 bmpImg = bmp.GetBitmap( bmSize *
scale );
316 bmpImg.SetScaleFactor(
scale );
318 else if( bmp.IsOk() )
320 bmpImg = bmp.GetBitmapFor(
this );
321 bmSize = bmpImg.GetSize();
327 int x = std::max( ( rect.width - bmSize.x ) / 2, 0 );
328 int y = std::max( ( rect.height - bmSize.y ) / 2, 0 );
329 drawBmpPos = wxPoint( x, y );
334 dc.DrawBitmap( bmpImg, drawBmpPos,
true );
341 wxSize text_padding( 3, 1 );
346 wxSize box_size = dc.GetTextExtent(
m_badgeText ) + text_padding;
347 wxSize box_offset = box_size;
354 dc.DrawRoundedRectangle( rect.GetRightBottom() - box_offset, box_size, -0.25 );
357 dc.DrawText(
m_badgeText, rect.GetRightBottom() - box_offset + ( text_padding / 2 ) );
365 if( aEnable !=
hasFlag( wxCONTROL_DISABLED ) )
368 wxPanel::Enable( aEnable );
370 if( aEnable &&
hasFlag( wxCONTROL_DISABLED ) )
376 if( !aEnable && !
hasFlag( wxCONTROL_DISABLED ) )
388 setFlag( wxCONTROL_CHECKABLE );
394 setFlag( wxCONTROL_CHECKABLE );
402 SetMinSize( wxSize(
m_padding * 2, wxButton::GetDefaultSize().y ) );
408 wxASSERT_MSG(
hasFlag( wxCONTROL_CHECKABLE ), wxS(
"Button is not a checkButton." ) );
410 if( aCheck && !
hasFlag( wxCONTROL_CHECKED ) )
416 if( !aCheck &&
hasFlag( wxCONTROL_CHECKED ) )
426 wxASSERT_MSG(
hasFlag( wxCONTROL_CHECKABLE ), wxS(
"Button is not a checkButton." ) );
428 return hasFlag( wxCONTROL_CHECKED );
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.