libyui  3.1.5
 All Classes Files Functions Variables Typedefs Enumerations Friends Pages
YRichText.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YRichText.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YRichText_h
26 #define YRichText_h
27 
28 #include <string>
29 #include "YWidget.h"
30 #include "ImplPtr.h"
31 
32 
33 class YRichTextPrivate;
34 
35 
36 class YRichText : public YWidget
37 {
38 public:
39 
40  /**
41  * Constructor.
42  *
43  * 'plainTextMode' indicates that the text should be treated as plain text,
44  * i.e. any HTML-like tags in the text should not be interpreted in any
45  * way.
46  **/
48  const std::string & text,
49  bool plainTextMode = false );
50 
51  /**
52  * Destructor.
53  **/
54  virtual ~YRichText();
55 
56  /**
57  * Returns a descriptive name of this widget class for logging,
58  * debugging etc.
59  **/
60  virtual const char * widgetClass() const { return "YRichText"; }
61 
62  /**
63  * Change the text content of the RichText widget.
64  *
65  * Derived classes should overwrite this function, but call this base class
66  * function in the new function.
67  **/
68  virtual void setValue( const std::string & newValue );
69 
70  /**
71  * Return the text content of the RichText widget.
72  **/
73  std::string value() const;
74 
75  /**
76  * Alias for setValue().
77  **/
78  void setText( const std::string & newText ) { setValue( newText ); }
79 
80  /**
81  * Alias for value().
82  **/
83  std::string text() const { return value(); }
84 
85  /**
86  * Return 'true' if this RichText widget is in "plain text" mode, i.e. does
87  * not try to interpret RichText/HTML tags.
88  **/
89  bool plainTextMode() const;
90 
91  /**
92  * Set this RichText widget's "plain text" mode on or off.
93  *
94  * Derived classes may want to reimplement this, but they should call this
95  * base class function in the new function.
96  **/
97  virtual void setPlainTextMode( bool on = true );
98 
99  /**
100  * Return 'true' if this RichText widget should automatically scroll down
101  * when the text content is changed. This is useful for progress displays
102  * and log files.
103  **/
104  bool autoScrollDown() const;
105 
106  /**
107  * Set this RichText widget's "auto scroll down" mode on or off.
108  *
109  * Derived classes may want to reimplement this, but they should call this
110  * base class function in the new function.
111  **/
112  virtual void setAutoScrollDown( bool on = true );
113 
114  /**
115  * Returns 'true' if this widget is "shrinkable", i.e. it should be very
116  * small by default.
117  **/
118  bool shrinkable() const;
119 
120  /**
121  * Make this widget shrinkable, i.e. very small in layouts.
122  *
123  * This method is intentionally not virtual because it doesn't have any
124  * immediate effect; it is only needed in preferredWidth() /
125  * preferredHeight().
126  **/
127  void setShrinkable( bool shrinkable = true );
128 
129  /**
130  * Set a property.
131  * Reimplemented from YWidget.
132  *
133  * This function may throw YUIPropertyExceptions.
134  *
135  * This function returns 'true' if the value was successfully set and
136  * 'false' if that value requires special handling (not in error cases:
137  * those are covered by exceptions).
138  **/
139  virtual bool setProperty( const std::string & propertyName,
140  const YPropertyValue & val );
141 
142  /**
143  * Get a property.
144  * Reimplemented from YWidget.
145  *
146  * This method may throw YUIPropertyExceptions.
147  **/
148  virtual YPropertyValue getProperty( const std::string & propertyName );
149 
150  /**
151  * Return this class's property set.
152  * This also initializes the property upon the first call.
153  *
154  * Reimplemented from YWidget.
155  **/
156  virtual const YPropertySet & propertySet();
157 
158 
159 protected:
160 
162 };
163 
164 
165 #endif // YRichText_h
YWidget * parent() const
Return this widget&#39;s parent or 0 if it doesn&#39;t have a parent.
Definition: YWidget.cc:269
std::string text() const
Alias for value().
Definition: YRichText.h:83
Transport class for the value of simple properties.
Definition: YProperty.h:104
std::string value() const
Return the text content of the RichText widget.
Definition: YRichText.cc:77
A set of properties to check names and types against.
Definition: YProperty.h:184
virtual void setValue(const std::string &newValue)
Change the text content of the RichText widget.
Definition: YRichText.cc:71
virtual ~YRichText()
Destructor.
Definition: YRichText.cc:65
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
Definition: YRichText.cc:120
YRichText(YWidget *parent, const std::string &text, bool plainTextMode=false)
Constructor.
Definition: YRichText.cc:54
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YRichText.cc:156
bool plainTextMode() const
Return &#39;true&#39; if this RichText widget is in &quot;plain text&quot; mode, i.e.
Definition: YRichText.cc:83
void setText(const std::string &newText)
Alias for setValue().
Definition: YRichText.h:78
bool autoScrollDown() const
Return &#39;true&#39; if this RichText widget should automatically scroll down when the text content is chang...
Definition: YRichText.cc:95
virtual void setAutoScrollDown(bool on=true)
Set this RichText widget&#39;s &quot;auto scroll down&quot; mode on or off.
Definition: YRichText.cc:101
bool shrinkable() const
Returns &#39;true&#39; if this widget is &quot;shrinkable&quot;, i.e.
Definition: YRichText.cc:107
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YRichText.h:60
Abstract base class of all UI widgets.
Definition: YWidget.h:54
void setShrinkable(bool shrinkable=true)
Make this widget shrinkable, i.e.
Definition: YRichText.cc:113
virtual void setPlainTextMode(bool on=true)
Set this RichText widget&#39;s &quot;plain text&quot; mode on or off.
Definition: YRichText.cc:89
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YRichText.cc:140