KiCad PCB EDA Suite
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 (C) 2004-2022 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/ee_actions.h>
33#include <widgets/wx_menubar.h>
34
35
37{
38 if( m_mainToolBar )
39 {
41 }
42 else
43 {
44 m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
45 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
47 }
48
49 m_mainToolBar->AddTool( ID_LIBVIEW_SELECT_PART, wxEmptyString,
51 _( "Choose symbol" ) );
52
53 m_mainToolBar->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString,
55 _( "Display previous symbol" ) );
56
57 m_mainToolBar->AddTool( ID_LIBVIEW_NEXT, wxEmptyString,
59 _( "Display next symbol" ) );
60
66
70
74
76
77 if( m_unitChoice == nullptr )
79 wxDefaultPosition, wxSize( 150, -1 ) );
80 m_mainToolBar->AddControl( m_unitChoice );
81
84
87
88 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
90
91 m_mainToolBar->Refresh();
92}
93
94
96{
97}
98
99
101{
103 // wxWidgets handles the OSX Application menu behind the scenes, but that means
104 // we always have to start from scratch with a new wxMenuBar.
105 wxMenuBar* oldMenuBar = GetMenuBar();
106 WX_MENUBAR* menuBar = new WX_MENUBAR();
107
108 //-- File menu -----------------------------------------------------------
109 //
110 ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl );
111
112 fileMenu->AddClose( _( "Symbol Viewer" ) );
113
114
115 //-- View menu -----------------------------------------------------------
116 //
117 ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl );
118
119 viewMenu->Add( ACTIONS::zoomInCenter );
120 viewMenu->Add( ACTIONS::zoomOutCenter );
121 viewMenu->Add( ACTIONS::zoomFitScreen );
122 viewMenu->Add( ACTIONS::zoomRedraw );
123
124 viewMenu->AppendSeparator();
126 viewMenu->Add( ACTIONS::gridProperties );
127
128 viewMenu->AppendSeparator();
131
132
133 //-- Menubar -------------------------------------------------------------
134 //
135 menuBar->Append( fileMenu, _( "&File" ) );
136 menuBar->Append( viewMenu, _( "&View" ) );
137 AddStandardHelpMenu( menuBar );
138
139 SetMenuBar( menuBar );
140 delete oldMenuBar;
141}
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:156
@ lib_previous
@ library_browser
static TOOL_ACTION gridProperties
Definition: actions.h:144
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION zoomRedraw
Definition: actions.h:92
static TOOL_ACTION zoomOutCenter
Definition: actions.h:96
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION zoomInCenter
Definition: actions.h:95
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
static constexpr bool CHECK
Definition: action_menu.h:189
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.
Define the structure of a toolbar with buttons that invoke ACTIONs.
static constexpr bool TOGGLE
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
void ClearToolbar()
Clear the toolbar and remove all associated menus.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Add a TOOL_ACTION-based button to the toolbar.
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
wxAuiManager m_auimgr
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
ACTION_TOOLBAR * m_mainToolBar
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:135
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:134
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:176
static TOOL_ACTION showPinNumbers
Definition: ee_actions.h:225
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:149
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:224
Handle actions for the various symbol editor and viewers.
void ReCreateVToolbar() override
void ReCreateHToolbar() override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:46
#define _(s)
@ ID_LIBVIEW_SELECT_UNIT_NUMBER
Definition: eeschema_id.h:72
@ ID_LIBVIEW_NEXT
Definition: eeschema_id.h:70
@ ID_LIBVIEW_SELECT_PART
Definition: eeschema_id.h:69
@ ID_LIBVIEW_PREVIOUS
Definition: eeschema_id.h:71
@ ID_H_TOOLBAR
Definition: id.h:100
This file contains miscellaneous commonly used macros and functions.
Definition for symbol library class.