// wxListCtrl, wxDataViewCtrl or wxGrid
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxHeaderColumnBase : public wxObject
+class WXDLLIMPEXP_CORE wxHeaderColumnBase
{
public:
// ctors and dtor
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
// ------------------------------------------
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:
// --------------------
// 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
{ ChangeFlag(wxCOL_HIDDEN, hidden); }
virtual bool IsHidden() const
{ return HasFlag(wxCOL_HIDDEN); }
+ 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;
int GetFromIndividualFlags() const;
};
-#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
- #include "wx/msw/headercol.h"
-#elif 0 // TODO
- #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_