KiCad PCB EDA Suite
LIB_TABLE_GRID Class Referenceabstract

This abstract base class mixes any object derived from LIB_TABLE into wxGridTableBase so the result can be used as any type of library table within wxGrid. More...

#include <lib_table_grid.h>

Inheritance diagram for LIB_TABLE_GRID:
FP_LIB_TABLE_GRID SYMBOL_LIB_TABLE_GRID

Public Member Functions

int GetNumberRows () override
 
int GetNumberCols () override
 
wxString GetValue (int aRow, int aCol) override
 
bool GetValueAsBool (int aRow, int aCol) override
 
void SetValue (int aRow, int aCol, const wxString &aValue) override
 
void SetValueAsBool (int aRow, int aCol, bool aValue) override
 
bool IsEmptyCell (int aRow, int aCol) override
 
bool InsertRows (size_t aPos=0, size_t aNumRows=1) override
 
bool AppendRows (size_t aNumRows=1) override
 
bool DeleteRows (size_t aPos, size_t aNumRows) override
 
wxString GetColLabelValue (int aCol) override
 
bool ContainsNickname (const wxString &aNickname)
 

Protected Member Functions

virtual LIB_TABLE_ROWat (size_t aIndex)=0
 
virtual size_t size () const =0
 
virtual LIB_TABLE_ROWmakeNewRow ()=0
 
virtual LIB_TABLE_ROWS_ITER begin ()=0
 
virtual LIB_TABLE_ROWS_ITER insert (LIB_TABLE_ROWS_ITER aIterator, LIB_TABLE_ROW *aRow)=0
 
virtual void push_back (LIB_TABLE_ROW *aRow)=0
 
virtual LIB_TABLE_ROWS_ITER erase (LIB_TABLE_ROWS_ITER aFirst, LIB_TABLE_ROWS_ITER aLast)=0
 

Detailed Description

This abstract base class mixes any object derived from LIB_TABLE into wxGridTableBase so the result can be used as any type of library table within wxGrid.

Definition at line 47 of file lib_table_grid.h.

Member Function Documentation

◆ AppendRows()

bool LIB_TABLE_GRID::AppendRows ( size_t  aNumRows = 1)
inlineoverride

Definition at line 141 of file lib_table_grid.h.

142  {
143  // do not modify aNumRows, original value needed for wxGridTableMessage below
144  for( int i = aNumRows; i; --i )
145  push_back( makeNewRow() );
146 
147  if( GetView() )
148  {
149  wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, aNumRows );
150  GetView()->ProcessTableMessage( msg );
151  }
152 
153  return true;
154  }
virtual LIB_TABLE_ROW * makeNewRow()=0
virtual void push_back(LIB_TABLE_ROW *aRow)=0

References makeNewRow(), and push_back().

Referenced by SYMBOL_GRID_TRICKS::paste_text(), and FP_GRID_TRICKS::paste_text().

◆ at()

virtual LIB_TABLE_ROW* LIB_TABLE_GRID::at ( size_t  aIndex)
protectedpure virtual

◆ begin()

virtual LIB_TABLE_ROWS_ITER LIB_TABLE_GRID::begin ( )
protectedpure virtual

Implemented in FP_LIB_TABLE_GRID, and SYMBOL_LIB_TABLE_GRID.

Referenced by DeleteRows(), and InsertRows().

◆ ContainsNickname()

bool LIB_TABLE_GRID::ContainsNickname ( const wxString &  aNickname)
inline

Definition at line 192 of file lib_table_grid.h.

193  {
194  for( size_t i = 0; i < size(); ++i )
195  {
196  LIB_TABLE_ROW* row = at( i );
197 
198  if( row->GetNickName() == aNickname )
199  return true;
200  }
201  return false;
202  }
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
virtual LIB_TABLE_ROW * at(size_t aIndex)=0
const wxString & GetNickName() const
virtual size_t size() const =0

References at(), LIB_TABLE_ROW::GetNickName(), and size().

Referenced by PANEL_SYM_LIB_TABLE::browseLibrariesHandler(), and PANEL_FP_LIB_TABLE::browseLibrariesHandler().

◆ DeleteRows()

bool LIB_TABLE_GRID::DeleteRows ( size_t  aPos,
size_t  aNumRows 
)
inlineoverride

Definition at line 156 of file lib_table_grid.h.

