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 <symbol_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 <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
50 /* TODO (ISM): Move these to actions
51 m_tbTopMain->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString,
52 KiScaledBitmap( BITMAPS::lib_previous, this ),
53 _( "Display previous symbol" ) );
54
55 m_tbTopMain->AddTool( ID_LIBVIEW_NEXT, wxEmptyString,
56 KiScaledBitmap( BITMAPS::lib_next, this ),
57 _( "Display next symbol" ) );
58 */
59
60 config.AppendSeparator()
61 .AppendAction( ACTIONS::zoomRedraw )
62 .AppendAction( ACTIONS::zoomInCenter )
63 .AppendAction( ACTIONS::zoomOutCenter )
64 .AppendAction( ACTIONS::zoomFitScreen );
65
66 config.AppendSeparator()
68 .AppendAction( SCH_ACTIONS::showPinNumbers );
69
70 config.AppendSeparator()
72
73 config.AppendSeparator()
75
76 config.AppendSeparator()
77 .AppendAction( ACTIONS::showDatasheet );
78
79 config.AppendSeparator()
80 .AppendAction( SCH_ACTIONS::addSymbolToSchematic );
81 break;
82 }
83
84 // clang-format on
85 return config;
86}
87
88
90{
92
93 // Toolbar widget for selecting the unit to show in the symbol viewer
94 auto unitChoiceFactory =
95 [this]( ACTION_TOOLBAR* aToolbar )
96 {
97 if( !m_unitChoice )
98 {
100 wxDefaultPosition, wxSize( 150, -1 ) );
101 }
102
103 aToolbar->Add( m_unitChoice );
104 };
105
106 auto bodyChoiceFactory =
107 [this]( ACTION_TOOLBAR* aToolbar )
108 {
109 if( !m_bodyStyleChoice )
110 {
112 wxDefaultPosition, wxSize( 150, -1 ) );
113 }
114
115 aToolbar->Add( m_bodyStyleChoice );
116 };
117
120}
121
122
124{
126 // wxWidgets handles the OSX Application menu behind the scenes, but that means
127 // we always have to start from scratch with a new wxMenuBar.
128 wxMenuBar* oldMenuBar = GetMenuBar();
129 WX_MENUBAR* menuBar = new WX_MENUBAR();
130
131 //-- File menu -----------------------------------------------------------
132 //
133 ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl );
134
135 fileMenu->AddClose( _( "Symbol Viewer" ) );
136
137
138 //-- View menu -----------------------------------------------------------
139 //
140 ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl );
141
142 viewMenu->Add( ACTIONS::zoomInCenter );
143 viewMenu->Add( ACTIONS::zoomOutCenter );
144 viewMenu->Add( ACTIONS::zoomFitScreen );
145 viewMenu->Add( ACTIONS::zoomRedraw );
146
147 viewMenu->AppendSeparator();
148
149 viewMenu->AppendSeparator();
152
153
154 //-- Menubar -------------------------------------------------------------
155 //
156 menuBar->Append( fileMenu, _( "&File" ) );
157 menuBar->Append( viewMenu, _( "&View" ) );
158 AddStandardHelpMenu( menuBar );
159
160 SetMenuBar( menuBar );
161 delete oldMenuBar;
162}
static TOOL_ACTION zoomRedraw
Definition actions.h:131
static TOOL_ACTION zoomOutCenter
Definition actions.h:135
static TOOL_ACTION showDatasheet
Definition actions.h:266
static TOOL_ACTION zoomFitScreen
Definition actions.h:141
static TOOL_ACTION zoomInCenter
Definition actions.h:134
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.
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 showElectricalTypes
static TOOL_ACTION showPinNumbers
static TOOL_ACTION addSymbolToSchematic
Handle actions for the various symbol editor and viewers.
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:71
@ ID_LIBVIEW_SELECT_BODY_STYLE
Definition eeschema_id.h:72
This file contains miscellaneous commonly used macros and functions.
Definition for symbol library class.
@ 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.