KiCad PCB EDA Suite
tool_viewlib.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 <stambaughw@gmail.com>
6  * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
28 #include <dialog_helpers.h>
29 #include <macros.h>
30 #include <menus_helpers.h>
31 
32 #include "class_library.h"
33 #include "eeschema_id.h"
34 #include "general.h"
35 #include "help_common_strings.h"
36 #include "hotkeys.h"
37 #include "viewlib_frame.h"
38 #include <symbol_lib_table.h>
39 
40 
42 {
43  wxString msg;
44 
45  if( m_mainToolBar )
46  m_mainToolBar->Clear();
47  else
48  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
49  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
50 
51  m_mainToolBar->AddTool( ID_LIBVIEW_SELECT_PART, wxEmptyString,
52  KiScaledBitmap( add_component_xpm, this ),
53  _( "Select symbol to browse" ) );
54 
55  m_mainToolBar->AddSeparator();
56  m_mainToolBar->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString,
57  KiScaledBitmap( lib_previous_xpm, this ),
58  _( "Display previous symbol" ) );
59 
60  m_mainToolBar->AddTool( ID_LIBVIEW_NEXT, wxEmptyString,
61  KiScaledBitmap( lib_next_xpm, this ),
62  _( "Display next symbol" ) );
63 
64  m_mainToolBar->AddSeparator();
65  msg = AddHotkeyName( _( "Zoom in" ), g_Viewlib_Hokeys_Descr,
67  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString,
68  KiScaledBitmap( zoom_in_xpm, this ), msg );
69 
70  msg = AddHotkeyName( _( "Zoom out" ), g_Viewlib_Hokeys_Descr,
72  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString,
73  KiScaledBitmap( zoom_out_xpm, this ), msg );
74 
75  msg = AddHotkeyName( _( "Redraw view" ), g_Viewlib_Hokeys_Descr,
77  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
78  KiScaledBitmap( zoom_redraw_xpm, this ), msg );
79 
80  msg = AddHotkeyName( _( "Zoom to fit symbol" ), g_Viewlib_Hokeys_Descr,
82  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
83  KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
84 
85  m_mainToolBar->AddSeparator();
86  m_mainToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
87  KiScaledBitmap( morgan1_xpm, this ),
88  _( "Show as \"De Morgan\" normal symbol" ),
89  wxITEM_CHECK );
90 
91  m_mainToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
92  KiScaledBitmap( morgan2_xpm, this ),
93  _( "Show as \"De Morgan\" convert symbol" ),
94  wxITEM_CHECK );
95 
96  m_mainToolBar->AddSeparator();
97 
99  wxDefaultPosition, wxSize( 150, -1 ) );
100  m_mainToolBar->AddControl( m_unitChoice );
101 
102  m_mainToolBar->AddSeparator();
103  m_mainToolBar->AddTool( ID_LIBVIEW_VIEWDOC, wxEmptyString,
104  KiScaledBitmap( datasheet_xpm, this ),
105  _( "View symbol documents" ) );
106 
107  if( IsModal() )
108  {
109  m_mainToolBar->AddSeparator();
111  wxEmptyString, KiScaledBitmap( export_xpm, this ),
112  _( "Insert symbol in schematic" ) );
113  }
114 
115  // after adding the buttons to the toolbar, must call Realize() to
116  // reflect the changes
117  m_mainToolBar->Realize();
118 
119  m_mainToolBar->Refresh();
120 }
121 
122 
124 {
125 }
126 
127 
128 // Virtual function
130 {
131  // wxWidgets handles the Mac Application menu behind the scenes, but that means
132  // we always have to start from scratch with a new wxMenuBar.
133  wxMenuBar* oldMenuBar = GetMenuBar();
134  wxMenuBar* menuBar = new wxMenuBar();
135  wxString text;
136 
137  // Recreate all menus:
138 
139  // Menu File:
140  wxMenu* fileMenu = new wxMenu;
141 
142  AddMenuItem( fileMenu, wxID_EXIT,
143  _( "Cl&ose" ),
144  _( "Close schematic symbol viewer" ),
145  KiBitmap( exit_xpm ) );
146 
147  // View menu
148  wxMenu* viewMenu = new wxMenu;
149 
150  text = AddHotkeyName( _( "Zoom &In" ), g_Viewlib_Hokeys_Descr,
152  AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
153 
154  text = AddHotkeyName( _( "Zoom &Out" ), g_Viewlib_Hokeys_Descr,
156  AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
157 
158  text = AddHotkeyName( _( "&Zoom to Fit" ), g_Viewlib_Hokeys_Descr, HK_ZOOM_AUTO );
159  AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, _( "Zoom to fit symbol" ),
160  KiBitmap( zoom_fit_in_page_xpm ) );
161 
162  text = AddHotkeyName( _( "&Redraw" ), g_Viewlib_Hokeys_Descr, HK_ZOOM_REDRAW );
163  AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text,
164  HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
165 
166  viewMenu->AppendSeparator();
167  AddMenuItem( viewMenu, ID_LIBVIEW_SHOW_ELECTRICAL_TYPE, _( "&Show Pin Electrical Type" ),
168  wxEmptyString, KiBitmap( pin_show_etype_xpm ), wxITEM_CHECK );
169 
170  // Menu Help:
171  wxMenu* helpMenu = new wxMenu;
172 
173  // Contents
174  AddMenuItem( helpMenu, wxID_HELP,
175  _( "Eeschema &Manual" ),
176  _( "Open Eeschema manual" ),
177  KiBitmap( online_help_xpm ) );
178 
179  AddMenuItem( helpMenu, wxID_INDEX,
180  _( "&Getting Started in KiCad" ),
181  _( "Open the \"Getting Started in KiCad\" guide for beginners" ),
182  KiBitmap( help_xpm ) );
183 
184  helpMenu->AppendSeparator();
186  _( "Get &Involved" ),
187  _( "Contribute to KiCad (opens a web browser)" ),
188  KiBitmap( info_xpm ) );
189 
190  helpMenu->AppendSeparator();
191  AddMenuItem( helpMenu, wxID_ABOUT,
192  _( "&About Eeschema" ),
193  _( "About Eeschema schematic designer" ),
194  KiBitmap( info_xpm ) );
195 
196  // Append menus to the menubar
197  menuBar->Append( fileMenu, _( "&File" ) );
198 
199  menuBar->Append( viewMenu, _( "&View" ) );
200  menuBar->Append( helpMenu, _( "&Help" ) );
201 
202  SetMenuBar( menuBar );
203  delete oldMenuBar;
204 }
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:223
Definition: id.h:241
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:116
#define HELP_ZOOM_OUT
This file contains miscellaneous commonly used macros and functions.
#define HELP_ZOOM_REDRAW
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
strings common to toolbars and menubar
Helper dialog and control classes.
void ReCreateHToolbar() override
bool IsModal()
Definition: kiway_player.h:226
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
#define HELP_ZOOM_IN
struct EDA_HOTKEY_CONFIG g_Viewlib_Hokeys_Descr[]
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
wxChoice * m_unitChoice
void ReCreateVToolbar() override
Definition for part library class.