KiCad PCB EDA Suite
toolbars_symbol_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) 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 "symbol_viewer_frame.h"
28 #include "sch_painter.h"
29 #include <tool/action_menu.h>
30 #include <tool/action_toolbar.h>
31 #include <tool/tool_manager.h>
32 #include <tools/ee_actions.h>
34 #include <widgets/wx_menubar.h>
35 
37 {
38  if( m_mainToolBar )
39  {
41  }
42  else
43  {
44  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
45  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
47  }
48 
49  m_mainToolBar->AddTool( ID_LIBVIEW_SELECT_PART, wxEmptyString,
51  _( "Choose symbol" ) );
52 
53  m_mainToolBar->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString,
55  _( "Display previous symbol" ) );
56 
57  m_mainToolBar->AddTool( ID_LIBVIEW_NEXT, wxEmptyString,
59  _( "Display next symbol" ) );
60 
66 
70 
72 
73  if( m_unitChoice == nullptr )
75  wxDefaultPosition, wxSize( 150, -1 ) );
76  m_mainToolBar->AddControl( m_unitChoice );
77 
80 
83 
84  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
86 
87  m_mainToolBar->Refresh();
88 }
89 
90 
92 {
93 }
94 
95 
97 {
99  // wxWidgets handles the OSX Application menu behind the scenes, but that means
100  // we always have to start from scratch with a new wxMenuBar.
101  wxMenuBar* oldMenuBar = GetMenuBar();
102  WX_MENUBAR* menuBar = new WX_MENUBAR();
103 
104  //-- File menu -----------------------------------------------------------
105  //
106  ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl );
107 
108  fileMenu->AddClose( _( "Symbol Viewer" ) );
109 
110 
111  //-- View menu -----------------------------------------------------------
112  //
113  ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl );
114 
115  viewMenu->Add( ACTIONS::zoomInCenter );
116  viewMenu->Add( ACTIONS::zoomOutCenter );
117  viewMenu->Add( ACTIONS::zoomFitScreen );
118  viewMenu->Add( ACTIONS::zoomRedraw );
119 
120  viewMenu->AppendSeparator();
122  viewMenu->Add( ACTIONS::gridProperties );
123 
124  viewMenu->AppendSeparator();
126 
127 
128  //-- Menubar -------------------------------------------------------------
129  //
130  menuBar->Append( fileMenu, _( "&File" ) );
131  menuBar->Append( viewMenu, _( "&View" ) );
132  AddStandardHelpMenu( menuBar );
133 
134  SetMenuBar( menuBar );
135  delete oldMenuBar;
136 }
void ReCreateMenuBar() override
Recreates the menu bar.
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon)
Add a wxWidgets-style entry to the menu.
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:137
Define the structure of a toolbar with buttons that invoke ACTIONs.
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:45
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)
Add a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
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:125
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
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
static TOOL_ACTION zoomOutCenter
Definition: actions.h:97
This file contains miscellaneous commonly used macros and functions.
void ReCreateHToolbar() override
static TOOL_ACTION toggleGrid
Definition: actions.h:143
const BITMAP_OPAQUE lib_previous_xpm[1]
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
const BITMAP_OPAQUE lib_next_xpm[1]
Definition: lib_next.cpp:53
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:164
void ReCreateVToolbar() override
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:124
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:200
static constexpr bool CHECK
Definition: action_menu.h:175
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
const BITMAP_OPAQUE library_browser_xpm[1]
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:93
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
static TOOL_ACTION gridProperties
Definition: actions.h:144
Definition for part library class.
Handle actions for the various symbol editor and viewers.
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.