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 )
47  else
48  m_mainToolBar = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
49  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
50 
51  // Set up toolbar
52  m_mainToolBar->AddTool( ID_MODVIEW_PREVIOUS, wxEmptyString,
54  _( "Display previous footprint" ) );
55  m_mainToolBar->AddTool( ID_MODVIEW_NEXT, wxEmptyString,
57  _( "Display next footprint" ) );
58 
66 
69  m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
70  KiScaledBitmap( export_xpm, this ),
71  _( "Insert footprint in board" ) );
72 
74 
75  // Grid selection choice box.
76  if( m_gridSelectBox == nullptr )
78  wxDefaultPosition, wxDefaultSize, 0, NULL );
79 
81  m_mainToolBar->AddControl( m_gridSelectBox );
82 
84 
85  // Zoom selection choice box.
86  if( m_zoomSelectBox == nullptr )
88  wxDefaultPosition, wxDefaultSize, 0, NULL );
89 
91  m_mainToolBar->AddControl( m_zoomSelectBox );
92 
93  // after adding the buttons to the toolbar, must call Realize() to
94  // reflect the changes
95  m_mainToolBar->Realize();
96 }
97 
98 
100 {
101  if( m_optionsToolBar )
103  else
104  m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
105  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
106 
109 
116 
122 
123  m_optionsToolBar->Realize();
124 }
125 
126 
128 {
129  // This toolbar is not currently used
130 }
131 
132 
134 {
137  m_mainToolBar->Refresh();
138 
144 
145  const PCB_DISPLAY_OPTIONS& opts = GetDisplayOptions();
146 
151 
152  m_optionsToolBar->Refresh();
153 }
154 
155 
157 {
159  // wxWidgets handles the Mac Application menu behind the scenes, but that means
160  // we always have to start from scratch with a new wxMenuBar.
161  wxMenuBar* oldMenuBar = GetMenuBar();
162  WX_MENUBAR* menuBar = new WX_MENUBAR();
163 
164  //----- File menu -----------------------------------------------------------
165  //
166  CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
167 
168  fileMenu->AddClose( _( "Footprint Viewer" ) );
169 
170  fileMenu->Resolve();
171 
172  //----- View menu -----------------------------------------------------------
173  //
174  CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
175 
176  viewMenu->AddSeparator();
181 
182  viewMenu->AddSeparator();
184 
185  viewMenu->Resolve();
186 
187  //----- Menubar -------------------------------------------------------------
188  //
189  menuBar->Append( fileMenu, _( "&File" ) );
190  menuBar->Append( viewMenu, _( "&View" ) );
191  AddStandardHelpMenu( menuBar );
192 
193  SetMenuBar( menuBar );
194  delete oldMenuBar;
195 }
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
static TOOL_ACTION show3DViewer
Definition: actions.h:152
bool IsCurrentTool(const TOOL_ACTION &aAction) const
ACTION_TOOLBAR.
static TOOL_ACTION zoomInCenter
Definition: actions.h:90
ACTION_TOOLBAR * m_optionsToolBar
static const bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:95
SELECTION_TOOL.
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
bool GetAutoZoom() override
Always returns false.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false)
Function Add() Adds a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
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:231
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, wxWindow *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:116
static TOOL_ACTION imperialUnits
Definition: actions.h:140
wxChoice * m_gridSelectBox
static TOOL_ACTION zoomOutCenter
Definition: actions.h:91
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:148
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
#define NULL
bool IsGridVisible() const
static TOOL_ACTION toggleGrid
Definition: actions.h:136
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:230
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:75
static TOOL_ACTION togglePolarCoords
Definition: actions.h:143
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
const BITMAP_OPAQUE lib_next_xpm[1]
Definition: lib_next.cpp:82
void Resolve()
Function Resolve()
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:224
static TOOL_ACTION graphicsOutlines
Display module edges as outlines.
Definition: pcb_actions.h:368
static TOOL_ACTION metricUnits
Definition: actions.h:141
void AddClose(wxString aAppname="")
Function AddClose()
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:87
void Toggle(const TOOL_ACTION &aAction, bool aState)
Applies the default toggle action.
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:98
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
static TOOL_ACTION selectionTool
Definition: actions.h:147
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:371
void ClearToolbar()
Clear the toolbar and remove all associated menus.