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