1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: stattext.h 3 // Purpose: interface of wxStaticText 4 // Author: wxWidgets team 5 // Licence: wxWindows licence 6 ///////////////////////////////////////////////////////////////////////////// 7 8 #define wxST_NO_AUTORESIZE 0x0001 9 #define wxST_ELLIPSIZE_START 0x0004 10 #define wxST_ELLIPSIZE_MIDDLE 0x0008 11 #define wxST_ELLIPSIZE_END 0x0010 12 13 /** 14 @class wxStaticText 15 16 A static text control displays one or more lines of read-only text. 17 wxStaticText supports the three classic text alignments, label 18 ellipsization i.e. replacing parts of the text with the ellipsis ("...") if 19 the label doesn't fit into the provided space and also formatting markup 20 with wxControl::SetLabelMarkup(). 21 22 @beginStyleTable 23 @style{wxALIGN_LEFT} 24 Align the text to the left. 25 @style{wxALIGN_RIGHT} 26 Align the text to the right. 27 @style{wxALIGN_CENTRE_HORIZONTAL} 28 Center the text (horizontally). 29 @style{wxST_NO_AUTORESIZE} 30 By default, the control will adjust its size to exactly fit to the 31 size of the text when SetLabel() is called. If this style flag is 32 given, the control will not change its size (this style is 33 especially useful with controls which also have the @c wxALIGN_RIGHT or 34 the @c wxALIGN_CENTRE_HORIZONTAL style because otherwise they won't make sense any 35 longer after a call to SetLabel()). 36 @style{wxST_ELLIPSIZE_START} 37 If the labeltext width exceeds the control width, replace the beginning 38 of the label with an ellipsis; uses wxControl::Ellipsize. 39 @style{wxST_ELLIPSIZE_MIDDLE} 40 If the label text width exceeds the control width, replace the middle 41 of the label with an ellipsis; uses wxControl::Ellipsize. 42 @style{wxST_ELLIPSIZE_END} 43 If the label text width exceeds the control width, replace the end 44 of the label with an ellipsis; uses wxControl::Ellipsize. 45 @endStyleTable 46 47 @library{wxcore} 48 @category{ctrl} 49 @appearance{statictext} 50 51 @see wxStaticBitmap, wxStaticBox 52 */ 53 class wxStaticText : public wxControl 54 { 55 public: 56 /** 57 Default constructor. 58 */ 59 wxStaticText(); 60 61 /** 62 Constructor, creating and showing a text control. 63 64 @param parent 65 Parent window. Should not be @NULL. 66 @param id 67 Control identifier. A value of -1 denotes a default value. 68 @param label 69 Text label. 70 @param pos 71 Window position. 72 @param size 73 Window size. 74 @param style 75 Window style. See wxStaticText. 76 @param name 77 Window name. 78 79 @see Create() 80 */ 81 wxStaticText(wxWindow* parent, wxWindowID id, 82 const wxString& label, 83 const wxPoint& pos = wxDefaultPosition, 84 const wxSize& size = wxDefaultSize, 85 long style = 0, 86 const wxString& name = wxStaticTextNameStr); 87 88 /** 89 Creation function, for two-step construction. For details see wxStaticText(). 90 */ 91 bool Create(wxWindow* parent, wxWindowID id, const wxString& label, 92 const wxPoint& pos = wxDefaultPosition, 93 const wxSize& size = wxDefaultSize, long style = 0, 94 const wxString& name = wxStaticTextNameStr); 95 96 /** 97 Returns @true if the window styles for this control contains one of the 98 @c wxST_ELLIPSIZE_START, @c wxST_ELLIPSIZE_MIDDLE or @c wxST_ELLIPSIZE_END styles. 99 */ 100 bool IsEllipsized() const; 101 102 /** 103 Change the label shown in the control. 104 105 Notice that since wxWidgets 3.1.1 this function is guaranteed not to do 106 anything if the label didn't really change, so there is no benefit to 107 checking if the new label is different from the current one in the 108 application code. 109 110 @see wxControl::SetLabel() 111 */ 112 virtual void SetLabel(const wxString& label); 113 114 /** 115 This functions wraps the controls label so that each of its lines becomes at 116 most @a width pixels wide if possible (the lines are broken at words 117 boundaries so it might not be the case if words are too long). 118 119 If @a width is negative, no wrapping is done. Note that this width is not 120 necessarily the total width of the control, since a few pixels for the 121 border (depending on the controls border style) may be added. 122 123 @since 2.6.2 124 */ 125 void Wrap(int width); 126 }; 127 128