KiCad PCB EDA Suite
footprint_preview_widget.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) 2017 KiCad Developers, see AUTHORS.txt for contributors.
5  * Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __FOOTPRINT_PREVIEW_WIDGET_H
22 #define __FOOTPRINT_PREVIEW_WIDGET_H
23 
24 #include <wx/panel.h>
25 #include <functional>
26 #include <import_export.h>
27 
28 class FOOTPRINT_LOAD_EVENT;
30 class LIB_ID;
31 class KIWAY;
32 class wxStaticText;
33 class wxSizer;
34 
35 
38  FPS_READY = 1,
40 };
41 
42 
43 class FOOTPRINT_PREVIEW_WIDGET: public wxPanel
44 {
45 public:
46 
53  FOOTPRINT_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway );
54 
60  bool IsInitialized() const { return !! m_prev_panel; }
61 
65  void SetStatusText( wxString const& aText );
66 
70  void ClearStatus();
71 
76  void CacheFootprint( const LIB_ID& aFPID );
77 
82  void DisplayFootprint( const LIB_ID& aFPID );
83 
84 private:
85 
89  void OnStatusChange( FOOTPRINT_STATUS aStatus );
90 
92  wxStaticText* m_status_label;
93  wxSizer* m_sizer;
94 };
95 
96 
97 typedef std::function<void( FOOTPRINT_STATUS )> FOOTPRINT_STATUS_HANDLER;
98 
99 
105 {
106 public:
108 
113  virtual void CacheFootprint( LIB_ID const& aFPID ) = 0;
114 
119  virtual void DisplayFootprint( LIB_ID const& aFPID ) = 0;
120 
124  virtual void SetStatusHandler( FOOTPRINT_STATUS_HANDLER aHandler ) = 0;
125 
129  virtual wxWindow* GetWindow() = 0;
130 
135  static FOOTPRINT_PREVIEW_PANEL_BASE* Create( wxWindow* aParent, KIWAY& aKiway );
136 };
137 
138 
139 #endif // __FOOTPRINT_PREVIEW_WIDGET_H
void OnStatusChange(FOOTPRINT_STATUS aStatus)
Callback from the FOOTPRINT_PREVIEW_PANEL.
#define APIEXPORT
Macros which export functions from a DLL/DSO.
Definition: import_export.h:44
Class LIB_ID.
Definition: lib_id.h:56
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
void ClearStatus()
Clear the contents of the status label and hide it.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
void SetStatusText(wxString const &aText)
Set the contents of the status label and display it.
Base class for the actual viewer panel.
void CacheFootprint(const LIB_ID &aFPID)
Preload a footprint into the cache.
bool IsInitialized() const
Return whether the widget initialized properly.
void DisplayFootprint(const LIB_ID &aFPID)
Set the currently displayed footprint.
FOOTPRINT_PREVIEW_WIDGET(wxWindow *aParent, KIWAY &aKiway)
Construct a footprint preview widget.
std::function< void(FOOTPRINT_STATUS)> FOOTPRINT_STATUS_HANDLER