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 #include <gal/color4d.h>
29 
30 class FOOTPRINT_LOAD_EVENT;
32 class LIB_ID;
33 class KIWAY;
34 class wxStaticText;
35 class wxSizer;
36 
37 
40  FPS_READY = 1,
42 };
43 
44 
45 class FOOTPRINT_PREVIEW_WIDGET: public wxPanel
46 {
47 public:
48 
55  FOOTPRINT_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway );
56 
62  bool IsInitialized() const { return !! m_prev_panel; }
63 
67  void SetStatusText( wxString const& aText );
68 
72  void ClearStatus();
73 
78  void CacheFootprint( const LIB_ID& aFPID );
79 
84  void DisplayFootprint( const LIB_ID& aFPID );
85 
86 private:
87 
91  void OnStatusChange( FOOTPRINT_STATUS aStatus );
92 
94 
95  wxStaticText* m_status;
96  wxPanel* m_statusPanel;
97  wxSizer* m_statusSizer;
98  wxSizer* m_outerSizer;
99 
100 };
101 
102 
103 typedef std::function<void( FOOTPRINT_STATUS )> FOOTPRINT_STATUS_HANDLER;
104 
105 
111 {
112 public:
114 
119  virtual void CacheFootprint( LIB_ID const& aFPID ) = 0;
120 
125  virtual void DisplayFootprint( LIB_ID const& aFPID ) = 0;
126 
130  virtual void SetStatusHandler( FOOTPRINT_STATUS_HANDLER aHandler ) = 0;
131 
135  virtual wxWindow* GetWindow() = 0;
136 
140  virtual const KIGFX::COLOR4D& GetBackgroundColor() = 0;
141  virtual const KIGFX::COLOR4D& GetForegroundColor() = 0;
142 
147  static FOOTPRINT_PREVIEW_PANEL_BASE* Create( wxWindow* aParent, KIWAY& aKiway );
148 };
149 
150 
151 #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
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
void ClearStatus()
Clear the contents of the status label and hide it.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
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.
void DisplayFootprint(const LIB_ID &aFPID)
Set the currently displayed footprint.
FOOTPRINT_PREVIEW_WIDGET(wxWindow *aParent, KIWAY &aKiway)
Construct a footprint preview widget.
bool IsInitialized() const
Return whether the widget initialized properly.
std::function< void(FOOTPRINT_STATUS)> FOOTPRINT_STATUS_HANDLER
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99