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 DisplayFootprint (const LIB_ID &aFPID)
 Set the currently displayed footprint. More...
 

Private Attributes

FOOTPRINT_PREVIEW_PANEL_BASEm_prev_panel
 
wxStaticText * m_status
 
wxPanel * m_statusPanel
 
wxSizer * m_statusSizer
 
wxSizer * m_outerSizer
 
LIB_ID m_libid
 

Detailed Description

Definition at line 38 of file footprint_preview_widget.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_PREVIEW_WIDGET()

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 28 of file footprint_preview_widget.cpp.

28  :
29  wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
30  wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL ),
31  m_prev_panel( nullptr ),
32  m_status( nullptr ),
33  m_statusPanel( nullptr ),
34  m_statusSizer( nullptr ),
35  m_outerSizer( nullptr )
36 {
38 
39  if( !m_prev_panel )
40  return;
41 
42  m_statusPanel = new wxPanel( this );
43  m_status = new wxStaticText( m_statusPanel, wxID_ANY, wxEmptyString );
44  m_statusSizer = new wxBoxSizer( wxVERTICAL );
45  m_statusSizer->Add( 0, 0, 1 ); // add a spacer
46  m_statusSizer->Add( m_status, 0, wxALIGN_CENTER );
47  m_statusSizer->Add( 0, 0, 1 ); // add a spacer
48  m_statusPanel->SetSizer( m_statusSizer );
49 
50  // Give the status panel the same color scheme as the canvas so it isn't jarring when
51  // switched to
52  m_statusPanel->SetBackgroundColour( m_prev_panel->GetBackgroundColor().ToColour() );
53  m_statusPanel->SetForegroundColour( m_prev_panel->GetForegroundColor().ToColour() );
54  m_status->SetForegroundColour( m_prev_panel->GetForegroundColor().ToColour() );
55 
56  // Set our background so wx doesn't render a normal control background momentarily when
57  // rapidly navigating with arrow keys
58  SetBackgroundColour( m_prev_panel->GetBackgroundColor().ToColour() );
59  SetForegroundColour( m_prev_panel->GetForegroundColor().ToColour() );
60 
61  m_outerSizer = new wxBoxSizer( wxVERTICAL );
62  m_outerSizer->Add( m_prev_panel->GetWindow(), 1, wxALL | wxEXPAND, 0 );
63  m_outerSizer->Add( m_statusPanel, 1, wxALL | wxEXPAND, 0 );
64 
65  SetSizer( m_outerSizer );
66 
67  SetStatusText( wxEmptyString );
68 }
virtual const KIGFX::COLOR4D & GetForegroundColor()=0
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
virtual wxWindow * GetWindow()=0
Get the underlying wxWindow.
virtual const KIGFX::COLOR4D & GetBackgroundColor()=0
Get the colors to use in a preview widget to match the preview panel.
void SetStatusText(wxString const &aText)
Set the contents of the status label and display it.
static FOOTPRINT_PREVIEW_PANEL_BASE * Create(wxWindow *aParent, KIWAY &aKiway)
Return a footprint preview panel instance via Kiface.

References FOOTPRINT_PREVIEW_PANEL_BASE::Create(), FOOTPRINT_PREVIEW_PANEL_BASE::GetBackgroundColor(), FOOTPRINT_PREVIEW_PANEL_BASE::GetForegroundColor(), FOOTPRINT_PREVIEW_PANEL_BASE::GetWindow(), m_outerSizer, m_prev_panel, m_status, m_statusPanel, m_statusSizer, and SetStatusText().

Member Function Documentation

◆ ClearStatus()

void FOOTPRINT_PREVIEW_WIDGET::ClearStatus ( )

Clear the contents of the status label and hide it.

Definition at line 80 of file footprint_preview_widget.cpp.

81 {
82  m_status->SetLabel( wxEmptyString );
83  m_statusPanel->Hide();
84  m_prev_panel->GetWindow()->Show();
85  Layout();
86 }
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
virtual wxWindow * GetWindow()=0
Get the underlying wxWindow.

References FOOTPRINT_PREVIEW_PANEL_BASE::GetWindow(), m_prev_panel, m_status, and m_statusPanel.