157  {
158  // aPos may be a large positive, e.g. size_t(-1), and the sum of
159  // aPos+aNumRows may wrap here, so both ends of the range are tested.
160  if( aPos < size() && aPos + aNumRows <= size() )
161  {
162  LIB_TABLE_ROWS_ITER start = begin() + aPos;
163  erase( start, start + aNumRows );
164  if( GetView() )
165  {
166  wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aPos, aNumRows );
167  GetView()->ProcessTableMessage( msg );
168  }
169  return true;
170  }
171 
172  return false;
173  }
virtual LIB_TABLE_ROWS_ITER begin()=0
virtual size_t size() const =0
LIB_TABLE_ROWS::iterator LIB_TABLE_ROWS_ITER
virtual LIB_TABLE_ROWS_ITER erase(LIB_TABLE_ROWS_ITER aFirst, LIB_TABLE_ROWS_ITER aLast)=0

References begin(), erase(), and size().

◆ erase()

virtual LIB_TABLE_ROWS_ITER LIB_TABLE_GRID::erase ( LIB_TABLE_ROWS_ITER  aFirst,
LIB_TABLE_ROWS_ITER  aLast 
)
protectedpure virtual

Implemented in FP_LIB_TABLE_GRID, and SYMBOL_LIB_TABLE_GRID.

Referenced by DeleteRows().

◆ GetColLabelValue()

wxString LIB_TABLE_GRID::GetColLabelValue ( int  aCol)
inlineoverride

Definition at line 175 of file lib_table_grid.h.

176  {
177  switch( aCol )
178  {
179  case COL_NICKNAME: return _( "Nickname" );
180  case COL_URI: return _( "Library Path" );
181 
182  // keep this "Library Format" text fairly long so column is sized wide enough
183  case COL_TYPE: return _( "Library Format" );
184  case COL_OPTIONS: return _( "Options" );
185  case COL_DESCR: return _( "Description" );
186  case COL_ENABLED: return _( "Active" );
187 
188  default: return wxEmptyString;
189  }
190  }
#define _(s)

References _, COL_DESCR, COL_ENABLED, COL_NICKNAME, COL_OPTIONS, COL_TYPE, and COL_URI.

◆ GetNumberCols()

int LIB_TABLE_GRID::GetNumberCols ( )
inlineoverride

Definition at line 55 of file lib_table_grid.h.

55 { return COL_COUNT; }

References COL_COUNT.

◆ GetNumberRows()

int LIB_TABLE_GRID::GetNumberRows ( )
inlineoverride

Definition at line 53 of file lib_table_grid.h.

53 { return (int) size(); }
virtual size_t size() const =0

References size().

Referenced by FP_GRID_TRICKS::optionsEditor(), SYMBOL_GRID_TRICKS::paste_text(), and FP_GRID_TRICKS::paste_text().

◆ GetValue()

wxString LIB_TABLE_GRID::GetValue ( int  aRow,
int  aCol 
)
inlineoverride

Definition at line 57 of file lib_table_grid.h.

58  {
59  if( aRow < (int) size() )
60  {
61  const LIB_TABLE_ROW* r = at( (size_t) aRow );
62 
63  switch( aCol )
64  {
65  case COL_NICKNAME: return UnescapeString( r->GetNickName() );
66  case COL_URI: return r->GetFullURI();
67  case COL_TYPE: return r->GetType();
68  case COL_OPTIONS: return r->GetOptions();
69  case COL_DESCR: return r->GetDescr();
70  case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" );
71  default: return wxEmptyString;
72  }
73  }
74 
75  return wxEmptyString;
76  }
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
virtual LIB_TABLE_ROW * at(size_t aIndex)=0
E_SERIE r
Definition: eserie.cpp:41
wxString UnescapeString(const wxString &aSource)
virtual size_t size() const =0

References at(), COL_DESCR, COL_ENABLED, COL_NICKNAME, COL_OPTIONS, COL_TYPE, COL_URI, r, size(), and UnescapeString().

Referenced by IsEmptyCell().

◆ GetValueAsBool()

bool LIB_TABLE_GRID::GetValueAsBool ( int  aRow,
int  aCol 
)
inlineoverride

Definition at line 78 of file lib_table_grid.h.

79  {
80  if( aRow < (int) size() && aCol == COL_ENABLED )
81  return at( (size_t) aRow )->GetIsEnabled();
82  else
83  return false;
84  }
virtual LIB_TABLE_ROW * at(size_t aIndex)=0
bool GetIsEnabled() const
virtual size_t size() const =0

References at(), COL_ENABLED, LIB_TABLE_ROW::GetIsEnabled(), and size().

