libyui  3.3.2
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 /**
37  * Text formatted with simple HTML-like tags, with "links" generating events.
38  **/
39 class YRichText : public YWidget
40 {
41 public:
42 
43  /**
44  * Constructor.
45  *
46  * 'plainTextMode' indicates that the text should be treated as plain text,
47  * i.e. any HTML-like tags in the text should not be interpreted in any
48  * way.
49  **/
51  const std::string & text,
52  bool plainTextMode = false );
53 
54  /**
55  * Destructor.
56  **/
57  virtual ~YRichText();
58 
59  /**
60  * Returns a descriptive name of this widget class for logging,
61  * debugging etc.
62  **/
63  virtual const char * widgetClass() const { return "YRichText"; }
64 
65  /**
66  * Change the text content of the RichText widget.
67  *
68  * Derived classes should overwrite this function, but call this base class
69  * function in the new function.
70  **/
71  virtual void setValue( const std::string & newValue );
72 
73  /**
74  * Return the text content of the RichText widget.
75  **/
76  std::string value() const;
77 
78  /**
79  * Alias for setValue().
80  **/
81  void setText( const std::string & newText ) { setValue( newText ); }
82 
83  /**
84  * Alias for value().
85  **/
86  std::string text() const { return value(); }
87 
88  /**
89  * Return 'true' if this RichText widget is in "plain text" mode, i.e. does
90  * not try to interpret RichText/HTML tags.
91  **/
92  bool plainTextMode() const;
93 
94  /**
95  * Set this RichText widget's "plain text" mode on or off.
96  *
97  * Derived classes may want to reimplement this, but they should call this
98  * base class function in the new function.
99  **/
100  virtual void setPlainTextMode( bool on = true );
101 
102  /**
103  * Return 'true' if this RichText widget should automatically scroll down
104  * when the text content is changed. This is useful for progress displays
105  * and log files.
106  **/
107  bool autoScrollDown() const;
108 
109  /**
110  * Set this RichText widget's "auto scroll down" mode on or off.
111  *
112  * Derived classes may want to reimplement this, but they should call this
113  * base class function in the new function.
114  **/
115  virtual void setAutoScrollDown( bool on = true );
116 
117  /**
118  * Returns 'true' if this widget is "shrinkable", i.e. it should be very
119  * small by default.
120  **/
121  bool shrinkable() const;
122 
123  /**
124  * Make this widget shrinkable, i.e. very small in layouts.
125  *
126  * This method is intentionally not virtual because it doesn't have any
127  * immediate effect; it is only needed in preferredWidth() /
128  * preferredHeight().
129  **/
130  void setShrinkable( bool shrinkable = true );
131 
132  /**
133  * Set a property.
134  * Reimplemented from YWidget.
135  *
136  * This function may throw YUIPropertyExceptions.
137  *
138  * This function returns 'true' if the value was successfully set and
139  * 'false' if that value requires special handling (not in error cases:
140  * those are covered by exceptions).
141  **/
142  virtual bool setProperty( const std::string & propertyName,
143  const YPropertyValue & val );
144 
145  /**
146  * Get a property.
147  * Reimplemented from YWidget.
148  *
149  * This method may throw YUIPropertyExceptions.
150  **/
151  virtual YPropertyValue getProperty( const std::string & propertyName );
152 
153  /**
154  * Return this class's property set.
155  * This also initializes the property upon the first call.
156  *
157  * Reimplemented from YWidget.
158  **/
159  virtual const YPropertySet & propertySet();
160 
161 
162 protected:
163 
165 };
166 
167 
168 #endif // YRichText_h
bool shrinkable() const
Returns &#39;true&#39; if this widget is "shrinkable", i.e.
Definition: YRichText.cc:107
Transport class for the value of simple properties.
Definition: YProperty.h:104
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
A set of properties to check names and types against.
Definition: YProperty.h:197
YWidget * parent() const
Return this widget&#39;s parent or 0 if it doesn&#39;t have a parent.
Definition: YWidget.cc:269
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
void setText(const std::string &newText)
Alias for setValue().
Definition: YRichText.h:81
std::string value() const
Return the text content of the RichText widget.
Definition: YRichText.cc:77
virtual void setAutoScrollDown(bool on=true)
Set this RichText widget&#39;s "auto scroll down" mode on or off.
Definition: YRichText.cc:101
Text formatted with simple HTML-like tags, with "links" generating events.
Definition: YRichText.h:39
bool plainTextMode() const
Return &#39;true&#39; if this RichText widget is in "plain text" mode, i.e.
Definition: YRichText.cc:83
std::string text() const
Alias for value().
Definition: YRichText.h:86
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 "plain text" mode on or off.
Definition: YRichText.cc:89
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YRichText.h:63
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YRichText.cc:140