X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b63f9a33301b1cead8b9ccbb16e2f50b0d82bbe9..0dd9646ea8b9e6f3a5fa8c42b6a4954cf8e3a48d:/include/wx/headercol.h?ds=inline diff --git a/include/wx/headercol.h b/include/wx/headercol.h index de5d1b0481..548298a831 100644 --- a/include/wx/headercol.h +++ b/include/wx/headercol.h @@ -47,7 +47,7 @@ enum // wxListCtrl, wxDataViewCtrl or wxGrid // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxHeaderColumnBase : public wxObject +class WXDLLIMPEXP_CORE wxHeaderColumnBase { public: // ctors and dtor @@ -67,6 +67,11 @@ public: int flags = wxCOL_DEFAULT_FLAGS); */ + // virtual dtor for the base class to avoid gcc warnings even though we + // don't normally delete the objects of this class via a pointer to + // wxHeaderColumnBase so it's not necessary, strictly speaking + virtual ~wxHeaderColumnBase() { } + // setters and getters for various attributes // ------------------------------------------ @@ -93,14 +98,6 @@ public: virtual void SetAlignment(wxAlignment align) = 0; virtual wxAlignment GetAlignment() const = 0; - // arbitrary client data associated with the column (currently only - // implemented in MSW because it is used in MSW wxDataViewCtrl - // implementation) - virtual void SetClientData(wxUIntPtr WXUNUSED(data)) - { wxFAIL_MSG("not implemented"); } - virtual wxUIntPtr GetClientData() const - { return 0; } - // flags manipulations: // -------------------- @@ -108,7 +105,7 @@ public: // notice that while we make Set/GetFlags() pure virtual here and implement // the individual flags access in terms of them, for some derived classes // it is more natural to implement access to each flag individually, in - // which case they can use SetIndividualFlags() and GetFromIndividualFlags() + // which case they can use SetIndividualFlags() and GetFromIndividualFlags() // below to implement Set/GetFlags() // set or retrieve all column flags at once: combination of wxCOL_XXX @@ -151,8 +148,19 @@ public: bool IsShown() const { return !IsHidden(); } + + // sorting + // ------- + + // set this column as the one used to sort the control + virtual void SetAsSortKey(bool sort = true) = 0; + void UnsetAsSortKey() { SetAsSortKey(false); } + + // return true if the column is used for sorting + virtual bool IsSortKey() const = 0; + // for sortable columns indicate whether we should sort in ascending or - // descending order + // descending order (this should only be taken into account if IsSortKey()) virtual void SetSortOrder(bool ascending) = 0; void ToggleSortOrder() { SetSortOrder(!IsSortOrderAscending()); } virtual bool IsSortOrderAscending() const = 0; @@ -163,12 +171,80 @@ protected: int GetFromIndividualFlags() const; }; -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - #include "wx/msw/headercol.h" -#else - #define wxHAS_GENERIC_HEADERCOL - #include "wx/generic/headercolg.h" -#endif +// ---------------------------------------------------------------------------- +// wxHeaderColumnSimple: trivial generic implementation of wxHeaderColumnBase +// ---------------------------------------------------------------------------- +class wxHeaderColumnSimple : public wxHeaderColumnBase +{ +public: + // ctors and dtor + wxHeaderColumnSimple(const wxString& title, + int width = wxCOL_WIDTH_DEFAULT, + wxAlignment align = wxALIGN_NOT, + int flags = wxCOL_DEFAULT_FLAGS) + : m_title(title), + m_width(width), + m_align(align), + m_flags(flags) + { + Init(); + } + + wxHeaderColumnSimple(const wxBitmap& bitmap, + int width = wxCOL_WIDTH_DEFAULT, + wxAlignment align = wxALIGN_CENTER, + int flags = wxCOL_DEFAULT_FLAGS) + : m_bitmap(bitmap), + m_width(width), + m_align(align), + m_flags(flags) + { + Init(); + } + + // implement base class pure virtuals + virtual void SetTitle(const wxString& title) { m_title = title; } + virtual wxString GetTitle() const { return m_title; } + + virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; } + wxBitmap GetBitmap() const { return m_bitmap; } + + virtual void SetWidth(int width) { m_width = width; } + virtual int GetWidth() const { return m_width; } + + virtual void SetMinWidth(int minWidth) { m_minWidth = minWidth; } + virtual int GetMinWidth() const { return m_minWidth; } + + virtual void SetAlignment(wxAlignment align) { m_align = align; } + virtual wxAlignment GetAlignment() const { return m_align; } + + virtual void SetFlags(int flags) { m_flags = flags; } + virtual int GetFlags() const { return m_flags; } + + virtual void SetAsSortKey(bool sort = true) { m_sort = sort; } + virtual bool IsSortKey() const { return m_sort; } + + virtual void SetSortOrder(bool ascending) { m_sortAscending = ascending; } + virtual bool IsSortOrderAscending() const { return m_sortAscending; } + +private: + // common part of all ctors + void Init() + { + m_minWidth = 0; + m_sort = false; + m_sortAscending = true; + } + + wxString m_title; + wxBitmap m_bitmap; + int m_width, + m_minWidth; + wxAlignment m_align; + int m_flags; + bool m_sort, + m_sortAscending; +}; #endif // _WX_HEADERCOL_H_