KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_toolbar_customization.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
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 PANEL_TOOLBAR_CUSTOMIZATION_H_
25 #define PANEL_TOOLBAR_CUSTOMIZATION_H_
26
28
29#include <tool/action_toolbar.h>
31
32#include <wx/bmpbndl.h>
33
34class wxImageList;
35
37class TOOL_ACTION;
38
39
46class TOOLBAR_TREE : public wxTreeCtrl
47{
48public:
49 TOOLBAR_TREE( wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize, long style = wxTR_DEFAULT_STYLE ) :
51 wxTreeCtrl( parent, id, pos, size, style )
52 {
53 }
54
55 int OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 ) override;
56
57private:
58 // Need to use wxRTTI macros in order for OnCompareItems to work properly
59 // See: https://docs.wxwidgets.org/3.1/classwx_tree_ctrl.html#ab90a465793c291ca7aa827a576b7d146
61};
62
63
65{
66public:
67 PANEL_TOOLBAR_CUSTOMIZATION( wxWindow* aParent, APP_SETTINGS_BASE* aCfg, TOOLBAR_SETTINGS* aTbSettings,
68 const std::vector<TOOL_ACTION*>& aTools,
69 const std::vector<ACTION_TOOLBAR_CONTROL*>& aControls );
70
72
73 void ResetPanel() override;
74
75 bool TransferDataFromWindow() override;
76 bool TransferDataToWindow() override;
77
78protected:
79 std::optional<TOOLBAR_CONFIGURATION> parseToolbarTree();
80
82
83 void populateActions();
84
85 void enableCustomControls( bool enable );
86 void enableToolbarControls( bool enable );
87
88 void onGroupPress( wxCommandEvent& aEvent );
89 void onSpacerPress( wxCommandEvent& aEvent );
90 void onSeparatorPress( wxCommandEvent& aEvent );
91
92 // From the base class
93 void onCustomizeTbCb( wxCommandEvent& event ) override;
94 void onToolDelete( wxCommandEvent& event ) override;
95 void onToolMoveUp( wxCommandEvent& event ) override;
96 void onToolMoveDown( wxCommandEvent& event ) override;
97 void onBtnAddAction( wxCommandEvent& event ) override;
98 void onTreeBeginLabelEdit( wxTreeEvent& event ) override;
99 void onTreeEndLabelEdit( wxTreeEvent& event ) override;
100 void onTbChoiceSelect( wxCommandEvent& event ) override;
101 void onListItemActivated( wxListEvent& event ) override;
102
103protected:
104 wxVector<wxBitmapBundle> m_actionImageBundleVector;
105 std::map<std::string, int> m_actionImageListMap;
106
107 // Actual settings for the frame
110
111 // The toolbar currently being viewed
113
114 // Shadow copy of the toolbar configurations used to store the changes in the dialog
115 std::map<TOOLBAR_LOC, TOOLBAR_CONFIGURATION> m_toolbars;
116
117 std::map<std::string, TOOL_ACTION*> m_availableTools;
118 std::map<std::string, ACTION_TOOLBAR_CONTROL*> m_availableControls;
120};
121
122 #endif /* PANEL_TOOLBAR_CUSTOMIZATION_H_ */
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
PANEL_TOOLBAR_CUSTOMIZATION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void onSpacerPress(wxCommandEvent &aEvent)
wxVector< wxBitmapBundle > m_actionImageBundleVector
void onTbChoiceSelect(wxCommandEvent &event) override
void onTreeEndLabelEdit(wxTreeEvent &event) override
void onTreeBeginLabelEdit(wxTreeEvent &event) override
void onToolDelete(wxCommandEvent &event) override
std::map< TOOLBAR_LOC, TOOLBAR_CONFIGURATION > m_toolbars
void onGroupPress(wxCommandEvent &aEvent)
void onSeparatorPress(wxCommandEvent &aEvent)
void ResetPanel() override
Reset the contents of this panel.
PANEL_TOOLBAR_CUSTOMIZATION(wxWindow *aParent, APP_SETTINGS_BASE *aCfg, TOOLBAR_SETTINGS *aTbSettings, const std::vector< TOOL_ACTION * > &aTools, const std::vector< ACTION_TOOLBAR_CONTROL * > &aControls)
std::map< std::string, int > m_actionImageListMap
void onBtnAddAction(wxCommandEvent &event) override
std::map< std::string, TOOL_ACTION * > m_availableTools
std::map< std::string, ACTION_TOOLBAR_CONTROL * > m_availableControls
std::optional< TOOLBAR_CONFIGURATION > parseToolbarTree()
void onCustomizeTbCb(wxCommandEvent &event) override
void onToolMoveDown(wxCommandEvent &event) override
void onListItemActivated(wxListEvent &event) override
void onToolMoveUp(wxCommandEvent &event) override
TOOLBAR_TREE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTR_DEFAULT_STYLE)
wxDECLARE_ABSTRACT_CLASS(TOOLBAR_TREE)
int OnCompareItems(const wxTreeItemId &item1, const wxTreeItemId &item2) override
Represent a single user action.