stattext.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef _WX_STATTEXT_H_BASE_
  11. #define _WX_STATTEXT_H_BASE_
  12. #include "wx/defs.h"
  13. #if wxUSE_STATTEXT
  14. #include "wx/control.h"
  15. /*
  16. * wxStaticText flags
  17. */
  18. #define wxST_NO_AUTORESIZE 0x0001
  19. // free 0x0002 bit
  20. #define wxST_ELLIPSIZE_START 0x0004
  21. #define wxST_ELLIPSIZE_MIDDLE 0x0008
  22. #define wxST_ELLIPSIZE_END 0x0010
  23. extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticTextNameStr[];
  24. class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl
  25. {
  26. public:
  27. wxStaticTextBase() { }
  28. // wrap the text of the control so that no line is longer than the given
  29. // width (if possible: this function won't break words)
  30. // This function will modify the value returned by GetLabel()!
  31. void Wrap(int width);
  32. // overridden base virtuals
  33. virtual bool AcceptsFocus() const { return false; }
  34. virtual bool HasTransparentBackground() { return true; }
  35. bool IsEllipsized() const
  36. {
  37. return HasFlag(wxST_ELLIPSIZE_START) ||
  38. HasFlag(wxST_ELLIPSIZE_MIDDLE) ||
  39. HasFlag(wxST_ELLIPSIZE_END);
  40. }
  41. protected: // functions required for wxST_ELLIPSIZE_* support
  42. // choose the default border for this window
  43. virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
  44. // Calls Ellipsize() on the real label if necessary. Unlike GetLabelText(),
  45. // keeps the mnemonics instead of removing them.
  46. virtual wxString GetEllipsizedLabel() const;
  47. // Replaces parts of the string with ellipsis according to the ellipsize
  48. // style. Shouldn't be called if we don't have any.
  49. wxString Ellipsize(const wxString& label) const;
  50. // to be called when updating the size of the static text:
  51. // updates the label redoing ellipsization calculations
  52. void UpdateLabel();
  53. // These functions are platform-specific and must be overridden in ports
  54. // which do not natively support ellipsization and they must be implemented
  55. // in a way so that the m_labelOrig member of wxControl is not touched:
  56. // returns the real label currently displayed inside the control.
  57. virtual wxString DoGetLabel() const { return wxEmptyString; }
  58. // sets the real label currently displayed inside the control,
  59. // _without_ invalidating the size. The text passed is always markup-free
  60. // but may contain the mnemonic characters.
  61. virtual void DoSetLabel(const wxString& WXUNUSED(str)) { }
  62. private:
  63. wxDECLARE_NO_COPY_CLASS(wxStaticTextBase);
  64. };
  65. // see wx/generic/stattextg.h for the explanation
  66. #ifndef wxNO_PORT_STATTEXT_INCLUDE
  67. #if defined(__WXUNIVERSAL__)
  68. #include "wx/univ/stattext.h"
  69. #elif defined(__WXMSW__)
  70. #include "wx/msw/stattext.h"
  71. #elif defined(__WXMOTIF__)
  72. #include "wx/motif/stattext.h"
  73. #elif defined(__WXGTK20__)
  74. #include "wx/gtk/stattext.h"
  75. #elif defined(__WXGTK__)
  76. #include "wx/gtk1/stattext.h"
  77. #elif defined(__WXMAC__)
  78. #include "wx/osx/stattext.h"
  79. #elif defined(__WXCOCOA__)
  80. #include "wx/cocoa/stattext.h"
  81. #elif defined(__WXPM__)
  82. #include "wx/os2/stattext.h"
  83. #endif
  84. #endif // !wxNO_PORT_STATTEXT_INCLUDE
  85. #endif // wxUSE_STATTEXT
  86. #endif // _WX_STATTEXT_H_BASE_