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
 

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::DeleteRows ( size_t  aPos,
size_t  aNumRows 
)
inlineoverride

Definition at line 163 of file lib_table_grid.h.

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

Referenced by DIALOG_SYMBOL_LIB_TABLE::verifyTables(), and DIALOG_FP_LIB_TABLE::verifyTables().

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 
172  if( GetView() )
173  {
174  wxGridTableMessage msg( this,
175  wxGRIDTABLE_NOTIFY_ROWS_DELETED,
176  aPos,
177  aNumRows );
178 
179  GetView()->ProcessTableMessage( msg );
180  }
181 
182  return true;
183  }
184 
185  return false;
186  }
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 DeleteRows(), and GetColLabelValue().

wxString LIB_TABLE_GRID::GetColLabelValue ( int  aCol)
inlineoverride

Definition at line 188 of file lib_table_grid.h.

References at(), begin(), COL_DESCR, COL_ENABLED, COL_NICKNAME, COL_OPTIONS, COL_TYPE, COL_URI, erase(), insert(), makeNewRow(), push_back(), and size().

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

Definition at line 55 of file lib_table_grid.h.

References COL_COUNT.

55 { return COL_COUNT; }
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(), DIALOG_SYMBOL_LIB_TABLE::populateEnvironReadOnlyTable(), DIALOG_FP_LIB_TABLE::populateEnvironReadOnlyTable(), DIALOG_SYMBOL_LIB_TABLE::verifyTables(), and DIALOG_FP_LIB_TABLE::verifyTables().

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 GetColLabelValue(), 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 GetColLabelValue().

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().

Referenced by DIALOG_FP_LIB_TABLE::OnClickLibraryWizard(), DIALOG_SYMBOL_LIB_TABLE::verifyTables(), and DIALOG_FP_LIB_TABLE::verifyTables().

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: