KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
6 * Copyright The 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#include <bitmaps.h>
24#include <macros.h>
25#include <eeschema_id.h>
26#include <symbol_viewer_frame.h>
27#include <sch_painter.h>
28#include <tool/action_menu.h>
29#include <tool/action_toolbar.h>
30#include <tools/sch_actions.h>
32#include <widgets/wx_menubar.h>
34#include <wx/choice.h>
35
36std::optional<TOOLBAR_CONFIGURATION> SYMBOL_VIEWER_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
37{
39
40 // clang-format off
41 switch( aToolbar )
42 {
46 return std::nullopt;
47
50 .AppendAction( SCH_ACTIONS::nextSymbol );
51
52 config.AppendSeparator()
53 .AppendAction( ACTIONS::zoomRedraw )
54 .AppendAction( ACTIONS::zoomInCenter )
55 .AppendAction( ACTIONS::zoomOutCenter )
56 .AppendAction( ACTIONS::zoomFitScreen );
57
58 config.AppendSeparator()
60 .AppendAction( SCH_ACTIONS::showPinNumbers );
61
62 config.AppendSeparator()
64
65 config.AppendSeparator()
67
68 config.AppendSeparator()
69 .AppendAction( ACTIONS::showDatasheet );
70
71 config.AppendSeparator()
72 .AppendAction( SCH_ACTIONS::addSymbolToSchematic );
73 break;
74 }
75
76 // clang-format on
77 return config;
78}
79
80
82{
84
85 // Toolbar widget for selecting the unit to show in the symbol viewer
86 auto unitChoiceFactory =
87 [this]( ACTION_TOOLBAR* aToolbar )
88 {
89 if( !m_unitChoice )
90 {
92 wxDefaultPosition, wxSize( 150, -1 ) );
93 }
94
95 aToolbar->Add( m_unitChoice );
96 };
97
98 auto bodyChoiceFactory =
99 [this]( ACTION_TOOLBAR* aToolbar )
100 {
101 if( !m_bodyStyleChoice )
102 {
104 wxDefaultPosition, wxSize( 150, -1 ) );
105 }
106
107 aToolbar->Add( m_bodyStyleChoice );
108 };
109
112}
113
114
116{
118
119 switch( aId )
120 {
121 case ID_LIBVIEW_SELECT_UNIT_NUMBER: m_unitChoice = nullptr; break;
122 case ID_LIBVIEW_SELECT_BODY_STYLE: m_bodyStyleChoice = nullptr; break;
123 }
124}
125
126
128{
130 // wxWidgets handles the OSX Application menu behind the scenes, but that means
131 // we always have to start from scratch with a new wxMenuBar.
132 wxMenuBar* oldMenuBar = GetMenuBar();
133 WX_MENUBAR* menuBar = new WX_MENUBAR();
134
135 //-- File menu -----------------------------------------------------------
136 //
137 ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl );
138
139 fileMenu->AddClose( _( "Symbol Viewer" ) );
140
141
142 //-- View menu -----------------------------------------------------------
143 //
144 ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl );
145
146 viewMenu->Add( ACTIONS::zoomInCenter );
147 viewMenu->Add( ACTIONS::zoomOutCenter );
148 viewMenu->Add( ACTIONS::zoomFitScreen );
149 viewMenu->Add( ACTIONS::zoomRedraw );
150
151 viewMenu->AppendSeparator();
152
153 viewMenu->AppendSeparator();
156
157
158 //-- Menubar -------------------------------------------------------------
159 //
160 menuBar->Append( fileMenu, _( "&File" ) );
161 menuBar->Append( viewMenu, _( "&View" ) );
162 AddStandardHelpMenu( menuBar );
163
164 SetMenuBar( menuBar );
165 delete oldMenuBar;
166}
static TOOL_ACTION zoomRedraw
Definition actions.h:132
static TOOL_ACTION zoomOutCenter
Definition actions.h:136
static TOOL_ACTION showDatasheet
Definition actions.h:267
static TOOL_ACTION zoomFitScreen
Definition actions.h:142
static TOOL_ACTION zoomInCenter
Definition actions.h:135
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:47
static constexpr bool CHECK
void AddClose(const wxString &aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
static ACTION_TOOLBAR_CONTROL unitSelector
static ACTION_TOOLBAR_CONTROL bodyStyleSelector
Define the structure of a toolbar with buttons that invoke ACTIONs.
virtual void ClearToolbarControl(int aId)
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
virtual void configureToolbars()
ACTION_TOOLBAR * m_tbTopMain
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Add the standard KiCad help menu to the menubar.
static TOOL_ACTION previousSymbol
static TOOL_ACTION showElectricalTypes
static TOOL_ACTION nextSymbol
static TOOL_ACTION showPinNumbers
static TOOL_ACTION addSymbolToSchematic
Handle actions for the various symbol editor and viewers.
void ClearToolbarControl(int aId) override
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
TOOL_MANAGER * m_toolManager
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition wx_menubar.h:47
#define _(s)
@ ID_LIBVIEW_SELECT_UNIT_NUMBER
Definition eeschema_id.h:69
@ ID_LIBVIEW_SELECT_BODY_STYLE
Definition eeschema_id.h:70
This file contains miscellaneous commonly used macros and functions.
@ RIGHT
Toolbar on the right side of the canvas.
@ LEFT
Toolbar on the left side of the canvas.
@ TOP_AUX
Toolbar on the top of the canvas.
@ TOP_MAIN
Toolbar on the top of the canvas.