libyui-ncurses
2.44.1
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: NCComboBox.h 00020 00021 Author: Michael Andres <ma@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef NCComboBox_h 00026 #define NCComboBox_h 00027 00028 #include <iosfwd> 00029 #include <list> 00030 00031 #include <yui/YComboBox.h> 00032 #include "NCWidget.h" 00033 #include "NCApplication.h" 00034 #include <yui/YItem.h> 00035 00036 00037 class NCComboBox : public YComboBox, public NCWidget 00038 { 00039 private: 00040 00041 friend std::ostream & operator<<( std::ostream & STREAM, const NCComboBox & OBJ ); 00042 00043 NCComboBox & operator=( const NCComboBox & ); 00044 NCComboBox( const NCComboBox & ); 00045 00046 00047 bool mayedit; 00048 NClabel label; 00049 NCstring privText; 00050 std::wstring buffer; 00051 bool modified; 00052 NCursesWindow * lwin; 00053 NCursesWindow * twin; 00054 00055 std::string::size_type fldstart; 00056 std::string::size_type fldlength; 00057 std::string::size_type curpos; 00058 std::string::size_type longest_line; 00059 00060 NCstring validChars; 00061 00062 std::list<std::string> deflist; 00063 int index; 00064 00065 void setDefsze(); 00066 void tUpdate(); 00067 00068 bool haveUtf8() { return YUI::app()->hasFullUtf8Support(); } 00069 00070 protected: 00071 00072 virtual const char * location() const { return "NCComboBox"; } 00073 00074 virtual void wCreate( const wrect & newrect ); 00075 virtual void wDelete(); 00076 00077 virtual void wRedraw(); 00078 virtual void wRecoded(); 00079 00080 int listPopup(); 00081 00082 bool validKey( wint_t key ) const; 00083 00084 // specifies how much characters can be inserted. -1 for unlimited input 00085 int InputMaxLength; 00086 00087 public: 00088 00089 NCComboBox( YWidget * parent, 00090 const std::string & label, 00091 bool editable ); 00092 virtual ~NCComboBox(); 00093 00094 virtual void addItem( YItem * item ); 00095 virtual void selectItem( YItem * item, bool selected = true ); 00096 00097 void addItem( const std::string & label, bool selected ); 00098 00099 virtual int preferredWidth(); 00100 virtual int preferredHeight(); 00101 00102 virtual void setSize( int newWidth, int newHeight ); 00103 00104 virtual void setLabel( const std::string & nlabel ); 00105 00106 virtual void setText( const std::string & ntext ); 00107 virtual std::string text(); 00108 00109 virtual void setValidChars( const std::string & validchars ); 00110 00111 virtual int getCurrentItem() const; 00112 virtual void setCurrentItem( int index ); 00113 00114 virtual NCursesEvent wHandleInput( wint_t key ); 00115 00116 virtual void setEnabled( bool do_bv ); 00117 00118 virtual bool setKeyboardFocus() 00119 { 00120 if ( !grabFocus() ) 00121 return YWidget::setKeyboardFocus(); 00122 00123 return true; 00124 } 00125 00126 unsigned int getListSize( ) { return deflist.size(); } 00127 00128 void deleteAllItems(); 00129 00130 // limits the input to numberOfChars characters and truncates the text 00131 // if appropriate 00132 void setInputMaxLength( int nr ); 00133 00134 }; 00135 00136 00137 #endif // NCComboBox_h