KiCad PCB EDA Suite
viewlib_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-2019 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 
33 class wxListBox;
34 class SCHLIB_FILTER;
35 class LIB_PART;
37 
38 
43 {
44 public:
45 
53  LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent,
54  FRAME_T aFrameType, const wxString& aLibraryName = wxEmptyString );
55 
57 
65  bool ShowModal( wxString* aSymbol, wxWindow* aParent ) override;
66 
70  void FinishModal();
71 
72  void OnSize( wxSizeEvent& event ) override;
73 
80  bool ReCreateListLib();
81 
88  bool ReCreateListCmp();
89 
90  void DisplayLibInfos();
91  void OnCloseWindow( wxCloseEvent& Event );
92  void CloseLibraryViewer( wxCommandEvent& event );
93  void ReCreateHToolbar() override;
94  void ReCreateVToolbar() override;
95  void ReCreateOptToolbar() override {}
96  void ReCreateMenuBar() override;
97 
98  void ClickOnLibList( wxCommandEvent& event );
99  void ClickOnCmpList( wxCommandEvent& event );
100  void OnSelectSymbol( wxCommandEvent& aEvent );
101 
102  void LoadSettings( wxConfigBase* aCfg ) override;
103  void SaveSettings( wxConfigBase* aCfg ) override;
104  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
105 
113  void SetFilter( const SCHLIB_FILTER* aFilter );
114 
120  void SetSelectedLibrary( const wxString& aLibName );
121 
127  void SetSelectedComponent( const wxString& aComponentName );
128 
129  // Accessors:
136  void SetUnitAndConvert( int aUnit, int aConvert );
137  int GetUnit() const { return m_unit; }
138  int GetConvert() const { return m_convert; }
139 
140  LIB_PART* GetSelectedSymbol() const;
141 
142  const BOX2I GetDocumentExtents() const override;
143 
144  void SyncToolbars() override;
145 
146 private:
147  // Sets up the tool framework
148  void setupTools();
149 
154  void OnActivate( wxActivateEvent& event );
155 
156  void DClickOnCmpList( wxCommandEvent& event );
157 
158  void onUpdateUnitChoice( wxUpdateUIEvent& aEvent );
159 
160  void onSelectNextSymbol( wxCommandEvent& aEvent );
161  void onSelectPreviousSymbol( wxCommandEvent& aEvent );
162  void onSelectSymbolUnit( wxCommandEvent& aEvent );
163 
164  void updatePreviewSymbol();
165 
166 // Private members:
167  wxChoice* m_unitChoice;
168 
169  // List of libraries (for selection )
170  wxListBox* m_libList; // The list of libs
171  int m_libListWidth; // Last width of the window
172 
173  // List of components in the selected library
174  wxListBox* m_cmpList; // The list of components
175  int m_cmpListWidth; // Last width of the window
176 
177  // Filters to build list of libs/list of parts
179  wxArrayString m_allowedLibs;
180 
181  static wxString m_libraryName;
182  static wxString m_entryName;
183 
184  static int m_unit;
185  static int m_convert;
186 
192 
194 
195  DECLARE_EVENT_TABLE()
196 };
197 
198 #endif // LIB_VIEW_FRAME_H__
199 
static int m_unit
static int m_convert
void SetFilter(const SCHLIB_FILTER *aFilter)
Set a filter to display only libraries and/or components which match the filter.
LIB_PART * GetSelectedSymbol() const
static wxString m_entryName
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
void SetUnitAndConvert(int aUnit, int aConvert)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
bool m_selection_changed
Updated to true if a list rewrite on GUI activation resulted in the component selection changing,...
bool ShowModal(wxString *aSymbol, wxWindow *aParent) override
Function ShowModal.
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
void onSelectPreviousSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:101
void OnCloseWindow(wxCloseEvent &Event)
int GetUnit() const
wxListBox * m_cmpList
wxArrayString m_allowedLibs
static wxString m_libraryName
LIB_PART * m_previewItem
void SetSelectedComponent(const wxString &aComponentName)
Set the selected component.
Symbol library viewer main window.
Definition: viewlib_frame.h:42
int GetConvert() const
void OnSelectSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:42
LIB_VIEW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aLibraryName=wxEmptyString)
Constructor.
void ReCreateMenuBar() override
Recreates the menu bar.
void onUpdateUnitChoice(wxUpdateUIEvent &aEvent)
void CloseLibraryViewer(wxCommandEvent &event)
Define a library symbol object.
void ReCreateHToolbar() override
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:274
const BOX2I GetDocumentExtents() const override
bool ReCreateListCmp()
Create or recreate the list of components in the currently selected library.
void DisplayLibInfos()
Definition: viewlibs.cpp:128
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
void ClickOnLibList(wxCommandEvent &event)
void onSelectNextSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:87
void updatePreviewSymbol()
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
wxListBox * m_libList
void FinishModal()
Send the selected symbol back to the caller.
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
void ClickOnCmpList(wxCommandEvent &event)
void OnActivate(wxActivateEvent &event)
Called when the frame is activated to reload the libraries and component lists that can be changed by...
wxChoice * m_unitChoice
void ReCreateOptToolbar() override
Definition: viewlib_frame.h:95
void ReCreateVToolbar() override
void onSelectSymbolUnit(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:115
void DClickOnCmpList(wxCommandEvent &event)
bool ReCreateListLib()
Creates or recreates a sorted list of currently loaded libraries.
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
void SetSelectedLibrary(const wxString &aLibName)
Set the selected library in the library window.
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.