◆ insert()

virtual LIB_TABLE_ROWS_ITER LIB_TABLE_GRID::insert ( LIB_TABLE_ROWS_ITER  aIterator,
LIB_TABLE_ROW aRow 
)
protectedpure virtual

Implemented in FP_LIB_TABLE_GRID, and SYMBOL_LIB_TABLE_GRID.

Referenced by InsertRows().

◆ InsertRows()

bool LIB_TABLE_GRID::InsertRows ( size_t  aPos = 0,
size_t  aNumRows = 1 
)
inlineoverride

Definition at line 115 of file lib_table_grid.h.

116  {
117  if( aPos < size() )
118  {
119  for( size_t i = 0; i < aNumRows; i++ )
120  {
121  insert( begin() + i, makeNewRow() );
122  }
123 
124  // use the (wxGridStringTable) source Luke.
125  if( GetView() )
126  {
127  wxGridTableMessage msg( this,
128  wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
129  aPos,
130  aNumRows );
131 
132  GetView()->ProcessTableMessage( msg );
133  }
134 
135  return true;
136  }
137 
138  return false;
139  }
virtual LIB_TABLE_ROWS_ITER insert(LIB_TABLE_ROWS_ITER aIterator, LIB_TABLE_ROW *aRow)=0
virtual LIB_TABLE_ROW * makeNewRow()=0
virtual LIB_TABLE_ROWS_ITER begin()=0
virtual size_t size() const =0

References begin(), insert(), makeNewRow(), and size().

◆ IsEmptyCell()

bool LIB_TABLE_GRID::IsEmptyCell ( int  aRow,
int  aCol 
)
inlineoverride

Definition at line 110 of file lib_table_grid.h.

111  {
112  return !GetValue( aRow, aCol );
113  }
wxString GetValue(int aRow, int aCol) override

References GetValue().

◆ makeNewRow()

virtual LIB_TABLE_ROW* LIB_TABLE_GRID::makeNewRow ( )
protectedpure virtual

Implemented in FP_LIB_TABLE_GRID, and SYMBOL_LIB_TABLE_GRID.

Referenced by AppendRows(), and InsertRows().

◆ push_back()

virtual void LIB_TABLE_GRID::push_back ( LIB_TABLE_ROW aRow)
protectedpure virtual

Implemented in FP_LIB_TABLE_GRID, and SYMBOL_LIB_TABLE_GRID.

Referenced by AppendRows().

◆ SetValue()

void LIB_TABLE_GRID::SetValue ( int  aRow,
int  aCol,
const wxString &  aValue 
)
inlineoverride

Definition at line 86 of file lib_table_grid.h.

87  {
88  if( aRow < (int) size() )
89  {
90  LIB_TABLE_ROW* r = at( (size_t) aRow );
91 
92  switch( aCol )
93  {
94  case COL_NICKNAME: r->SetNickName( EscapeString( aValue, CTX_LIBID ) ); break;
95  case COL_URI: r->SetFullURI( aValue ); break;
96  case COL_TYPE: r->SetType( aValue ); break;
97  case COL_OPTIONS: r->SetOptions( aValue ); break;
98  case COL_DESCR: r->SetDescr( aValue ); break;
99  case COL_ENABLED: r->SetEnabled( aValue == wxT( "1" ) ); break;
100  }
101  }
102  }
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
virtual LIB_TABLE_ROW * at(size_t aIndex)=0
E_SERIE r
Definition: eserie.cpp:41
virtual size_t size() const =0
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...

References at(), COL_DESCR, COL_ENABLED, COL_NICKNAME, COL_OPTIONS, COL_TYPE, COL_URI, CTX_LIBID, EscapeString(), r, and size().

Referenced by SYMBOL_LIB_TABLE_GRID::SetValue().

◆ SetValueAsBool()

void LIB_TABLE_GRID::SetValueAsBool ( int  aRow,
int  aCol,
bool  aValue 
)
inlineoverride

Definition at line 104 of file lib_table_grid.h.

105  {
106  if( aRow < (int) size() && aCol == COL_ENABLED )
107  at( (size_t) aRow )->SetEnabled( aValue );
108  }
virtual LIB_TABLE_ROW * at(size_t aIndex)=0
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.
virtual size_t size() const =0

References at(), COL_ENABLED, LIB_TABLE_ROW::SetEnabled(), and size().

◆ size()

virtual size_t LIB_TABLE_GRID::size ( ) const
protectedpure virtual

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