libyui
3.0.10
|
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: YMultiLineEdit.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef YMultiLineEdit_h 00026 #define YMultiLineEdit_h 00027 00028 #include "YWidget.h" 00029 00030 class YMultiLineEditPrivate; 00031 00032 00033 class YMultiLineEdit : public YWidget 00034 { 00035 protected: 00036 /** 00037 * Constructor. 00038 **/ 00039 YMultiLineEdit( YWidget * parent, const std::string & label ); 00040 00041 public: 00042 /** 00043 * Destructor. 00044 **/ 00045 virtual ~YMultiLineEdit(); 00046 00047 /** 00048 * Returns a descriptive name of this widget class for logging, 00049 * debugging etc. 00050 **/ 00051 virtual const char * widgetClass() const { return "YMultiLineEdit"; } 00052 00053 /** 00054 * Get the current value (the text entered by the user or set from the 00055 * outside) of this MultiLineEdit. 00056 * 00057 * Derived classes are required to implement this. 00058 **/ 00059 virtual std::string value() = 0; 00060 00061 /** 00062 * Set the current value (the text entered by the user or set from the 00063 * outside) of this MultiLineEdit. 00064 * 00065 * Derived classes are required to implement this. 00066 **/ 00067 virtual void setValue( const std::string & text ) = 0; 00068 00069 /** 00070 * Get the label (the caption above the MultiLineEdit). 00071 **/ 00072 std::string label() const; 00073 00074 /** 00075 * Set the label (the caption above the MultiLineEdit). 00076 * 00077 * Derived classes are free to reimplement this, but they should call this 00078 * base class method at the end of the overloaded function. 00079 **/ 00080 virtual void setLabel( const std::string & label ); 00081 00082 /** 00083 * The maximum input length, i.e., the maximum number of characters the 00084 * user can enter. -1 means no limit. 00085 **/ 00086 int inputMaxLength() const; 00087 00088 /** 00089 * Set the maximum input length, i.e., the maximum number of characters the 00090 * user can enter. -1 means no limit. 00091 * 00092 * Derived classes are free to reimplement this, but they should call this 00093 * base class method at the end of the overloaded function. 00094 **/ 00095 virtual void setInputMaxLength( int numberOfChars ); 00096 00097 /** 00098 * Return the number of input lines that are visible by default. 00099 * 00100 * This is what the widget would like to get (which will be reflected by 00101 * preferredHeight() ), not what it currently actually has due to layout 00102 * constraints. 00103 **/ 00104 int defaultVisibleLines() const; 00105 00106 /** 00107 * Set the number of input lines that are visible by default. 00108 * 00109 * This is what the widget would like to get (which will be reflected by 00110 * preferredHeight() ), not what it currently actually has due to layout 00111 * constraints. 00112 * 00113 * Notice that since a MultiLineEdit is stretchable in both dimensions, it 00114 * might get more or less screen space, depending on the layout. This value 00115 * is only meaningful if there are no other layout constraints. 00116 * 00117 * Changing this value will not trigger a re-layout. 00118 * 00119 * Derived classes can overwrite this function (but should call this base 00120 * class function in the new function implementation), but it will normally 00121 * be sufficient to query defaultVisibleLines() in preferredHeight(). 00122 **/ 00123 virtual void setDefaultVisibleLines( int newVisibleLines ); 00124 00125 /** 00126 * Set a property. 00127 * Reimplemented from YWidget. 00128 * 00129 * This function may throw YUIPropertyExceptions. 00130 * 00131 * This function returns 'true' if the value was successfully set and 00132 * 'false' if that value requires special handling (not in error cases: 00133 * those are covered by exceptions). 00134 **/ 00135 virtual bool setProperty( const std::string & propertyName, 00136 const YPropertyValue & val ); 00137 00138 /** 00139 * Get a property. 00140 * Reimplemented from YWidget. 00141 * 00142 * This method may throw YUIPropertyExceptions. 00143 **/ 00144 virtual YPropertyValue getProperty( const std::string & propertyName ); 00145 00146 /** 00147 * Return this class's property set. 00148 * This also initializes the property upon the first call. 00149 * 00150 * Reimplemented from YWidget. 00151 **/ 00152 virtual const YPropertySet & propertySet(); 00153 00154 /** 00155 * Get the string of this widget that holds the keyboard shortcut. 00156 * 00157 * Reimplemented from YWidget. 00158 **/ 00159 virtual std::string shortcutString() const { return label(); } 00160 00161 /** 00162 * Set the string of this widget that holds the keyboard shortcut. 00163 * 00164 * Reimplemented from YWidget. 00165 **/ 00166 virtual void setShortcutString( const std::string & str ) 00167 { setLabel( str ); } 00168 00169 /** 00170 * The name of the widget property that will return user input. 00171 * Inherited from YWidget. 00172 **/ 00173 const char * userInputProperty() { return YUIProperty_Value; } 00174 00175 00176 private: 00177 00178 ImplPtr<YMultiLineEditPrivate> priv; 00179 }; 00180 00181 00182 #endif // YMultiLineEdit_h