KiCad PCB EDA Suite
symbol_viewer_frame.h
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 *
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
27#ifndef LIB_VIEW_FRAME_H__
28#define LIB_VIEW_FRAME_H__
29
30#include <sch_base_frame.h>
31#include <sch_screen.h>
32#include <tool/selection.h>
33
34class WX_LISTBOX;
35class wxSearchCtrl;
37class LIB_SYMBOL;
39
40
45{
46public:
47
54 SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
55 const wxString& aLibraryName = wxEmptyString );
56
58
65 bool ShowModal( wxString* aSymbol, wxWindow* aParent ) override;
66
70 void FinishModal();
71
72 void OnSize( wxSizeEvent& event ) override;
73
80 bool ReCreateLibList();
81
88 bool ReCreateSymbolList();
89
90 void DisplayLibInfos();
91 void doCloseWindow() override;
92 void CloseLibraryViewer( wxCommandEvent& event );
93 void ReCreateHToolbar() override;
94 void ReCreateVToolbar() override;
95 void ReCreateOptToolbar() override {}
96
97 void ClickOnLibList( wxCommandEvent& event );
98 void ClickOnSymbolList( wxCommandEvent& event );
99 void OnSelectSymbol( wxCommandEvent& aEvent );
100
101 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
102 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
103
105
106 void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
107
115 void SetFilter( const SYMBOL_LIBRARY_FILTER* aFilter );
116
120 void SetSelectedLibrary( const wxString& aLibName,
121 const wxString& aSubLibName = wxEmptyString );
122
126 void SetSelectedSymbol( const wxString& aSymbolName );
127
128 // Accessors:
135 void SetUnitAndConvert( int aUnit, int aConvert );
136 int GetUnit() const { return m_unit; }
137 int GetConvert() const { return m_convert; }
138
140
141 const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
142
143 SELECTION& GetCurrentSelection() override;
144
145protected:
146 void setupUIConditions() override;
147
148 void doReCreateMenuBar() override;
149
150private:
151 // Set up the tool framework.
152 void setupTools();
153
158 void OnActivate( wxActivateEvent& event );
159
160 void DClickOnSymbolList( wxCommandEvent& event );
161
162 void onUpdateUnitChoice( wxUpdateUIEvent& aEvent );
163
164 void OnLibFilter( wxCommandEvent& aEvent );
165 void OnSymFilter( wxCommandEvent& aEvent );
166 void OnCharHook( wxKeyEvent& aEvent ) override;
167
168 void onSelectNextSymbol( wxCommandEvent& aEvent );
169 void onSelectPreviousSymbol( wxCommandEvent& aEvent );
170 void onSelectSymbolUnit( wxCommandEvent& aEvent );
171
172 void updatePreviewSymbol();
173
174 void loadAllLibraries();
175
176private:
177 wxChoice* m_unitChoice;
178
179 wxSearchCtrl* m_libFilter;
180 WX_LISTBOX* m_libList; // The list of libraries.
181 int m_libListWidth; // Last width of the window.
182
183 wxSearchCtrl* m_symbolFilter;
184 WX_LISTBOX* m_symbolList; // The list of symbols.
185 int m_symbolListWidth; // Last width of the window.
186
187 // Filters to build list of libs/list of symbols.
189 wxArrayString m_allowedLibs;
190
192
193 static int m_unit;
194 static int m_convert;
195 static bool m_show_progress;
196
202
204
205 DECLARE_EVENT_TABLE()
206};
207
208#endif // LIB_VIEW_FRAME_H__
209
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:274
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Define a library symbol object.
Definition: lib_symbol.h:99
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Helper object to filter a list of libraries.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
Symbol library viewer main window.
void SetUnitAndConvert(int aUnit, int aConvert)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
void OnLibFilter(wxCommandEvent &aEvent)
void CloseLibraryViewer(wxCommandEvent &event)
void onSelectNextSymbol(wxCommandEvent &aEvent)
wxSearchCtrl * m_libFilter
void SetSelectedLibrary(const wxString &aLibName, const wxString &aSubLibName=wxEmptyString)
Set the selected library in the library window.
void ClickOnLibList(wxCommandEvent &event)
void onUpdateUnitChoice(wxUpdateUIEvent &aEvent)
void DClickOnSymbolList(wxCommandEvent &event)
bool ShowModal(wxString *aSymbol, wxWindow *aParent) override
Runs the symbol viewer as a modal dialog.
void OnActivate(wxActivateEvent &event)
Called when the frame is activated to reload the libraries and symbol lists that can be changed by th...
void OnSymFilter(wxCommandEvent &aEvent)
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void doCloseWindow() override
void FinishModal()
Send the selected symbol back to the caller.
void SetSelectedSymbol(const wxString &aSymbolName)
Set the selected symbol.
void SetFilter(const SYMBOL_LIBRARY_FILTER *aFilter)
Set a filter to display only libraries and/or symbols which match the filter.
bool ReCreateLibList()
Create o recreates a sorted list of currently loaded libraries.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void ClickOnSymbolList(wxCommandEvent &event)
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void OnSelectSymbol(wxCommandEvent &aEvent)
void ReCreateVToolbar() override
wxSearchCtrl * m_symbolFilter
void ReCreateHToolbar() override
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
static LIB_ID m_currentSymbol
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
SYMBOL_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aLibraryName=wxEmptyString)
LIB_SYMBOL * GetSelectedSymbol() const
void onSelectSymbolUnit(wxCommandEvent &aEvent)
void ReCreateOptToolbar() override
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
void onSelectPreviousSymbol(wxCommandEvent &aEvent)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
bool m_selection_changed
Updated to true if a list rewrite on GUI activation resulted in the symbol selection changing,...
bool ReCreateSymbolList()
Create or recreate the list of symbols in the currently selected library.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:92