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 ( wxWindow *  aParent,
DIALOG_TEMPLATE_SELECTOR aDialog 
)

Definition at line 40 of file dialog_template_selector.cpp.

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

40  :
41  TEMPLATE_WIDGET_BASE( aParent )
42 {
43  m_parent = aParent;
44  m_dialog = aDialog;
45 
46  // wxWidgets_3.xx way of doing the same...
47  // Bind(wxEVT_LEFT_DOWN, &TEMPLATE_WIDGET::OnMouse, this );
48 
49  m_bitmapIcon->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( TEMPLATE_WIDGET::OnMouse ), NULL, this );
50  m_staticTitle->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( TEMPLATE_WIDGET::OnMouse ), NULL, this );
51 
52  // We're not selected until we're clicked
53  Unselect();
54 
55  // Start with template being NULL
56  m_currTemplate = NULL;
57 }
TEMPLATE_WIDGET_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(74,-1), long style=wxTAB_TRAVERSAL)
DIALOG_TEMPLATE_SELECTOR * m_dialog
PROJECT_TEMPLATE * m_currTemplate
void OnMouse(wxMouseEvent &event)

Member Function Documentation

PROJECT_TEMPLATE* TEMPLATE_WIDGET::GetTemplate ( )
inline
bool TEMPLATE_WIDGET::IsSelected ( )
inlineprivate

Definition at line 61 of file dialog_template_selector.h.

References m_selected.

61 { return m_selected; }
void TEMPLATE_WIDGET::OnKillFocus ( wxFocusEvent &  event)
protected
void TEMPLATE_WIDGET::OnMouse ( wxMouseEvent &  event)
protected

Definition at line 85 of file dialog_template_selector.cpp.

References Select().

Referenced by TEMPLATE_WIDGET().

86 {
87  // Toggle selection here
88  Select();
89  event.Skip();
90 }
void TEMPLATE_WIDGET::Select ( )

Definition at line 60 of file dialog_template_selector.cpp.

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

Referenced by OnMouse().

61 {
62  m_dialog->SetWidget( this );
63  SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ) );
64  m_selected = true;
65  Refresh();
66 }
void Refresh()
DIALOG_TEMPLATE_SELECTOR * m_dialog
void SetWidget(TEMPLATE_WIDGET *aWidget)
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 77 of file dialog_template_selector.cpp.

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

Referenced by DIALOG_TEMPLATE_SELECTOR::AddTemplate().

78 {
79  m_currTemplate = aTemplate;
80  m_staticTitle->SetLabel( *(aTemplate->GetTitle()) );
81  m_bitmapIcon->SetBitmap( *(aTemplate->GetIcon()) );
82 }
wxString * GetTitle()
Get the title of the project (extracted from the html title tag)
PROJECT_TEMPLATE * m_currTemplate
wxBitmap * GetIcon()
Get the 64px^2 icon for the project template.
void TEMPLATE_WIDGET::Unselect ( )

Definition at line 69 of file dialog_template_selector.cpp.

References m_selected, and Refresh().

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

70 {
71  SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
72  m_selected = false;
73  Refresh();
74 }
void Refresh()

Member Data Documentation

wxStaticBitmap* TEMPLATE_WIDGET_BASE::m_bitmapIcon
protectedinherited
PROJECT_TEMPLATE* TEMPLATE_WIDGET::m_currTemplate
protected

Definition at line 41 of file dialog_template_selector.h.

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

DIALOG_TEMPLATE_SELECTOR* TEMPLATE_WIDGET::m_dialog
protected

Definition at line 36 of file dialog_template_selector.h.

Referenced by Select(), and TEMPLATE_WIDGET().

wxPanel* TEMPLATE_WIDGET::m_panel
protected

Definition at line 38 of file dialog_template_selector.h.

wxWindow* TEMPLATE_WIDGET::m_parent
protected

Definition at line 37 of file dialog_template_selector.h.

Referenced by TEMPLATE_WIDGET().

bool TEMPLATE_WIDGET::m_selected
protected

Definition at line 39 of file dialog_template_selector.h.

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

wxStaticText* TEMPLATE_WIDGET_BASE::m_staticTitle
protectedinherited

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