libyui  3.0.10
/usr/src/RPM/BUILD/libyui-3.0.10/src/YRichText.h
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:         YRichText.h
00020 
00021   Author:       Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 #ifndef YRichText_h
00026 #define YRichText_h
00027 
00028 #include <string>
00029 #include "YWidget.h"
00030 #include "ImplPtr.h"
00031 
00032 
00033 class YRichTextPrivate;
00034 
00035 
00036 class YRichText : public YWidget
00037 {
00038 public:
00039 
00040     /**
00041      * Constructor.
00042      *
00043      * 'plainTextMode' indicates that the text should be treated as plain text,
00044      * i.e. any HTML-like tags in the text should not be interpreted in any
00045      * way.
00046      **/
00047     YRichText( YWidget *                parent,
00048                const std::string &      text,
00049                bool                     plainTextMode = false );
00050 
00051     /**
00052      * Destructor.
00053      **/
00054     virtual ~YRichText();
00055 
00056     /**
00057      * Returns a descriptive name of this widget class for logging,
00058      * debugging etc.
00059      **/
00060     virtual const char * widgetClass() const { return "YRichText"; }
00061 
00062     /**
00063      * Change the text content of the RichText widget.
00064      *
00065      * Derived classes should overwrite this function, but call this base class
00066      * function in the new function.
00067      **/
00068     virtual void setValue( const std::string & newValue );
00069 
00070     /**
00071      * Return the text content of the RichText widget.
00072      **/
00073     std::string value() const;
00074 
00075     /**
00076      * Alias for setValue().
00077      **/
00078     void setText( const std::string & newText ) { setValue( newText ); }
00079 
00080     /**
00081      * Alias for value().
00082      **/
00083     std::string text() const { return value(); }
00084 
00085     /**
00086      * Return 'true' if this RichText widget is in "plain text" mode, i.e. does
00087      * not try to interpret RichText/HTML tags.
00088      **/
00089     bool plainTextMode() const;
00090 
00091     /**
00092      * Set this RichText widget's "plain text" mode on or off.
00093      *
00094      * Derived classes may want to reimplement this, but they should call this
00095      * base class function in the new function.
00096      **/
00097     virtual void setPlainTextMode( bool on = true );
00098 
00099     /**
00100      * Return 'true' if this RichText widget should automatically scroll down
00101      * when the text content is changed. This is useful for progress displays
00102      * and log files.
00103      **/
00104     bool autoScrollDown() const;
00105 
00106     /**
00107      * Set this RichText widget's "auto scroll down" mode on or off.
00108      *
00109      * Derived classes may want to reimplement this, but they should call this
00110      * base class function in the new function.
00111      **/
00112     virtual void setAutoScrollDown( bool on = true );
00113 
00114     /**
00115      * Returns 'true' if this widget is "shrinkable", i.e. it should be very
00116      * small by default.
00117      **/
00118     bool shrinkable() const;
00119 
00120     /**
00121      * Make this widget shrinkable, i.e. very small in layouts.
00122      *
00123      * This method is intentionally not virtual because it doesn't have any
00124      * immediate effect; it is only needed in preferredWidth() /
00125      * preferredHeight().
00126      **/
00127     void setShrinkable( bool shrinkable = true );
00128 
00129     /**
00130      * Set a property.
00131      * Reimplemented from YWidget.
00132      *
00133      * This function may throw YUIPropertyExceptions.
00134      *
00135      * This function returns 'true' if the value was successfully set and
00136      * 'false' if that value requires special handling (not in error cases:
00137      * those are covered by exceptions).
00138      **/
00139     virtual bool setProperty( const std::string & propertyName,
00140                               const YPropertyValue & val );
00141 
00142     /**
00143      * Get a property.
00144      * Reimplemented from YWidget.
00145      *
00146      * This method may throw YUIPropertyExceptions.
00147      **/
00148     virtual YPropertyValue getProperty( const std::string & propertyName );
00149 
00150     /**
00151      * Return this class's property set.
00152      * This also initializes the property upon the first call.
00153      *
00154      * Reimplemented from YWidget.
00155      **/
00156     virtual const YPropertySet & propertySet();
00157 
00158 
00159 protected:
00160 
00161     ImplPtr<YRichTextPrivate> priv;
00162 };
00163 
00164 
00165 #endif // YRichText_h
 All Classes Functions Variables Enumerations Friends