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 
34 
36 {
37  // Note:
38  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
39  // all wxAuiToolBarItems.
40  // However the wxAuiToolBarItems are not the owners of controls managed by
41  // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
42  // So we do not recreate them after clearing the tools.
43 
44  wxString msg;
45 
46  if( m_mainToolBar )
47  m_mainToolBar->Clear();
48  else
49  m_mainToolBar = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
50  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
51 
52  // Set up toolbar
53  m_mainToolBar->AddTool( ID_MODVIEW_OPTIONS, wxEmptyString,
54  KiScaledBitmap( config_xpm, this ),
55  _( "Display options" ) );
56 
57  m_mainToolBar->AddSeparator();
58  m_mainToolBar->AddTool( ID_MODVIEW_PREVIOUS, wxEmptyString,
59  KiScaledBitmap( lib_previous_xpm, this ),
60  _( "Display previous footprint" ) );
61  m_mainToolBar->AddTool( ID_MODVIEW_NEXT, wxEmptyString,
62  KiScaledBitmap( lib_next_xpm, this ),
63  _( "Display next footprint" ) );
64 
65  m_mainToolBar->AddSeparator();
70 
73  m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
74  KiScaledBitmap( export_xpm, this ),
75  _( "Insert footprint in board" ) );
76 
78 
79  // Grid selection choice box.
80  if( m_gridSelectBox == nullptr )
82  wxDefaultPosition, wxDefaultSize, 0, NULL );
83 
85  m_mainToolBar->AddControl( m_gridSelectBox );
86 
88 
89  // Zoom selection choice box.
90  if( m_zoomSelectBox == nullptr )
92  wxDefaultPosition, wxDefaultSize, 0, NULL );
93 
95  m_mainToolBar->AddControl( m_zoomSelectBox );
96 
97  // after adding the buttons to the toolbar, must call Realize() to
98  // reflect the changes
99  m_mainToolBar->Realize();
100  m_mainToolBar->Refresh();
101 }
102 
103 
105 {
106 }
107 
108 
110 {
112  // wxWidgets handles the Mac Application menu behind the scenes, but that means
113  // we always have to start from scratch with a new wxMenuBar.
114  wxMenuBar* oldMenuBar = GetMenuBar();
115  wxMenuBar* menuBar = new wxMenuBar();
116 
117  //----- File menu -----------------------------------------------------------
118  //
119  CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
120 
121  fileMenu->AddClose( _( "Footprint Viewer" ) );
122 
123  fileMenu->Resolve();
124 
125  //----- View menu -----------------------------------------------------------
126  //
127  CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
128 
129  viewMenu->AddSeparator();
134 
135  viewMenu->AddSeparator();
137 
138  viewMenu->Resolve();
139 
140  //----- Menubar -------------------------------------------------------------
141  //
142  menuBar->Append( fileMenu, _( "&File" ) );
143  menuBar->Append( viewMenu, _( "&View" ) );
144  AddStandardHelpMenu( menuBar );
145 
146  SetMenuBar( menuBar );
147  delete oldMenuBar;
148 }
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
static TOOL_ACTION show3DViewer
Definition: actions.h:147
Class ACTION_TOOLBAR.
static TOOL_ACTION zoomInCenter
Definition: actions.h:89
Class SELECTION_TOOL.
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:92
ACTION_TOOLBAR * m_mainToolBar
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:116
wxChoice * m_gridSelectBox
static TOOL_ACTION zoomOutCenter
Definition: actions.h:90
This file contains miscellaneous commonly used macros and functions.
wxChoice * m_zoomSelectBox
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
#define _(s)
void Resolve()
Function Resolve()
void UpdateGridSelectBox()
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
void AddClose(wxString aAppname="")
Function AddClose()
void ReCreateMenuBar() override
Recreates the menu bar.
static TOOL_ACTION zoomRedraw
Definition: actions.h:86
void KiScaledSeparator(wxAuiToolBar *aToolbar, EDA_BASE_FRAME *aWindow)
Add a separator to the given toolbar scaled the same way as KiScaledBitmap.
Definition: bitmap.cpp:167
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
TOOL_MANAGER * m_toolManager
void updateZoomSelectBox()
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()