1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/generic/stattextg.h 3 // Purpose: wxGenericStaticText header 4 // Author: Marcin Wojdyr 5 // Created: 2008-06-26 6 // Copyright: Marcin Wojdyr 7 // Licence: wxWindows licence 8 ///////////////////////////////////////////////////////////////////////////// 9 10 #ifndef _WX_GENERIC_STATTEXTG_H_ 11 #define _WX_GENERIC_STATTEXTG_H_ 12 13 // prevent it from including the platform-specific wxStaticText declaration as 14 // this is not going to compile if it derives from wxGenericStaticText defined 15 // below (currently this is only the case in wxUniv but it could also happen 16 // with other ports) 17 #define wxNO_PORT_STATTEXT_INCLUDE 18 #include "wx/stattext.h" 19 #undef wxNO_PORT_STATTEXT_INCLUDE 20 21 class WXDLLIMPEXP_CORE wxGenericStaticText : public wxStaticTextBase 22 { 23 public: wxGenericStaticText()24 wxGenericStaticText() { Init(); } 25 26 wxGenericStaticText(wxWindow *parent, 27 wxWindowID id, 28 const wxString& label, 29 const wxPoint& pos = wxDefaultPosition, 30 const wxSize& size = wxDefaultSize, 31 long style = 0, 32 const wxString& name = wxASCII_STR(wxStaticTextNameStr)) 33 { 34 Init(); 35 36 Create(parent, id, label, pos, size, style, name); 37 } 38 39 bool Create(wxWindow *parent, 40 wxWindowID id, 41 const wxString& label, 42 const wxPoint& pos = wxDefaultPosition, 43 const wxSize& size = wxDefaultSize, 44 long style = 0, 45 const wxString& name = wxASCII_STR(wxStaticTextNameStr)); 46 47 virtual ~wxGenericStaticText(); 48 49 50 // overridden base class virtual methods 51 virtual void SetLabel(const wxString& label) wxOVERRIDE; 52 virtual bool SetFont(const wxFont &font) wxOVERRIDE; 53 54 protected: 55 virtual wxSize DoGetBestClientSize() const wxOVERRIDE; 56 WXGetVisibleLabel()57 virtual wxString WXGetVisibleLabel() const wxOVERRIDE { return m_label; } 58 virtual void WXSetVisibleLabel(const wxString& label) wxOVERRIDE; 59 60 void DoSetSize(int x, int y, int width, int height, int sizeFlags) wxOVERRIDE; 61 62 #if wxUSE_MARKUP 63 virtual bool DoSetLabelMarkup(const wxString& markup) wxOVERRIDE; 64 #endif // wxUSE_MARKUP 65 66 private: Init()67 void Init() 68 { 69 #if wxUSE_MARKUP 70 m_markupText = NULL; 71 #endif // wxUSE_MARKUP 72 } 73 74 void OnPaint(wxPaintEvent& event); 75 76 void DoDrawLabel(wxDC& dc, const wxRect& rect); 77 78 // These fields are only used if m_markupText == NULL. 79 wxString m_label; 80 int m_mnemonic; 81 82 #if wxUSE_MARKUP 83 class wxMarkupText *m_markupText; 84 #endif // wxUSE_MARKUP 85 86 wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericStaticText); 87 }; 88 89 #endif // _WX_GENERIC_STATTEXTG_H_ 90 91