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

Member Function Documentation

◆ AppendRows()

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

Definition at line 148 of file lib_table_grid.h.

149 {
150 // do not modify aNumRows, original value needed for wxGridTableMessage below
151 for( int i = aNumRows; i; --i )
153
154 if( GetView() )
155 {
156 wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, aNumRows );
157 GetView()->ProcessTableMessage( msg );
158 }
159
160 return true;
161 }
virtual void push_back(LIB_TABLE_ROW *aRow)=0
virtual LIB_TABLE_ROW * makeNewRow()=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 SYMBOL_LIB_TABLE_GRID, and FP_LIB_TABLE_GRID.

Referenced by DeleteRows(), and InsertRows().

◆ ContainsNickname()

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

Definition at line 200 of file lib_table_grid.h.

201 {
202 for( size_t i = 0; i < size(); ++i )
203 {
204 LIB_TABLE_ROW* row = at( i );
205
206 if( row->GetNickName() == aNickname )
207 return true;
208 }
209 return false;
210 }
virtual LIB_TABLE_ROW * at(size_t aIndex)=0
virtual size_t size() const =0
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
const wxString & GetNickName() const

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

◆ DeleteRows()

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

Definition at line 163 of file lib_table_grid.h.

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, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aPos, aNumRows );
174 GetView()->ProcessTableMessage( msg );
175 }
176 return true;
177 }
178
179 return false;
180 }
virtual LIB_TABLE_ROWS_ITER erase(LIB_TABLE_ROWS_ITER aFirst, LIB_TABLE_ROWS_ITER aLast)=0
virtual LIB_TABLE_ROWS_ITER begin()=0
LIB_TABLE_ROWS::iterator LIB_TABLE_ROWS_ITER

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 SYMBOL_LIB_TABLE_GRID, and FP_LIB_TABLE_GRID.

Referenced by DeleteRows().

◆ GetColLabelValue()

wxString LIB_TABLE_GRID::GetColLabelValue ( int  aCol)
inlineoverride

Definition at line 182 of file lib_table_grid.h.

183 {
184 switch( aCol )
185 {
186 case COL_NICKNAME: return _( "Nickname" );
187 case COL_URI: return _( "Library Path" );
188
189 // keep this "Library Format" text fairly long so column is sized wide enough
190 case COL_TYPE: return _( "Library Format" );
191 case COL_OPTIONS: return _( "Options" );
192 case COL_DESCR: return _( "Description" );
193 case COL_ENABLED: return _( "Active" );
194 case COL_VISIBLE: return _( "Visible" );
195
196 default: return wxEmptyString;
197 }
198 }
#define _(s)
@ COL_DESCR
@ COL_VISIBLE
@ COL_NICKNAME
@ COL_OPTIONS
@ COL_ENABLED
@ COL_URI
@ COL_TYPE

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

◆ GetNumberCols()

int LIB_TABLE_GRID::GetNumberCols ( )
inlineoverride

Definition at line 56 of file lib_table_grid.h.

56{ return COL_COUNT; }
@ COL_COUNT

References COL_COUNT.

◆ GetNumberRows()

int LIB_TABLE_GRID::GetNumberRows ( )
inlineoverride

Definition at line 54 of file lib_table_grid.h.

54{ return (int) size(); }

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

59 {
60 if( aRow < (int) size() )
61 {
62 const LIB_TABLE_ROW* r = at( (size_t) aRow );
63
64 switch( aCol )
65 {
66 case COL_NICKNAME: return UnescapeString( r->GetNickName() );
67 case COL_URI: return r->GetFullURI();
68 case COL_TYPE: return r->GetType();
69 case COL_OPTIONS: return r->GetOptions();
70 case COL_DESCR: return r->GetDescr();
71 case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" );
72 case COL_VISIBLE: return r->GetIsVisible() ? wxT( "1" ) : wxT( "0" );
73 default: return wxEmptyString;
74 }
75 }
76
77 return wxEmptyString;
78 }
E_SERIE r
Definition: eserie.cpp:41
wxString UnescapeString(const wxString &aSource)

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

Referenced by IsEmptyCell().

◆ GetValueAsBool()

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

Definition at line 80 of file lib_table_grid.h.

81 {
82 if( aRow < (int) size() && aCol == COL_ENABLED )
83 return at( (size_t) aRow )->GetIsEnabled();
84 else if( aRow < (int) size() && aCol == COL_VISIBLE )
85 return at( (size_t) aRow )->GetIsVisible();
86 else
87 return false;
88 }
bool GetIsEnabled() const
bool GetIsVisible() const

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

Referenced by LIB_TABLE_GRID_TRICKS::showPopupMenu().

◆ insert()

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

Implemented in SYMBOL_LIB_TABLE_GRID, and FP_LIB_TABLE_GRID.

Referenced by InsertRows().

◆ InsertRows()

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

Definition at line 122 of file lib_table_grid.h.

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

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

◆ IsEmptyCell()

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

Definition at line 117 of file lib_table_grid.h.

118 {
119 return !GetValue( aRow, aCol );
120 }
wxString GetValue(int aRow, int aCol) override

References GetValue().

◆ makeNewRow()

virtual LIB_TABLE_ROW * LIB_TABLE_GRID::makeNewRow ( )
protectedpure virtual

Implemented in SYMBOL_LIB_TABLE_GRID, and FP_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 SYMBOL_LIB_TABLE_GRID, and FP_LIB_TABLE_GRID.

Referenced by AppendRows().

◆ SetValue()

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

Definition at line 90 of file lib_table_grid.h.

91 {
92 if( aRow < (int) size() )
93 {
94 LIB_TABLE_ROW* r = at( (size_t) aRow );
95
96 switch( aCol )
97 {
98 case COL_NICKNAME: r->SetNickName( EscapeString( aValue, CTX_LIBID ) ); break;
99 case COL_URI: r->SetFullURI( aValue ); break;
100 case COL_TYPE: r->SetType( aValue ); break;
101 case COL_OPTIONS: r->SetOptions( aValue ); break;
102 case COL_DESCR: r->SetDescr( aValue ); break;
103 case COL_ENABLED: r->SetEnabled( aValue == wxT( "1" ) ); break;
104 case COL_VISIBLE: r->SetVisible( aValue == wxT( "1" ) ); break;
105 }
106 }
107 }
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
Definition: string_utils.h:55

References at(), COL_DESCR, COL_ENABLED, COL_NICKNAME, COL_OPTIONS, COL_TYPE, COL_URI, COL_VISIBLE, 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 109 of file lib_table_grid.h.

110 {
111 if( aRow < (int) size() && aCol == COL_ENABLED )
112 at( (size_t) aRow )->SetEnabled( aValue );
113 else if( aRow < (int) size() && aCol == COL_VISIBLE )
114 at( (size_t) aRow )->SetVisible( aValue );
115 }
void SetVisible(bool aVisible=true)
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.

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

Referenced by LIB_TABLE_GRID_TRICKS::doPopupSelection().

◆ size()

virtual size_t LIB_TABLE_GRID::size ( ) const
protectedpure virtual

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