KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wx_collapsible_pane.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef KICAD_WX_COLLAPSIBLE_PANE_H
21#define KICAD_WX_COLLAPSIBLE_PANE_H
22
23#include <wx/control.h>
24#include <wx/containr.h>
25#include <wx/statbox.h> // needed to provide a hint that wx libraries instantiated
26 // wxNavigationEnabled<wxControl>
27
28
29wxDECLARE_EVENT( WX_COLLAPSIBLE_PANE_HEADER_CHANGED, wxCommandEvent );
30wxDECLARE_EVENT( WX_COLLAPSIBLE_PANE_CHANGED, wxCommandEvent );
31
38class WX_COLLAPSIBLE_PANE_HEADER : public wxControl
39{
40public:
42 {
43 init();
44 }
45
46 WX_COLLAPSIBLE_PANE_HEADER( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
47 const wxPoint& aPos = wxDefaultPosition,
48 const wxSize& aSize = wxDefaultSize, long aStyle = wxBORDER_NONE,
49 const wxValidator& aValidator = wxDefaultValidator,
50 const wxString& aName = wxT( "COLLAPSIBLE_PANE_HEADER" ) )
51 {
52 init();
53
54 Create( aParent, aId, aLabel, aPos, aSize, aStyle, aValidator, aName );
55 }
56
57 bool Create( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
58 const wxPoint& aPos = wxDefaultPosition,
59 const wxSize& aSize = wxDefaultSize, long aStyle = wxBORDER_NONE,
60 const wxValidator& aValidator = wxDefaultValidator,
61 const wxString& aName = wxT( "COLLAPSIBLE_PANE_HEADER" ) );
62
63 void SetCollapsed( bool aCollapsed = true );
64
65 bool IsCollapsed() const
66 {
67 return m_collapsed;
68 }
69
70protected:
71
72 wxSize DoGetBestClientSize() const override;
73
74private:
75 wxString m_label;
78
79 void init();
80
81 void onPaint( wxPaintEvent& aEvent );
82
83 void onFocus( wxFocusEvent& aEvent );
84
85 void onEnterWindow( wxMouseEvent& aEvent );
86
87 void onLeaveWindow( wxMouseEvent& aEvent );
88
89 void onLeftUp( wxMouseEvent& aEvent );
90
91 void onChar( wxKeyEvent& aEvent );
92
93 void doSetCollapsed( bool aCollapsed );
94
95 void drawArrow( wxDC& aDC, wxRect aRect, bool aIsActive );
96};
97
98
105class WX_COLLAPSIBLE_PANE : public wxNavigationEnabled<wxControl>
106{
107public:
109 {
110 init();
111 }
112
113 WX_COLLAPSIBLE_PANE( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
114 const wxPoint& aPos = wxDefaultPosition,
115 const wxSize& aSize = wxDefaultSize, long aStyle = wxBORDER_NONE,
116 const wxValidator& aValidator = wxDefaultValidator,
117 const wxString& aName = wxT( "COLLAPSIBLE_PANE_HEADER" ) )
118 {
119 init();
120
121 Create( aParent, aId, aLabel, aPos, aSize, aStyle, aValidator, aName );
122 }
123
125
126 bool Create( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
127 const wxPoint& aPos = wxDefaultPosition,
128 const wxSize& aSize = wxDefaultSize, long aStyle = wxBORDER_NONE,
129 const wxValidator& aValidator = wxDefaultValidator,
130 const wxString& aName = wxT( "COLLAPSIBLE_PANE_HEADER" ) );
131
132 void Collapse( bool aCollapse = true );
133
134 void Expand()
135 {
136 Collapse( false );
137 }
138
139 bool IsCollapsed() const;
140
141 bool IsExpanded() const { return !IsCollapsed(); }
142
143 wxWindow* GetPane()
144 {
145 return m_pane;
146 }
147
148 wxString GetLabel() const override
149 {
150 return m_header->GetLabel();
151 }
152
153 void SetLabel( const wxString& aLabel ) override;
154
155 bool SetBackgroundColour( const wxColour& aColor ) override;
156
157 bool InformFirstDirection( int aDirection, int aSize, int aAvailableOtherDir ) override;
158
159 wxSize DoGetBestClientSize() const override;
160
161 bool Layout() override;
162
163private:
164 wxWindow* m_pane;
165 wxSizer* m_sizer;
167
168 void init();
169
170 int getBorder() const;
171
172 void onSize( wxSizeEvent& aEvent );
173
174 void onHeaderClicked( wxCommandEvent& aEvent );
175};
176
177#endif // KICAD_WX_COLLAPSIBLE_PANE_H
A header control for WX_COLLAPSIBLE_PANE.
void drawArrow(wxDC &aDC, wxRect aRect, bool aIsActive)
void onLeaveWindow(wxMouseEvent &aEvent)
void onFocus(wxFocusEvent &aEvent)
void onChar(wxKeyEvent &aEvent)
void SetCollapsed(bool aCollapsed=true)
void onPaint(wxPaintEvent &aEvent)
wxSize DoGetBestClientSize() const override
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"))
void doSetCollapsed(bool aCollapsed)
void onEnterWindow(wxMouseEvent &aEvent)
void onLeftUp(wxMouseEvent &aEvent)
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"))
A better wxCollapsiblePane that.
wxSize DoGetBestClientSize() const override
void Collapse(bool aCollapse=true)
void onSize(wxSizeEvent &aEvent)
void onHeaderClicked(wxCommandEvent &aEvent)
WX_COLLAPSIBLE_PANE_HEADER * m_header
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"))
void SetLabel(const wxString &aLabel) override
bool InformFirstDirection(int aDirection, int aSize, int aAvailableOtherDir) override
wxString GetLabel() const 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
wxDECLARE_EVENT(WX_COLLAPSIBLE_PANE_HEADER_CHANGED, wxCommandEvent)