KiCad PCB EDA Suite
Loading...
Searching...
No Matches
FOOTPRINT_CHOICE Class Reference

Customized combo box for footprint selection. More...

#include <footprint_choice.h>

Inheritance diagram for FOOTPRINT_CHOICE:

Public Member Functions

 FOOTPRINT_CHOICE (wxWindow *aParent, int aId)
 
virtual ~FOOTPRINT_CHOICE ()
 

Protected Member Functions

virtual void DoSetPopupControl (wxComboPopup *aPopup) override
 
virtual void OnDrawItem (wxDC &aDC, const wxRect &aRect, int aItem, int aFlags) const override
 
virtual wxCoord OnMeasureItem (size_t aItem) const override
 
virtual wxCoord OnMeasureItemWidth (size_t aItem) const override
 
void TryVetoMouse (wxMouseEvent &aEvent)
 Veto a mouseover event if in the separator. More...
 
void TryVetoSelect (wxCommandEvent &aEvent, bool aInner)
 Veto a select event for the separator. More...
 
wxString SafeGetString (int aItem) const
 Safely get a string for an item, returning wxEmptyString if the item doesn't exist. More...
 
int GetSelectionEither (bool aInner) const
 Get selection from either the outer (combo box) or inner (popup) list. More...
 
void SetSelectionEither (bool aInner, int aSel)
 Safely set selection for either the outer (combo box) or inner (popup) list, doing nothing for invalid selections. More...
 

Static Protected Member Functions

static wxCoord DrawTextFragment (wxDC &aDC, wxCoord x, wxCoord y, const wxString &aText)
 Draw a fragment of text, then return the next x coordinate to continue drawing. More...
 

Static Protected Attributes

static wxColour m_grey
 

Private Attributes

int m_last_selection
 

Detailed Description

Customized combo box for footprint selection.

This provides the following features:

  • library name is greyed out for readability when lib:footprint format is found in the item text
  • empty items are displayed as nonselectable separators

Multiple separators in a row is undefined behavior; it is likely to result in errors such as the ability to select separators. Separators ARE valid at the top and bottom.

For any items containing footprints, the "lib:footprint" name should be attached to the item as a wxStringClientData.

Definition at line 38 of file footprint_choice.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_CHOICE()

FOOTPRINT_CHOICE::FOOTPRINT_CHOICE ( wxWindow *  aParent,
int  aId 
)

Definition at line 28 of file footprint_choice.cpp.

◆ ~FOOTPRINT_CHOICE()

FOOTPRINT_CHOICE::~FOOTPRINT_CHOICE ( )
virtual

Definition at line 36 of file footprint_choice.cpp.

Member Function Documentation

◆ DoSetPopupControl()

void FOOTPRINT_CHOICE::DoSetPopupControl ( wxComboPopup *  aPopup)
overrideprotectedvirtual

Definition at line 41 of file footprint_choice.cpp.

References TryVetoMouse(), and TryVetoSelect().

◆ DrawTextFragment()

wxCoord FOOTPRINT_CHOICE::DrawTextFragment ( wxDC &  aDC,
wxCoord  x,
wxCoord  y,
const wxString &  aText 
)
staticprotected

Draw a fragment of text, then return the next x coordinate to continue drawing.

Definition at line 142 of file footprint_choice.cpp.

Referenced by OnDrawItem().

◆ GetSelectionEither()

int FOOTPRINT_CHOICE::GetSelectionEither ( bool  aInner) const
protected

Get selection from either the outer (combo box) or inner (popup) list.

Definition at line 188 of file footprint_choice.cpp.

Referenced by TryVetoSelect().

◆ OnDrawItem()

void FOOTPRINT_CHOICE::OnDrawItem ( wxDC &  aDC,
const wxRect &  aRect,
int  aItem,
int  aFlags 
) const
overrideprotectedvirtual

Definition at line 57 of file footprint_choice.cpp.

References DrawTextFragment(), m_grey, SafeGetString(), and text.

◆ OnMeasureItem()

wxCoord FOOTPRINT_CHOICE::OnMeasureItem ( size_t  aItem) const
overrideprotectedvirtual

Definition at line 124 of file footprint_choice.cpp.

References SafeGetString().

◆ OnMeasureItemWidth()

wxCoord FOOTPRINT_CHOICE::OnMeasureItemWidth ( size_t  aItem) const
overrideprotectedvirtual

Definition at line 133 of file footprint_choice.cpp.

References SafeGetString().

◆ SafeGetString()

wxString FOOTPRINT_CHOICE::SafeGetString ( int  aItem) const
protected

Safely get a string for an item, returning wxEmptyString if the item doesn't exist.

Definition at line 179 of file footprint_choice.cpp.

Referenced by OnDrawItem(), OnMeasureItem(), OnMeasureItemWidth(), TryVetoMouse(), and TryVetoSelect().

◆ SetSelectionEither()

void FOOTPRINT_CHOICE::SetSelectionEither ( bool  aInner,
int  aSel 
)
protected

Safely set selection for either the outer (combo box) or inner (popup) list, doing nothing for invalid selections.

Definition at line 197 of file footprint_choice.cpp.

Referenced by TryVetoSelect().

◆ TryVetoMouse()

void FOOTPRINT_CHOICE::TryVetoMouse ( wxMouseEvent &  aEvent)
protected

Veto a mouseover event if in the separator.

Definition at line 149 of file footprint_choice.cpp.

References SafeGetString().

Referenced by DoSetPopupControl().

◆ TryVetoSelect()

void FOOTPRINT_CHOICE::TryVetoSelect ( wxCommandEvent &  aEvent,
bool  aInner 
)
protected

Veto a select event for the separator.

Parameters
aEvent- the wxCommandEvent caller
aInner- true if event was called for the inner list (ie the popup)

Definition at line 158 of file footprint_choice.cpp.

References GetSelectionEither(), m_last_selection, SafeGetString(), SetSelectionEither(), and text.

Referenced by DoSetPopupControl().

Member Data Documentation

◆ m_grey

wxColour FOOTPRINT_CHOICE::m_grey
staticprotected

Definition at line 83 of file footprint_choice.h.

Referenced by OnDrawItem().

◆ m_last_selection

int FOOTPRINT_CHOICE::m_last_selection
private

Definition at line 86 of file footprint_choice.h.

Referenced by TryVetoSelect().


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