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 EDA_DRAW_FRAME;
33 class TOOL_MANAGER;
34 class TOOL_ACTION;
35 
41 class ACTION_TOOLBAR : public wxAuiToolBar
42 {
43 public:
44  ACTION_TOOLBAR( EDA_BASE_FRAME* parent, wxWindowID id = wxID_ANY,
45  const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
46  long style = wxAUI_TB_DEFAULT_STYLE );
47 
48  virtual ~ACTION_TOOLBAR() {}
49 
55  void Add( const TOOL_ACTION& aAction, bool aIsToggleEntry = false );
56 
62  void AddButton( const TOOL_ACTION& aAction );
63 
69  void SetToolBitmap( const TOOL_ACTION& aAction, const wxBitmap& aBitmap );
70 
75  void Toggle( const TOOL_ACTION& aAction, bool aState );
76 
77  void Toggle( const TOOL_ACTION& aAction, bool aEnabled, bool aChecked );
78 
79  static const bool TOGGLE = true;
80 
81 protected:
83  void onToolEvent( wxAuiToolBarEvent& aEvent );
84 
85 protected:
87  static const int ACTION_ID = 10000;
88 
90  std::map<int, bool> m_toolKinds;
91  std::map<int, const TOOL_ACTION*> m_toolActions;
92 };
93 
94 #endif
Class ACTION_TOOLBAR.
static const bool TOGGLE
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false)
Function Add() Adds a TOOL_ACTION-based button to the toolbar.
void onToolEvent(wxAuiToolBarEvent &aEvent)
The default tool event handler.
The base class for create windows for drawing purpose.
std::map< int, const TOOL_ACTION * > m_toolActions
Class TOOL_MANAGER.
Definition: tool_manager.h:50
void AddButton(const TOOL_ACTION &aAction)
Function AddButton() Adds a large button such as used in the Kicad Manager Frame's launch bar.
virtual ~ACTION_TOOLBAR()
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.
Class TOOL_ACTION.
Definition: tool_action.h:46
void SetToolBitmap(const TOOL_ACTION &aAction, const wxBitmap &aBitmap)
Function SetToolBitmap() Updates the bitmap of a particular tool.
void Toggle(const TOOL_ACTION &aAction, bool aState)
Applies the default toggle action.
static const int ACTION_ID
Tool items with ID higher than that are considered TOOL_ACTIONs
std::map< int, bool > m_toolKinds