23#include <wx/collpane.h>
25#include <wx/dcclient.h>
27#include <wx/renderer.h>
28#include <wx/settings.h>
30#include <wx/toplevel.h>
45 const wxPoint& aPos,
const wxSize& aSize,
long aStyle,
46 const wxValidator& aValidator,
const wxString& aName )
48 if( !wxControl::Create( aParent, aId, aPos, aSize, aStyle, aValidator, aName ) )
51 m_sizer =
new wxBoxSizer( wxVERTICAL );
58 m_pane =
new wxPanel(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
59 wxTAB_TRAVERSAL | wxNO_BORDER, wxT(
"COLLAPSIBLE_PANE_PANE" ) );
81 m_sizer->SetContainingWindow(
nullptr );
95 m_pane->Show( !aCollapse );
98 SetSize( GetBestSize() );
119 m_header->SetBackgroundColour( aColor );
120 return wxWindow::SetBackgroundColour( aColor );
126 wxWindow*
const pane =
GetPane();
131 if( !pane->InformFirstDirection( aDirection, aSize, aAvailableOtherDir ) )
134 InvalidateBestSize();
142 wxSize size =
m_sizer->GetMinSize();
146 wxSize paneSize =
m_pane->GetBestSize();
148 size.SetWidth( std::max( size.GetWidth(), paneSize.x ) );
149 size.SetHeight( size.y +
getBorder() + paneSize.y );
161 wxSize size( GetSize() );
169 m_pane->SetSize( 0, yoffset, size.x, size.y - yoffset );
179#if defined( __WXMSW__ )
181 return m_header->ConvertDialogToPixels( wxSize( 2, 0 ) ).x;
197 if( aEvent.GetEventObject() !=
m_header )
205 wxCommandEvent evt( WX_COLLAPSIBLE_PANE_CHANGED, GetId() );
206 evt.SetEventObject(
this );
222 const wxPoint& aPos,
const wxSize& aSize,
long aStyle,
223 const wxValidator& aValidator,
const wxString& aName )
225 if ( !wxControl::Create( aParent, aId, aPos, aSize, aStyle, aValidator, aName ) )
253 wxCommandEvent evt( WX_COLLAPSIBLE_PANE_HEADER_CHANGED, GetId() );
254 evt.SetEventObject(
this );
264 wxClientDC dc( self );
267 wxControl::FindAccelIndex( GetLabel(), &
text );
269 wxSize size = dc.GetTextExtent(
text );
272 size.x += size.GetHeight();
275 size.IncBy( GetSystemMetrics( SM_CXFOCUSBORDER ),
276 GetSystemMetrics( SM_CYFOCUSBORDER ) );
285 wxPaintDC dc(
this );
286 wxRect rect( wxPoint( 0, 0 ), GetClientSize() );
289 wxBrush brush = dc.GetBrush();
290 brush.SetColour( GetParent()->GetBackgroundColour() );
291 dc.SetBrush( brush );
292 dc.SetPen( *wxTRANSPARENT_PEN );
293 dc.DrawRectangle( rect );
299 dc.SetBrush( wxBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ) ) );
300 dc.SetPen( *wxTRANSPARENT_PEN );
301 dc.DrawRectangle( rect );
305 int indexAccel = wxControl::FindAccelIndex( GetLabel(), &
text );
307 wxSize textSize = dc.GetTextExtent(
text );
310 wxRect arrowRect( 0, 0, textSize.GetHeight(), textSize.GetHeight() );
311 wxRect textRect( arrowRect.GetTopRight(), textSize );
312 textRect = textRect.CenterIn( rect, wxVERTICAL );
315 bool isActive =
true;
316 wxTopLevelWindow* tlw =
dynamic_cast<wxTopLevelWindow*
>( wxGetTopLevelParent(
this ) );
318 if( tlw && !tlw->IsActive() )
328 clr = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
330 clr = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
332 dc.SetTextForeground( clr );
333 dc.DrawLabel(
text, textRect, wxALIGN_CENTER_VERTICAL, indexAccel );
339 flags |= wxCONTROL_CURRENT;
341 int focusSize = GetSystemMetrics( SM_CXFOCUSBORDER );
344 wxRendererNative::Get().DrawFocusRect(
this, dc, textRect.Inflate( focusSize ), flags );
381 switch( aEvent.GetKeyCode() )
385 case WXK_NUMPAD_ENTER:
399 wxPoint btmCorner( aRect.GetWidth() / 2, 3 * aRect.GetHeight() / 4 );
402 wxPoint rtCorner( 3 * aRect.GetWidth() / 4, aRect.GetHeight() / 2 );
405 wxPoint otherCorner( 0, 0 );
408 otherCorner = wxPoint( aRect.GetWidth() / 2, aRect.GetHeight() / 4 );
410 otherCorner = wxPoint( aRect.GetWidth() / 4, aRect.GetHeight() / 2 );
417 clr = wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT );
419 clr = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
423 clr = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
426 aDC.SetPen( wxPen( clr ) );
427 aDC.SetBrush( wxBrush( clr ) );
431 points.Append( &btmCorner );
432 points.Append( &rtCorner );
433 points.Append( &otherCorner );
435 aDC.DrawPolygon( &points );
wxSize DoGetBestClientSize() const override
void Collapse(bool aCollapse=true)
void onSize(wxSizeEvent &aEvent)
void onHeaderClicked(wxCommandEvent &aEvent)
WX_COLLAPSIBLE_PANE_HEADER * m_header
void SetLabel(const wxString &aLabel) override
bool InformFirstDirection(int aDirection, int aSize, int aAvailableOtherDir) override
bool Create(wxWindow *aParent, wxWindowID aId, const wxString &aLabel, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxBORDER_NONE, const wxValidator &aValidator=wxDefaultValidator, const wxString &aName=wxT("COLLAPSIBLE_PANE_HEADER"))
bool SetBackgroundColour(const wxColour &aColor) override
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
wxDEFINE_EVENT(WX_COLLAPSIBLE_PANE_HEADER_CHANGED, wxCommandEvent)