KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol_viewer_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 <[email protected]>
6 * Copyright The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22
23#ifndef LIB_VIEW_FRAME_H__
24#define LIB_VIEW_FRAME_H__
25
26#include <sch_base_frame.h>
27#include <sch_screen.h>
28#include <tool/selection.h>
29
30class WX_LISTBOX;
31class wxSearchCtrl;
33class LIB_SYMBOL;
34
35
40{
41public:
42
49 SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent );
50
52
53 void OnSize( wxSizeEvent& event ) override;
54
61 bool ReCreateLibList();
62
69 bool ReCreateSymbolList();
70
71 void DisplayLibInfos();
72 void doCloseWindow() override;
73 void CloseLibraryViewer( wxCommandEvent& event );
74
75 void ClickOnLibList( wxCommandEvent& event );
76 void ClickOnSymbolList( wxCommandEvent& event );
77
78 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
79 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
80
82
83 void CommonSettingsChanged( int aFlags ) override;
84
88 void SetSelectedLibrary( const wxString& aLibName, const wxString& aSubLibName = wxEmptyString );
89
93 void SetSelectedSymbol( const wxString& aSymbolName );
94 void SelectNextSymbol();
96
97 // Accessors:
104 void SetUnitAndBodyStyle( int aUnit, int aBodyStyle );
105 int GetUnit() const { return m_unit; }
106 int GetBodyStyle() const { return m_bodyStyle; }
107
109
110 const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
111
112 SELECTION& GetCurrentSelection() override;
113
114 void KiwayMailIn( KIWAY_MAIL_EVENT& mail ) override;
115
116 void ClearToolbarControl( int aId ) override;
117
118protected:
119 void configureToolbars() override;
120
121 void setupUIConditions() override;
122
123 void doReCreateMenuBar() override;
124
125private:
126 // Set up the tool framework.
127 void setupTools();
128
133 void OnActivate( wxActivateEvent& event );
134
135 void DClickOnSymbolList( wxCommandEvent& event );
136
137 // Rebuild the wxChoice m_unitChoice widget. Must be called after changing the selected symbol
138 void updateUnitChoice();
139 // Rebuild the wxChoice m_bodyStyleChoice widget. Must be called after changing the selected symbol
141
142 void OnLibFilter( wxCommandEvent& aEvent );
143 void OnSymFilter( wxCommandEvent& aEvent );
144 void OnCharHook( wxKeyEvent& aEvent ) override;
145
146 void onSelectSymbolUnit( wxCommandEvent& aEvent );
147 void onSelectSymbolBodyStyle( wxCommandEvent& aEvent );
148
149 void updatePreviewSymbol();
150
151private:
152 wxChoice* m_unitChoice;
154
155 wxSearchCtrl* m_libFilter;
156 WX_LISTBOX* m_libList; // The list of libraries.
157 int m_libListWidth; // Last width of the window.
158
159 wxSearchCtrl* m_symbolFilter;
160 WX_LISTBOX* m_symbolList; // The list of symbols.
161 int m_symbolListWidth; // Last width of the window.
162
163 // Filters to build list of libs/list of symbols.
165 wxArrayString m_allowedLibs;
166
168
169 static int m_unit;
170 static int m_bodyStyle;
171
177
178 std::unique_ptr<LIB_SYMBOL> m_previewItem;
179
180 DECLARE_EVENT_TABLE()
181};
182
183#endif // LIB_VIEW_FRAME_H__
184
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition kiway_mail.h:34
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:311
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
Define a library symbol object.
Definition lib_symbol.h:79
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
Helper object to filter a list of libraries.
void OnLibFilter(wxCommandEvent &aEvent)
std::unique_ptr< LIB_SYMBOL > m_previewItem
void CloseLibraryViewer(wxCommandEvent &event)
void SetSelectedLibrary(const wxString &aLibName, const wxString &aSubLibName=wxEmptyString)
Set the selected library in the library window.
void ClickOnLibList(wxCommandEvent &event)
SYMBOL_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent)
void DClickOnSymbolList(wxCommandEvent &event)
void OnActivate(wxActivateEvent &event)
Called when the frame is activated to reload the libraries and symbol lists that can be changed by th...
void OnSymFilter(wxCommandEvent &aEvent)
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void SetSelectedSymbol(const wxString &aSymbolName)
Set the selected symbol.
bool ReCreateLibList()
Create o recreates a sorted list of currently loaded libraries.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void ClickOnSymbolList(wxCommandEvent &event)
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box of document with option to not include some items.
void ClearToolbarControl(int aId) override
void SetUnitAndBodyStyle(int aUnit, int aBodyStyle)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
wxSearchCtrl * m_symbolFilter
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
void KiwayMailIn(KIWAY_MAIL_EVENT &mail) override
Receive #KIWAY_ROUTED_EVENT messages from other players.
LIB_SYMBOL * GetSelectedSymbol() const
void onSelectSymbolUnit(wxCommandEvent &aEvent)
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void onSelectSymbolBodyStyle(wxCommandEvent &aEvent)
bool m_selection_changed
Updated to true if a list rewrite on GUI activation resulted in the symbol selection changing,...
bool ReCreateSymbolList()
Create or recreate the list of symbols in the currently selected library.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
Store the common settings that are saved and loaded for each window / frame.