stattext.h 4.1 KB

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