KiCad PCB EDA Suite
TEMPLATE_WIDGET Class Reference

#include <dialog_template_selector.h>

Inheritance diagram for TEMPLATE_WIDGET:
TEMPLATE_WIDGET_BASE

Public Member Functions

 TEMPLATE_WIDGET (wxWindow *aParent, DIALOG_TEMPLATE_SELECTOR *aDialog)
 
void SetTemplate (PROJECT_TEMPLATE *aTemplate)
 Set the project template for this widget, which will determine the icon and title associated with this project template widget. More...
 
PROJECT_TEMPLATEGetTemplate ()
 
void Select ()
 
void Unselect ()
 

Protected Member Functions

void OnKillFocus (wxFocusEvent &event)
 
void OnMouse (wxMouseEvent &event)
 

Protected Attributes

DIALOG_TEMPLATE_SELECTORm_dialog
 
wxWindow * m_parent
 
wxPanel * m_panel
 
bool m_selected
 
PROJECT_TEMPLATEm_currTemplate
 
wxStaticBitmap * m_bitmapIcon
 
wxStaticText * m_staticTitle
 

Private Member Functions

bool IsSelected ()
 

Detailed Description

Definition at line 33 of file dialog_template_selector.h.

Constructor & Destructor Documentation

◆ TEMPLATE_WIDGET()

TEMPLATE_WIDGET::TEMPLATE_WIDGET ( wxWindow *  aParent,
DIALOG_TEMPLATE_SELECTOR aDialog 
)

Definition at line 52 of file dialog_template_selector.cpp.

52 :
53 TEMPLATE_WIDGET_BASE( aParent )
54{
55 m_parent = aParent;
56 m_dialog = aDialog;
57
58 // wxWidgets_3.xx way of doing the same...
59 // Bind(wxEVT_LEFT_DOWN, &TEMPLATE_WIDGET::OnMouse, this );
60
61 m_bitmapIcon->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( TEMPLATE_WIDGET::OnMouse ),
62 nullptr, this );
63 m_staticTitle->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( TEMPLATE_WIDGET::OnMouse ),
64 nullptr, this );
65
66 // We're not selected until we're clicked
67 Unselect();
68
69 // Start with template being NULL
70 m_currTemplate = nullptr;
71}
TEMPLATE_WIDGET_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(108,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void OnMouse(wxMouseEvent &event)
DIALOG_TEMPLATE_SELECTOR * m_dialog
PROJECT_TEMPLATE * m_currTemplate

References TEMPLATE_WIDGET_BASE::m_bitmapIcon, m_currTemplate, m_dialog, m_parent, TEMPLATE_WIDGET_BASE::m_staticTitle, OnMouse(), and Unselect().

Member Function Documentation

◆ GetTemplate()

PROJECT_TEMPLATE * TEMPLATE_WIDGET::GetTemplate ( )
inline

◆ IsSelected()

bool TEMPLATE_WIDGET::IsSelected ( )
inlineprivate

Definition at line 54 of file dialog_template_selector.h.

54{ return m_selected; }

References m_selected.

◆ OnKillFocus()

void TEMPLATE_WIDGET::OnKillFocus ( wxFocusEvent &  event)
protected

◆ OnMouse()

void TEMPLATE_WIDGET::OnMouse ( wxMouseEvent &  event)
protected

Definition at line 101 of file dialog_template_selector.cpp.

102{
103 // Toggle selection here
104 Select();
105 event.Skip();
106}

References Select().

Referenced by TEMPLATE_WIDGET().

◆ Select()

void TEMPLATE_WIDGET::Select ( )

Definition at line 74 of file dialog_template_selector.cpp.

75{
76 m_dialog->SetWidget( this );
77 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ) );
78 m_selected = true;
79 Refresh();
80}
void SetWidget(TEMPLATE_WIDGET *aWidget)
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...

References m_dialog, m_selected, Refresh(), and DIALOG_TEMPLATE_SELECTOR::SetWidget().

Referenced by OnMouse().

◆ SetTemplate()

void TEMPLATE_WIDGET::SetTemplate ( PROJECT_TEMPLATE aTemplate)

Set the project template for this widget, which will determine the icon and title associated with this project template widget.

Definition at line 91 of file dialog_template_selector.cpp.

92{
93 m_currTemplate = aTemplate;
94 m_staticTitle->SetLabel( *aTemplate->GetTitle() );
95 m_staticTitle->SetFont( KIUI::GetInfoFont( this ) );
96 m_staticTitle->Wrap( 100 );
97 m_bitmapIcon->SetBitmap( *aTemplate->GetIcon() );
98}
wxBitmap * GetIcon()
Get the 64px^2 icon for the project template.
wxString * GetTitle()
Get the title of the project (extracted from the html title tag)
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:156

References PROJECT_TEMPLATE::GetIcon(), KIUI::GetInfoFont(), PROJECT_TEMPLATE::GetTitle(), TEMPLATE_WIDGET_BASE::m_bitmapIcon, m_currTemplate, and TEMPLATE_WIDGET_BASE::m_staticTitle.

Referenced by DIALOG_TEMPLATE_SELECTOR::AddTemplate().

◆ Unselect()

void TEMPLATE_WIDGET::Unselect ( )

Definition at line 83 of file dialog_template_selector.cpp.

84{
85 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
86 m_selected = false;
87 Refresh();
88}

References m_selected, and Refresh().

Referenced by DIALOG_TEMPLATE_SELECTOR::SetWidget(), and TEMPLATE_WIDGET().

Member Data Documentation

◆ m_bitmapIcon

wxStaticBitmap* TEMPLATE_WIDGET_BASE::m_bitmapIcon
protectedinherited

◆ m_currTemplate

PROJECT_TEMPLATE* TEMPLATE_WIDGET::m_currTemplate
protected

Definition at line 62 of file dialog_template_selector.h.

Referenced by GetTemplate(), SetTemplate(), and TEMPLATE_WIDGET().

◆ m_dialog

DIALOG_TEMPLATE_SELECTOR* TEMPLATE_WIDGET::m_dialog
protected

Definition at line 57 of file dialog_template_selector.h.

Referenced by Select(), and TEMPLATE_WIDGET().

◆ m_panel

wxPanel* TEMPLATE_WIDGET::m_panel
protected

Definition at line 59 of file dialog_template_selector.h.

◆ m_parent

wxWindow* TEMPLATE_WIDGET::m_parent
protected

Definition at line 58 of file dialog_template_selector.h.

Referenced by TEMPLATE_WIDGET().

◆ m_selected

bool TEMPLATE_WIDGET::m_selected
protected

Definition at line 60 of file dialog_template_selector.h.

Referenced by IsSelected(), Select(), and Unselect().

◆ m_staticTitle

wxStaticText* TEMPLATE_WIDGET_BASE::m_staticTitle
protectedinherited

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