libyui  3.9.3
YRichText.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  Copyright (C) 2019 SUSE LLC
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as
6  published by the Free Software Foundation; either version 2.1 of the
7  License, or (at your option) version 3.0 of the License. This library
8  is distributed in the hope that it will be useful, but WITHOUT ANY
9  WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11  License for more details. You should have received a copy of the GNU
12  Lesser General Public License along with this library; if not, write
13  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
14  Floor, Boston, MA 02110-1301 USA
15 */
16 
17 
18 /*-/
19 
20  File: YRichText.h
21 
22  Author: Stefan Hundhammer <sh@suse.de>
23 
24 /-*/
25 
26 #ifndef YRichText_h
27 #define YRichText_h
28 
29 #include <string>
30 #include "YWidget.h"
31 #include "ImplPtr.h"
32 
33 
34 class YRichTextPrivate;
35 
36 
37 /**
38  * Text formatted with simple HTML-like tags, with "links" generating events.
39  **/
40 class YRichText : public YWidget
41 {
42 public:
43 
44  /**
45  * Constructor.
46  *
47  * 'plainTextMode' indicates that the text should be treated as plain text,
48  * i.e. any HTML-like tags in the text should not be interpreted in any
49  * way.
50  **/
52  const std::string & text,
53  bool plainTextMode = false );
54 
55  /**
56  * Destructor.
57  **/
58  virtual ~YRichText();
59 
60  /**
61  * Returns a descriptive name of this widget class for logging,
62  * debugging etc.
63  **/
64  virtual const char * widgetClass() const { return "YRichText"; }
65 
66  /**
67  * Change the text content of the RichText widget.
68  *
69  * Derived classes should overwrite this function, but call this base class
70  * function in the new function.
71  **/
72  virtual void setValue( const std::string & newValue );
73 
74  /**
75  * Return the text content of the RichText widget.
76  **/
77  std::string value() const;
78 
79  /**
80  * Alias for setValue().
81  **/
82  void setText( const std::string & newText ) { setValue( newText ); }
83 
84  /**
85  * Alias for value().
86  **/
87  std::string text() const { return value(); }
88 
89  /**
90  * Return 'true' if this RichText widget is in "plain text" mode, i.e. does
91  * not try to interpret RichText/HTML tags.
92  **/
93  bool plainTextMode() const;
94 
95  /**
96  * Set this RichText widget's "plain text" mode on or off.
97  *
98  * Derived classes may want to reimplement this, but they should call this
99  * base class function in the new function.
100  **/
101  virtual void setPlainTextMode( bool on = true );
102 
103  /**
104  * Return 'true' if this RichText widget should automatically scroll down
105  * when the text content is changed. This is useful for progress displays
106  * and log files.
107  **/
108  bool autoScrollDown() const;
109 
110  /**
111  * Set this RichText widget's "auto scroll down" mode on or off.
112  *
113  * Derived classes may want to reimplement this, but they should call this
114  * base class function in the new function.
115  **/
116  virtual void setAutoScrollDown( bool on = true );
117 
118  /**
119  * Returns 'true' if this widget is "shrinkable", i.e. it should be very
120  * small by default.
121  **/
122  bool shrinkable() const;
123 
124  /**
125  * Make this widget shrinkable, i.e. very small in layouts.
126  *
127  * This method is intentionally not virtual because it doesn't have any
128  * immediate effect; it is only needed in preferredWidth() /
129  * preferredHeight().
130  **/
131  void setShrinkable( bool shrinkable = true );
132 
133  /**
134  * Set a property.
135  * Reimplemented from YWidget.
136  *
137  * This function may throw YUIPropertyExceptions.
138  *
139  * This function returns 'true' if the value was successfully set and
140  * 'false' if that value requires special handling (not in error cases:
141  * those are covered by exceptions).
142  **/
143  virtual bool setProperty( const std::string & propertyName,
144  const YPropertyValue & val );
145 
146  /**
147  * Get a property.
148  * Reimplemented from YWidget.
149  *
150  * This method may throw YUIPropertyExceptions.
151  **/
152  virtual YPropertyValue getProperty( const std::string & propertyName );
153 
154  /**
155  * Return this class's property set.
156  * This also initializes the property upon the first call.
157  *
158  * Reimplemented from YWidget.
159  **/
160  virtual const YPropertySet & propertySet();
161 
162  /**
163  * Get the position value of the vertical scrollbar.
164  *
165  * Might not be available in all frontends.
166  */
167  virtual std::string vScrollValue() const;
168 
169  /**
170  * Set the position value of the vertical scrollbar. Only values
171  * previously obtained using vScrollValue() and some special
172  * values are allowed.
173  *
174  * The special values are:
175  *
176  * "minimum" Moves the scrollbar to the start.
177  *
178  * "maximum" Moves the scrollbar to the end.
179  *
180  * Might not be available in all frontends.
181  */
182  virtual void setVScrollValue( const std::string & newValue );
183 
184  /**
185  * Get the position value of the horizontal scrollbar.
186  *
187  * Might not be available in all frontends.
188  */
189  virtual std::string hScrollValue() const;
190 
191  /**
192  * Set the position value of the horizontal scrollbar. Only values
193  * previously obtained using hScrollValue() and some special
194  * values are allowed.
195  *
196  * The special values are:
197  *
198  * "minimum" Moves the scrollbar to the start.
199  *
200  * "maximum" Moves the scrollbar to the end.
201  *
202  * The meaning of start and end can depend on the text direction
203  * (LTR or RTL).
204  *
205  * Might not be available in all frontends.
206  */
207  virtual void setHScrollValue( const std::string & newValue );
208 
209  /**
210  * Derived classes should implement this, method is used to trigger event
211  * like user has pressed the link in the RichText
212  **/
213  virtual void activateLink( const std::string & url ) = 0;
214 
215 protected:
216 
218 };
219 
220 
221 #endif // YRichText_h
bool shrinkable() const
Returns &#39;true&#39; if this widget is "shrinkable", i.e.
Definition: YRichText.cc:110
std::string value() const
Return the text content of the RichText widget.
Definition: YRichText.cc:80
virtual void activateLink(const std::string &url)=0
Derived classes should implement this, method is used to trigger event like user has pressed the link...
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:98
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:271
virtual void setValue(const std::string &newValue)
Change the text content of the RichText widget.
Definition: YRichText.cc:74
virtual ~YRichText()
Destructor.
Definition: YRichText.cc:68
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
Definition: YRichText.cc:123
YRichText(YWidget *parent, const std::string &text, bool plainTextMode=false)
Constructor.
Definition: YRichText.cc:57
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YRichText.cc:165
void setText(const std::string &newText)
Alias for setValue().
Definition: YRichText.h:82
virtual void setAutoScrollDown(bool on=true)
Set this RichText widget&#39;s "auto scroll down" mode on or off.
Definition: YRichText.cc:104
Text formatted with simple HTML-like tags, with "links" generating events.
Definition: YRichText.h:40
virtual void setVScrollValue(const std::string &newValue)
Set the position value of the vertical scrollbar.
Definition: YRichText.cc:186
bool plainTextMode() const
Return &#39;true&#39; if this RichText widget is in "plain text" mode, i.e.
Definition: YRichText.cc:86
virtual void setHScrollValue(const std::string &newValue)
Set the position value of the horizontal scrollbar.
Definition: YRichText.cc:197
std::string text() const
Alias for value().
Definition: YRichText.h:87
virtual std::string hScrollValue() const
Get the position value of the horizontal scrollbar.
Definition: YRichText.cc:191
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:116
virtual void setPlainTextMode(bool on=true)
Set this RichText widget&#39;s "plain text" mode on or off.
Definition: YRichText.cc:92
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YRichText.h:64
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YRichText.cc:147
virtual std::string vScrollValue() const
Get the position value of the vertical scrollbar.
Definition: YRichText.cc:180