KiCad PCB EDA Suite
CURSOR_STORE Class Reference

Simple class to construct and store cursors against unique ID keys. More...

#include <cursor_store.h>

Classes

struct  CURSOR_DEF
 Definition of a cursor. More...
 

Public Member Functions

 CURSOR_STORE (const std::vector< CURSOR_DEF > &aDefs)
 Construct a store with a pre-set list of cursors. More...
 
const wxCursor & Get (int aIdKey) const
 Get a given cursor by its ID. More...
 

Private Attributes

std::map< int, wxCursor > m_store
 

Internal store of cursors by ID

More...
 

Detailed Description

Simple class to construct and store cursors against unique ID keys.

This can be used to lazily construct cursors as needed for specific applications.

Definition at line 39 of file cursor_store.h.

Constructor & Destructor Documentation

◆ CURSOR_STORE()

CURSOR_STORE::CURSOR_STORE ( const std::vector< CURSOR_DEF > &  aDefs)

Construct a store with a pre-set list of cursors.

In future, an "Add()" function could be added if stores need to dynamically add cursors.

Parameters
aDefsthe list of pre-set cursor definitions

Definition at line 79 of file cursor_store.cpp.

80 {
81  for( const auto& def : aDefs )
82  {
83  m_store[def.m_id_key] = constructCursor( def );
84  }
85 }
wxCursor constructCursor(const CURSOR_STORE::CURSOR_DEF &aDef)
Construct a cursor for the given definition.
std::map< int, wxCursor > m_store
Internal store of cursors by ID
Definition: cursor_store.h:82

References constructCursor(), and m_store.

Member Function Documentation

◆ Get()

const wxCursor & CURSOR_STORE::Get ( int  aIdKey) const

Get a given cursor by its ID.

Parameters
aIdKeythe ID key to look up
Returns
the cursor, if found, else wxNullCursor

Definition at line 88 of file cursor_store.cpp.

89 {
90  const auto find_iter = m_store.find( aIdKey );
91 
92  if( find_iter != m_store.end() )
93  {
94  return find_iter->second;
95  }
96 
97  wxASSERT_MSG( false,
98  wxString::Format( "Could not find cursor with ID %d", static_cast<int>( aIdKey ) ) );
99  return wxNullCursor;
100 }
std::map< int, wxCursor > m_store
Internal store of cursors by ID
Definition: cursor_store.h:82
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205

References Format(), and m_store.

Referenced by SIM_CURSORS::GetCursor().

Member Data Documentation

◆ m_store

std::map<int, wxCursor> CURSOR_STORE::m_store
private

Internal store of cursors by ID

Definition at line 82 of file cursor_store.h.

Referenced by CURSOR_STORE(), and Get().


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