KiCad PCB EDA Suite
action_toolbar.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) 2019 KiCad Developers, see CHANGELOG.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 ACTION_TOOLBAR_H
25 #define ACTION_TOOLBAR_H
26 
27 #include <map>
28 #include <wx/bitmap.h> // Needed for the auibar include
29 #include <wx/aui/auibar.h>
30 #include <tool/tool_event.h>
31 
32 class ACTION_MENU;
33 class EDA_BASE_FRAME;
34 class TOOL_MANAGER;
35 class TOOL_ACTION;
36 
42 class ACTION_TOOLBAR : public wxAuiToolBar
43 {
44 public:
45  ACTION_TOOLBAR( EDA_BASE_FRAME* parent, wxWindowID id = wxID_ANY,
46  const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
47  long style = wxAUI_TB_DEFAULT_STYLE );
48 
49  virtual ~ACTION_TOOLBAR();
50 
59  void Add( const TOOL_ACTION& aAction, bool aIsToggleEntry = false,
60  bool aIsCancellable = false );
61 
67  void AddButton( const TOOL_ACTION& aAction );
68 
75  void AddScaledSeparator( wxWindow* aWindow );
76 
85  void AddToolContextMenu( const TOOL_ACTION& aAction, ACTION_MENU* aMenu );
86 
90  void ClearToolbar();
91 
96  void SetToolBitmap( const TOOL_ACTION& aAction, const wxBitmap& aBitmap );
97 
102  void Toggle( const TOOL_ACTION& aAction, bool aState );
103 
104  void Toggle( const TOOL_ACTION& aAction, bool aEnabled, bool aChecked );
105 
106  static constexpr bool TOGGLE = true;
107  static constexpr bool CANCEL = true;
108 
109 protected:
111  void onToolEvent( wxAuiToolBarEvent& aEvent );
112 
114  void onToolRightClick( wxAuiToolBarEvent& aEvent );
115 
116 protected:
118  std::map<int, bool> m_toolKinds;
119  std::map<int, bool> m_toolCancellable;
120  std::map<int, const TOOL_ACTION*> m_toolActions;
121  std::map<int, ACTION_MENU*> m_toolMenus;
122 };
123 
124 #endif
ACTION_TOOLBAR.
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:43
static constexpr bool TOGGLE
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Adds a TOOL_ACTION-based button to the toolbar.
void onToolRightClick(wxAuiToolBarEvent &aEvent)
Handle a right-click on a menu item
void AddToolContextMenu(const TOOL_ACTION &aAction, ACTION_MENU *aMenu)
Add a context menu to a specific tool item on the toolbar.
void onToolEvent(wxAuiToolBarEvent &aEvent)
The default tool event handler.
std::map< int, ACTION_MENU * > m_toolMenus
std::map< int, const TOOL_ACTION * > m_toolActions
TOOL_MANAGER.
Definition: tool_manager.h:51
static constexpr bool CANCEL
void AddButton(const TOOL_ACTION &aAction)
Adds a large button such as used in the Kicad Manager Frame's launch bar.
std::map< int, bool > m_toolCancellable
ACTION_TOOLBAR(EDA_BASE_FRAME *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxAUI_TB_DEFAULT_STYLE)
TOOL_MANAGER * m_toolManager
The base frame for deriving all KiCad main window classes.
Represents a single user action.
Definition: tool_action.h:44
void SetToolBitmap(const TOOL_ACTION &aAction, const wxBitmap &aBitmap)
Updates the bitmap of a particular tool.
void Toggle(const TOOL_ACTION &aAction, bool aState)
Applies the default toggle action.
virtual ~ACTION_TOOLBAR()
std::map< int, bool > m_toolKinds
void ClearToolbar()
Clear the toolbar and remove all associated menus.