1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/stattext.h 3 // Purpose: wxStaticText base header 4 // Author: Julian Smart 5 // Modified by: 6 // Created: 7 // Copyright: (c) Julian Smart 8 // Licence: wxWindows licence 9 ///////////////////////////////////////////////////////////////////////////// 10 11 #ifndef _WX_STATTEXT_H_BASE_ 12 #define _WX_STATTEXT_H_BASE_ 13 14 #include "wx/defs.h" 15 16 #if wxUSE_STATTEXT 17 18 #include "wx/control.h" 19 20 /* 21 * wxStaticText flags 22 */ 23 #define wxST_NO_AUTORESIZE 0x0001 24 // free 0x0002 bit 25 #define wxST_ELLIPSIZE_START 0x0004 26 #define wxST_ELLIPSIZE_MIDDLE 0x0008 27 #define wxST_ELLIPSIZE_END 0x0010 28 29 #define wxST_ELLIPSIZE_MASK \ 30 (wxST_ELLIPSIZE_START | wxST_ELLIPSIZE_MIDDLE | wxST_ELLIPSIZE_END) 31 32 extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticTextNameStr[]; 33 34 class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl 35 { 36 public: wxStaticTextBase()37 wxStaticTextBase() { } 38 39 // wrap the text of the control so that no line is longer than the given 40 // width (if possible: this function won't break words) 41 // This function will modify the value returned by GetLabel()! 42 void Wrap(int width); 43 44 // overridden base virtuals AcceptsFocus()45 virtual bool AcceptsFocus() const wxOVERRIDE { return false; } HasTransparentBackground()46 virtual bool HasTransparentBackground() wxOVERRIDE { return true; } 47 IsEllipsized()48 bool IsEllipsized() const 49 { 50 return (GetWindowStyle() & wxST_ELLIPSIZE_MASK) != 0; 51 } 52 53 protected: // functions required for wxST_ELLIPSIZE_* support 54 55 // choose the default border for this window GetDefaultBorder()56 virtual wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_NONE; } 57 58 // Calls Ellipsize() on the real label if necessary. Unlike GetLabelText(), 59 // keeps the mnemonics instead of removing them. 60 virtual wxString GetEllipsizedLabel() const; 61 62 // Replaces parts of the string with ellipsis according to the ellipsize 63 // style. Shouldn't be called if we don't have any. 64 wxString Ellipsize(const wxString& label) const; 65 66 67 // Note that even though ports with native support for ellipsization 68 // (currently only wxGTK) don't need this stuff, we still need to define it 69 // as it's used by wxGenericStaticText. 70 71 // Must be called when the size or font changes to redo the ellipsization 72 // for the new size. Calls WXSetVisibleLabel() to actually update the 73 // display. 74 void UpdateLabel(); 75 76 // These functions are platform-specific and must be implemented in the 77 // platform-specific code. They must not use or update m_labelOrig. 78 79 // Returns the label currently displayed inside the control, with mnemonics 80 // if any. 81 virtual wxString WXGetVisibleLabel() const = 0; 82 83 // Sets the real label currently displayed inside the control, _without_ 84 // invalidating the size. The text passed is always markup-free but may 85 // contain the mnemonic characters. 86 virtual void WXSetVisibleLabel(const wxString& str) = 0; 87 88 // Update the current size to match the best size unless wxST_NO_AUTORESIZE 89 // style is explicitly used. 90 void AutoResizeIfNecessary(); 91 92 private: 93 wxDECLARE_NO_COPY_CLASS(wxStaticTextBase); 94 }; 95 96 // see wx/generic/stattextg.h for the explanation 97 #ifndef wxNO_PORT_STATTEXT_INCLUDE 98 99 #if defined(__WXUNIVERSAL__) 100 #include "wx/univ/stattext.h" 101 #elif defined(__WXMSW__) 102 #include "wx/msw/stattext.h" 103 #elif defined(__WXMOTIF__) 104 #include "wx/motif/stattext.h" 105 #elif defined(__WXGTK20__) 106 #include "wx/gtk/stattext.h" 107 #elif defined(__WXGTK__) 108 #include "wx/gtk1/stattext.h" 109 #elif defined(__WXMAC__) 110 #include "wx/osx/stattext.h" 111 #elif defined(__WXQT__) 112 #include "wx/qt/stattext.h" 113 #endif 114 115 #endif // !wxNO_PORT_STATTEXT_INCLUDE 116 117 #endif // wxUSE_STATTEXT 118 119 #endif // _WX_STATTEXT_H_BASE_ 120