statusbr.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: statusbr.h
  3. // Purpose: interface of wxStatusBar
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. // wxStatusBar styles
  8. #define wxSTB_SIZEGRIP 0x0010
  9. #define wxSTB_SHOW_TIPS 0x0020
  10. #define wxSTB_ELLIPSIZE_START 0x0040
  11. #define wxSTB_ELLIPSIZE_MIDDLE 0x0080
  12. #define wxSTB_ELLIPSIZE_END 0x0100
  13. #define wxSTB_DEFAULT_STYLE (wxSTB_SIZEGRIP|wxSTB_ELLIPSIZE_END|wxSTB_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE)
  14. // style flags for wxStatusBar fields
  15. #define wxSB_NORMAL 0x0000
  16. #define wxSB_FLAT 0x0001
  17. #define wxSB_RAISED 0x0002
  18. #define wxSB_SUNKEN 0x0003
  19. /**
  20. @class wxStatusBarPane
  21. A status bar pane data container used by wxStatusBar.
  22. @library{wxcore}
  23. @category{data}
  24. @see wxStatusBar
  25. */
  26. class wxStatusBarPane
  27. {
  28. public:
  29. /**
  30. Constructs the pane with the given @a style and @a width.
  31. */
  32. wxStatusBarPane(int style = wxSB_NORMAL, int width = 0);
  33. /**
  34. Returns the pane width; it maybe negative, indicating a variable-width field.
  35. */
  36. int GetWidth() const;
  37. /**
  38. Returns the pane style.
  39. */
  40. int GetStyle() const;
  41. /**
  42. Returns the text currently shown in this pane.
  43. */
  44. wxString GetText() const;
  45. };
  46. /**
  47. @class wxStatusBar
  48. A status bar is a narrow window that can be placed along the bottom of a frame
  49. to give small amounts of status information. It can contain one or more fields,
  50. one or more of which can be variable length according to the size of the window.
  51. wxStatusBar also maintains an independent stack of status texts for each field
  52. (see PushStatusText() and PopStatusText()).
  53. Note that in wxStatusBar context, the terms @e pane and @e field are synonyms.
  54. @beginStyleTable
  55. @style{wxSTB_SIZEGRIP}
  56. Displays a gripper at the right-hand side of the status bar which can be used
  57. to resize the parent window.
  58. @style{wxSTB_SHOW_TIPS}
  59. Displays tooltips for those panes whose status text has been ellipsized/truncated
  60. because the status text doesn't fit the pane width.
  61. Note that this style has effect only on wxGTK (with GTK+ >= 2.12) currently.
  62. @style{wxSTB_ELLIPSIZE_START}
  63. Replace the beginning of the status texts with an ellipsis when the status text
  64. widths exceed the status bar pane's widths (uses wxControl::Ellipsize).
  65. @style{wxSTB_ELLIPSIZE_MIDDLE}
  66. Replace the middle of the status texts with an ellipsis when the status text
  67. widths exceed the status bar pane's widths (uses wxControl::Ellipsize).
  68. @style{wxSTB_ELLIPSIZE_END}
  69. Replace the end of the status texts with an ellipsis when the status text
  70. widths exceed the status bar pane's widths (uses wxControl::Ellipsize).
  71. @style{wxSTB_DEFAULT_STYLE}
  72. The default style: includes
  73. @c wxSTB_SIZEGRIP|wxSTB_SHOW_TIPS|wxSTB_ELLIPSIZE_END|wxFULL_REPAINT_ON_RESIZE.
  74. @endStyleTable
  75. @remarks
  76. It is possible to create controls and other windows on the status bar.
  77. Position these windows from an OnSize() event handler.
  78. @remarks
  79. Notice that only the first 127 characters of a string will be shown in
  80. status bar fields under pre-XP MSW systems (or even under later systems if
  81. a proper manifest indicating that the program uses version 6 of common
  82. controls library is not used). This is a limitation of the native control
  83. on these platforms.
  84. @library{wxcore}
  85. @category{miscwnd}
  86. @see wxStatusBarPane, wxFrame, @ref page_samples_statbar
  87. */
  88. class wxStatusBar : public wxControl
  89. {
  90. public:
  91. /**
  92. Default ctor.
  93. */
  94. wxStatusBar();
  95. /**
  96. Constructor, creating the window.
  97. @param parent
  98. The window parent, usually a frame.
  99. @param id
  100. The window identifier.
  101. It may take a value of -1 to indicate a default value.
  102. @param style
  103. The window style. See wxStatusBar.
  104. @param name
  105. The name of the window. This parameter is used to associate a name with the
  106. item, allowing the application user to set Motif resource values for
  107. individual windows.
  108. @see Create()
  109. */
  110. wxStatusBar(wxWindow* parent, wxWindowID id = wxID_ANY,
  111. long style = wxSTB_DEFAULT_STYLE,
  112. const wxString& name = wxStatusBarNameStr);
  113. /**
  114. Destructor.
  115. */
  116. virtual ~wxStatusBar();
  117. /**
  118. Creates the window, for two-step construction.
  119. See wxStatusBar() for details.
  120. */
  121. bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
  122. long style = wxSTB_DEFAULT_STYLE,
  123. const wxString& name = wxStatusBarNameStr);
  124. /**
  125. Returns the size and position of a field's internal bounding rectangle.
  126. @param i
  127. The field in question.
  128. @param rect
  129. The rectangle values are placed in this variable.
  130. @return @true if the field index is valid, @false otherwise.
  131. @beginWxPerlOnly
  132. In wxPerl this function returns a @c Wx::Rect if the field
  133. index is valid, @c undef otherwise.
  134. @endWxPerlOnly
  135. @see wxRect
  136. */
  137. virtual bool GetFieldRect(int i, wxRect& rect) const;
  138. /**
  139. Returns the number of fields in the status bar.
  140. */
  141. int GetFieldsCount() const;
  142. /**
  143. Returns the wxStatusBarPane representing the @a n-th field.
  144. */
  145. const wxStatusBarPane& GetField(int n) const;
  146. /**
  147. Returns the horizontal and vertical borders used when rendering the field
  148. text inside the field area.
  149. Note that the rect returned by GetFieldRect() already accounts for the
  150. presence of horizontal and vertical border returned by this function.
  151. */
  152. wxSize GetBorders() const;
  153. /**
  154. Returns the string associated with a status bar field.
  155. @param i
  156. The number of the status field to retrieve, starting from zero.
  157. @return The status field string if the field is valid, otherwise the
  158. empty string.
  159. @see SetStatusText()
  160. */
  161. virtual wxString GetStatusText(int i = 0) const;
  162. /**
  163. Returns the width of the @a n-th field.
  164. See wxStatusBarPane::GetWidth() for more info.
  165. */
  166. int GetStatusWidth(int n) const;
  167. /**
  168. Returns the style of the @a n-th field.
  169. See wxStatusBarPane::GetStyle() for more info.
  170. */
  171. int GetStatusStyle(int n) const;
  172. /**
  173. Restores the text to the value it had before the last call to
  174. PushStatusText().
  175. Notice that if SetStatusText() had been called in the meanwhile,
  176. PopStatusText() will not change the text, i.e. it does not override
  177. explicit changes to status text but only restores the saved text if it
  178. hadn't been changed since.
  179. @see PushStatusText()
  180. */
  181. void PopStatusText(int field = 0);
  182. /**
  183. Saves the current field text in a per-field stack, and sets the field
  184. text to the string passed as argument.
  185. @see PopStatusText()
  186. */
  187. void PushStatusText(const wxString& string, int field = 0);
  188. /**
  189. Sets the number of fields, and optionally the field widths.
  190. @param number
  191. The number of fields. If this is greater than the previous number,
  192. then new fields with empty strings will be added to the status bar.
  193. @param widths
  194. An array of n integers interpreted in the same way as
  195. in SetStatusWidths().
  196. @beginWxPerlOnly
  197. In wxPerl this function accepts only the @a number parameter.
  198. Use SetStatusWidths to set the field widths.
  199. @endWxPerlOnly
  200. */
  201. virtual void SetFieldsCount(int number = 1, const int* widths = NULL);
  202. /**
  203. Sets the minimal possible height for the status bar.
  204. The real height may be bigger than the height specified here depending
  205. on the size of the font used by the status bar.
  206. */
  207. virtual void SetMinHeight(int height);
  208. /**
  209. Sets the styles of the fields in the status line which can make fields appear
  210. flat or raised instead of the standard sunken 3D border.
  211. @param n
  212. The number of fields in the status bar. Must be equal to the
  213. number passed to SetFieldsCount() the last time it was called.
  214. @param styles
  215. Contains an array of @a n integers with the styles for each field.
  216. There are four possible styles:
  217. - @c wxSB_NORMAL (default): The field appears with the default native border.
  218. - @c wxSB_FLAT: No border is painted around the field so that it appears flat.
  219. - @c wxSB_RAISED: A raised 3D border is painted around the field.
  220. - @c wxSB_SUNKEN: A sunken 3D border is painted around the field
  221. (this style is new since wxWidgets 2.9.5).
  222. */
  223. virtual void SetStatusStyles(int n, const int* styles);
  224. /**
  225. Sets the status text for the @a i-th field.
  226. The given text will replace the current text.
  227. Note that if PushStatusText() had been called before the new text will
  228. also replace the last saved value to make sure that the next call to
  229. PopStatusText() doesn't restore the old value, which was overwritten by
  230. the call to this function.
  231. @param text
  232. The text to be set. Use an empty string ("") to clear the field.
  233. @param i
  234. The field to set, starting from zero.
  235. @see GetStatusText(), wxFrame::SetStatusText
  236. */
  237. virtual void SetStatusText(const wxString& text, int i = 0);
  238. /**
  239. Sets the widths of the fields in the status line. There are two types of
  240. fields: @b fixed widths and @b variable width fields. For the fixed width fields
  241. you should specify their (constant) width in pixels. For the variable width
  242. fields, specify a negative number which indicates how the field should expand:
  243. the space left for all variable width fields is divided between them according
  244. to the absolute value of this number. A variable width field with width of -2
  245. gets twice as much of it as a field with width -1 and so on.
  246. For example, to create one fixed width field of width 100 in the right part of
  247. the status bar and two more fields which get 66% and 33% of the remaining
  248. space correspondingly, you should use an array containing -2, -1 and 100.
  249. @param n
  250. The number of fields in the status bar. Must be equal to the
  251. number passed to SetFieldsCount() the last time it was called.
  252. @param widths_field
  253. Contains an array of n integers, each of which is either an
  254. absolute status field width in pixels if positive or indicates a
  255. variable width field if negative.
  256. The special value @NULL means that all fields should get the same width.
  257. @remarks The widths of the variable fields are calculated from the total
  258. width of all fields, minus the sum of widths of the
  259. non-variable fields, divided by the number of variable fields.
  260. @beginWxPerlOnly
  261. In wxPerl this method takes as parameters the field widths.
  262. @endWxPerlOnly
  263. @see SetFieldsCount(), wxFrame::SetStatusWidths()
  264. */
  265. virtual void SetStatusWidths(int n, const int* widths_field);
  266. };