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
17 * along with this program. If not, see <https://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#include <kicommon.h>
28
29
30extern const KICOMMON_API wxEventTypeTag<wxCommandEvent> WX_COLLAPSIBLE_PANE_HEADER_CHANGED;
31extern const KICOMMON_API wxEventTypeTag<wxCommandEvent> WX_COLLAPSIBLE_PANE_CHANGED;
32
34
35
43{
44public:
45 WX_COLLAPSIBLE_PANE_HEADER( WX_COLLAPSIBLE_PANE* aParent, wxWindowID aId, const wxString& aLabel );
46
47 bool Create( wxWindow* aParent, wxWindowID aId, const wxString& aLabel );
48
49 void SetCollapsed( bool aCollapsed = true );
50
51 bool IsCollapsed() const { return m_collapsed; }
52
53protected:
54 wxSize DoGetBestClientSize() const override;
55
56private:
57 void init();
58
59 void onPaint( wxPaintEvent& aEvent );
60
61 void onFocus( wxFocusEvent& aEvent );
62
63 void onEnterWindow( wxMouseEvent& aEvent );
64
65 void onLeaveWindow( wxMouseEvent& aEvent );
66
67 void onLeftUp( wxMouseEvent& aEvent );
68
69 void onChar( wxKeyEvent& aEvent );
70
71 void doSetCollapsed( bool aCollapsed );
72
73 void drawArrow( wxDC& aDC, wxRect aRect, bool aIsActive );
74
75private:
77 wxString m_label;
80};
81
82
89class KICOMMON_API WX_COLLAPSIBLE_PANE : public wxNavigationEnabled<wxControl>
90{
91public:
92 WX_COLLAPSIBLE_PANE( wxWindow* aParent, wxWindowID aId, const wxString& aLabel )
93 {
94 init();
95 Create( aParent, aId, aLabel );
96 }
97
99
100 bool Create( wxWindow* aParent, wxWindowID aId, const wxString& aLabel );
101
102 void Collapse( bool aCollapse = true );
103
104 void Expand()
105 {
106 Collapse( false );
107 }
108
109 bool IsCollapsed() const;
110
111 bool IsExpanded() const { return !IsCollapsed(); }
112
113 wxWindow* GetPane() { return m_pane; }
114
115 int GetMargin() const;
116
117 wxString GetLabel() const override
118 {
119 return m_header->GetLabel();
120 }
121
122 void SetLabel( const wxString& aLabel ) override;
123
124 bool SetBackgroundColour( const wxColour& aColor ) override;
125
126 bool InformFirstDirection( int aDirection, int aSize, int aAvailableOtherDir ) override;
127
128 bool Layout() override;
129
130protected:
131 wxSize DoGetBestClientSize() const override;
132
133private:
134 void init();
135
136 void onSize( wxSizeEvent& aEvent );
137
138 void onHeaderClicked( wxCommandEvent& aEvent );
139
140private:
141 wxWindow* m_pane;
142 wxSizer* m_sizer;
144};
145
146#endif // KICAD_WX_COLLAPSIBLE_PANE_H
A header control for WX_COLLAPSIBLE_PANE.
WX_COLLAPSIBLE_PANE * m_parent
void SetCollapsed(bool aCollapsed=true)
WX_COLLAPSIBLE_PANE_HEADER(WX_COLLAPSIBLE_PANE *aParent, wxWindowID aId, const wxString &aLabel)
bool Create(wxWindow *aParent, wxWindowID aId, const wxString &aLabel)
A better wxCollapsiblePane that.
WX_COLLAPSIBLE_PANE(wxWindow *aParent, wxWindowID aId, const wxString &aLabel)
void Collapse(bool aCollapse=true)
bool Create(wxWindow *aParent, wxWindowID aId, const wxString &aLabel)
WX_COLLAPSIBLE_PANE_HEADER * m_header
wxString GetLabel() const override
#define KICOMMON_API
Definition kicommon.h:27
const KICOMMON_API wxEventTypeTag< wxCommandEvent > WX_COLLAPSIBLE_PANE_CHANGED
const KICOMMON_API wxEventTypeTag< wxCommandEvent > WX_COLLAPSIBLE_PANE_HEADER_CHANGED