KiCad PCB EDA Suite
INDICATOR_ICON Class Reference

Class representing a row indicator icon for use in places like the layer widget. More...

#include <indicator_icon.h>

Inheritance diagram for INDICATOR_ICON:

Classes

class  ICON_PROVIDER
 A simple object that can provide fixed bitmaps for use as row indicators. More...
 

Public Types

using ICON_ID = int
 An id that refers to a certain icon state. More...
 

Public Member Functions

 INDICATOR_ICON (wxWindow *aParent, ICON_PROVIDER &aIconProvider, ICON_ID aInitialIcon, int aID)
 
void SetIndicatorState (ICON_ID aIconId)
 Sets the row indiciator to the given state. More...
 
ICON_ID GetIndicatorState () const
 

Static Public Member Functions

static ICON_PROVIDERGetDefaultRowIconProvider (bool aAlternative)
 Accessor for the default icon providers, which take true and false for IDs, meaining on/off. More...
 

Private Attributes

ICON_PROVIDERm_iconProvider
 

An class that delivers icons for the indictor (currently just uses a default implementation).

More...
 
wxStaticBitmap * m_bitmap
 

Handle on the bitmap widget

More...
 
ICON_ID m_currentId
 

Is the icon currently "on"

More...
 

Detailed Description

Class representing a row indicator icon for use in places like the layer widget.

Definition at line 33 of file indicator_icon.h.

Member Typedef Documentation

An id that refers to a certain icon state.

Exactly what that state might mean in terms of icons is up to the icon provider.

Definition at line 43 of file indicator_icon.h.

Constructor & Destructor Documentation

INDICATOR_ICON::INDICATOR_ICON ( wxWindow *  aParent,
ICON_PROVIDER aIconProvider,
ICON_ID  aInitialIcon,
int  aID 
)
Parameters
aParentthe owning window
aIconProviderthe icon provider to get icons from
aInitialIconis the initial state of the icon (the meaning depends on what is the purpose of the icon)
aIDthe ID to use for the widgets - events will have this ID.

Definition at line 27 of file indicator_icon.cpp.

References INDICATOR_ICON::ICON_PROVIDER::GetIndicatorIcon(), m_bitmap, m_currentId, and m_iconProvider.

29  :
30  wxPanel( aParent, aID ),
31  m_iconProvider( aIconProvider ),
32  m_currentId( aInitialIcon )
33 {
34  auto sizer = new wxBoxSizer( wxHORIZONTAL );
35  SetSizer( sizer );
36 
37  const wxBitmap& initBitmap = m_iconProvider.GetIndicatorIcon( m_currentId );
38 
39  m_bitmap = new wxStaticBitmap( this, aID,
40  initBitmap, wxDefaultPosition,
41  initBitmap.GetSize() );
42 
43  sizer->Add( m_bitmap, 0, 0 );
44 
45  auto evtSkipper = [this] ( wxEvent& aEvent ) {
46  wxPostEvent( this, aEvent );
47  };
48 
49  m_bitmap->Bind( wxEVT_LEFT_DOWN, evtSkipper );
50 }
virtual const wxBitmap & GetIndicatorIcon(ICON_ID aIconId) const =0
Gets a reference to the row icon in the given mode.
wxStaticBitmap * m_bitmap
Handle on the bitmap widget
ICON_PROVIDER & m_iconProvider
An class that delivers icons for the indictor (currently just uses a default implementation).
ICON_ID m_currentId
Is the icon currently "on"

Member Function Documentation

static ICON_PROVIDER& INDICATOR_ICON::GetDefaultRowIconProvider ( bool  aAlternative)
static

Accessor for the default icon providers, which take true and false for IDs, meaining on/off.

Parameters
aAlternativefalse for blue arrow/blank, true for the green diamond
INDICATOR_ICON::ICON_ID INDICATOR_ICON::GetIndicatorState ( ) const
Returns
the current state of the indicator

Definition at line 64 of file indicator_icon.cpp.

References m_currentId.

65 {
66  return m_currentId;
67 }
ICON_ID m_currentId
Is the icon currently "on"
void INDICATOR_ICON::SetIndicatorState ( ICON_ID  aIconId)

Sets the row indiciator to the given state.

Parameters
aIconIdthe icon ID to pass to the provider.

Definition at line 53 of file indicator_icon.cpp.

References INDICATOR_ICON::ICON_PROVIDER::GetIndicatorIcon(), m_bitmap, m_currentId, and m_iconProvider.

Referenced by LAYER_WIDGET::SelectLayerRow(), and LAYER_WIDGET::UpdateLayerIcons().

54 {
55  if( aIconId == m_currentId )
56  return;
57 
58  m_currentId = aIconId;
59 
61 }
virtual const wxBitmap & GetIndicatorIcon(ICON_ID aIconId) const =0
Gets a reference to the row icon in the given mode.
wxStaticBitmap * m_bitmap
Handle on the bitmap widget
ICON_PROVIDER & m_iconProvider
An class that delivers icons for the indictor (currently just uses a default implementation).
ICON_ID m_currentId
Is the icon currently "on"

Member Data Documentation

wxStaticBitmap* INDICATOR_ICON::m_bitmap
private

Handle on the bitmap widget

Definition at line 105 of file indicator_icon.h.

Referenced by INDICATOR_ICON(), and SetIndicatorState().

ICON_ID INDICATOR_ICON::m_currentId
private

Is the icon currently "on"

Definition at line 108 of file indicator_icon.h.

Referenced by GetIndicatorState(), INDICATOR_ICON(), and SetIndicatorState().

ICON_PROVIDER& INDICATOR_ICON::m_iconProvider
private

An class that delivers icons for the indictor (currently just uses a default implementation).

Definition at line 102 of file indicator_icon.h.

Referenced by INDICATOR_ICON(), and SetIndicatorState().


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