00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: YDumbTab.h 00014 00015 Author: Stefan Hundhammer <sh@suse.de> 00016 00017 /-*/ 00018 00019 #ifndef YDumbTab_h 00020 #define YDumbTab_h 00021 00022 #include "YContainerWidget.h" 00023 #include <ycp/YCPString.h> 00024 00028 class YDumbTab : public YContainerWidget 00029 { 00030 public: 00031 00035 YDumbTab( const YWidgetOpt & opt ); 00036 00041 virtual char *widgetClass() { return "YDumbTab"; } 00042 00046 YCPValue changeWidget( const YCPSymbol & property, const YCPValue & newvalue ); 00047 00051 YCPValue queryWidget( const YCPSymbol & property ); 00052 00057 void addTab( const YCPValue & id, 00058 const YCPString & label, 00059 bool selected ); 00060 00061 protected: 00062 00068 int findTab( const YCPValue & id ); 00069 00075 virtual void addTab( const YCPString & label ); 00076 00082 virtual int getSelectedTabIndex(); 00083 00089 virtual void setSelectedTab( int index ); 00090 00091 00092 00093 class Tab 00094 { 00095 public: 00096 Tab( const YCPValue & id, const YCPString & label ) 00097 : _id( id ) 00098 , _label( label ) 00099 {} 00100 00101 Tab( const Tab & other ) 00102 : _id( other.internalId() ) 00103 , _label( other.label() ) 00104 {} 00105 00106 Tab & operator=( const Tab & other ) 00107 { 00108 _id = other.internalId(); 00109 _label = other.label(); 00110 00111 return *this; 00112 } 00113 00114 YCPString label() const { return _label; } 00115 YCPValue internalId() const { return _id; } 00116 YCPValue id() const 00117 { return ( ! _id.isNull() && ! _id->isVoid() ) ? _id : _label; } 00118 00119 private: 00120 YCPValue _id; 00121 YCPString _label; 00122 }; 00123 00124 00125 vector<Tab> _tabs; 00126 }; 00127 00128 00129 #endif // YDumbTab_h