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:
68 {
69 wxString label;
70 wxString tooltip;
71 wxString search_text;
72 TOOL_ACTION* action = nullptr;
74 int image_index = -1;
75 };
76
77 PANEL_TOOLBAR_CUSTOMIZATION( wxWindow* aParent, APP_SETTINGS_BASE* aCfg, TOOLBAR_SETTINGS* aTbSettings,
78 FRAME_T aActionContext, const std::vector<TOOL_ACTION*>& aTools,
79 const std::vector<ACTION_TOOLBAR_CONTROL*>& aControls );
80
82
83 void ResetPanel() override;
84
85 bool TransferDataFromWindow() override;
86 bool TransferDataToWindow() override;
87
88protected:
89 std::optional<TOOLBAR_CONFIGURATION> parseToolbarTree();
90
92
93 void populateActions();
94 void applyActionFilter();
95 bool isActionSupported( const TOOL_ACTION& aAction ) const;
96 bool actionMatchesFilter( const ACTION_LIST_ENTRY& aEntry, const wxString& aFilter ) const;
97
98 void enableCustomControls( bool enable );
99 void enableToolbarControls( bool enable );
100
101 void onGroupPress( wxCommandEvent& aEvent );
102 void onSpacerPress( wxCommandEvent& aEvent );
103 void onSeparatorPress( wxCommandEvent& aEvent );
104
105 // From the base class
106 void onCustomizeTbCb( wxCommandEvent& event ) override;
107 void onToolDelete( wxCommandEvent& event ) override;
108 void onToolMoveUp( wxCommandEvent& event ) override;
109 void onToolMoveDown( wxCommandEvent& event ) override;
110 void onBtnAddAction( wxCommandEvent& event ) override;
111 void onTreeBeginLabelEdit( wxTreeEvent& event ) override;
112 void onTreeEndLabelEdit( wxTreeEvent& event ) override;
113 void onTbChoiceSelect( wxCommandEvent& event ) override;
114 void onListItemActivated( wxListEvent& event ) override;
115 void onActionFilterText( wxCommandEvent& event );
116 void onActionListMouseMove( wxMouseEvent& event );
117
118protected:
119 wxVector<wxBitmapBundle> m_actionImageBundleVector;
120 std::map<std::string, int> m_actionImageListMap;
121 std::vector<ACTION_LIST_ENTRY> m_actionEntries;
123
124 // Actual settings for the frame
127
128 // The toolbar currently being viewed
131 std::vector<TOOLBAR_LOC> m_toolbarChoices;
132
133 // Shadow copy of the toolbar configurations used to store the changes in the dialog
134 std::map<TOOLBAR_LOC, TOOLBAR_CONFIGURATION> m_toolbars;
135
136 std::map<std::string, TOOL_ACTION*> m_availableTools;
137 std::map<std::string, ACTION_TOOLBAR_CONTROL*> m_availableControls;
138};
139
140 #endif /* PANEL_TOOLBAR_CUSTOMIZATION_H_ */
Class to hold basic information about controls that can be added to the toolbars.
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)
bool actionMatchesFilter(const ACTION_LIST_ENTRY &aEntry, const wxString &aFilter) const
void onSpacerPress(wxCommandEvent &aEvent)
wxVector< wxBitmapBundle > m_actionImageBundleVector
void onActionListMouseMove(wxMouseEvent &event)
void onTbChoiceSelect(wxCommandEvent &event) override
bool isActionSupported(const TOOL_ACTION &aAction) const
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.
std::vector< TOOLBAR_LOC > m_toolbarChoices
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()
PANEL_TOOLBAR_CUSTOMIZATION(wxWindow *aParent, APP_SETTINGS_BASE *aCfg, TOOLBAR_SETTINGS *aTbSettings, FRAME_T aActionContext, const std::vector< TOOL_ACTION * > &aTools, const std::vector< ACTION_TOOLBAR_CONTROL * > &aControls)
void onCustomizeTbCb(wxCommandEvent &event) override
void onActionFilterText(wxCommandEvent &event)
void onToolMoveDown(wxCommandEvent &event) override
void onListItemActivated(wxListEvent &event) override
void onToolMoveUp(wxCommandEvent &event) override
std::vector< ACTION_LIST_ENTRY > m_actionEntries
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.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:33
TOOL_ACTION * action
wxString label
ACTION_TOOLBAR_CONTROL * control
int image_index
wxString tooltip
wxString search_text