Browse Source
Switch appearance panel to custom collapsible pane widget
Switch appearance panel to custom collapsible pane widget
The new widget looks the same on all platforms and fixes a few bugs with the wxWidgets versionpull/16/head
12 changed files with 753 additions and 953 deletions
-
2bitmaps_png/CMakeLists.txt
-
19bitmaps_png/cpp_16/triangle_down.cpp
-
20bitmaps_png/cpp_16/triangle_right.cpp
-
2bitmaps_png/include/bitmaps_png/bitmaps_list.h
-
1common/CMakeLists.txt
-
364common/widgets/collapsible_pane.cpp
-
173include/widgets/collapsible_pane.h
-
155pcbnew/widgets/appearance_controls.cpp
-
26pcbnew/widgets/appearance_controls.h
-
103pcbnew/widgets/appearance_controls_base.cpp
-
819pcbnew/widgets/appearance_controls_base.fbp
-
22pcbnew/widgets/appearance_controls_base.h
@ -0,0 +1,19 @@ |
|||||
|
|
||||
|
/* Do not modify this file, it was automatically generated by the
|
||||
|
* PNG2cpp CMake script, using a *.png file as input. |
||||
|
*/ |
||||
|
|
||||
|
#include <bitmaps_png/bitmaps_list.h>
|
||||
|
|
||||
|
static const unsigned char png[] = { |
||||
|
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, |
||||
|
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0xb5, 0xfa, 0x37, |
||||
|
0xea, 0x00, 0x00, 0x00, 0x24, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x18, 0x05, 0xc8, |
||||
|
0xa0, 0x9c, 0xe1, 0x3f, 0x1a, 0xac, 0xc7, 0xaf, 0xa4, 0x1e, 0xbf, 0x29, 0xf5, 0xf8, 0x2d, 0xaa, |
||||
|
0xc7, 0xe7, 0x96, 0x06, 0x20, 0xa4, 0x37, 0x00, 0x00, 0x13, 0xe8, 0x18, 0xc5, 0xba, 0x45, 0x45, |
||||
|
0xda, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, |
||||
|
}; |
||||
|
|
||||
|
const BITMAP_OPAQUE triangle_down_xpm[1] = {{ png, sizeof( png ), "triangle_down_xpm" }}; |
||||
|
|
||||
|
//EOF
|
||||
@ -0,0 +1,20 @@ |
|||||
|
|
||||
|
/* Do not modify this file, it was automatically generated by the
|
||||
|
* PNG2cpp CMake script, using a *.png file as input. |
||||
|
*/ |
||||
|
|
||||
|
#include <bitmaps_png/bitmaps_list.h>
|
||||
|
|
||||
|
static const unsigned char png[] = { |
||||
|
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, |
||||
|
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0xb5, 0xfa, 0x37, |
||||
|
0xea, 0x00, 0x00, 0x00, 0x30, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x18, 0x00, 0xd0, |
||||
|
0x41, 0x48, 0xc1, 0x7f, 0x42, 0x4a, 0xfe, 0x13, 0x52, 0xf2, 0x9f, 0x90, 0x92, 0xff, 0x84, 0x94, |
||||
|
0xc0, 0x14, 0xd4, 0xe3, 0x57, 0x50, 0x8f, 0xdf, 0x8a, 0x7a, 0xfc, 0x8e, 0xac, 0xc7, 0xef, 0xcd, |
||||
|
0x06, 0xba, 0x47, 0x0d, 0x00, 0x87, 0xf7, 0x19, 0x11, 0xb1, 0x1b, 0x8d, 0xb6, 0x00, 0x00, 0x00, |
||||
|
0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, |
||||
|
}; |
||||
|
|
||||
|
const BITMAP_OPAQUE triangle_right_xpm[1] = {{ png, sizeof( png ), "triangle_right_xpm" }}; |
||||
|
|
||||
|
//EOF
|
||||
@ -0,0 +1,364 @@ |
|||||
|
/*
|
||||
|
* This program source code file is part of KiCad, a free EDA CAD application. |
||||
|
* |
||||
|
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation, either version 3 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
|
* General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
#include <bitmaps.h>
|
||||
|
#include <widgets/collapsible_pane.h>
|
||||
|
|
||||
|
#include <wx/collpane.h>
|
||||
|
#include <wx/renderer.h>
|
||||
|
|
||||
|
wxDEFINE_EVENT( WX_COLLAPSIBLE_PANE_HEADER_CHANGED, wxCommandEvent ); |
||||
|
wxDEFINE_EVENT( WX_COLLAPSIBLE_PANE_CHANGED, wxCommandEvent ); |
||||
|
|
||||
|
|
||||
|
bool WX_COLLAPSIBLE_PANE:: Create( wxWindow* aParent, wxWindowID aId, const wxString& aLabel, |
||||
|
const wxPoint& aPos, const wxSize& aSize, long aStyle, |
||||
|
const wxValidator& aValidator, const wxString& aName ) |
||||
|
{ |
||||
|
if( !wxControl::Create( aParent, aId, aPos, aSize, aStyle, aValidator, aName ) ) |
||||
|
return false; |
||||
|
|
||||
|
m_sizer = new wxBoxSizer( wxVERTICAL ); |
||||
|
|
||||
|
m_header = new WX_COLLAPSIBLE_PANE_HEADER( this, wxID_ANY, aLabel, wxPoint( 0, 0 ), |
||||
|
wxDefaultSize ); |
||||
|
|
||||
|
m_sizer->Add( m_header, wxSizerFlags().Border( wxBOTTOM, getBorder() ) ); |
||||
|
|
||||
|
m_pane = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, |
||||
|
wxTAB_TRAVERSAL | wxNO_BORDER, wxT( "COLLAPSIBLE_PANE_PANE" ) ); |
||||
|
|
||||
|
m_pane->Hide(); |
||||
|
|
||||
|
Bind( wxEVT_SIZE, &WX_COLLAPSIBLE_PANE::onSize, this ); |
||||
|
Bind( WX_COLLAPSIBLE_PANE_HEADER_CHANGED, &WX_COLLAPSIBLE_PANE::onHeaderClicked, this ); |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE::init() |
||||
|
{ |
||||
|
m_pane = nullptr; |
||||
|
m_sizer = nullptr; |
||||
|
m_header = nullptr; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
WX_COLLAPSIBLE_PANE::~WX_COLLAPSIBLE_PANE() |
||||
|
{ |
||||
|
if( m_sizer ) |
||||
|
m_sizer->SetContainingWindow( nullptr ); |
||||
|
|
||||
|
// Not owned by wxWindow
|
||||
|
delete m_sizer; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE::Collapse( bool aCollapse ) |
||||
|
{ |
||||
|
if( IsCollapsed() == aCollapse ) |
||||
|
return; |
||||
|
|
||||
|
InvalidateBestSize(); |
||||
|
|
||||
|
m_pane->Show( !aCollapse ); |
||||
|
m_header->SetCollapsed( aCollapse ); |
||||
|
|
||||
|
SetSize( GetBestSize() ); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool WX_COLLAPSIBLE_PANE::IsCollapsed() const |
||||
|
{ |
||||
|
return !m_pane || !m_pane->IsShown(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE::SetLabel( const wxString& aLabel ) |
||||
|
{ |
||||
|
m_header->SetLabel( aLabel ); |
||||
|
m_header->SetInitialSize(); |
||||
|
|
||||
|
Layout(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool WX_COLLAPSIBLE_PANE::SetBackgroundColour( const wxColour& aColor ) |
||||
|
{ |
||||
|
m_header->SetBackgroundColour( aColor ); |
||||
|
return wxWindow::SetBackgroundColour( aColor ); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool WX_COLLAPSIBLE_PANE::InformFirstDirection( int aDirection, int aSize, int aAvailableOtherDir ) |
||||
|
{ |
||||
|
wxWindow* const pane = GetPane(); |
||||
|
|
||||
|
if( !pane ) |
||||
|
return false; |
||||
|
|
||||
|
if( !pane->InformFirstDirection( aDirection, aSize, aAvailableOtherDir ) ) |
||||
|
return false; |
||||
|
|
||||
|
InvalidateBestSize(); |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
wxSize WX_COLLAPSIBLE_PANE::DoGetBestClientSize() const |
||||
|
{ |
||||
|
wxSize size = m_sizer->GetMinSize(); |
||||
|
|
||||
|
if( IsExpanded() ) |
||||
|
{ |
||||
|
wxSize paneSize = m_pane->GetBestSize(); |
||||
|
|
||||
|
size.SetWidth( std::max( size.GetWidth(), paneSize.x ) ); |
||||
|
size.SetHeight( size.y + getBorder() + paneSize.y ); |
||||
|
} |
||||
|
|
||||
|
return size; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool WX_COLLAPSIBLE_PANE::Layout() |
||||
|
{ |
||||
|
if( !m_sizer || !m_pane || !m_header ) |
||||
|
return false; |
||||
|
|
||||
|
wxSize size( GetSize() ); |
||||
|
|
||||
|
m_sizer->SetDimension( 0, 0, size.x, m_sizer->GetMinSize().y ); |
||||
|
m_sizer->Layout(); |
||||
|
|
||||
|
if( IsExpanded() ) |
||||
|
{ |
||||
|
int yoffset = m_sizer->GetSize().y + getBorder(); |
||||
|
m_pane->SetSize( 0, yoffset, size.x, size.y - yoffset ); |
||||
|
m_pane->Layout(); |
||||
|
} |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
int WX_COLLAPSIBLE_PANE::getBorder() const |
||||
|
{ |
||||
|
#if defined( __WXMSW__ )
|
||||
|
wxASSERT( m_header ); |
||||
|
return m_header->ConvertDialogToPixels( wxSize( 2, 0 ) ).x; |
||||
|
#else
|
||||
|
return 3; |
||||
|
#endif
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE::onSize( wxSizeEvent& aEvent ) |
||||
|
{ |
||||
|
Layout(); |
||||
|
aEvent.Skip(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE::onHeaderClicked( wxCommandEvent& aEvent ) |
||||
|
{ |
||||
|
if( aEvent.GetEventObject() != m_header ) |
||||
|
{ |
||||
|
aEvent.Skip(); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Collapse( !IsCollapsed() ); |
||||
|
|
||||
|
wxCommandEvent evt( WX_COLLAPSIBLE_PANE_CHANGED, GetId() ); |
||||
|
evt.SetEventObject( this ); |
||||
|
ProcessEvent( evt ); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// WX_COLLAPSIBLE_PANE_HEADER implementation
|
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE_HEADER::init() |
||||
|
{ |
||||
|
m_collapsed = true; |
||||
|
m_inWindow = false; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool WX_COLLAPSIBLE_PANE_HEADER::Create( wxWindow* aParent, wxWindowID aId, const wxString& aLabel, |
||||
|
const wxPoint& aPos, const wxSize& aSize, long aStyle, |
||||
|
const wxValidator& aValidator, const wxString& aName ) |
||||
|
{ |
||||
|
if ( !wxControl::Create( aParent, aId, aPos, aSize, aStyle, aValidator, aName ) ) |
||||
|
return false; |
||||
|
|
||||
|
m_iconRight = KiBitmap( triangle_right_xpm ); |
||||
|
m_iconDown = KiBitmap( triangle_down_xpm ); |
||||
|
|
||||
|
SetLabel( aLabel ); |
||||
|
|
||||
|
Bind( wxEVT_PAINT, &WX_COLLAPSIBLE_PANE_HEADER::onPaint, this ); |
||||
|
Bind( wxEVT_SET_FOCUS, &WX_COLLAPSIBLE_PANE_HEADER::onFocus, this ); |
||||
|
Bind( wxEVT_KILL_FOCUS, &WX_COLLAPSIBLE_PANE_HEADER::onFocus, this ); |
||||
|
Bind( wxEVT_ENTER_WINDOW, &WX_COLLAPSIBLE_PANE_HEADER::onEnterWindow, this); |
||||
|
Bind( wxEVT_LEAVE_WINDOW, &WX_COLLAPSIBLE_PANE_HEADER::onLeaveWindow, this); |
||||
|
Bind( wxEVT_LEFT_UP, &WX_COLLAPSIBLE_PANE_HEADER::onLeftUp, this ); |
||||
|
Bind( wxEVT_CHAR, &WX_COLLAPSIBLE_PANE_HEADER::onChar, this ); |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE_HEADER::SetCollapsed( bool aCollapsed ) |
||||
|
{ |
||||
|
m_collapsed = aCollapsed; |
||||
|
Refresh(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE_HEADER::doSetCollapsed( bool aCollapsed ) |
||||
|
{ |
||||
|
SetCollapsed( aCollapsed ); |
||||
|
|
||||
|
wxCommandEvent evt( WX_COLLAPSIBLE_PANE_HEADER_CHANGED, GetId() ); |
||||
|
evt.SetEventObject( this ); |
||||
|
ProcessEvent( evt ); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
wxSize WX_COLLAPSIBLE_PANE_HEADER::DoGetBestClientSize() const |
||||
|
{ |
||||
|
WX_COLLAPSIBLE_PANE_HEADER* self = const_cast<WX_COLLAPSIBLE_PANE_HEADER*>( this ); |
||||
|
|
||||
|
// The code here parallels that of OnPaint() -- except without drawing.
|
||||
|
wxClientDC dc( self ); |
||||
|
wxString text; |
||||
|
|
||||
|
wxControl::FindAccelIndex( GetLabel(), &text ); |
||||
|
|
||||
|
wxSize size = dc.GetTextExtent( text ); |
||||
|
|
||||
|
// Reserve space for icon
|
||||
|
size.x += m_iconRight.GetWidth(); |
||||
|
size.y = std::max( size.y, m_iconRight.GetHeight() ); |
||||
|
|
||||
|
#ifdef __WXMSW__
|
||||
|
size.IncBy( GetSystemMetrics( SM_CXFOCUSBORDER ), |
||||
|
GetSystemMetrics( SM_CYFOCUSBORDER ) ); |
||||
|
#endif // __WXMSW__
|
||||
|
|
||||
|
return size; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE_HEADER::onPaint( wxPaintEvent& aEvent ) |
||||
|
{ |
||||
|
wxPaintDC dc( this ); |
||||
|
wxRect rect( wxPoint( 0, 0 ), GetClientSize() ); |
||||
|
|
||||
|
#ifdef __WXMSW__
|
||||
|
wxBrush brush = dc.GetBrush(); |
||||
|
brush.SetColour( GetParent()->GetBackgroundColour() ); |
||||
|
dc.SetBrush( brush ); |
||||
|
dc.SetPen( *wxTRANSPARENT_PEN ); |
||||
|
dc.DrawRectangle( rect ); |
||||
|
#endif
|
||||
|
|
||||
|
wxString text; |
||||
|
int indexAccel = wxControl::FindAccelIndex( GetLabel(), &text ); |
||||
|
|
||||
|
wxSize textSize = dc.GetTextExtent( text ); |
||||
|
wxRect textRect( wxPoint( m_iconRight.GetWidth(), 0 ), textSize ); |
||||
|
textRect = textRect.CenterIn( rect, wxVERTICAL ); |
||||
|
|
||||
|
wxBitmap* icon = m_collapsed ? &m_iconRight : &m_iconDown; |
||||
|
|
||||
|
if( m_inWindow ) |
||||
|
{ |
||||
|
dc.SetTextForeground( wxSystemColour::wxSYS_COLOUR_HOTLIGHT ); |
||||
|
dc.DrawBitmap( icon->ConvertToDisabled( 200 ), wxPoint( 0, 0 ) ); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
dc.DrawBitmap( *icon, wxPoint( 0, 0 ) ); |
||||
|
} |
||||
|
|
||||
|
dc.DrawLabel( text, textRect, wxALIGN_CENTER_VERTICAL, indexAccel ); |
||||
|
|
||||
|
#ifdef __WXMSW__
|
||||
|
int flags = 0; |
||||
|
|
||||
|
if( m_inWindow ) |
||||
|
flags |= wxCONTROL_CURRENT; |
||||
|
|
||||
|
int focusSize = GetSystemMetrics( SM_CXFOCUSBORDER ); |
||||
|
|
||||
|
if( HasFocus() ) |
||||
|
wxRendererNative::Get().DrawFocusRect( this, dc, textRect.Inflate( focusSize ), flags ); |
||||
|
#endif
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE_HEADER::onFocus( wxFocusEvent& aEvent ) |
||||
|
{ |
||||
|
Refresh(); |
||||
|
aEvent.Skip(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE_HEADER::onEnterWindow( wxMouseEvent& aEvent ) |
||||
|
{ |
||||
|
m_inWindow = true; |
||||
|
Refresh(); |
||||
|
aEvent.Skip(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE_HEADER::onLeaveWindow( wxMouseEvent& aEvent ) |
||||
|
{ |
||||
|
m_inWindow = false; |
||||
|
Refresh(); |
||||
|
aEvent.Skip(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE_HEADER::onLeftUp( wxMouseEvent& aEvent ) |
||||
|
{ |
||||
|
doSetCollapsed( !m_collapsed ); |
||||
|
aEvent.Skip(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void WX_COLLAPSIBLE_PANE_HEADER::onChar( wxKeyEvent& aEvent ) |
||||
|
{ |
||||
|
switch( aEvent.GetKeyCode() ) |
||||
|
{ |
||||
|
case WXK_SPACE: |
||||
|
case WXK_RETURN: |
||||
|
doSetCollapsed( !m_collapsed ); |
||||
|
break; |
||||
|
|
||||
|
default: |
||||
|
aEvent.Skip(); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,173 @@ |
|||||
|
/* |
||||
|
* This program source code file is part of KiCad, a free EDA CAD application. |
||||
|
* |
||||
|
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation, either version 3 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
|
* General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
*/ |
||||
|
|
||||
|
#ifndef KICAD_COLLAPSIBLE_PANE_H |
||||
|
#define KICAD_COLLAPSIBLE_PANE_H |
||||
|
|
||||
|
#include <wx/wx.h> |
||||
|
|
||||
|
|
||||
|
wxDECLARE_EVENT( WX_COLLAPSIBLE_PANE_HEADER_CHANGED, wxCommandEvent ); |
||||
|
wxDECLARE_EVENT( WX_COLLAPSIBLE_PANE_CHANGED, wxCommandEvent ); |
||||
|
|
||||
|
/** |
||||
|
* A header control for WX_COLLAPSIBLE_PANE |
||||
|
* Looks like a static text with a unicode arrow prepended to show the state |
||||
|
* Takes the same space as a static text. This is similar to the wxCollapsiblePane on GTK. |
||||
|
*/ |
||||
|
class WX_COLLAPSIBLE_PANE_HEADER : public wxControl |
||||
|
{ |
||||
|
public: |
||||
|
WX_COLLAPSIBLE_PANE_HEADER() |
||||
|
{ |
||||
|
init(); |
||||
|
} |
||||
|
|
||||
|
WX_COLLAPSIBLE_PANE_HEADER( 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" ) ) |
||||
|
{ |
||||
|
init(); |
||||
|
|
||||
|
Create( aParent, aId, aLabel, aPos, aSize, aStyle, aValidator, aName ); |
||||
|
} |
||||
|
|
||||
|
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" ) ); |
||||
|
|
||||
|
void SetCollapsed( bool aCollapsed = true ); |
||||
|
|
||||
|
bool IsCollapsed() const |
||||
|
{ |
||||
|
return m_collapsed; |
||||
|
} |
||||
|
|
||||
|
protected: |
||||
|
|
||||
|
wxSize DoGetBestClientSize() const override; |
||||
|
|
||||
|
private: |
||||
|
wxString m_label; |
||||
|
bool m_collapsed; |
||||
|
bool m_inWindow; |
||||
|
wxBitmap m_iconRight; |
||||
|
wxBitmap m_iconDown; |
||||
|
|
||||
|
void init(); |
||||
|
|
||||
|
void onPaint( wxPaintEvent& aEvent ); |
||||
|
|
||||
|
void onFocus( wxFocusEvent& aEvent ); |
||||
|
|
||||
|
void onEnterWindow( wxMouseEvent& aEvent ); |
||||
|
|
||||
|
void onLeaveWindow( wxMouseEvent& aEvent ); |
||||
|
|
||||
|
void onLeftUp( wxMouseEvent& aEvent ); |
||||
|
|
||||
|
void onChar( wxKeyEvent& aEvent ); |
||||
|
|
||||
|
void doSetCollapsed( bool aCollapsed ); |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* A better wxCollapsiblePane that |
||||
|
* - Looks the same on all platforms |
||||
|
* - Doesn't have the same sizer bugs |
||||
|
* - Uses proper window colors |
||||
|
*/ |
||||
|
class WX_COLLAPSIBLE_PANE : public wxNavigationEnabled<wxControl> |
||||
|
{ |
||||
|
public: |
||||
|
WX_COLLAPSIBLE_PANE() |
||||
|
{ |
||||
|
init(); |
||||
|
} |
||||
|
|
||||
|
WX_COLLAPSIBLE_PANE( 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" ) ) |
||||
|
{ |
||||
|
init(); |
||||
|
|
||||
|
Create( aParent, aId, aLabel, aPos, aSize, aStyle, aValidator, aName ); |
||||
|
} |
||||
|
|
||||
|
~WX_COLLAPSIBLE_PANE(); |
||||
|
|
||||
|
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" ) ); |
||||
|
|
||||
|
void Collapse( bool aCollapse = true ); |
||||
|
|
||||
|
void Expand() |
||||
|
{ |
||||
|
Collapse( false ); |
||||
|
} |
||||
|
|
||||
|
bool IsCollapsed() const; |
||||
|
|
||||
|
bool IsExpanded() const { return !IsCollapsed(); } |
||||
|
|
||||
|
wxWindow* GetPane() |
||||
|
{ |
||||
|
return m_pane; |
||||
|
} |
||||
|
|
||||
|
wxString GetLabel() const override |
||||
|
{ |
||||
|
return m_header->GetLabel(); |
||||
|
} |
||||
|
|
||||
|
void SetLabel( const wxString& aLabel ) override; |
||||
|
|
||||
|
bool SetBackgroundColour( const wxColour& aColor ) override; |
||||
|
|
||||
|
bool InformFirstDirection( int aDirection, int aSize, int aAvailableOtherDir ) override; |
||||
|
|
||||
|
wxSize DoGetBestClientSize() const override; |
||||
|
|
||||
|
bool Layout() override; |
||||
|
|
||||
|
private: |
||||
|
wxWindow* m_pane; |
||||
|
wxSizer* m_sizer; |
||||
|
WX_COLLAPSIBLE_PANE_HEADER* m_header; |
||||
|
|
||||
|
void init(); |
||||
|
|
||||
|
int getBorder() const; |
||||
|
|
||||
|
void onSize( wxSizeEvent& aEvent ); |
||||
|
|
||||
|
void onHeaderClicked( wxCommandEvent& aEvent ); |
||||
|
}; |
||||
|
|
||||
|
#endif // KICAD_COLLAPSIBLE_PANE_H |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue