00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: NCComboBox.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 /-*/ 00019 #ifndef NCComboBox_h 00020 #define NCComboBox_h 00021 00022 #include <iosfwd> 00023 00024 #include <list> 00025 using namespace std; 00026 00027 #include "YComboBox.h" 00028 #include "NCWidget.h" 00029 00030 class NCComboBox; 00031 00033 // 00034 // CLASS NAME : NCComboBox 00035 // 00036 // DESCRIPTION : 00037 // 00038 class NCComboBox : public YComboBox, public NCWidget { 00039 00040 friend std::ostream & operator<<( std::ostream & STREAM, const NCComboBox & OBJ ); 00041 00042 NCComboBox & operator=( const NCComboBox & ); 00043 NCComboBox ( const NCComboBox & ); 00044 00045 private: 00046 00047 bool mayedit; 00048 NClabel label; 00049 NCstring text; 00050 wstring buffer; 00051 bool modified; 00052 NCursesWindow * lwin; 00053 NCursesWindow * twin; 00054 00055 string::size_type fldstart; 00056 string::size_type fldlength; 00057 string::size_type curpos; 00058 00059 NCstring validChars; 00060 00061 list<YCPString> deflist; 00062 int index; 00063 00064 void setDefsze(); 00065 void tUpdate(); 00066 00067 protected: 00068 00069 virtual const char * location() const { return "NCComboBox"; } 00070 00071 virtual void wCreate( const wrect & newrect ); 00072 virtual void wDelete(); 00073 00074 virtual void wRedraw(); 00075 virtual void wRecoded(); 00076 00077 int listPopup(); 00078 00079 bool validKey( wint_t key ) const; 00080 00081 public: 00082 00083 NCComboBox( NCWidget * parent, const YWidgetOpt & opt, 00084 const YCPString & label ); 00085 virtual ~NCComboBox(); 00086 00087 virtual void itemAdded( const YCPString & string, 00088 int index, 00089 bool selected ); 00090 00091 virtual long nicesize( YUIDimension dim ); 00092 virtual void setSize( long newwidth, long newheight ); 00093 00094 virtual void setLabel( const YCPString & nlabel ); 00095 00096 virtual void setValue( const YCPString & ntext ); 00097 virtual YCPString getValue() const; 00098 00099 virtual void setValidChars( const YCPString & validchars ); 00100 00101 virtual int getCurrentItem() const; 00102 virtual void setCurrentItem( int index ); 00103 00104 virtual NCursesEvent wHandleInput( wint_t key ); 00105 00106 virtual void setEnabling( bool do_bv ) { NCWidget::setEnabling( enabled=do_bv ); } 00107 00108 virtual bool setKeyboardFocus() { 00109 if ( !grabFocus() ) 00110 return YWidget::setKeyboardFocus(); 00111 return true; 00112 } 00113 00114 unsigned int getListSize( ) { return deflist.size(); } 00115 }; 00116 00118 00119 #endif // NCComboBox_h