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
20 * along with this program. If not, see <https://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 <tool/tool_manager.h>
31#include <tools/sch_actions.h>
33#include <widgets/wx_menubar.h>
35#include <wx/choice.h>
36
37std::optional<TOOLBAR_CONFIGURATION> SYMBOL_VIEWER_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
38{
40
41 // clang-format off
42 switch( aToolbar )
43 {
47 return std::nullopt;
48
51 .AppendAction( SCH_ACTIONS::nextSymbol );
52
53 config.AppendSeparator()
54 .AppendAction( ACTIONS::zoomRedraw )
55 .AppendAction( ACTIONS::zoomInCenter )
56 .AppendAction( ACTIONS::zoomOutCenter )
57 .AppendAction( ACTIONS::zoomFitScreen );
58
59 config.AppendSeparator()
61 .AppendAction( SCH_ACTIONS::showPinNumbers );
62
63 config.AppendSeparator()
65
66 config.AppendSeparator()
68
69 config.AppendSeparator()
70 .AppendAction( ACTIONS::showDatasheet );
71
72 config.AppendSeparator()
73 .AppendAction( SCH_ACTIONS::addSymbolToSchematic );
74 break;
75 }
76
77 // clang-format on
78 return config;
79}
80
81
83{
85
86 // Toolbar widget for selecting the unit to show in the symbol viewer
87 auto unitChoiceFactory =
88 [this]( ACTION_TOOLBAR* aToolbar )
89 {
90 if( !m_unitChoice )
91 {
93 wxDefaultPosition, wxSize( 150, -1 ) );
94 }
95
96 aToolbar->Add( m_unitChoice );
97 };
98
99 auto bodyChoiceFactory =
100 [this]( ACTION_TOOLBAR* aToolbar )
101 {
102 if( !m_bodyStyleChoice )
103 {
105 wxDefaultPosition, wxSize( 150, -1 ) );
106 }
107
108 aToolbar->Add( m_bodyStyleChoice );
109 };
110
113}
114
115
117{
119
120 switch( aId )
121 {
122 case ID_LIBVIEW_SELECT_UNIT_NUMBER: m_unitChoice = nullptr; break;
123 case ID_LIBVIEW_SELECT_BODY_STYLE: m_bodyStyleChoice = nullptr; break;
124 }
125}
126
127
129{
131 // wxWidgets handles the OSX Application menu behind the scenes, but that means
132 // we always have to start from scratch with a new wxMenuBar.
133 wxMenuBar* oldMenuBar = GetMenuBar();
134 WX_MENUBAR* menuBar = new WX_MENUBAR();
135
136 //-- File menu -----------------------------------------------------------
137 //
138 ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl );
139
140 fileMenu->AddClose( _( "Symbol Viewer" ) );
141
142
143 //-- View menu -----------------------------------------------------------
144 //
145 ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl );
146
147 viewMenu->Add( ACTIONS::zoomInCenter );
148 viewMenu->Add( ACTIONS::zoomOutCenter );
149 viewMenu->Add( ACTIONS::zoomFitScreen );
150 viewMenu->Add( ACTIONS::zoomRedraw );
151
152 viewMenu->AppendSeparator();
153
154 viewMenu->AppendSeparator();
157
158
159 //-- Menubar -------------------------------------------------------------
160 //
161 menuBar->Append( fileMenu, _( "&File" ) );
162 menuBar->Append( viewMenu, _( "&View" ) );
163 AddStandardHelpMenu( menuBar );
164
165 SetMenuBar( menuBar );
166 delete oldMenuBar;
167}
static TOOL_ACTION zoomRedraw
Definition actions.h:128
static TOOL_ACTION zoomOutCenter
Definition actions.h:132
static TOOL_ACTION showDatasheet
Definition actions.h:263
static TOOL_ACTION zoomFitScreen
Definition actions.h:138
static TOOL_ACTION zoomInCenter
Definition actions.h:131
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:43
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:43
#define _(s)
@ ID_LIBVIEW_SELECT_UNIT_NUMBER
Definition eeschema_id.h:63
@ ID_LIBVIEW_SELECT_BODY_STYLE
Definition eeschema_id.h:64
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.