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_ALIAS;
36 class LIB_PART;
38 
39 
44 {
45 public:
46 
54  LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent,
55  FRAME_T aFrameType, const wxString& aLibraryName = wxEmptyString );
56 
58 
66  bool ShowModal( wxString* aSymbol, wxWindow* aParent ) override;
67 
71  void FinishModal();
72 
73  void OnSize( wxSizeEvent& event ) override;
74 
81  bool ReCreateListLib();
82 
89  bool ReCreateListCmp();
90 
91  void DisplayLibInfos();
92  void OnCloseWindow( wxCloseEvent& Event );
93  void CloseLibraryViewer( wxCommandEvent& event );
94  void ReCreateHToolbar() override;
95  void ReCreateVToolbar() override;
96  void ReCreateOptToolbar() override {}
97  void ReCreateMenuBar() override;
98 
99  double BestZoom() override;
100  void ClickOnLibList( wxCommandEvent& event );
101  void ClickOnCmpList( wxCommandEvent& event );
102  void OnSelectSymbol( wxCommandEvent& aEvent );
103 
104  void LoadSettings( wxConfigBase* aCfg ) override;
105  void SaveSettings( wxConfigBase* aCfg ) override;
106  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
107 
115  void SetFilter( const SCHLIB_FILTER* aFilter );
116 
122  void SetSelectedLibrary( const wxString& aLibName );
123 
129  void SetSelectedComponent( const wxString& aComponentName );
130 
131  // Accessors:
138  void SetUnitAndConvert( int aUnit, int aConvert );
139  int GetUnit() const { return m_unit; }
140  int GetConvert() const { return m_convert; }
141 
142  LIB_PART* GetSelectedSymbol() const;
143  LIB_ALIAS* GetSelectedAlias() const;
144 
145  const BOX2I GetDocumentExtents() const override;
146 
147  void SyncToolbars() override;
148 
149 private:
150  // Sets up the tool framework
151  void setupTools();
152 
157  void OnActivate( wxActivateEvent& event );
158 
159  void DClickOnCmpList( wxCommandEvent& event );
160 
161  void onUpdateUnitChoice( wxUpdateUIEvent& aEvent );
162 
163  void onSelectNextSymbol( wxCommandEvent& aEvent );
164  void onSelectPreviousSymbol( wxCommandEvent& aEvent );
165  void onSelectSymbolUnit( wxCommandEvent& aEvent );
166 
167  void updatePreviewSymbol();
168 
169 // Private members:
170  wxChoice* m_unitChoice;
171 
172  // List of libraries (for selection )
173  wxListBox* m_libList; // The list of libs
174  int m_libListWidth; // Last width of the window
175 
176  // List of components in the selected library
177  wxListBox* m_cmpList; // The list of components
178  int m_cmpListWidth; // Last width of the window
179 
180  // Filters to build list of libs/list of parts
182  wxArrayString m_allowedLibs;
183 
184  static wxString m_libraryName;
185  static wxString m_entryName;
186 
187  static int m_unit;
188  static int m_convert;
189 
195 
197 
198  DECLARE_EVENT_TABLE()
199 };
200 
201 #endif // LIB_VIEW_FRAME_H__
202 
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
Part library alias object definition.
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.
LIB_ALIAS * m_previewItem
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:100
void OnCloseWindow(wxCloseEvent &Event)
int GetUnit() const
wxListBox * m_cmpList
wxArrayString m_allowedLibs
static wxString m_libraryName
void SetSelectedComponent(const wxString &aComponentName)
Set the selected component.
Symbol library viewer main window.
Definition: viewlib_frame.h:43
int GetConvert() const
void OnSelectSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:41
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:258
const BOX2I GetDocumentExtents() const override
bool ReCreateListCmp()
Create or recreate the list of components in the currently selected library.
void DisplayLibInfos()
Definition: viewlibs.cpp:127
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:86
void updatePreviewSymbol()
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
LIB_ALIAS * GetSelectedAlias() const
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:96
double BestZoom() override
Return the zoom level which displays the full page on screen.
void ReCreateVToolbar() override
void onSelectSymbolUnit(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:114
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.