stattextg.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifndef _WX_GENERIC_STATTEXTG_H_
  10. #define _WX_GENERIC_STATTEXTG_H_
  11. // prevent it from including the platform-specific wxStaticText declaration as
  12. // this is not going to compile if it derives from wxGenericStaticText defined
  13. // below (currently this is only the case in wxUniv but it could also happen
  14. // with other ports)
  15. #define wxNO_PORT_STATTEXT_INCLUDE
  16. #include "wx/stattext.h"
  17. #undef wxNO_PORT_STATTEXT_INCLUDE
  18. class WXDLLIMPEXP_CORE wxGenericStaticText : public wxStaticTextBase
  19. {
  20. public:
  21. wxGenericStaticText() { Init(); }
  22. wxGenericStaticText(wxWindow *parent,
  23. wxWindowID id,
  24. const wxString& label,
  25. const wxPoint& pos = wxDefaultPosition,
  26. const wxSize& size = wxDefaultSize,
  27. long style = 0,
  28. const wxString& name = wxStaticTextNameStr)
  29. {
  30. Init();
  31. Create(parent, id, label, pos, size, style, name);
  32. }
  33. bool Create(wxWindow *parent,
  34. wxWindowID id,
  35. const wxString& label,
  36. const wxPoint& pos = wxDefaultPosition,
  37. const wxSize& size = wxDefaultSize,
  38. long style = 0,
  39. const wxString& name = wxStaticTextNameStr);
  40. virtual ~wxGenericStaticText();
  41. // overridden base class virtual methods
  42. virtual void SetLabel(const wxString& label);
  43. virtual bool SetFont(const wxFont &font);
  44. protected:
  45. virtual wxSize DoGetBestClientSize() const;
  46. virtual wxString DoGetLabel() const { return m_label; }
  47. virtual void DoSetLabel(const wxString& label);
  48. void DoSetSize(int x, int y, int width, int height, int sizeFlags);
  49. #if wxUSE_MARKUP
  50. virtual bool DoSetLabelMarkup(const wxString& markup);
  51. #endif // wxUSE_MARKUP
  52. private:
  53. void Init()
  54. {
  55. #if wxUSE_MARKUP
  56. m_markupText = NULL;
  57. #endif // wxUSE_MARKUP
  58. }
  59. void OnPaint(wxPaintEvent& event);
  60. void DoDrawLabel(wxDC& dc, const wxRect& rect);
  61. // These fields are only used if m_markupText == NULL.
  62. wxString m_label;
  63. int m_mnemonic;
  64. #if wxUSE_MARKUP
  65. class wxMarkupText *m_markupText;
  66. #endif // wxUSE_MARKUP
  67. DECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericStaticText)
  68. };
  69. #endif // _WX_GENERIC_STATTEXTG_H_