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-2016 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2004-2016 KiCad Developers, see change_log.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 
30 #ifndef LIBVIEWFRM_H_
31 #define LIBVIEWFRM_H_
32 
33 
34 #include <wx/gdicmn.h>
35 
36 #include <sch_base_frame.h>
37 #include <class_sch_screen.h>
38 
39 class wxListBox;
40 class PART_LIB;
41 class SCHLIB_FILTER;
42 class LIB_ALIAS;
43 class LIB_PART;
44 
45 
50 {
51 public:
52 
61  LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent,
62  FRAME_T aFrameType, PART_LIB* aLibrary = NULL );
63 
65 
66  void OnSize( wxSizeEvent& event ) override;
67 
74  void ReCreateListLib();
75 
76  void ReCreateListCmp();
77  void DisplayLibInfos();
78  void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
79  void OnCloseWindow( wxCloseEvent& Event );
80  void CloseLibraryViewer( wxCommandEvent& event );
81  void ReCreateHToolbar() override;
82  void ReCreateVToolbar() override;
83  void ReCreateMenuBar() override;
84 
85  void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
86  double BestZoom() override;
87  void ClickOnLibList( wxCommandEvent& event );
88  void ClickOnCmpList( wxCommandEvent& event );
89  void OnSetRelativeOffset( wxCommandEvent& event );
90  void OnSelectSymbol( wxCommandEvent& aEvent );
91  void OnShowElectricalType( wxCommandEvent& event );
92 
93  bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
94 
96  EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
97 
106  bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
107  EDA_ITEM* aItem = NULL ) override;
108 
109  void LoadSettings( wxConfigBase* aCfg ) override;
110  void SaveSettings( wxConfigBase* aCfg ) override;
111 
121  void SetFilter( const SCHLIB_FILTER* aFilter );
122 
128  void SetSelectedLibrary( const wxString& aLibName );
129 
135  void SetSelectedComponent( const wxString& aComponentName );
136 
137  // Accessors:
138  void SetUnit( int aUnit ) { m_unit = aUnit; }
139  int GetUnit( void ) { return m_unit; }
140 
141  void SetConvert( int aConvert ) { m_convert = aConvert; }
142  int GetConvert( void ) { return m_convert; }
143 
145  void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; }
146 
147 private:
153  virtual void OnActivate( wxActivateEvent& event ) override;
154 
159  void ExportToSchematicLibraryPart( wxCommandEvent& event );
160  bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
161  void DClickOnCmpList( wxCommandEvent& event );
162 
163  void onUpdateAlternateBodyStyleButton( wxUpdateUIEvent& aEvent );
164  void onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent );
165  void onUpdateViewDoc( wxUpdateUIEvent& aEvent );
166  void OnUpdateElectricalType( wxUpdateUIEvent& aEvent );
167  void onSelectNextSymbol( wxCommandEvent& aEvent );
168  void onSelectPreviousSymbol( wxCommandEvent& aEvent );
169  void onViewSymbolDocument( wxCommandEvent& aEvent );
170  void onSelectSymbolBodyStyle( wxCommandEvent& aEvent );
171  void onSelectSymbolUnit( wxCommandEvent& aEvent );
172 
175 
176 // Private members:
177  wxComboBox* m_selpartBox;
178 
179  // List of libraries (for selection )
180  wxListBox* m_libList; // The list of libs
181  int m_libListWidth; // Last width of the window
182 
183  // List of components in the selected library
184  wxListBox* m_cmpList; // The list of components
185  int m_cmpListWidth; // Last width of the window
186 
187  // Filters to build list of libs/list of parts
189  wxArrayString m_allowedLibs;
190 
191  // TODO(hzeller): looks like these members were chosen to be static to survive different
192  // instances of this browser and communicate it to the next instance. This looks like an
193  // ugly hack, and should be solved differently.
194  static wxString m_libraryName;
195 
196  static wxString m_entryName;
197 
198  static int m_unit;
199  static int m_convert;
200 
205 
206  DECLARE_EVENT_TABLE()
207 };
208 
209 #endif // LIBVIEWFRM_H_
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.
void onUpdateViewDoc(wxUpdateUIEvent &aEvent)
virtual void OnActivate(wxActivateEvent &event) override
Function OnActivate is called when the frame frame is activate to reload the libraries and component ...
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:166
EDA_HOTKEY * GetHotKeyDescription(int aCommand) const override
>
void onSelectPreviousSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:101
void OnCloseWindow(wxCloseEvent &Event)
void SetShowElectricalType(bool aShow)
void OnLeftClick(wxDC *DC, const wxPoint &MousePos) override
Definition: viewlibs.cpp:161
wxListBox * m_cmpList
LIB_VIEW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, PART_LIB *aLibrary=NULL)
Constructor.
wxArrayString m_allowedLibs
static wxString m_libraryName
void SetUnit(int aUnit)
LIB_ALIAS * getSelectedAlias()
void SetSelectedComponent(const wxString &aComponentName)
Set the selected component.
Component library viewer main window.
Definition: viewlib_frame.h:49
void OnSelectSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:47
void onViewSymbolDocument(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:115
bool m_showPinElectricalTypeName
the option to show the pin electrical name in the component editor
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL) override
Function OnHotKey handle hot key events.
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
int GetUnit(void)
Definitions for the Eeschema program SCH_SCREEN class.
void CloseLibraryViewer(wxCommandEvent &event)
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
Definition: viewlibs.cpp:187
void onSelectSymbolBodyStyle(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:129
LIB_PART * getSelectedSymbol()
Class LIB_PART defines a library part object.
void ReCreateHToolbar() override
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
uint32_t EDA_KEY
Definition: common.h:53
void OnSetRelativeOffset(wxCommandEvent &event)
void ExportToSchematicLibraryPart(wxCommandEvent &event)
Function ExportToSchematicLibraryPart exports the current component to schematic and close the librar...
void DisplayLibInfos()
Definition: viewlibs.cpp:172
int GetConvert(void)
void ClickOnLibList(wxCommandEvent &event)
void onSelectNextSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:87
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:57
void onUpdateNormalBodyStyleButton(wxUpdateUIEvent &aEvent)
void SetConvert(int aConvert)
void OnUpdateElectricalType(wxUpdateUIEvent &aEvent)
wxListBox * m_libList
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
void onUpdateAlternateBodyStyleButton(wxUpdateUIEvent &aEvent)
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:151
double BestZoom() override
Return the zoom level which displays the full page on screen.
void ReCreateVToolbar() override
bool GetShowElectricalType()
void onSelectSymbolUnit(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:149
bool GeneralControl(wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey=0) override
Function GeneralControl performs application specific control using aDC at aPosition in logical units...
void OnShowElectricalType(wxCommandEvent &event)
void DClickOnCmpList(wxCommandEvent &event)
Class SCH_BASE_FRAME is a shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRA...
Class PART_LIB is used to load, save, search, and otherwise manipulate part library files...
wxComboBox * m_selpartBox
void ReCreateListLib()
Function ReCreateListLib.
void SetSelectedLibrary(const wxString &aLibName)
Set the selected library in the library window.
void OnSize(wxSizeEvent &event) override
Function OnSize recalculates the size of toolbars and display panel when the frame size changes...