OpenCPN Partial API docs
Loading...
Searching...
No Matches
expand_panel.h
1/***************************************************************************
2 * Copyright (C) 2025 Alec Leamas *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
18#ifndef SHOW_HIDE_WIDGET__H_
19#define SHOW_HIDE_WIDGET__H_
20
21#include <functional>
22
23#include <wx/panel.h>
24
25#include "expand_icon.h"
26
40class ExpandablePanel : public wxPanel {
41public:
48 ExpandablePanel(wxWindow* parent, wxWindow* child,
49 std::function<void()> on_resize = [] {});
54 ExpandablePanel(wxWindow* parent);
55
61 void Create(wxWindow* child, std::function<void()> on_resize = [] {} );
62
64 wxWindow* GetIcon() const { return m_expand_icon; }
65
67 wxWindow* GetChild() const { return m_child; }
68
70 void EnableChild(bool enable);
71
73 void Collapse();
74
75protected:
76 void OnClick(bool collapse) const;
77
78private:
79 bool m_is_enabled;
80 wxWindow* m_child;
81 ExpandableIcon* m_expand_icon;
82 std::function<void()> m_on_resize;
83};
84
85#endif // SHOW_HIDE_WIDGET__H_
Simple panel showing either an "expand" or "collapse" icon, state switches when clicked.
Definition expand_icon.h:38
void EnableChild(bool enable)
Enable/disable showing the child.
ExpandablePanel(wxWindow *parent, wxWindow *child, std::function< void()> on_resize=[] {})
Single step constructor.
void Create(wxWindow *child, std::function< void()> on_resize=[] {})
Second part of two step creation.
void Collapse()
Show collapsed icon and hide child.
ExpandablePanel(wxWindow *parent)
First part of two step create.
wxWindow * GetIcon() const
Return the ExpandableIcon reflecting expanded/collapsed state.
wxWindow * GetChild() const
Return the managed window which is shown or hidden.