Referenced by DisplayFootprint(), DIALOG_CHOOSE_FOOTPRINT::OnComponentPreselected(), and DIALOG_CHOOSE_SYMBOL::ShowFootprint().

◆ DisplayFootprint()

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 89 of file footprint_preview_widget.cpp.

90 {
91  if( !m_prev_panel || m_libid == aFPID )
92  return;
93 
94  wxBusyCursor busy;
95 
96  if( m_prev_panel->DisplayFootprint( aFPID ) )
97  {
98  ClearStatus();
99  m_libid = aFPID;
100  }
101  else
102  {
103  SetStatusText( _( "Footprint not found." ) );
104  m_libid.clear();
105  }
106 }
virtual bool DisplayFootprint(LIB_ID const &aFPID)=0
Set the currently displayed footprint.
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
void ClearStatus()
Clear the contents of the status label and hide it.
#define _(s)
void SetStatusText(wxString const &aText)
Set the contents of the status label and display it.
void clear()
Clear the contents of the library nickname, library entry name, and revision strings.
Definition: lib_id.cpp:114

References _, LIB_ID::clear(), ClearStatus(), FOOTPRINT_PREVIEW_PANEL_BASE::DisplayFootprint(), m_libid, m_prev_panel, and SetStatusText().

Referenced by DIALOG_CHOOSE_FOOTPRINT::OnComponentPreselected(), and DIALOG_CHOOSE_SYMBOL::ShowFootprint().

◆ IsInitialized()

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 55 of file footprint_preview_widget.h.

55 { return m_prev_panel != nullptr; }
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel

References m_prev_panel.

Referenced by DIALOG_CHOOSE_FOOTPRINT::OnComponentPreselected(), DIALOG_CHOOSE_SYMBOL::OnComponentPreselected(), DIALOG_CHOOSE_SYMBOL::OnInitDialog(), DIALOG_CHOOSE_SYMBOL::ShowFootprint(), and DIALOG_CHOOSE_SYMBOL::ShowFootprintFor().

◆ SetStatusText()

void FOOTPRINT_PREVIEW_WIDGET::SetStatusText ( wxString const &  aText)

Set the contents of the status label and display it.

Definition at line 71 of file footprint_preview_widget.cpp.

72 {
73  m_status->SetLabel( aText );
74  m_statusPanel->Show();
75  m_prev_panel->GetWindow()->Hide();
76  Layout();
77 }
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
virtual wxWindow * GetWindow()=0
Get the underlying wxWindow.

References FOOTPRINT_PREVIEW_PANEL_BASE::GetWindow(), m_prev_panel, m_status, and m_statusPanel.

Referenced by DisplayFootprint(), FOOTPRINT_PREVIEW_WIDGET(), DIALOG_CHOOSE_FOOTPRINT::OnComponentPreselected(), DIALOG_CHOOSE_SYMBOL::OnComponentPreselected(), DIALOG_CHOOSE_SYMBOL::OnInitDialog(), and DIALOG_CHOOSE_SYMBOL::ShowFootprint().

Member Data Documentation

◆ m_libid

LIB_ID FOOTPRINT_PREVIEW_WIDGET::m_libid
private

Definition at line 80 of file footprint_preview_widget.h.

Referenced by DisplayFootprint().

◆ m_outerSizer

wxSizer* FOOTPRINT_PREVIEW_WIDGET::m_outerSizer
private

Definition at line 79 of file footprint_preview_widget.h.

Referenced by FOOTPRINT_PREVIEW_WIDGET().

◆ m_prev_panel

FOOTPRINT_PREVIEW_PANEL_BASE* FOOTPRINT_PREVIEW_WIDGET::m_prev_panel
private

◆ m_status

wxStaticText* FOOTPRINT_PREVIEW_WIDGET::m_status
private

Definition at line 76 of file footprint_preview_widget.h.

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

◆ m_statusPanel

wxPanel* FOOTPRINT_PREVIEW_WIDGET::m_statusPanel
private

Definition at line 77 of file footprint_preview_widget.h.

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

◆ m_statusSizer

wxSizer* FOOTPRINT_PREVIEW_WIDGET::m_statusSizer
private

Definition at line 78 of file footprint_preview_widget.h.

Referenced by FOOTPRINT_PREVIEW_WIDGET().


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