]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/headercol.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/headercol.h
3 // Purpose: interface of wxHeaderColumn
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows license
9 /////////////////////////////////////////////////////////////////////////////
12 Special value used for column width meaning unspecified or default.
14 enum { wxCOL_WIDTH_DEFAULT
= -1 };
17 Bit flags used as wxHeaderColumn flags.
21 /// Column can be resized (included in default flags).
24 /// Column can be clicked to toggle the sort order by its contents.
27 /// Column can be dragged to change its order (included in default).
28 wxCOL_REORDERABLE
= 4,
30 /// Column is not shown at all.
33 /// Default flags for wxHeaderColumn ctor.
34 wxCOL_DEFAULT_FLAGS
= wxCOL_RESIZABLE
| wxCOL_REORDERABLE
40 Represents a column header in controls displaying tabular data such as
41 wxHeaderCtrl, wxDataViewCtrl or wxGrid.
53 Constructor for a column header.
55 The first constructor creates a header showing the given text @a title
56 while the second one creates one showing the specified @a bitmap image.
58 wxHeaderColumn(const wxString
& title
,
59 int width
= wxCOL_WIDTH_DEFAULT
,
60 wxAlignment align
= wxALIGN_NOT
,
61 int flags
= wxCOL_DEFAULT_FLAGS
);
62 wxHeaderColumn(const wxBitmap
&bitmap
,
63 int width
= wxDVC_DEFAULT_WIDTH
,
64 wxAlignment align
= wxALIGN_CENTER
,
65 int flags
= wxCOL_DEFAULT_FLAGS
);
69 Set the text to display in the column header.
71 virtual void SetTitle(const wxString
& title
);
74 Get the text shown in the column header.
76 virtual wxString
GetTitle() const;
79 Set the bitmap to be displayed in the column header.
81 Notice that the bitmaps displayed in different columns of the same
82 control must all be of the same size.
84 virtual void SetBitmap(const wxBitmap
& bitmap
);
87 Returns the bitmap in the header of the column, if any.
89 If the column has no associated bitmap, wxNullBitmap is returned.
91 virtual wxBitmap
GetBitmap() const; \
97 The column width in pixels or the special wxCOL_WIDTH_DEFAULT value
98 meaning to use default width.
100 virtual void SetWidth(int width
);
103 Returns the current width of the column.
106 Width of the column in pixels, never wxCOL_WIDTH_DEFAULT.
108 virtual int GetWidth() const;
111 Set the minimal column width.
113 This method can be used with resizeable columns (i.e. those for which
114 wxCOL_RESIZABLE flag is set in GetFlags() or, alternatively,
115 IsResizeable() returns @true) to prevent the user from making them
116 narrower than the given width.
119 The minimal column width in pixels, may be 0 to remove any
120 previously set restrictions.
122 virtual void SetMinWidth(int minWidth
);
125 Return the minimal column width.
128 The value previously set by SetMinWidth() or 0 by default.
130 virtual int GetMinWidth() const;
133 Set the alignment of the column header.
136 The text alignment in horizontal direction only or wxALIGN_NOT to
137 use the default alignment, The possible values here are
138 wxALIGN_CENTRE, wxALIGN_LEFT or wxALIGN_RIGHT with
139 wxALIGN_CENTRE_HORIZONTAL being also supported as synonym for
140 wxALIGN_CENTRE for consistency (but notice that GetAlignment()
143 virtual void SetAlignment(wxAlignment align
);
146 Returns the current column alignment.
149 One of wxALIGN_CENTRE, wxALIGN_LEFT or wxALIGN_RIGHT.
151 virtual wxAlignment
GetAlignment() const;
154 // not documented because I'm not sure if it should be in the public API at
157 // arbitrary client data associated with the column (currently only
158 // implemented in MSW because it is used in MSW wxDataViewCtrl
160 virtual void SetClientData(wxUIntPtr data
);
161 virtual wxUIntPtr
GetClientData() const;
166 Set the column flags.
168 This method allows to set all flags at once, see also generic
169 ChangeFlag(), SetFlag(), ClearFlag() and ToggleFlag() methods below as
170 well as specific SetResizeable(), SetSortable(), SetReorderable() and
174 Combination of wxCOL_RESIZABLE, wxCOL_SORTABLE, wxCOL_REORDERABLE
175 and wxCOL_HIDDEN bit flags.
177 virtual void SetFlags(int flags
);
180 Set or clear the given flag.
183 The flag to set or clear.
185 If @true, set the flag, i.e. equivalent to calling SetFlag(),
186 otherwise clear it, as ClearFlag().
190 void ChangeFlag(int flag
, bool set
);
193 Set the specified flag for the column.
197 void SetFlag(int flag
);
200 Clear the specified flag for the column.
204 void ClearFlag(int flag
);
207 Toggle the specified flag for the column.
209 If the flag is currently set, equivalent to ClearFlag(), otherwise --
214 void ToggleFlag(int flag
);
217 Get the column flags.
219 This method retrieves all the flags at once, you can also use HasFlag()
220 to test for any individual flag or IsResizeable(), IsSortable(),
221 IsReorderable() and IsHidden() to test for particular flags.
225 virtual int GetFlags() const;
228 Return @true if the specified flag is currently set for this column.
230 bool HasFlag(int flag
) const;
234 Call this to enable or disable interactive resizing of the column by
237 By default, the columns are resizeable.
239 Equivalent to ChangeFlag(wxCOL_RESIZABLE, resizeable).
241 virtual void SetResizeable(bool resizeable
);
244 Return true if the column can be resized by the user.
246 Equivalent to HasFlag(wxCOL_RESIZABLE).
248 virtual bool IsResizeable() const;
251 Allow clicking the column to sort the control contents by the field in
254 By default, the columns are not sortable so you need to explicitly call
255 this function to allow sorting by the field corresponding to this
258 Equivalent to ChangeFlag(wxCOL_SORTABLE, sortable).
260 virtual void SetSortable(bool sortable
);
263 Returns @true if the column can be clicked by user to sort the control
264 contents by the field in this column.
266 This corresponds to wxCOL_SORTABLE flag which is off by default.
270 virtual bool IsSortable() const;
273 Allow changing the column order by dragging it.
275 Equivalent to ChangeFlag(wxCOL_REORDERABLE, reorderable).
277 virtual void SetReorderable(bool reorderable
);
280 Returns @true if the column can be dragged by user to change its order.
282 This corresponds to wxCOL_REORDERABLE flag which is on by default.
284 @see SetReorderable()
286 virtual bool IsReorderable() const;
289 Hide or show the column.
291 By default all columns are shown but some of them can be completely
292 hidden from view by calling this function.
294 Equivalent to ChangeFlag(wxCOL_HIDDEN, hidden).
296 virtual void SetHidden(bool hidden
);
299 Returns @true if the column is currently hidden.
301 This corresponds to wxCOL_HIDDEN flag which is off by default.
303 virtual bool IsHidden() const;
306 Sets the sort order for this column.
308 This only makes sense for sortable columns and is only taken into
309 account by the control in which this column is inserted, this function
310 just stores the sort order in the wxHeaderColumn object.
313 If @true, sort in ascending order, otherwise in descending order.
315 virtual void SetSortOrder(bool ascending
);
318 Inverses the sort order.
320 This function is typically called when the user clicks on a column used
321 for sorting to change sort order from ascending to descending or vice
324 @see SetSortOrder(), IsSortOrderAscending()
326 void ToggleSortOrder();
329 Returns @true, if the sort order is ascending.
333 virtual bool IsSortOrderAscending() const;