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 <stambaughw@gmail.com>
6  * Copyright (C) 2004-2021 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 
34 class wxListBox;
35 class SCHLIB_FILTER;
36 class LIB_SYMBOL;
38 
39 
44 {
45 public:
46 
53  SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
54  const wxString& aLibraryName = wxEmptyString );
55 
57 
64  bool ShowModal( wxString* aSymbol, wxWindow* aParent ) override;
65 
69  void FinishModal();
70 
71  void OnSize( wxSizeEvent& event ) override;
72 
79  bool ReCreateLibList();
80 
87  bool ReCreateSymbolList();
88 
89  void DisplayLibInfos();
90  void doCloseWindow() override;
91  void CloseLibraryViewer( wxCommandEvent& event );
92  void ReCreateHToolbar() override;
93  void ReCreateVToolbar() override;
94  void ReCreateOptToolbar() override {}
95  void ReCreateMenuBar() override;
96 
97  void ClickOnLibList( wxCommandEvent& event );
98  void ClickOnCmpList( 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 SCHLIB_FILTER* aFilter );
116 
120  void SetSelectedLibrary( const wxString& aLibName );
121 
125  void SetSelectedSymbol( const wxString& aSymbolName );
126 
127  // Accessors:
134  void SetUnitAndConvert( int aUnit, int aConvert );
135  int GetUnit() const { return m_unit; }
136  int GetConvert() const { return m_convert; }
137 
138  LIB_SYMBOL* GetSelectedSymbol() const;
139 
140  const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
141 
142  SELECTION& GetCurrentSelection() override;
143 
144 protected:
145  void setupUIConditions() override;
146 
147 private:
148  // Set up the tool framework.
149  void setupTools();
150 
155  void OnActivate( wxActivateEvent& event );
156 
157  void DClickOnCmpList( wxCommandEvent& event );
158 
159  void onUpdateUnitChoice( wxUpdateUIEvent& aEvent );
160 
161  void onSelectNextSymbol( wxCommandEvent& aEvent );
162  void onSelectPreviousSymbol( wxCommandEvent& aEvent );
163  void onSelectSymbolUnit( wxCommandEvent& aEvent );
164 
165  void updatePreviewSymbol();
166 
167 private:
168  wxChoice* m_unitChoice;
169 
170  wxListBox* m_libList; // The list of libraries.
171  int m_libListWidth; // Last width of the window.
172 
173  wxListBox* m_symbolList; // The list of symbols.
174  int m_symbolListWidth; // Last width of the window.
175 
176  // Filters to build list of libs/list of symbols.
178  wxArrayString m_allowedLibs;
179 
180  static wxString m_libraryName;
181  static wxString m_entryName;
182 
183  static int m_unit;
184  static int m_convert;
185 
191 
193 
194  DECLARE_EVENT_TABLE()
195 };
196 
197 #endif // LIB_VIEW_FRAME_H__
198 
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
void ReCreateMenuBar() override
Recreates the menu bar.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
void ReCreateOptToolbar() override
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
void ClickOnCmpList(wxCommandEvent &event)
Symbol library viewer main window.
static wxString m_entryName
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void onUpdateUnitChoice(wxUpdateUIEvent &aEvent)
Define a library symbol object.
Definition: lib_symbol.h:96
void OnSelectSymbol(wxCommandEvent &aEvent)
void CloseLibraryViewer(wxCommandEvent &event)
void onSelectNextSymbol(wxCommandEvent &aEvent)
void onSelectPreviousSymbol(wxCommandEvent &aEvent)
void onSelectSymbolUnit(wxCommandEvent &aEvent)
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:81
void ReCreateHToolbar() override
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void SetSelectedSymbol(const wxString &aSymbolName)
Set the selected symbol.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
void SetUnitAndConvert(int aUnit, int aConvert)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
bool ReCreateLibList()
Create o recreates a sorted list of currently loaded libraries.
void ReCreateVToolbar() override
bool m_selection_changed
Updated to true if a list rewrite on GUI activation resulted in the symbol selection changing,...
void SetFilter(const SCHLIB_FILTER *aFilter)
Set a filter to display only libraries and/or symbols which match the filter.
void OnActivate(wxActivateEvent &event)
Called when the frame is activated to reload the libraries and symbol lists that can be changed by th...
void SetSelectedLibrary(const wxString &aLibName)
Set the selected library in the library window.
void DClickOnCmpList(wxCommandEvent &event)
LIB_SYMBOL * GetSelectedSymbol() const
void ClickOnLibList(wxCommandEvent &event)
bool ShowModal(wxString *aSymbol, wxWindow *aParent) override
Runs the symbol viewer as a modal dialog.
void doCloseWindow() override
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
static wxString m_libraryName
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SYMBOL_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aLibraryName=wxEmptyString)
void FinishModal()
Send the selected symbol back to the caller.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
bool ReCreateSymbolList()
Create or recreate the list of symbols in the currently selected library.