KiCad PCB EDA Suite
toolbars_footprint_viewer.cpp
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) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation, either version 3 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 
24 #include <macros.h>
25 #include <bitmaps.h>
26 #include <tool/action_toolbar.h>
27 #include <tool/conditional_menu.h>
28 #include <tool/tool_manager.h>
29 #include <tools/selection_tool.h>
30 #include <tools/pcb_actions.h>
31 #include "footprint_viewer_frame.h"
32 #include "pcbnew_id.h"
33 #include <widgets/wx_menubar.h>
34 
35 
37 {
38  // Note:
39  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
40  // all wxAuiToolBarItems.
41  // However the wxAuiToolBarItems are not the owners of controls managed by
42  // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
43  // So we do not recreate them after clearing the tools.
44 
45  if( m_mainToolBar )
46  {
48  }
49  else
50  {
51  m_mainToolBar = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
52  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
54  }
55 
56  // Set up toolbar
57  m_mainToolBar->AddTool( ID_MODVIEW_PREVIOUS, wxEmptyString,
59  _( "Display previous footprint" ) );
60  m_mainToolBar->AddTool( ID_MODVIEW_NEXT, wxEmptyString,
62  _( "Display next footprint" ) );
63 
71 
74  m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
75  KiScaledBitmap( export_xpm, this ),
76  _( "Insert footprint in board" ) );
77 
79 
80  // Grid selection choice box.
81  if( m_gridSelectBox == nullptr )
83  wxDefaultPosition, wxDefaultSize, 0, NULL );
84 
86  m_mainToolBar->AddControl( m_gridSelectBox );
87 
89 
90  // Zoom selection choice box.
91  if( m_zoomSelectBox == nullptr )
93  wxDefaultPosition, wxDefaultSize, 0, NULL );
94 
96  m_mainToolBar->AddControl( m_zoomSelectBox );
97 
98  // after adding the buttons to the toolbar, must call Realize() to
99  // reflect the changes
100  m_mainToolBar->Realize();
101 }
102 
103 
105 {
106  if( m_optionsToolBar )
107  {
109  }
110  else
111  {
112  m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
113  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
115  }
116 
119 
127 
133 
134  m_optionsToolBar->Realize();
135 }
136 
137 
139 {
140  // This toolbar is not currently used
141 }
142 
143 
145 {
147  // wxWidgets handles the Mac Application menu behind the scenes, but that means
148  // we always have to start from scratch with a new wxMenuBar.
149  wxMenuBar* oldMenuBar = GetMenuBar();
150  WX_MENUBAR* menuBar = new WX_MENUBAR();
151 
152 
153  //----- File menu -----------------------------------------------------------
154  //
155  ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
156 
157  fileMenu->AddClose( _( "Footprint Viewer" ) );
158 
159 
160  //----- View menu -----------------------------------------------------------
161  //
162  ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
163 
164  viewMenu->AppendSeparator();
165  viewMenu->Add( ACTIONS::zoomInCenter );
166  viewMenu->Add( ACTIONS::zoomOutCenter );
167  viewMenu->Add( ACTIONS::zoomFitScreen );
168  viewMenu->Add( ACTIONS::zoomRedraw );
169 
170  viewMenu->AppendSeparator();
171  viewMenu->Add( ACTIONS::show3DViewer );
172 
173 
174  //----- Menubar -------------------------------------------------------------
175  //
176  menuBar->Append( fileMenu, _( "&File" ) );
177  menuBar->Append( viewMenu, _( "&View" ) );
178  AddStandardHelpMenu( menuBar );
179 
180  SetMenuBar( menuBar );
181  delete oldMenuBar;
182 }
static TOOL_ACTION show3DViewer
Definition: actions.h:156
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon)
Adds a wxWidgets-style entry to the menu.
ACTION_TOOLBAR.
static TOOL_ACTION zoomInCenter
Definition: actions.h:91
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:43
ACTION_TOOLBAR * m_optionsToolBar
static constexpr bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:97
SELECTION_TOOL.
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.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION millimetersUnits
Definition: actions.h:144
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:45
static TOOL_ACTION zoomFootprintAutomatically
Definition: pcb_actions.h:242
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, wxWindow *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:119
wxChoice * m_gridSelectBox
static TOOL_ACTION zoomOutCenter
Definition: actions.h:92
This file contains miscellaneous commonly used macros and functions.
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
static TOOL_ACTION measureTool
Definition: actions.h:152
static constexpr bool CANCEL
#define NULL
static TOOL_ACTION toggleGrid
Definition: actions.h:138
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:241
static TOOL_ACTION inchesUnits
Definition: actions.h:142
wxChoice * m_zoomSelectBox
const BITMAP_OPAQUE lib_previous_xpm[1]
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
const BITMAP_OPAQUE export_xpm[1]
Definition: export.cpp:71
static TOOL_ACTION togglePolarCoords
Definition: actions.h:147
const BITMAP_OPAQUE lib_next_xpm[1]
Definition: lib_next.cpp:84
static TOOL_ACTION milsUnits
Definition: actions.h:143
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:235
static TOOL_ACTION graphicsOutlines
Display module edges as outlines.
Definition: pcb_actions.h:378
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
void ReCreateMenuBar() override
Recreates the menu bar.
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:88
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
static TOOL_ACTION selectionTool
Definition: actions.h:151
void AddClose(wxString aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:381
void ClearToolbar()
Clear the toolbar and remove all associated menus.