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 42 of file lib_table_grid.h.

Member Function Documentation

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

Definition at line 121 of file lib_table_grid.h.

References makeNewRow(), and push_back().

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

122  {
123  // do not modify aNumRows, original value needed for wxGridTableMessage below
124  for( int i = aNumRows; i; --i )
125  push_back( makeNewRow() );
126 
127  if( GetView() )
128  {
129  wxGridTableMessage msg( this,
130  wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
131  aNumRows );
132 
133  GetView()->ProcessTableMessage( msg );
134  }
135 
136  return true;
137  }
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

Implemented in FP_LIB_TABLE_GRID, and SYMBOL_LIB_TABLE_GRID.

Referenced by GetValue(), and SetValue().

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

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

Definition at line 139 of file lib_table_grid.h.

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

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

140  {
141  // aPos may be a large positive, e.g. size_t(-1), and the sum of
142  // aPos+aNumRows may wrap here, so both ends of the range are tested.
143  if( aPos < size() && aPos + aNumRows <= size() )
144  {
145  LIB_TABLE_ROWS_ITER start = begin() + aPos;
146  erase( start, start + aNumRows );
147 
148  if( GetView() )
149  {
150  wxGridTableMessage msg( this,
151  wxGRIDTABLE_NOTIFY_ROWS_DELETED,
152  aPos,
153  aNumRows );
154 
155  GetView()->ProcessTableMessage( msg );
156  }
157 
158  return true;
159  }
160 
161  return false;
162  }
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().

wxString LIB_TABLE_GRID::GetColLabelValue ( int  aCol)
inlineoverride

Definition at line 164 of file lib_table_grid.h.

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

165  {
166  switch( aCol )
167  {
168  case COL_NICKNAME: return _( "Nickname" );
169  case COL_URI: return _( "Library Path" );
170 
171  // keep this "Plugin Type" text fairly long so column is sized wide enough
172  case COL_TYPE: return _( "Plugin Type" );
173  case COL_OPTIONS: return _( "Options" );
174  case COL_DESCR: return _( "Description" );
175  default: return wxEmptyString;
176  }
177  }
int LIB_TABLE_GRID::GetNumberCols ( )
inlineoverride

Definition at line 50 of file lib_table_grid.h.

References COL_COUNT.

50 { return COL_COUNT; }
wxString LIB_TABLE_GRID::GetValue ( int  aRow,
int  aCol 
)
inlineoverride

Definition at line 52 of file lib_table_grid.h.

References at(), COL_DESCR, COL_NICKNAME, COL_OPTIONS, COL_TYPE, COL_URI, LIB_TABLE_ROW::GetDescr(), LIB_TABLE_ROW::GetFullURI(), 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().

53  {
54  if( aRow < (int) size() )
55  {
56  const LIB_TABLE_ROW* r = at( (size_t) aRow );
57 
58  switch( aCol )
59  {
60  case COL_NICKNAME: return r->GetNickName();
61  case COL_URI: return r->GetFullURI();
62  case COL_TYPE: return r->GetType();
63  case COL_OPTIONS: return r->GetOptions();
64  case COL_DESCR: return r->GetDescr();
65  default:
66  ; // fall thru to wxEmptyString
67  }
68  }
69 
70  return wxEmptyString;
71  }
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
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().

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

Definition at line 95 of file lib_table_grid.h.

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

96  {
97  if( aPos < size() )
98  {
99  for( size_t i = 0; i < aNumRows; i++ )
100  {
101  insert( begin() + i, makeNewRow() );
102  }
103 
104  // use the (wxGridStringTable) source Luke.
105  if( GetView() )
106  {
107  wxGridTableMessage msg( this,
108  wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
109  aPos,
110  aNumRows );
111 
112  GetView()->ProcessTableMessage( msg );
113  }
114 
115  return true;
116  }
117 
118  return false;
119  }
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 90 of file lib_table_grid.h.

References GetValue().

91  {
92  return !GetValue( aRow, aCol );
93  }
wxString GetValue(int aRow, int aCol) override
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().

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

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

Definition at line 73 of file lib_table_grid.h.

References at(), COL_DESCR, COL_NICKNAME, COL_OPTIONS, COL_TYPE, COL_URI, LIB_TABLE_ROW::SetDescr(), 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().

74  {
75  if( aRow < (int) size() )
76  {
77  LIB_TABLE_ROW* r = at( (size_t) aRow );
78 
79  switch( aCol )
80  {
81  case COL_NICKNAME: r->SetNickName( aValue ); break;
82  case COL_URI: r->SetFullURI( aValue ); break;
83  case COL_TYPE: r->SetType( aValue ); break;
84  case COL_OPTIONS: r->SetOptions( aValue ); break;
85  case COL_DESCR: r->SetDescr( aValue ); break;
86  }
87  }
88  }
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
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: