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
 
void SetValue (int aRow, int aCol, const wxString &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 132 of file lib_table_grid.h.

References makeNewRow(), and push_back().

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

133  {
134  // do not modify aNumRows, original value needed for wxGridTableMessage below
135  for( int i = aNumRows; i; --i )
136  push_back( makeNewRow() );
137 
138  if( GetView() )
139  {
140  wxGridTableMessage msg( this,
141  wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
142  aNumRows );
143 
144  GetView()->ProcessTableMessage( msg );
145  }
146 
147  return true;
148  }
virtual LIB_TABLE_ROW * makeNewRow()=0
virtual void push_back(LIB_TABLE_ROW *aRow)=0
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 150 of file lib_table_grid.h.

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

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

151  {
152  // aPos may be a large positive, e.g. size_t(-1), and the sum of
153  // aPos+aNumRows may wrap here, so both ends of the range are tested.
154  if( aPos < size() && aPos + aNumRows <= size() )
155  {
156  LIB_TABLE_ROWS_ITER start = begin() + aPos;
157  erase( start, start + aNumRows );
158 
159  if( GetView() )
160  {
161  wxGridTableMessage msg( this,
162  wxGRIDTABLE_NOTIFY_ROWS_DELETED,
163  aPos,
164  aNumRows );
165 
166  GetView()->ProcessTableMessage( msg );
167  }
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
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 175 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().

176  {
177  switch( aCol )
178  {
179  case COL_NICKNAME: return _( "Nickname" );
180  case COL_URI: return _( "Library Path" );
181 
182  // keep this "Plugin Type" text fairly long so column is sized wide enough
183  case COL_TYPE: return _( "Plugin Type" );
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  }
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() ? "1" : "";
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
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 106 of file lib_table_grid.h.

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

107  {
108  if( aPos < size() )
109  {
110  for( size_t i = 0; i < aNumRows; i++ )
111  {
112  insert( begin() + i, makeNewRow() );
113  }
114 
115  // use the (wxGridStringTable) source Luke.
116  if( GetView() )
117  {
118  wxGridTableMessage msg( this,
119  wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
120  aPos,
121  aNumRows );
122 
123  GetView()->ProcessTableMessage( msg );
124  }
125 
126  return true;
127  }
128 
129  return false;
130  }
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
bool LIB_TABLE_GRID::IsEmptyCell ( int  aRow,
int  aCol 
)
inlineoverride

Definition at line 101 of file lib_table_grid.h.

References GetValue().

102  {
103  return !GetValue( aRow, aCol );
104  }
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 80 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().

81  {
82  if( aRow < (int) size() )
83  {
84  LIB_TABLE_ROW* r = at( (size_t) aRow );
85 
86  switch( aCol )
87  {
88  case COL_NICKNAME: r->SetNickName( aValue ); break;
89  case COL_URI: r->SetFullURI( aValue ); break;
90  case COL_TYPE: r->SetType( aValue ); break;
91  case COL_OPTIONS: r->SetOptions( aValue ); break;
92  case COL_DESCR: r->SetDescr( aValue ); break;
93  case COL_ENABLED:
94  // Any non-empty string will set enabled to true
95  r->SetEnabled( !aValue.IsEmpty() );
96  break;
97  }
98  }
99  }
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.
virtual size_t LIB_TABLE_GRID::size ( ) const
protectedpure virtual

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