X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/af67f39da8ecf7c29ba5071ac49456d506c111cf..c29c95fe24973b94fd724db767193171ca7c513d:/interface/wx/headerctrl.h diff --git a/interface/wx/headerctrl.h b/interface/wx/headerctrl.h index 7f3a5ee756..718e02749a 100644 --- a/interface/wx/headerctrl.h +++ b/interface/wx/headerctrl.h @@ -5,7 +5,7 @@ // Created: 2008-12-01 // RCS-ID: $Id$ // Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** @@ -66,7 +66,7 @@ @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)} @@ -126,7 +126,7 @@ @see wxGrid, wxListCtrl, wxDataViewCtrl */ -class wxHeaderCtrl +class wxHeaderCtrl : public wxControl { public: /** @@ -325,7 +325,36 @@ 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 + columns to the given menu. + + This function is used by ShowColumnsMenu() but can also be used if you + show your own custom columns menu and still want all the columns shown + in it. It appends menu items with column labels as their text and + consecutive ids starting from @a idColumnsBase to the menu and checks + the items corresponding to the currently visible columns. + + Example of use: + @code + wxMenu menu; + menu.Append(100, "Some custom command"); + menu.AppendSeparator(); + AddColumnsItems(menu, 200); + const int rc = GetPopupMenuSelectionFromUser(menu, pt); + if ( rc >= 200 ) + ... toggle visibility of the column rc-200 ... + @endcode + + @param menu + The menu to append the items to. It may be currently empty or not. + @param idColumnsBase + The id for the menu item corresponding to the first column, the + other ones are consecutive starting from it. It should be positive. + */ + void AddColumnsItems(wxMenu& menu, int idColumnsBase = 0); /** Show the column customization dialog. @@ -354,7 +383,7 @@ protected: The column index, between 0 and the value last passed to SetColumnCount(). */ - virtual wxHeaderColumnBase& GetColumn(unsigned int idx) = 0; + virtual const wxHeaderColumn& GetColumn(unsigned int idx) const = 0; /** Method called when the column visibility is changed by the user. @@ -410,7 +439,7 @@ protected: 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: ... @@ -426,7 +455,7 @@ protected: { public: protected: - virtual wxHeaderColumnBase& GetColumn(unsigned int idx) + virtual wxHeaderColumn& GetColumn(unsigned int idx) const { return m_cols[idx]; } @@ -525,14 +554,14 @@ public: @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. @@ -578,22 +607,20 @@ public: @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: /** @@ -618,7 +645,7 @@ protected: Event class representing the events generated by wxHeaderCtrl. @library{wxcore} - @category{ctrl} + @category{events} @see wxHeaderCtrl */