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-2017 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 
29 #define LIB_VIEW_FRAME_H__
30 
31 #include <sch_base_frame.h>
32 #include <sch_screen.h>
33 
34 class wxListBox;
35 class SCHLIB_FILTER;
36 class LIB_ALIAS;
37 class LIB_PART;
39 
40 
45 {
46 public:
47 
56  LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent,
57  FRAME_T aFrameType, const wxString& aLibraryName = wxEmptyString );
58 
60 
61  void OnSize( wxSizeEvent& event ) override;
62 
69  bool ReCreateListLib();
70 
77  bool ReCreateListCmp();
78  void DisplayLibInfos();
79  void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
80  void OnCloseWindow( wxCloseEvent& Event );
81  void CloseLibraryViewer( wxCommandEvent& event );
82  void ReCreateHToolbar() override;
83  void ReCreateVToolbar() override;
84  void ReCreateMenuBar() override;
85 
86  void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
87  double BestZoom() override;
88  void ClickOnLibList( wxCommandEvent& event );
89  void ClickOnCmpList( wxCommandEvent& event );
90  void OnSetRelativeOffset( wxCommandEvent& event );
91  void OnSelectSymbol( wxCommandEvent& aEvent );
92  void OnShowElectricalType( wxCommandEvent& event );
93 
94  bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey ) override;
95 
97  EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
98 
107  bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem ) override;
108 
109  void LoadSettings( wxConfigBase* aCfg ) override;
110  void SaveSettings( wxConfigBase* aCfg ) override;
111 
119  void SetFilter( const SCHLIB_FILTER* aFilter );
120 
126  void SetSelectedLibrary( const wxString& aLibName );
127 
133  void SetSelectedComponent( const wxString& aComponentName );
134 
135  // Accessors:
142  void SetUnitAndConvert( int aUnit, int aConvert );
143  int GetUnit() const { return m_unit; }
144  int GetConvert() const { return m_convert; }
145 
147  void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; }
148 
149  const BOX2I GetDocumentExtents() const override;
150 
151 private:
156  virtual void OnActivate( wxActivateEvent& event ) override;
157 
162  void ExportToSchematicLibraryPart( wxCommandEvent& event );
163  bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
164  void DClickOnCmpList( wxCommandEvent& event );
165 
166  void onUpdateAltBodyStyleButton( wxUpdateUIEvent& aEvent );
167  void onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent );
168  void onUpdateDocButton( wxUpdateUIEvent& aEvent );
169  void OnUpdateElectricalType( wxUpdateUIEvent& aEvent );
170  void onUpdateUnitChoice( wxUpdateUIEvent& aEvent );
171  void onSelectNextSymbol( wxCommandEvent& aEvent );
172  void onSelectPreviousSymbol( wxCommandEvent& aEvent );
173  void onViewSymbolDocument( wxCommandEvent& aEvent );
174  void onSelectSymbolBodyStyle( wxCommandEvent& aEvent );
175  void onSelectSymbolUnit( wxCommandEvent& aEvent );
176 
177  LIB_ALIAS* getSelectedAlias() const;
178  LIB_PART* getSelectedSymbol() const;
179  void updatePreviewSymbol();
180 
181 // Private members:
182  wxChoice* m_unitChoice;
183 
184  // List of libraries (for selection )
185  wxListBox* m_libList; // The list of libs
186  int m_libListWidth; // Last width of the window
187 
188  // List of components in the selected library
189  wxListBox* m_cmpList; // The list of components
190  int m_cmpListWidth; // Last width of the window
191 
192  // Filters to build list of libs/list of parts
194  wxArrayString m_allowedLibs;
195 
196  // TODO(hzeller): looks like these members were chosen to be static to survive different
197  // instances of this browser and communicate it to the next instance. This looks like an
198  // ugly hack, and should be solved differently.
199  static wxString m_libraryName;
200 
201  static wxString m_entryName;
202 
203  static int m_unit;
204  static int m_convert;
205 
211 
213 
218 
219  DECLARE_EVENT_TABLE()
220 };
221 
222 #endif // LIB_VIEW_FRAME_H__
223 
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.
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...
bool GetShowElectricalType() const
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 GeneralControl(wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey) override
Perform application specific control using aDC at aPosition in logical units.
virtual void OnActivate(wxActivateEvent &event) override
Called when the frame is activated to reload the libraries and component lists that can be changed by...
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
bool OnRightClick(const wxPoint &MousePos, wxMenu *PopMenu) override
Definition: viewlibs.cpp:170
EDA_HOTKEY * GetHotKeyDescription(int aCommand) const override
>
void onSelectPreviousSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:97
void OnCloseWindow(wxCloseEvent &Event)
void SetShowElectricalType(bool aShow)
void OnLeftClick(wxDC *DC, const wxPoint &MousePos) override
Definition: viewlibs.cpp:165
wxListBox * m_cmpList
wxArrayString m_allowedLibs
static wxString m_libraryName
void SetSelectedComponent(const wxString &aComponentName)
Set the selected component.
int GetUnit() const
Symbol library viewer main window.
Definition: viewlib_frame.h:44
void onUpdateAltBodyStyleButton(wxUpdateUIEvent &aEvent)
void OnSelectSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:45
void onViewSymbolDocument(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:119
bool m_showPinElectricalTypeName
the option to show the pin electrical name in the component editor
LIB_VIEW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aLibraryName=wxEmptyString)
Constructor.
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
int GetConvert() const
void onUpdateUnitChoice(wxUpdateUIEvent &aEvent)
void CloseLibraryViewer(wxCommandEvent &event)
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem) override
Handle hot key events.
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
Definition: viewlibs.cpp:189
void onSelectSymbolBodyStyle(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:132
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
uint32_t EDA_KEY
Definition: common.h:73
void OnSetRelativeOffset(wxCommandEvent &event)
const BOX2I GetDocumentExtents() const override
bool ReCreateListCmp()
Create or recreate the list of components in the currently selected library.
void ExportToSchematicLibraryPart(wxCommandEvent &event)
Function ExportToSchematicLibraryPart exports the current component to schematic and close the librar...
void DisplayLibInfos()
Definition: viewlibs.cpp:176
void ClickOnLibList(wxCommandEvent &event)
Definitions for the Eeschema program SCH_SCREEN class.
void onSelectNextSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:83
void updatePreviewSymbol()
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
LIB_PART * getSelectedSymbol() const
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:59
void onUpdateNormalBodyStyleButton(wxUpdateUIEvent &aEvent)
void OnUpdateElectricalType(wxUpdateUIEvent &aEvent)
wxListBox * m_libList
LIB_ALIAS * getSelectedAlias() const
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
void ClickOnCmpList(wxCommandEvent &event)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
wxChoice * m_unitChoice
double BestZoom() override
Return the zoom level which displays the full page on screen.
void ReCreateVToolbar() override
void onSelectSymbolUnit(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:152
void OnShowElectricalType(wxCommandEvent &event)
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, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes.
void onUpdateDocButton(wxUpdateUIEvent &aEvent)
Definition: viewlibs.cpp:111
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.