KiCad PCB EDA Suite
toolbars_lib_view.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
7  * Copyright (C) 2019 CERN
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 "class_library.h"
26 #include "eeschema_id.h"
27 #include "lib_view_frame.h"
28 #include "sch_painter.h"
29 #include <symbol_lib_table.h>
30 #include <tool/action_menu.h>
31 #include <tool/action_toolbar.h>
32 #include <tool/tool_manager.h>
33 #include <tools/ee_actions.h>
34 #include <tools/lib_control.h>
35 #include <widgets/wx_menubar.h>
36 
38 {
39  if( m_mainToolBar )
40  {
42  }
43  else
44  {
46  wxDefaultPosition, wxDefaultSize,
47  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
49  }
50 
51  m_mainToolBar->AddTool( ID_LIBVIEW_SELECT_PART, wxEmptyString,
53  _( "Select symbol to browse" ) );
54 
56  m_mainToolBar->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString,
58  _( "Display previous symbol" ) );
59 
60  m_mainToolBar->AddTool( ID_LIBVIEW_NEXT, wxEmptyString,
62  _( "Display next symbol" ) );
63 
69 
73 
75 
76  if( m_unitChoice == nullptr )
78  wxDefaultPosition, wxSize( 150, -1 ) );
79  m_mainToolBar->AddControl( m_unitChoice );
80 
83 
86 
87  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
88  m_mainToolBar->Realize();
89 
90  m_mainToolBar->Refresh();
91 }
92 
93 
95 {
96 }
97 
98 
100 {
101  LIB_CONTROL* libControl = m_toolManager->GetTool<LIB_CONTROL>();
102  // wxWidgets handles the OSX Application menu behind the scenes, but that means
103  // we always have to start from scratch with a new wxMenuBar.
104  wxMenuBar* oldMenuBar = GetMenuBar();
105  WX_MENUBAR* menuBar = new WX_MENUBAR();
106 
107  //-- File menu -----------------------------------------------------------
108  //
109  ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl );
110 
111  fileMenu->AddClose( _( "Footprint Viewer" ) );
112 
113 
114  //-- View menu -----------------------------------------------------------
115  //
116  ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl );
117 
118  viewMenu->Add( ACTIONS::zoomInCenter );
119  viewMenu->Add( ACTIONS::zoomOutCenter );
120  viewMenu->Add( ACTIONS::zoomFitScreen );
121  viewMenu->Add( ACTIONS::zoomRedraw );
122 
123  viewMenu->AppendSeparator();
125  viewMenu->Add( ACTIONS::gridProperties );
126 
127  viewMenu->AppendSeparator();
129 
130 
131  //-- Menubar -------------------------------------------------------------
132  //
133  menuBar->Append( fileMenu, _( "&File" ) );
134  menuBar->Append( viewMenu, _( "&View" ) );
135  AddStandardHelpMenu( menuBar );
136 
137  SetMenuBar( menuBar );
138  delete oldMenuBar;
139 }
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon)
Adds a wxWidgets-style entry to the menu.
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:140
ACTION_TOOLBAR.
static TOOL_ACTION zoomInCenter
Definition: actions.h:91
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.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
const BITMAP_OPAQUE add_component_xpm[1]
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 showDeMorganAlternate
Definition: ee_actions.h:128
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, wxWindow *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:118
static TOOL_ACTION zoomOutCenter
Definition: actions.h:92
This file contains miscellaneous commonly used macros and functions.
Handle actions for the various symbol editor and viewers.
Definition: lib_control.h:37
void ReCreateMenuBar() override
Recreates the menu bar.
static TOOL_ACTION toggleGrid
Definition: actions.h:138
const BITMAP_OPAQUE lib_previous_xpm[1]
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
void ReCreateHToolbar() override
const BITMAP_OPAQUE lib_next_xpm[1]
Definition: lib_next.cpp:84
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:166
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:127
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:201
static constexpr bool CHECK
Definition: action_menu.h:162
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
#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 gridProperties
Definition: actions.h:139
wxChoice * m_unitChoice
void ReCreateVToolbar() override
Definition for part library class.
void AddClose(wxString aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.
void ClearToolbar()
Clear the toolbar and remove all associated menus.