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 #include <tool/selection.h>
33 
34 class wxListBox;
35 class SCHLIB_FILTER;
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  void ClickOnLibList( wxCommandEvent& event );
100  void ClickOnCmpList( wxCommandEvent& event );
101  void OnSelectSymbol( wxCommandEvent& aEvent );
102 
103  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
104  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
105 
107 
108  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
109 
117  void SetFilter( const SCHLIB_FILTER* aFilter );
118 
124  void SetSelectedLibrary( const wxString& aLibName );
125 
131  void SetSelectedComponent( const wxString& aComponentName );
132 
133  // Accessors:
140  void SetUnitAndConvert( int aUnit, int aConvert );
141  int GetUnit() const { return m_unit; }
142  int GetConvert() const { return m_convert; }
143 
144  LIB_PART* GetSelectedSymbol() const;
145 
146  const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
147 
148  SELECTION& GetCurrentSelection() override;
149 
150 protected:
151  void setupUIConditions() override;
152 
153 private:
154  // Sets up the tool framework
155  void setupTools();
156 
161  void OnActivate( wxActivateEvent& event );
162 
163  void DClickOnCmpList( wxCommandEvent& event );
164 
165  void onUpdateUnitChoice( wxUpdateUIEvent& aEvent );
166 
167  void onSelectNextSymbol( wxCommandEvent& aEvent );
168  void onSelectPreviousSymbol( wxCommandEvent& aEvent );
169  void onSelectSymbolUnit( wxCommandEvent& aEvent );
170 
171  void updatePreviewSymbol();
172 
173 // Private members:
174  wxChoice* m_unitChoice;
175 
176  // List of libraries (for selection )
177  wxListBox* m_libList; // The list of libs
178  int m_libListWidth; // Last width of the window
179 
180  // List of components in the selected library
181  wxListBox* m_cmpList; // The list of components
182  int m_cmpListWidth; // Last width of the window
183 
184  // Filters to build list of libs/list of parts
186  wxArrayString m_allowedLibs;
187 
188  static wxString m_libraryName;
189  static wxString m_entryName;
190 
191  static int m_unit;
192  static int m_convert;
193 
199 
201 
202  DECLARE_EVENT_TABLE()
203 };
204 
205 #endif // LIB_VIEW_FRAME_H__
206 
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
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 setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
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:81
void OnSelectSymbol(wxCommandEvent &aEvent)
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
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
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
bool ReCreateListCmp()
Create or recreate the list of components in the currently selected library.
void ClickOnLibList(wxCommandEvent &event)
void onSelectNextSymbol(wxCommandEvent &aEvent)
void updatePreviewSymbol()
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
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.