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