// Created: 2008-12-01
// RCS-ID: $Id$
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+
+enum
+{
+ // allow column drag and drop
+ wxHD_ALLOW_REORDER = 0x0001,
+
+ // allow hiding (and showing back) the columns using the menu shown by
+ // right clicking the header
+ wxHD_ALLOW_HIDE = 0x0002,
+
+ // style used by default when creating the control
+ wxHD_DEFAULT_STYLE = wxHD_ALLOW_REORDER
+};
+
+
+
/**
@class wxHeaderCtrl
@c wxHD_ALLOW_REORDER.
@endStyleTable
- @beginEventTable{wxHeaderCtrlEvent}
+ @beginEventEmissionTable{wxHeaderCtrlEvent}
@event{EVT_HEADER_CLICK(id, func)}
A column heading was clicked.
@event{EVT_HEADER_RIGHT_CLICK(id, func)}
@see wxGrid, wxListCtrl, wxDataViewCtrl
*/
-class wxHeaderCtrl
+class wxHeaderCtrl : public wxControl
{
public:
/**
@true if a column was shown or hidden or @false if nothing was
done, e.g. because the menu was cancelled.
*/
- int ShowColumnsMenu(const wxPoint& pt, const wxString& title = wxString());
+ bool ShowColumnsMenu(const wxPoint& pt, const wxString& title = wxString());
/**
Helper function appending the checkable items corresponding to all the
*/
bool ShowCustomizeDialog();
+ /**
+ Returns width needed for given column's title.
+
+ @since 2.9.4
+ */
+ int GetColumnTitleWidth(const wxHeaderColumn& col);
+
protected:
/**
Method to be implemented by the derived classes to return the
The column index, between 0 and the value last passed to
SetColumnCount().
*/
- virtual const wxHeaderColumnBase& GetColumn(unsigned int idx) const = 0;
+ virtual const wxHeaderColumn& GetColumn(unsigned int idx) const = 0;
/**
Method called when the column visibility is changed by the user.
to fit its width on header double click you need to implement this
method using logic similar to this example:
@code
- class MyHeaderCtrl : public wxHeaderColumnBase
+ class MyHeaderColumn : public wxHeaderColumn
{
public:
...
{
public:
protected:
- virtual wxHeaderColumnBase& GetColumn(unsigned int idx) const
+ virtual wxHeaderColumn& GetColumn(unsigned int idx) const
{
return m_cols[idx];
}
@see AppendColumn()
*/
- void InsertColumn(const wxHeaderColumn& col, unsigned int idx);
+ void InsertColumn(const wxHeaderColumnSimple& col, unsigned int idx);
/**
Append the column to the end of the control.
@see InsertColumn()
*/
- void AppendColumn(const wxHeaderColumn& col);
+ void AppendColumn(const wxHeaderColumnSimple& col);
/**
Delete the column at the given position.
@param idx
The column to set the sort indicator for.
+ If @c -1 is given, then the currently shown sort indicator
+ will be removed.
@param sortOrder
If @true or @false show the sort indicator corresponding to
- ascending or descending sort order respectively, if @c -1 remove
- the currently shown sort indicator.
+ ascending or descending sort order respectively.
*/
- virtual void ShowSortIndicator(unsigned int idx, int sortOrder);
+ void ShowSortIndicator(unsigned int idx, bool sortOrder = true);
/**
- Remove the sort indicator from the given column.
-
- This is the same as calling ShowSortIndicator() with @c -1 argument.
+ Remove the sort indicator from the column being used as sort key.
- @param idx
- The column to remove sort indicator for.
+ @see ShowSortIndicator
*/
- void RemoveSortIndicator(unsigned int idx);
+ void RemoveSortIndicator();
protected:
/**
Event class representing the events generated by wxHeaderCtrl.
@library{wxcore}
- @category{ctrl}
+ @category{events}
@see wxHeaderCtrl
*/
class wxHeaderCtrlEvent : public wxNotifyEvent
{
public:
+ wxHeaderCtrlEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
+ wxHeaderCtrlEvent(const wxHeaderCtrlEvent& event);
+
/**
Return the index of the column affected by this event.
This method can be called for all header control events.
*/
int GetColumn() const;
-
+ void SetColumn(int col);
+
/**
Return the current width of the column.
This method can only be called for the dragging events.
*/
int GetWidth() const;
-
+ void SetWidth(int width);
+
/**
Return the new order of the column.
- This method can only be called for end reorder event for which it
+ This method can only be called for a reorder event for which it
indicates the tentative new position for the column GetColumn()
selected by the user. If the event is not vetoed, this will become the
new column position in wxHeaderCtrl::GetColumnsOrder().
*/
unsigned int GetNewOrder() const;
+ void SetNewOrder(unsigned int order);
};
+
+
+
+wxEventType wxEVT_COMMAND_HEADER_CLICK;
+wxEventType wxEVT_COMMAND_HEADER_RIGHT_CLICK;
+wxEventType wxEVT_COMMAND_HEADER_MIDDLE_CLICK;
+wxEventType wxEVT_COMMAND_HEADER_DCLICK;
+wxEventType wxEVT_COMMAND_HEADER_RIGHT_DCLICK;
+wxEventType wxEVT_COMMAND_HEADER_MIDDLE_DCLICK;
+wxEventType wxEVT_COMMAND_HEADER_SEPARATOR_DCLICK;
+wxEventType wxEVT_COMMAND_HEADER_BEGIN_RESIZE;
+wxEventType wxEVT_COMMAND_HEADER_RESIZING;
+wxEventType wxEVT_COMMAND_HEADER_END_RESIZE;
+wxEventType wxEVT_COMMAND_HEADER_BEGIN_REORDER;
+wxEventType wxEVT_COMMAND_HEADER_END_REORDER;
+wxEventType wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED;