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

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

Definition at line 145 of file lib_table_grid.h.

References i, makeNewRow(), and push_back().

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

146  {
147  // do not modify aNumRows, original value needed for wxGridTableMessage below
148  for( int i = aNumRows; i; --i )
149  push_back( makeNewRow() );
150 
151  if( GetView() )
152  {
153  wxGridTableMessage msg( this,
154  wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
155  aNumRows );
156 
157  GetView()->ProcessTableMessage( msg );
158  }
159 
160  return true;
161  }
virtual LIB_TABLE_ROW * makeNewRow()=0
virtual void push_back(LIB_TABLE_ROW *aRow)=0
size_t i
Definition: json11.cpp:597
virtual LIB_TABLE_ROW* LIB_TABLE_GRID::at ( size_t  aIndex)
protectedpure virtual
virtual LIB_TABLE_ROWS_ITER LIB_TABLE_GRID::begin ( )
protectedpure virtual
bool LIB_TABLE_GRID::ContainsNickname ( const wxString &  aNickname)
inline

Definition at line 203 of file lib_table_grid.h.

References at(), begin(), erase(), LIB_TABLE_ROW::GetNickName(), i, insert(), makeNewRow(), push_back(), and size().

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

204  {
205  for( size_t i = 0; i < size(); ++i )
206  {
207  LIB_TABLE_ROW* row = at( i );
208 
209  if( row->GetNickName() == aNickname )
210  return true;
211  }
212  return false;
213  }
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
virtual size_t size() const =0
const wxString & GetNickName() const
size_t i
Definition: json11.cpp:597
bool LIB_TABLE_GRID::DeleteRows ( size_t  aPos,
size_t  aNumRows 
)
inlineoverride

Definition at line 163 of file lib_table_grid.h.

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

164  {
165  // aPos may be a large positive, e.g. size_t(-1), and the sum of
166  // aPos+aNumRows may wrap here, so both ends of the range are tested.
167  if( aPos < size() && aPos + aNumRows <= size() )
168  {
169  LIB_TABLE_ROWS_ITER start = begin() + aPos;
170  erase( start, start + aNumRows );
171  if( GetView() )
172  {
173  wxGridTableMessage msg( this,
174  wxGRIDTABLE_NOTIFY_ROWS_DELETED,
175  aPos,
176  aNumRows );
177 
178  GetView()->ProcessTableMessage( msg );
179  }
180  return true;
181  }
182 
183  return false;
184  }
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
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 ContainsNickname(), and DeleteRows().

wxString LIB_TABLE_GRID::GetColLabelValue ( int  aCol)
inlineoverride

Definition at line 186 of file lib_table_grid.h.

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

187  {
188  switch( aCol )
189  {
190  case COL_NICKNAME: return _( "Nickname" );
191  case COL_URI: return _( "Library Path" );
192 
193  // keep this "Plugin Type" text fairly long so column is sized wide enough
194  case COL_TYPE: return _( "Plugin Type" );
195  case COL_OPTIONS: return _( "Options" );
196  case COL_DESCR: return _( "Description" );
197  case COL_ENABLED: return _( "Active" );
198 
199  default: return wxEmptyString;
200  }
201  }
int LIB_TABLE_GRID::GetNumberCols ( )
inlineoverride

Definition at line 55 of file lib_table_grid.h.

References COL_COUNT.

55 { return COL_COUNT; }
int LIB_TABLE_GRID::GetNumberRows ( )
inlineoverride

Definition at line 53 of file lib_table_grid.h.

References size().

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

53 { return (int) size(); }
virtual size_t size() const =0
wxString LIB_TABLE_GRID::GetValue ( int  aRow,
int  aCol 
)
inlineoverride

Definition at line 57 of file lib_table_grid.h.

References at(), COL_DESCR, COL_ENABLED, COL_NICKNAME, COL_OPTIONS, COL_TYPE, COL_URI, LIB_TABLE_ROW::GetDescr(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE_ROW::GetIsEnabled(), LIB_TABLE_ROW::GetNickName(), LIB_TABLE_ROW::GetOptions(), LIB_TABLE_ROW::GetType(), and size().

Referenced by IsEmptyCell().

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 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  // Render a boolean value as its text equivalent
71  case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" );
72  default:
73  ; // fall thru to wxEmptyString
74  }
75  }
76 
77  return wxEmptyString;
78  }
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 & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
virtual const wxString GetType() const =0
Return the type of library represented by this row.
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const wxString & GetDescr() const
Return the description of the library referenced by this row.
virtual size_t size() const =0
const wxString & GetNickName() const
bool GetIsEnabled() const
bool LIB_TABLE_GRID::GetValueAsBool ( int  aRow,
int  aCol 
)
inlineoverride

Definition at line 80 of file lib_table_grid.h.

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

81  {
82  if( aRow < (int) size() && aCol == COL_ENABLED )
83  return at( (size_t) aRow )->GetIsEnabled();
84  else
85  return false;
86  }
virtual LIB_TABLE_ROW * at(size_t aIndex)=0
virtual size_t size() const =0
bool GetIsEnabled() const
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 ContainsNickname(), and InsertRows().

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

Definition at line 119 of file lib_table_grid.h.

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

120  {
121  if( aPos < size() )
122  {
123  for( size_t i = 0; i < aNumRows; i++ )
124  {
125  insert( begin() + i, makeNewRow() );
126  }
127 
128  // use the (wxGridStringTable) source Luke.
129  if( GetView() )
130  {
131  wxGridTableMessage msg( this,
132  wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
133  aPos,
134  aNumRows );
135 
136  GetView()->ProcessTableMessage( msg );
137  }
138 
139  return true;
140  }
141 
142  return false;
143  }
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
size_t i
Definition: json11.cpp:597
bool LIB_TABLE_GRID::IsEmptyCell ( int  aRow,
int  aCol 
)
inlineoverride

Definition at line 114 of file lib_table_grid.h.

References GetValue().

115  {
116  return !GetValue( aRow, aCol );
117  }
wxString GetValue(int aRow, int aCol) override
virtual LIB_TABLE_ROW* LIB_TABLE_GRID::makeNewRow ( )
protectedpure virtual
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(), and ContainsNickname().

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

Definition at line 88 of file lib_table_grid.h.

References at(), COL_DESCR, COL_ENABLED, COL_NICKNAME, COL_OPTIONS, COL_TYPE, COL_URI, LIB_TABLE_ROW::SetDescr(), LIB_TABLE_ROW::SetEnabled(), LIB_TABLE_ROW::SetFullURI(), LIB_TABLE_ROW::SetNickName(), LIB_TABLE_ROW::SetOptions(), LIB_TABLE_ROW::SetType(), and size().

89  {
90  if( aRow < (int) size() )
91  {
92  LIB_TABLE_ROW* r = at( (size_t) aRow );
93 
94  switch( aCol )
95  {
96  case COL_NICKNAME: r->SetNickName( aValue ); break;
97  case COL_URI: r->SetFullURI( aValue ); break;
98  case COL_TYPE: r->SetType( aValue ); break;
99  case COL_OPTIONS: r->SetOptions( aValue ); break;
100  case COL_DESCR: r->SetDescr( aValue ); break;
101  case COL_ENABLED:
102  r->SetEnabled( aValue == wxT( "1" ) );
103  break;
104  }
105  }
106  }
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE...
virtual void SetType(const wxString &aType)=0
Change the type of library represented by this row that must be implemented in the derived object to ...
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
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
void SetNickName(const wxString &aNickName)
Change the logical name of this library, useful for an editor.
void SetOptions(const wxString &aOptions)
Change the library options strings.
void SetDescr(const wxString &aDescr)
Change the description of the library referenced by this row.
void LIB_TABLE_GRID::SetValueAsBool ( int  aRow,
int  aCol,
bool  aValue 
)
inlineoverride

Definition at line 108 of file lib_table_grid.h.

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

109  {
110  if( aRow < (int) size() && aCol == COL_ENABLED )
111  at( (size_t) aRow )->SetEnabled( aValue );
112  }
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
virtual size_t LIB_TABLE_GRID::size ( ) const
protectedpure virtual

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