00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef YTable_h
00021 #define YTable_h
00022
00023 #include "YWidget.h"
00024 #include <ycp/YCPString.h>
00025 #include <ycp/YCPList.h>
00026
00027 class YMacroRecorder;
00028
00029
00033 class YTableRow
00034 {
00035 YCPValue id;
00036 vector<string> elements;
00037 YTableRow( YCPValue id, vector<string> elements )
00038 : id( id ), elements( elements ) {};
00039 friend class YTable;
00040
00044 YCPTerm makeTerm() const;
00045 };
00046
00047
00048
00052 class YTable : public YWidget
00053 {
00054 public:
00055
00060 YTable( const YWidgetOpt & opt, int num_cols );
00061
00066 virtual char *widgetClass() { return "YTable"; }
00067
00072 bool addItem( const YCPValue & item );
00073
00078 virtual bool addItems( const YCPList & itemlist );
00079
00083 void addItem( const YCPValue & id, vector<string> elements );
00084
00088 YCPValue changeWidget( const YCPSymbol & property, const YCPValue & newvalue );
00089
00093 YCPValue changeWidgetTerm( const YCPTerm & property, const YCPValue & newvalue );
00094
00098 YCPValue queryWidget( const YCPSymbol & property );
00099
00103 YCPValue queryWidgetTerm( const YCPTerm & property );
00104
00108 int numCols() const;
00109
00110 protected:
00117 virtual void itemAdded( vector<string> elements, int index );
00118
00123 virtual void itemsCleared() = 0;
00124
00129 virtual void cellChanged( int index, int colnum, const YCPString & newtext ) = 0;
00130
00135 virtual int getCurrentItem() = 0;
00136
00140 virtual void setCurrentItem( int index ) = 0;
00141
00142
00143 protected:
00147 vector<YTableRow> rows;
00148
00152 int num_cols;
00153
00157 int numItems() const;
00158
00165 int itemWithId( const YCPValue & id, bool report_error );
00166
00167
00168 private:
00169
00175 virtual void saveUserInput( YMacroRecorder *macroRecorder );
00176 };
00177
00178
00179 #endif // YTable_h