00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef YSelectionWidget_h
00020 #define YSelectionWidget_h
00021
00022 #include "YWidget.h"
00023 #include <ycp/YCPString.h>
00024 #include <ycp/YCPList.h>
00025
00026
00031 class YSelectionWidget : public YWidget
00032 {
00033 public:
00034
00040 YSelectionWidget( const YWidgetOpt & opt, YCPString label );
00041
00046 virtual char *widgetClass() { return "YSelectionWidget"; }
00047
00052 virtual const char *shortcutProperty() { return YUIProperty_Label; }
00053
00057 void parseItemList( const YCPList & itemlist );
00058
00059
00081 static bool parseItem( const YCPTerm & itemTerm,
00082 YCPValue & item_id_ret,
00083 YCPString & item_label_ret,
00084 YCPString & item_icon_ret,
00085 YCPBoolean & item_selected_ret,
00086 YCPList & sub_item_list_ret );
00087
00088
00089 protected:
00090
00098 virtual void itemAdded( const YCPString & string, int index, bool selected ) = 0;
00099
00106 int itemWithId( const YCPValue & id, bool report_error );
00107
00111 YCPString label;
00112
00116 YCPList item_ids;
00117
00121 YCPList item_labels;
00122
00126 int numItems() const;
00127
00132 virtual void setLabel( const YCPString & label );
00133
00139 YCPString getLabel();
00140
00144 virtual void addItem( const YCPValue & id,
00145 const YCPString & text,
00146 const YCPString & icon,
00147 bool selected );
00148
00153 virtual void deleteAllItems();
00154
00159 virtual YCPValue changeLabel( const YCPValue & newValue );
00160
00165 virtual YCPValue changeItems ( const YCPValue & newValue );
00166
00167
00172 YCPString itemIcon( int item_no ) const;
00173
00177 bool hasIcons() const { return _hasIcons; }
00178
00179
00180 private:
00181
00186 YCPList item_icons;
00187
00188 bool _hasIcons;
00189
00190 };
00191
00192
00193 #endif // YSelectionWidget_h