KiCad PCB EDA Suite
FOOTPRINT_PREVIEW_WIDGET Class Reference

#include <footprint_preview_widget.h>

Inheritance diagram for FOOTPRINT_PREVIEW_WIDGET:

Public Member Functions

 FOOTPRINT_PREVIEW_WIDGET (wxWindow *aParent, KIWAY &aKiway)
 Construct a footprint preview widget. More...
 
bool IsInitialized () const
 Return whether the widget initialized properly. More...
 
void SetStatusText (wxString const &aText)
 Set the contents of the status label and display it. More...
 
void ClearStatus ()
 Clear the contents of the status label and hide it. More...
 
void CacheFootprint (const LIB_ID &aFPID)
 Preload a footprint into the cache. More...
 
void DisplayFootprint (const LIB_ID &aFPID)
 Set the currently displayed footprint. More...
 

Private Member Functions

void OnStatusChange (FOOTPRINT_STATUS aStatus)
 Callback from the FOOTPRINT_PREVIEW_PANEL. More...
 

Private Attributes

FOOTPRINT_PREVIEW_PANEL_BASEm_prev_panel
 
wxStaticText * m_status_label
 
wxSizer * m_sizer
 

Detailed Description

Definition at line 43 of file footprint_preview_widget.h.

Constructor & Destructor Documentation

FOOTPRINT_PREVIEW_WIDGET::FOOTPRINT_PREVIEW_WIDGET ( wxWindow *  aParent,
KIWAY aKiway 
)

Construct a footprint preview widget.

Parameters
aParent- parent window
aKiway- an active Kiway instance

Definition at line 27 of file footprint_preview_widget.cpp.

References FOOTPRINT_PREVIEW_PANEL_BASE::Create(), FOOTPRINT_PREVIEW_PANEL_BASE::GetWindow(), m_prev_panel, m_sizer, m_status_label, OnStatusChange(), and FOOTPRINT_PREVIEW_PANEL_BASE::SetStatusHandler().

27  :
28  wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
29  wxFULL_REPAINT_ON_RESIZE | wxSUNKEN_BORDER | wxTAB_TRAVERSAL ),
30  m_prev_panel( nullptr ),
31  m_status_label( nullptr ),
32  m_sizer( nullptr )
33 {
35 
36  if( !m_prev_panel )
37  return;
38 
39  SetBackgroundColour( *wxBLACK );
40  SetForegroundColour( *wxWHITE );
41 
42  m_status_label = new wxStaticText( this, -1, wxEmptyString );
43  m_sizer = new wxBoxSizer( wxVERTICAL );
44  m_sizer->Add( 0, 0, 1 );
45  m_sizer->Add( m_status_label, 0, wxALL | wxALIGN_CENTER, 0 );
46  m_sizer->Add( 0, 0, 1 );
47 
48  auto outer_sizer = new wxBoxSizer( wxVERTICAL );
49  outer_sizer->Add( m_prev_panel->GetWindow(), 1, wxALL | wxEXPAND, 0 );
50  outer_sizer->Add( m_sizer, 1, wxALL | wxALIGN_CENTER, 0 );
51 
52  m_sizer->ShowItems( false );
53  m_prev_panel->SetStatusHandler( [this]( FOOTPRINT_STATUS s ){ this->OnStatusChange( s ); } );
54 
55  SetSizer( outer_sizer );
56 }
void OnStatusChange(FOOTPRINT_STATUS aStatus)
Callback from the FOOTPRINT_PREVIEW_PANEL.
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
virtual wxWindow * GetWindow()=0
Get the underlying wxWindow.
static FOOTPRINT_PREVIEW_PANEL_BASE * Create(wxWindow *aParent, KIWAY &aKiway)
Return a footprint preview panel instance via Kiface.
virtual void SetStatusHandler(FOOTPRINT_STATUS_HANDLER aHandler)=0
Set the callback to receive status updates.

Member Function Documentation

void FOOTPRINT_PREVIEW_WIDGET::CacheFootprint ( const LIB_ID aFPID)

Preload a footprint into the cache.

This must be called prior to DisplayFootprint, and may be called early.

Definition at line 77 of file footprint_preview_widget.cpp.

References FOOTPRINT_PREVIEW_PANEL_BASE::CacheFootprint(), and m_prev_panel.

Referenced by DIALOG_CHOOSE_COMPONENT::ShowFootprintFor().

78 {
79  if( m_prev_panel )
80  (void) m_prev_panel->CacheFootprint( aFPID );
81 }
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
virtual void CacheFootprint(LIB_ID const &aFPID)=0
Preload a footprint into the cache.
void FOOTPRINT_PREVIEW_WIDGET::ClearStatus ( )

