KiCad PCB EDA Suite
button_row_panel.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 (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef SIMPLE_BUTTON_PANEL_H
25#define SIMPLE_BUTTON_PANEL_H
26
27#include "wx/panel.h"
28
29#include <vector>
30#include <functional>
31
32
33// Forward defs for private-only classes
34class wxBoxSizer;
35
36
40class BUTTON_ROW_PANEL: public wxPanel
41{
42public:
43
48 using BTN_CALLBACK = std::function< void( wxCommandEvent& ) >;
49
53 struct BTN_DEF
54 {
59 wxWindowID m_id;
60
64 wxString m_text;
65
69 wxString m_tooltip;
70
76 };
77
81 using BTN_DEF_LIST = std::vector<BTN_DEF>;
82
89 BUTTON_ROW_PANEL( wxWindow* aWindow,
90 const BTN_DEF_LIST& aLeftBtns,
91 const BTN_DEF_LIST& aRightBtns );
92
93private:
94
102 void addButtons( bool aLeft, const BTN_DEF_LIST& aDefs );
103
104 wxBoxSizer* m_sizer;
105};
106
107#endif // SIMPLE_BUTTON_PANEL_H
A panel that contains buttons, arranged on the left and/or right sides.
wxBoxSizer * m_sizer
std::function< void(wxCommandEvent &) > BTN_CALLBACK
Callback function definition.
BUTTON_ROW_PANEL(wxWindow *aWindow, const BTN_DEF_LIST &aLeftBtns, const BTN_DEF_LIST &aRightBtns)
Construct a SIMPLE_BUTTON_PANEL with a set of buttons on each side.
void addButtons(bool aLeft, const BTN_DEF_LIST &aDefs)
Add a set of buttons to one side of the panel.
std::vector< BTN_DEF > BTN_DEF_LIST
A list of BTN_DEFs, used to group buttons into the left/right groups.
The information needed to instantiate a button on a BUTTON_ROW_PANEL.
wxString m_tooltip
Button tooltip text - empty string for no tooltip.
wxWindowID m_id
The button ID.
wxString m_text
The button display text.
BTN_CALLBACK m_callback
The callback fired when the button is clicked.