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 // specifies how much characters can be inserted. -1 for unlimited input 00082 int InputMaxLength; 00083 00084 public: 00085 00086 NCComboBox( NCWidget * parent, const YWidgetOpt & opt, 00087 const YCPString & label ); 00088 virtual ~NCComboBox(); 00089 00090 virtual void itemAdded( const YCPString & string, 00091 int index, 00092 bool selected ); 00093 00094 virtual long nicesize( YUIDimension dim ); 00095 virtual void setSize( long newwidth, long newheight ); 00096 00097 virtual void setLabel( const YCPString & nlabel ); 00098 00099 virtual void setValue( const YCPString & ntext ); 00100 virtual YCPString getValue() const; 00101 00102 virtual void setValidChars( const YCPString & validchars ); 00103 00104 virtual int getCurrentItem() const; 00105 virtual void setCurrentItem( int index ); 00106 00107 virtual NCursesEvent wHandleInput( wint_t key ); 00108 00109 virtual void setEnabling( bool do_bv ) { NCWidget::setEnabling( enabled=do_bv ); } 00110 00111 virtual bool setKeyboardFocus() { 00112 if ( !grabFocus() ) 00113 return YWidget::setKeyboardFocus(); 00114 return true; 00115 } 00116 00117 unsigned int getListSize( ) { return deflist.size(); } 00118 00119 void deleteAllItems(); 00120 00121 // limits the input to numberOfChars characters and truncates the text 00122 // if appropriate 00123 void setInputMaxLength( const YCPInteger & numberOfChars); 00124 00125 }; 00126 00128 00129 #endif // NCComboBox_h