KiCad PCB EDA Suite
toolbars_libedit.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) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <eeschema_id.h>
27 //#include <general.h>
28 #include <lib_edit_frame.h>
29 #include <sch_painter.h>
30 #include <dialog_helpers.h>
31 #include <bitmaps.h>
32 #include <lib_manager.h>
33 #include <class_libentry.h>
34 #include <tool/action_toolbar.h>
35 #include <tool/tool_manager.h>
36 #include <tools/ee_actions.h>
38 
39 #ifdef __UNIX__
40 #define LISTBOX_WIDTH 140
41 #else
42 #define LISTBOX_WIDTH 120
43 #endif
44 
45 
47 {
48  if( m_drawToolBar )
49  {
51  }
52  else
53  {
54  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
55  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
57  }
58 
59  // Set up toolbar
61 
70 
71  m_drawToolBar->AddTool( ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString,
72  KiScaledBitmap( import_xpm, this ),
73  _( "Import existing drawings" ), wxITEM_CHECK );
74 
75  m_drawToolBar->AddTool( ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString,
76  KiScaledBitmap( export_xpm, this ),
77  _( "Export current drawing" ), wxITEM_CHECK );
78 
80 
81  m_drawToolBar->Realize();
82 }
83 
84 
86 {
87  if( m_mainToolBar )
88  {
90  }
91  else
92  {
93  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
94  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
96  }
97 
98  // Set up toolbar
100 
101  if( !IsSymbolFromSchematic() )
103  else
105 
109 
116 
120 
124 
128 
130 
131  if( m_unitSelectBox == nullptr )
133  wxEmptyString, wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ), 0,
134  nullptr, wxCB_READONLY );
135  m_mainToolBar->AddControl( m_unitSelectBox );
136 
139 
142 
143  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
144  m_mainToolBar->Realize();
145 }
146 
147 
149 {
150  if( m_optionsToolBar )
151  {
153  }
154  else
155  {
157  wxDefaultPosition, wxDefaultSize,
158  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
160  }
161 
169 
171  std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
172  gridMenu->Add( ACTIONS::gridProperties );
173  m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
174 
175  m_optionsToolBar->Realize();
176 }
static TOOL_ACTION pinTable
Definition: ee_actions.h:146
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:140
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:102
ACTION_TOOLBAR.
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:106
static TOOL_ACTION zoomInCenter
Definition: actions.h:91
static TOOL_ACTION runERC
Definition: ee_actions.h:141
void AddToolContextMenu(const TOOL_ACTION &aAction, std::unique_ptr< ACTION_MENU > aMenu)
Add a context menu to a specific tool item on the toolbar.
ACTION_TOOLBAR * m_optionsToolBar
static constexpr bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:97
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Adds a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION millimetersUnits
Definition: actions.h:144
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
wxAuiManager m_auimgr
static TOOL_ACTION showComponentTree
Definition: ee_actions.h:202
ACTION_TOOLBAR * m_mainToolBar
#define LISTBOX_WIDTH
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:128
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, wxWindow *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:118
static TOOL_ACTION zoomOutCenter
Definition: actions.h:92
static TOOL_ACTION drawSymbolRectangle
Definition: ee_actions.h:103
static constexpr bool CANCEL
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:101
static TOOL_ACTION toggleGrid
Definition: actions.h:138
static TOOL_ACTION inchesUnits
Definition: actions.h:142
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:145
bool IsSymbolFromSchematic() const
const BITMAP_OPAQUE export_xpm[1]
Definition: export.cpp:71
const BITMAP_OPAQUE import_xpm[1]
Definition: import.cpp:68
static TOOL_ACTION drawSymbolCircle
Definition: ee_actions.h:104
Helper dialog and control classes.
void ReCreateOptToolbar() override
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:166
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:127
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:201
static TOOL_ACTION milsUnits
Definition: actions.h:143
static TOOL_ACTION saveInSchematic
Definition: ee_actions.h:180
static TOOL_ACTION newSymbol
Definition: ee_actions.h:169
static TOOL_ACTION redo
Definition: actions.h:68
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
void ReCreateHToolbar() override
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:88
static TOOL_ACTION drawSymbolArc
Definition: ee_actions.h:105
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
static TOOL_ACTION gridProperties
Definition: actions.h:139
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION toggleSyncedPinsMode
Definition: ee_actions.h:195
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
static TOOL_ACTION saveAll
Definition: actions.h:57
wxComboBox * m_unitSelectBox
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:107
static TOOL_ACTION selectionTool
Definition: actions.h:151
void ClearToolbar()
Clear the toolbar and remove all associated menus.
ACTION_TOOLBAR * m_drawToolBar
void ReCreateVToolbar() override