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 {
44 case TOOLBAR_LOC::LEFT:
45 case TOOLBAR_LOC::RIGHT:
46 case TOOLBAR_LOC::TOP_AUX:
47 return std::nullopt;
48
49 case TOOLBAR_LOC::TOP_MAIN:
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()
73
74 config.AppendSeparator()
76
77 config.AppendSeparator()
78 .AppendAction( ACTIONS::showDatasheet );
79
80 config.AppendSeparator()
81 .AppendAction( SCH_ACTIONS::addSymbolToSchematic );
82 break;
83 }
84
85 // clang-format on
86 return config;
87}
88
89
91{
93
94 // Toolbar widget for selecting the unit to show in the symbol viewer
95 auto unitChoiceFactory =
96 [this]( ACTION_TOOLBAR* aToolbar )
97 {
98 if( !m_unitChoice )
99 {
101 wxDefaultPosition, wxSize( 150, -1 ) );
102 }
103
104 aToolbar->Add( m_unitChoice );
105 };
106
108}
109
110
112{
114 // wxWidgets handles the OSX Application menu behind the scenes, but that means
115 // we always have to start from scratch with a new wxMenuBar.
116 wxMenuBar* oldMenuBar = GetMenuBar();
117 WX_MENUBAR* menuBar = new WX_MENUBAR();
118
119 //-- File menu -----------------------------------------------------------
120 //
121 ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl );
122
123 fileMenu->AddClose( _( "Symbol Viewer" ) );
124
125
126 //-- View menu -----------------------------------------------------------
127 //
128 ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl );
129
130 viewMenu->Add( ACTIONS::zoomInCenter );
131 viewMenu->Add( ACTIONS::zoomOutCenter );
132 viewMenu->Add( ACTIONS::zoomFitScreen );
133 viewMenu->Add( ACTIONS::zoomRedraw );
134
135 viewMenu->AppendSeparator();
136
137 viewMenu->AppendSeparator();
140
141
142 //-- Menubar -------------------------------------------------------------
143 //
144 menuBar->Append( fileMenu, _( "&File" ) );
145 menuBar->Append( viewMenu, _( "&View" ) );
146 AddStandardHelpMenu( menuBar );
147
148 SetMenuBar( menuBar );
149 delete oldMenuBar;
150}
static TOOL_ACTION zoomRedraw
Definition: actions.h:131
static TOOL_ACTION zoomOutCenter
Definition: actions.h:135
static TOOL_ACTION showDatasheet
Definition: actions.h:264
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:49
static constexpr bool CHECK
Definition: action_menu.h:201
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
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 showDeMorganAlternate
Definition: sch_actions.h:132
static TOOL_ACTION showElectricalTypes
Definition: sch_actions.h:251
static TOOL_ACTION showPinNumbers
Definition: sch_actions.h:252
static TOOL_ACTION showDeMorganStandard
Definition: sch_actions.h:131
static TOOL_ACTION addSymbolToSchematic
Definition: sch_actions.h:180
Handle actions for the various symbol editor and viewers.
void configureToolbars() 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
Definition: tools_holder.h:171
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:65
This file contains miscellaneous commonly used macros and functions.
Definition for symbol library class.