Clear the contents of the status label and hide it.

Definition at line 68 of file footprint_preview_widget.cpp.

References FOOTPRINT_PREVIEW_PANEL_BASE::GetWindow(), m_prev_panel, m_sizer, and m_status_label.

Referenced by OnStatusChange(), and DIALOG_CHOOSE_COMPONENT::ShowFootprintFor().

69 {
70  m_status_label->SetLabel( wxEmptyString );
71  m_prev_panel->GetWindow()->Show();
72  m_sizer->ShowItems( false );
73  Layout();
74 }
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
virtual wxWindow * GetWindow()=0
Get the underlying wxWindow.
void FOOTPRINT_PREVIEW_WIDGET::DisplayFootprint ( const LIB_ID aFPID)

Set the currently displayed footprint.

Any footprint passed in here must have been passed to CacheFootprint before.

Definition at line 84 of file footprint_preview_widget.cpp.

References FOOTPRINT_PREVIEW_PANEL_BASE::DisplayFootprint(), and m_prev_panel.

Referenced by DIALOG_CHOOSE_COMPONENT::ShowFootprintFor().

85 {
86  if( m_prev_panel )
87  (void) m_prev_panel->DisplayFootprint( aFPID );
88 }
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
virtual void DisplayFootprint(LIB_ID const &aFPID)=0
Set the currently displayed footprint.
bool FOOTPRINT_PREVIEW_WIDGET::IsInitialized ( ) const
inline

Return whether the widget initialized properly.

This could return false if Kiway is not available. If this returns false, no other methods should be called.

Definition at line 60 of file footprint_preview_widget.h.

References m_prev_panel.

Referenced by DIALOG_CHOOSE_COMPONENT::OnInitDialog(), DIALOG_CHOOSE_COMPONENT::OnTreeSelect(), and DIALOG_CHOOSE_COMPONENT::ShowFootprintFor().

60 { return !! m_prev_panel; }
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
void FOOTPRINT_PREVIEW_WIDGET::OnStatusChange ( FOOTPRINT_STATUS  aStatus)
private

Callback from the FOOTPRINT_PREVIEW_PANEL.

Definition at line 91 of file footprint_preview_widget.cpp.

References ClearStatus(), FPS_LOADING, FPS_NOT_FOUND, FPS_READY, Refresh(), and SetStatusText().

Referenced by FOOTPRINT_PREVIEW_WIDGET().

92 {
93  switch( aStatus )
94  {
95  case FPS_NOT_FOUND:
96  SetStatusText( _( "Footprint not found" ) );
97  break;
98 
99  case FPS_LOADING:
100  SetStatusText( _( "Loading..." ) );
101  break;
102 
103  case FPS_READY:
104  ClearStatus();
105  }
106 
107  Refresh();
108 }
void Refresh()
void ClearStatus()
Clear the contents of the status label and hide it.
void SetStatusText(wxString const &aText)
Set the contents of the status label and display it.
void FOOTPRINT_PREVIEW_WIDGET::SetStatusText ( wxString const &  aText)

Set the contents of the status label and display it.

Definition at line 59 of file footprint_preview_widget.cpp.

References FOOTPRINT_PREVIEW_PANEL_BASE::GetWindow(), m_prev_panel, m_sizer, and m_status_label.

Referenced by DIALOG_CHOOSE_COMPONENT::OnInitDialog(), OnStatusChange(), DIALOG_CHOOSE_COMPONENT::OnTreeSelect(), and DIALOG_CHOOSE_COMPONENT::ShowFootprintFor().

60 {
61  m_status_label->SetLabel( aText );
62  m_sizer->ShowItems( true );
63  m_prev_panel->GetWindow()->Hide();
64  Layout();
65 }
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
virtual wxWindow * GetWindow()=0
Get the underlying wxWindow.

Member Data Documentation

FOOTPRINT_PREVIEW_PANEL_BASE* FOOTPRINT_PREVIEW_WIDGET::m_prev_panel
private
wxSizer* FOOTPRINT_PREVIEW_WIDGET::m_sizer
private

Definition at line 93 of file footprint_preview_widget.h.

Referenced by ClearStatus(), FOOTPRINT_PREVIEW_WIDGET(), and SetStatusText().

wxStaticText* FOOTPRINT_PREVIEW_WIDGET::m_status_label
private

Definition at line 92 of file footprint_preview_widget.h.

Referenced by ClearStatus(), FOOTPRINT_PREVIEW_WIDGET(), and SetStatusText().


The documentation for this class was generated from the following files: