KiCad PCB EDA Suite
lib_view_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( APP_SETTINGS_BASE* aCfg ) override;
103  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
104 
106 
107  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
108 
116  void SetFilter( const SCHLIB_FILTER* aFilter );
117 
123  void SetSelectedLibrary( const wxString& aLibName );
124 
130  void SetSelectedComponent( const wxString& aComponentName );
131 
132  // Accessors:
139  void SetUnitAndConvert( int aUnit, int aConvert );
140  int GetUnit() const { return m_unit; }
141  int GetConvert() const { return m_convert; }
142 
143  LIB_PART* GetSelectedSymbol() 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
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)
void OnCloseWindow(wxCloseEvent &Event)
int GetUnit() const
wxListBox * m_cmpList
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Returns a pointer to the window settings for this frame.
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.
int GetConvert() const
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:68
void OnSelectSymbol(wxCommandEvent &aEvent)
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:91
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
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
const BOX2I GetDocumentExtents() const override
bool ReCreateListCmp()
Create or recreate the list of components in the currently selected library.
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
void ClickOnLibList(wxCommandEvent &event)
void onSelectNextSymbol(wxCommandEvent &aEvent)
void updatePreviewSymbol()
wxListBox * m_libList
void FinishModal()
Send the selected symbol back to the caller.
void LoadSettings(APP_SETTINGS_BASE *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
void ReCreateVToolbar() override
void onSelectSymbolUnit(wxCommandEvent &aEvent)
void DClickOnCmpList(wxCommandEvent &event)
bool ReCreateListLib()
Creates or recreates a sorted list of currently loaded libraries.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
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.