]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: stattext.h | |
e54c96f1 | 3 | // Purpose: interface of wxStaticText |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxStaticText | |
7c913512 | 11 | |
23324ae1 | 12 | A static text control displays one or more lines of read-only text. |
7c913512 | 13 | |
23324ae1 | 14 | @beginStyleTable |
8c6791e4 | 15 | @style{wxALIGN_LEFT} |
23324ae1 | 16 | Align the text to the left |
8c6791e4 | 17 | @style{wxALIGN_RIGHT} |
23324ae1 | 18 | Align the text to the right |
8c6791e4 | 19 | @style{wxALIGN_CENTRE} |
23324ae1 | 20 | Center the text (horizontally) |
8c6791e4 | 21 | @style{wxST_NO_AUTORESIZE} |
23324ae1 FM |
22 | By default, the control will adjust its size to exactly fit to the |
23 | size of the text when SetLabel is called. If this style flag is | |
24 | given, the control will not change its size (this style is | |
25 | especially useful with controls which also have wxALIGN_RIGHT or | |
26 | CENTER style because otherwise they won't make sense any longer | |
27 | after a call to SetLabel) | |
8c6791e4 | 28 | @style{wxST_ELLIPSIZE_START} |
23324ae1 FM |
29 | If the text width exceeds the control width, replace the beginning |
30 | of the text with an ellipsis | |
8c6791e4 | 31 | @style{wxST_ELLIPSIZE_MIDDLE} |
23324ae1 FM |
32 | Same as above, but replace the text in the middle of the control |
33 | with an ellipsis | |
8c6791e4 | 34 | @style{wxST_ELLIPSIZE_END} |
23324ae1 | 35 | Same as above, but replace the end of the text with an ellipsis |
8c6791e4 | 36 | @style{wxST_MARKUP} |
23324ae1 FM |
37 | Support markup in the label; see SetLabel for more information |
38 | @endStyleTable | |
7c913512 | 39 | |
23324ae1 FM |
40 | @library{wxcore} |
41 | @category{ctrl} | |
0c7fe6f2 | 42 | <!-- @appearance{statictext.png} --> |
7c913512 | 43 | |
e54c96f1 | 44 | @see wxStaticBitmap, wxStaticBox |
23324ae1 FM |
45 | */ |
46 | class wxStaticText : public wxControl | |
47 | { | |
48 | public: | |
671600d8 RR |
49 | /** |
50 | Default constructor. | |
51 | */ | |
52 | wxStaticText(); | |
53 | ||
23324ae1 FM |
54 | /** |
55 | Constructor, creating and showing a text control. | |
3c4f71cc | 56 | |
7c913512 | 57 | @param parent |
4cc4bfaf | 58 | Parent window. Should not be @NULL. |
7c913512 | 59 | @param id |
4cc4bfaf | 60 | Control identifier. A value of -1 denotes a default value. |
7c913512 | 61 | @param label |
4cc4bfaf | 62 | Text label. |
7c913512 | 63 | @param pos |
4cc4bfaf | 64 | Window position. |
7c913512 | 65 | @param size |
4cc4bfaf | 66 | Window size. |
7c913512 | 67 | @param style |
4cc4bfaf | 68 | Window style. See wxStaticText. |
7c913512 | 69 | @param name |
4cc4bfaf | 70 | Window name. |
3c4f71cc | 71 | |
4cc4bfaf | 72 | @see Create() |
23324ae1 | 73 | */ |
7c913512 FM |
74 | wxStaticText(wxWindow* parent, wxWindowID id, |
75 | const wxString& label, | |
76 | const wxPoint& pos = wxDefaultPosition, | |
77 | const wxSize& size = wxDefaultSize, | |
78 | long style = 0, | |
79 | const wxString& name = "staticText"); | |
23324ae1 FM |
80 | |
81 | /** | |
82 | Creation function, for two-step construction. For details see wxStaticText(). | |
83 | */ | |
84 | bool Create(wxWindow* parent, wxWindowID id, | |
85 | const wxString& label, | |
86 | const wxPoint& pos = wxDefaultPosition, | |
87 | const wxSize& size = wxDefaultSize, | |
88 | long style = 0, | |
89 | const wxString& name = "staticText"); | |
90 | ||
91 | /** | |
92 | Returns the contents of the control. | |
23324ae1 FM |
93 | Note that the returned string contains both the mnemonics (@c characters), |
94 | if any, and markup tags, if any. | |
23324ae1 FM |
95 | Use GetLabelText() if only the |
96 | label text is needed. | |
97 | */ | |
328f5751 | 98 | wxString GetLabel() const; |
23324ae1 FM |
99 | |
100 | //@{ | |
101 | /** | |
102 | The first form returns the control's label without the mnemonics characters (if | |
7c913512 | 103 | any) |
23324ae1 | 104 | and without the markup (if the control has @c wxST_MARKUP style). |
4cc4bfaf | 105 | The second (static) version returns the given @a label string without the |
7c913512 | 106 | mnemonics |
23324ae1 FM |
107 | characters (if any) and without the markup. |
108 | */ | |
109 | wxString GetLabelText(); | |
328f5751 | 110 | const static wxString GetLabelText(const wxString& label); |
23324ae1 FM |
111 | //@} |
112 | ||
113 | /** | |
114 | Sets the static text label and updates the controls size to exactly fit the | |
115 | label unless the control has wxST_NO_AUTORESIZE flag. | |
23324ae1 FM |
116 | This function allows to set decorated static label text on platforms which |
117 | support it (currently only GTK+ 2). For the other platforms, the markup is | |
118 | ignored. | |
23324ae1 | 119 | The supported tags are: |
3c4f71cc | 120 | |
23324ae1 | 121 | b |
3c4f71cc | 122 | |
23324ae1 | 123 | bold text |
3c4f71cc | 124 | |
23324ae1 | 125 | big |
3c4f71cc | 126 | |
23324ae1 | 127 | bigger text |
3c4f71cc | 128 | |
23324ae1 | 129 | i |
3c4f71cc | 130 | |
23324ae1 | 131 | italic text |
3c4f71cc | 132 | |
23324ae1 | 133 | s |
3c4f71cc | 134 | |
23324ae1 | 135 | strike-through text |
3c4f71cc | 136 | |
23324ae1 | 137 | sub |
3c4f71cc | 138 | |
23324ae1 | 139 | subscript text |
3c4f71cc | 140 | |
23324ae1 | 141 | sup |
3c4f71cc | 142 | |
23324ae1 | 143 | superscript text |
3c4f71cc | 144 | |
23324ae1 | 145 | small |
3c4f71cc | 146 | |
23324ae1 | 147 | smaller text |
3c4f71cc | 148 | |
23324ae1 | 149 | tt |
3c4f71cc | 150 | |
23324ae1 | 151 | monospaced text |
3c4f71cc | 152 | |
23324ae1 | 153 | u |
3c4f71cc | 154 | |
23324ae1 | 155 | underlined text |
3c4f71cc | 156 | |
23324ae1 | 157 | span |
3c4f71cc | 158 | |
23324ae1 | 159 | generic formatter tag; see Pango Markup for more information. |
3c4f71cc | 160 | |
23324ae1 FM |
161 | Note that the string must be well-formed (e.g. all tags must be correctly |
162 | closed) | |
163 | otherwise it can be not shown correctly or at all. | |
23324ae1 | 164 | Also note that you need to escape the following special characters: |
3c4f71cc | 165 | |
23324ae1 | 166 | @b Special character |
3c4f71cc | 167 | |
23324ae1 | 168 | @b Escape as |
3c4f71cc | 169 | |
7c913512 | 170 | @c |
3c4f71cc | 171 | |
7c913512 | 172 | @c amp; or as @c |
3c4f71cc | 173 | |
23324ae1 | 174 | @c ' |
3c4f71cc | 175 | |
23324ae1 | 176 | @c apos; |
3c4f71cc | 177 | |
23324ae1 | 178 | @c " |
3c4f71cc | 179 | |
23324ae1 | 180 | @c quot; |
3c4f71cc | 181 | |
7c913512 | 182 | @c |
3c4f71cc | 183 | |
23324ae1 | 184 | @c lt; |
3c4f71cc | 185 | |
7c913512 | 186 | @c |
3c4f71cc | 187 | |
23324ae1 | 188 | @c gt; |
3c4f71cc | 189 | |
23324ae1 FM |
190 | The non-escaped ampersand @c characters are interpreted as |
191 | mnemonics; see wxControl::SetLabel. | |
3c4f71cc | 192 | |
23324ae1 | 193 | Example: |
3c4f71cc | 194 | |
7c913512 | 195 | @param label |
4cc4bfaf | 196 | The new label to set. It may contain newline characters and the markup tags |
23324ae1 FM |
197 | described above. |
198 | */ | |
199 | virtual void SetLabel(const wxString& label); | |
200 | ||
201 | /** | |
202 | This functions wraps the controls label so that each of its lines becomes at | |
4cc4bfaf | 203 | most @a width pixels wide if possible (the lines are broken at words |
23324ae1 | 204 | boundaries so it might not be the case if words are too long). If @e width |
cd3eb0f7 SN |
205 | is negative, no wrapping is done. Note that this width is not |
206 | necessarily the total width of the control, since a few pixels for the | |
207 | border (depending on the controls border style) may be added. | |
3c4f71cc | 208 | |
1e24c2af | 209 | @since 2.6.2 |
23324ae1 FM |
210 | */ |
211 | void Wrap(int width); | |
212 | }; | |
e54c96f1 | 213 |