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 (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_PREVIOUS, wxEmptyString,
50 KiScaledBitmap( BITMAPS::lib_previous, this ),
51 _( "Display previous symbol" ) );
52
53 m_mainToolBar->AddTool( ID_LIBVIEW_NEXT, wxEmptyString,
54 KiScaledBitmap( BITMAPS::lib_next, this ),
55 _( "Display next symbol" ) );
56
62
66
70
72
73 if( m_unitChoice == nullptr )
75 wxDefaultPosition, wxSize( 150, -1 ) );
76 m_mainToolBar->AddControl( m_unitChoice );
77
80
83
84 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
86
87 m_mainToolBar->Refresh();
88}
89
90
92{
93}
94
95
97{
99 // wxWidgets handles the OSX Application menu behind the scenes, but that means
100 // we always have to start from scratch with a new wxMenuBar.
101 wxMenuBar* oldMenuBar = GetMenuBar();
102 WX_MENUBAR* menuBar = new WX_MENUBAR();
103
104 //-- File menu -----------------------------------------------------------
105 //
106 ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl );
107
108 fileMenu->AddClose( _( "Symbol Viewer" ) );
109
110
111 //-- View menu -----------------------------------------------------------
112 //
113 ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl );
114
115 viewMenu->Add( ACTIONS::zoomInCenter );
116 viewMenu->Add( ACTIONS::zoomOutCenter );
117 viewMenu->Add( ACTIONS::zoomFitScreen );
118 viewMenu->Add( ACTIONS::zoomRedraw );
119
120 viewMenu->AppendSeparator();
121
122 viewMenu->AppendSeparator();
125
126
127 //-- Menubar -------------------------------------------------------------
128 //
129 menuBar->Append( fileMenu, _( "&File" ) );
130 menuBar->Append( viewMenu, _( "&View" ) );
131 AddStandardHelpMenu( menuBar );
132
133 SetMenuBar( menuBar );
134 delete oldMenuBar;
135}
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:147
static TOOL_ACTION zoomRedraw
Definition: actions.h:124
static TOOL_ACTION zoomOutCenter
Definition: actions.h:128
static TOOL_ACTION showDatasheet
Definition: actions.h:217
static TOOL_ACTION zoomFitScreen
Definition: actions.h:134
static TOOL_ACTION zoomInCenter
Definition: actions.h:127
Defines 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.
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.
void SetMenuBar(wxMenuBar *menu_bar) override
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:142
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:141
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:187
static TOOL_ACTION showPinNumbers
Definition: ee_actions.h:266
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:265
Handle actions for the various symbol editor and viewers.
void doReCreateMenuBar() override
void ReCreateVToolbar() override
void ReCreateHToolbar() override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
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
@ ID_LIBVIEW_NEXT
Definition: eeschema_id.h:63
@ ID_LIBVIEW_PREVIOUS
Definition: eeschema_id.h:64
@ ID_H_TOOLBAR
Definition: id.h:99
This file contains miscellaneous commonly used macros and functions.
Definition for symbol library class.