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 (const wxString &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 SetUserUnits (EDA_UNITS aUnits)
 Set the units for the preview. 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 37 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 wxWindow * GetWindow()=0
Get the underlying wxWindow.
virtual const KIGFX::COLOR4D & GetForegroundColor() const =0
virtual const KIGFX::COLOR4D & GetBackgroundColor() const =0
Get the colors to use in a preview widget to match the preview panel.
static FOOTPRINT_PREVIEW_PANEL_BASE * Create(wxWindow *aParent, KIWAY &aKiway)
Return a footprint preview panel instance via Kiface.
FOOTPRINT_PREVIEW_PANEL_BASE * m_prev_panel
void SetStatusText(const wxString &aText)
Set the contents of the status label and display it.

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}

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

96{
97 if( !m_prev_panel || m_libid == aFPID )
98 return;
99
100 wxBusyCursor busy;
101
102 if( m_prev_panel->DisplayFootprint( aFPID ) )
103 {
104 ClearStatus();
105 m_libid = aFPID;
106 }
107 else
108 {
109 SetStatusText( _( "Footprint not found." ) );
110 m_libid.clear();
111 }
112}
virtual bool DisplayFootprint(LIB_ID const &aFPID)=0
Set the currently displayed footprint.
void ClearStatus()
Clear the contents of the status label and hide it.
void clear()
Clear the contents of the library nickname, library entry name.
Definition: lib_id.cpp:42
#define _(s)

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

54{ return m_prev_panel != nullptr; }

References m_prev_panel.

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

◆ SetStatusText()

void FOOTPRINT_PREVIEW_WIDGET::SetStatusText ( const wxString &  aText)

◆ SetUserUnits()

void FOOTPRINT_PREVIEW_WIDGET::SetUserUnits ( EDA_UNITS  aUnits)

Set the units for the preview.

Definition at line 89 of file footprint_preview_widget.cpp.

90{
91 m_prev_panel->SetUserUnits( aUnits );
92}
virtual void SetUserUnits(EDA_UNITS aUnits)=0

References m_prev_panel, and FOOTPRINT_PREVIEW_PANEL_BASE::SetUserUnits().

Referenced by DIALOG_CHOOSE_SYMBOL::ConstructRightPanel(), and DIALOG_CHOOSE_FOOTPRINT::ConstructRightPanel().

Member Data Documentation

◆ m_libid

LIB_ID FOOTPRINT_PREVIEW_WIDGET::m_libid
private

Definition at line 84 of file footprint_preview_widget.h.

Referenced by DisplayFootprint().

◆ m_outerSizer

wxSizer* FOOTPRINT_PREVIEW_WIDGET::m_outerSizer
private

Definition at line 83 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 80 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 81 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 82 of file footprint_preview_widget.h.

Referenced by FOOTPRINT_PREVIEW_WIDGET().


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