extract setters from wxHeaderColumnBase into a separate wxSettableHeaderColumn class as we don't always need to implement them in order to use this class; also renamed wxHeaderColumnBase to just wxHeaderColumn as we didn't have any wxHeaderColumn at all
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57246 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
953aebc2d5
commit
dcb6cbecc8
@ -508,7 +508,7 @@ enum wxDataViewColumnFlags
|
|||||||
wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN
|
wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLIMPEXP_ADV wxDataViewColumnBase : public wxHeaderColumnBase
|
class WXDLLIMPEXP_ADV wxDataViewColumnBase : public wxSettableHeaderColumn
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctor for the text columns: takes ownership of renderer
|
// ctor for the text columns: takes ownership of renderer
|
||||||
|
@ -43,11 +43,11 @@ enum
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxHeaderColumnBase: interface for a column in a header of controls such as
|
// wxHeaderColumn: interface for a column in a header of controls such as
|
||||||
// wxListCtrl, wxDataViewCtrl or wxGrid
|
// wxListCtrl, wxDataViewCtrl or wxGrid
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxHeaderColumnBase
|
class WXDLLIMPEXP_CORE wxHeaderColumn
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctors and dtor
|
// ctors and dtor
|
||||||
@ -69,80 +69,65 @@ public:
|
|||||||
|
|
||||||
// virtual dtor for the base class to avoid gcc warnings even though we
|
// 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
|
// don't normally delete the objects of this class via a pointer to
|
||||||
// wxHeaderColumnBase so it's not necessary, strictly speaking
|
// wxHeaderColumn so it's not necessary, strictly speaking
|
||||||
virtual ~wxHeaderColumnBase() { }
|
virtual ~wxHeaderColumn() { }
|
||||||
|
|
||||||
|
// getters for various attributes
|
||||||
|
// ------------------------------
|
||||||
|
|
||||||
// setters and getters for various attributes
|
// notice that wxHeaderColumn only provides getters as this is all the
|
||||||
// ------------------------------------------
|
// wxHeaderCtrl needs, various derived class must also provide some way to
|
||||||
|
// change these attributes but this can be done either at the column level
|
||||||
|
// (in which case they should inherit from wxSettableHeaderColumn) or via
|
||||||
|
// the methods of the main control in which case you don't need setters in
|
||||||
|
// the column class at all
|
||||||
|
|
||||||
// title is the string shown for this column
|
// title is the string shown for this column
|
||||||
virtual void SetTitle(const wxString& title) = 0;
|
|
||||||
virtual wxString GetTitle() const = 0;
|
virtual wxString GetTitle() const = 0;
|
||||||
|
|
||||||
// bitmap shown (instead of text) in the column header
|
// bitmap shown (instead of text) in the column header
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) = 0;
|
|
||||||
virtual wxBitmap GetBitmap() const = 0; \
|
virtual wxBitmap GetBitmap() const = 0; \
|
||||||
|
|
||||||
// width of the column in pixels, can be set to wxCOL_WIDTH_DEFAULT meaning
|
// width of the column in pixels, can be set to wxCOL_WIDTH_DEFAULT meaning
|
||||||
// unspecified/default
|
// unspecified/default
|
||||||
virtual void SetWidth(int width) = 0;
|
|
||||||
virtual int GetWidth() const = 0;
|
virtual int GetWidth() const = 0;
|
||||||
|
|
||||||
// minimal width can be set for resizeable columns to forbid resizing them
|
// minimal width can be set for resizeable columns to forbid resizing them
|
||||||
// below the specified size (set to 0 to remove)
|
// below the specified size (set to 0 to remove)
|
||||||
virtual void SetMinWidth(int minWidth) = 0;
|
|
||||||
virtual int GetMinWidth() const = 0;
|
virtual int GetMinWidth() const = 0;
|
||||||
|
|
||||||
// alignment of the text: wxALIGN_CENTRE, wxALIGN_LEFT or wxALIGN_RIGHT
|
// alignment of the text: wxALIGN_CENTRE, wxALIGN_LEFT or wxALIGN_RIGHT
|
||||||
virtual void SetAlignment(wxAlignment align) = 0;
|
|
||||||
virtual wxAlignment GetAlignment() const = 0;
|
virtual wxAlignment GetAlignment() const = 0;
|
||||||
|
|
||||||
|
|
||||||
// flags manipulations:
|
// flags manipulations:
|
||||||
// --------------------
|
// --------------------
|
||||||
|
|
||||||
// notice that while we make Set/GetFlags() pure virtual here and implement
|
// notice that while we make GetFlags() pure virtual here and implement the
|
||||||
// the individual flags access in terms of them, for some derived classes
|
// individual flags access in terms of it, for some derived classes it is
|
||||||
// it is more natural to implement access to each flag individually, in
|
// more natural to implement access to each flag individually, in which
|
||||||
// which case they can use SetIndividualFlags() and GetFromIndividualFlags()
|
// case they can use our GetFromIndividualFlags() helper below to implement
|
||||||
// below to implement Set/GetFlags()
|
// GetFlags()
|
||||||
|
|
||||||
// set or retrieve all column flags at once: combination of wxCOL_XXX
|
// retrieve all column flags at once: combination of wxCOL_XXX values above
|
||||||
// values above
|
|
||||||
virtual void SetFlags(int flags) = 0;
|
|
||||||
virtual int GetFlags() const = 0;
|
virtual int GetFlags() const = 0;
|
||||||
|
|
||||||
// change, set, clear, toggle or test for any individual flag
|
|
||||||
void ChangeFlag(int flag, bool set);
|
|
||||||
void SetFlag(int flag);
|
|
||||||
void ClearFlag(int flag);
|
|
||||||
void ToggleFlag(int flag);
|
|
||||||
|
|
||||||
bool HasFlag(int flag) const { return (GetFlags() & flag) != 0; }
|
bool HasFlag(int flag) const { return (GetFlags() & flag) != 0; }
|
||||||
|
|
||||||
|
|
||||||
// wxCOL_RESIZABLE
|
// wxCOL_RESIZABLE
|
||||||
virtual void SetResizeable(bool resizeable)
|
|
||||||
{ ChangeFlag(wxCOL_RESIZABLE, resizeable); }
|
|
||||||
virtual bool IsResizeable() const
|
virtual bool IsResizeable() const
|
||||||
{ return HasFlag(wxCOL_RESIZABLE); }
|
{ return HasFlag(wxCOL_RESIZABLE); }
|
||||||
|
|
||||||
// wxCOL_SORTABLE
|
// wxCOL_SORTABLE
|
||||||
virtual void SetSortable(bool sortable)
|
|
||||||
{ ChangeFlag(wxCOL_SORTABLE, sortable); }
|
|
||||||
virtual bool IsSortable() const
|
virtual bool IsSortable() const
|
||||||
{ return HasFlag(wxCOL_SORTABLE); }
|
{ return HasFlag(wxCOL_SORTABLE); }
|
||||||
|
|
||||||
// wxCOL_REORDERABLE
|
// wxCOL_REORDERABLE
|
||||||
virtual void SetReorderable(bool reorderable)
|
|
||||||
{ ChangeFlag(wxCOL_REORDERABLE, reorderable); }
|
|
||||||
virtual bool IsReorderable() const
|
virtual bool IsReorderable() const
|
||||||
{ return HasFlag(wxCOL_REORDERABLE); }
|
{ return HasFlag(wxCOL_REORDERABLE); }
|
||||||
|
|
||||||
// wxCOL_HIDDEN
|
// wxCOL_HIDDEN
|
||||||
virtual void SetHidden(bool hidden)
|
|
||||||
{ ChangeFlag(wxCOL_HIDDEN, hidden); }
|
|
||||||
virtual bool IsHidden() const
|
virtual bool IsHidden() const
|
||||||
{ return HasFlag(wxCOL_HIDDEN); }
|
{ return HasFlag(wxCOL_HIDDEN); }
|
||||||
bool IsShown() const
|
bool IsShown() const
|
||||||
@ -152,30 +137,67 @@ public:
|
|||||||
// sorting
|
// sorting
|
||||||
// -------
|
// -------
|
||||||
|
|
||||||
// set this column as the one used to sort the control
|
// return true if the column is the one currently used for sorting
|
||||||
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;
|
virtual bool IsSortKey() const = 0;
|
||||||
|
|
||||||
// for sortable columns indicate whether we should sort in ascending or
|
// for sortable columns indicate whether we should sort in ascending or
|
||||||
// descending order (this should only be taken into account if IsSortKey())
|
// 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;
|
virtual bool IsSortOrderAscending() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// helpers for the class overriding Set/IsXXX()
|
// helper for the class overriding IsXXX()
|
||||||
void SetIndividualFlags(int flags);
|
|
||||||
int GetFromIndividualFlags() const;
|
int GetFromIndividualFlags() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxHeaderColumnSimple: trivial generic implementation of wxHeaderColumnBase
|
// wxSettableHeaderColumn: column which allows to change its fields too
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxHeaderColumnSimple : public wxHeaderColumnBase
|
class wxSettableHeaderColumn : public wxHeaderColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void SetTitle(const wxString& title) = 0;
|
||||||
|
virtual void SetBitmap(const wxBitmap& bitmap) = 0;
|
||||||
|
virtual void SetWidth(int width) = 0;
|
||||||
|
virtual void SetMinWidth(int minWidth) = 0;
|
||||||
|
virtual void SetAlignment(wxAlignment align) = 0;
|
||||||
|
|
||||||
|
// see comment for wxHeaderColumn::GetFlags() about the relationship
|
||||||
|
// between SetFlags() and Set{Sortable,Reorderable,...}
|
||||||
|
|
||||||
|
// change, set, clear, toggle or test for any individual flag
|
||||||
|
virtual void SetFlags(int flags) = 0;
|
||||||
|
void ChangeFlag(int flag, bool set);
|
||||||
|
void SetFlag(int flag);
|
||||||
|
void ClearFlag(int flag);
|
||||||
|
void ToggleFlag(int flag);
|
||||||
|
|
||||||
|
virtual void SetResizeable(bool resizeable)
|
||||||
|
{ ChangeFlag(wxCOL_RESIZABLE, resizeable); }
|
||||||
|
virtual void SetSortable(bool sortable)
|
||||||
|
{ ChangeFlag(wxCOL_SORTABLE, sortable); }
|
||||||
|
virtual void SetReorderable(bool reorderable)
|
||||||
|
{ ChangeFlag(wxCOL_REORDERABLE, reorderable); }
|
||||||
|
virtual void SetHidden(bool hidden)
|
||||||
|
{ ChangeFlag(wxCOL_HIDDEN, hidden); }
|
||||||
|
|
||||||
|
virtual void SetAsSortKey(bool sort = true) = 0;
|
||||||
|
void UnsetAsSortKey() { SetAsSortKey(false); }
|
||||||
|
|
||||||
|
virtual void SetSortOrder(bool ascending) = 0;
|
||||||
|
void ToggleSortOrder() { SetSortOrder(!IsSortOrderAscending()); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// helper for the class overriding individual SetXXX() methods instead of
|
||||||
|
// overriding SetFlags()
|
||||||
|
void SetIndividualFlags(int flags);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxHeaderColumnSimple: trivial generic implementation of wxHeaderColumn
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxHeaderColumnSimple : public wxSettableHeaderColumn
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctors and dtor
|
// ctors and dtor
|
||||||
|
@ -113,7 +113,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// this method must be implemented by the derived classes to return the
|
// this method must be implemented by the derived classes to return the
|
||||||
// information for the given column
|
// information for the given column
|
||||||
virtual wxHeaderColumnBase& GetColumn(unsigned int idx) = 0;
|
virtual wxHeaderColumn& GetColumn(unsigned int idx) = 0;
|
||||||
|
|
||||||
// this method is called from the default EVT_HEADER_SEPARATOR_DCLICK
|
// this method is called from the default EVT_HEADER_SEPARATOR_DCLICK
|
||||||
// handler to update the fitting column width of the given column, it
|
// handler to update the fitting column width of the given column, it
|
||||||
@ -241,7 +241,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// implement/override base class methods
|
// implement/override base class methods
|
||||||
virtual wxHeaderColumnBase& GetColumn(unsigned int idx);
|
virtual wxHeaderColumn& GetColumn(unsigned int idx);
|
||||||
virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle);
|
virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle);
|
||||||
|
|
||||||
// and define another one to be overridden in the derived classes: it
|
// and define another one to be overridden in the derived classes: it
|
||||||
|
@ -42,9 +42,18 @@ enum
|
|||||||
|
|
||||||
Notice that this is an abstract base class which is implemented (usually
|
Notice that this is an abstract base class which is implemented (usually
|
||||||
using the information stored in the associated control) by the different
|
using the information stored in the associated control) by the different
|
||||||
controls using wxHeaderCtrl. You may use wxHeaderCtrlSimple which uses
|
controls using wxHeaderCtrl. As the control only needs to retrieve the
|
||||||
concrete wxHeaderColumnSimple if you don't already store the column
|
information about the column, this class defines only the methods for
|
||||||
information somewhere.
|
accessing the various column properties but not for changing them as the
|
||||||
|
setters might not be needed at all, e.g. if the column attributes can only
|
||||||
|
be changed via the methods of the main associated control (this is the case
|
||||||
|
for wxGrid for example). If you do want to allow changing them directly
|
||||||
|
using the column itself, you should inherit from wxSettableHeaderColumn
|
||||||
|
instead of this class.
|
||||||
|
|
||||||
|
Finally, if you don't already store the column information at all anywhere,
|
||||||
|
you should use the concrete wxHeaderColumnSimple class and
|
||||||
|
wxHeaderCtrlSimple.
|
||||||
|
|
||||||
@library{wxcore}
|
@library{wxcore}
|
||||||
@category{ctrl}
|
@category{ctrl}
|
||||||
@ -52,16 +61,132 @@ enum
|
|||||||
class wxHeaderColumn
|
class wxHeaderColumn
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
Set the text to display in the column header.
|
|
||||||
*/
|
|
||||||
virtual void SetTitle(const wxString& title) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the text shown in the column header.
|
Get the text shown in the column header.
|
||||||
*/
|
*/
|
||||||
virtual wxString GetTitle() const = 0;
|
virtual wxString GetTitle() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the bitmap in the header of the column, if any.
|
||||||
|
|
||||||
|
If the column has no associated bitmap, wxNullBitmap should be returned.
|
||||||
|
*/
|
||||||
|
virtual wxBitmap GetBitmap() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the current width of the column.
|
||||||
|
|
||||||
|
@return
|
||||||
|
Width of the column in pixels, never wxCOL_WIDTH_DEFAULT.
|
||||||
|
*/
|
||||||
|
virtual int GetWidth() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the minimal column width.
|
||||||
|
|
||||||
|
@return
|
||||||
|
The minimal width such that the user can't resize the column to
|
||||||
|
lesser size (notice that it is still possible to set the column
|
||||||
|
width to smaller value from the program code). Return 0 from here
|
||||||
|
to allow resizing the column to arbitrarily small size.
|
||||||
|
*/
|
||||||
|
virtual int GetMinWidth() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the current column alignment.
|
||||||
|
|
||||||
|
@return
|
||||||
|
One of wxALIGN_CENTRE, wxALIGN_LEFT or wxALIGN_RIGHT.
|
||||||
|
*/
|
||||||
|
virtual wxAlignment GetAlignment() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the column flags.
|
||||||
|
|
||||||
|
This method retrieves all the flags at once, you can also use HasFlag()
|
||||||
|
to test for any individual flag or IsResizeable(), IsSortable(),
|
||||||
|
IsReorderable() and IsHidden() to test for particular flags.
|
||||||
|
*/
|
||||||
|
virtual int GetFlags() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return @true if the specified flag is currently set for this column.
|
||||||
|
*/
|
||||||
|
bool HasFlag(int flag) const;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return true if the column can be resized by the user.
|
||||||
|
|
||||||
|
Equivalent to HasFlag(wxCOL_RESIZABLE).
|
||||||
|
*/
|
||||||
|
virtual bool IsResizeable() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns @true if the column can be clicked by user to sort the control
|
||||||
|
contents by the field in this column.
|
||||||
|
|
||||||
|
This corresponds to wxCOL_SORTABLE flag which is off by default.
|
||||||
|
*/
|
||||||
|
virtual bool IsSortable() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns @true if the column can be dragged by user to change its order.
|
||||||
|
|
||||||
|
This corresponds to wxCOL_REORDERABLE flag which is on by default.
|
||||||
|
*/
|
||||||
|
virtual bool IsReorderable() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns @true if the column is currently hidden.
|
||||||
|
|
||||||
|
This corresponds to wxCOL_HIDDEN flag which is off by default.
|
||||||
|
*/
|
||||||
|
virtual bool IsHidden() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns @true if the column is currently shown.
|
||||||
|
|
||||||
|
This corresponds to the absence of wxCOL_HIDDEN flag.
|
||||||
|
*/
|
||||||
|
bool IsShown() const;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns @true if the column is currently used for sorting.
|
||||||
|
*/
|
||||||
|
virtual bool IsSortKey() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns @true, if the sort order is ascending.
|
||||||
|
|
||||||
|
Notice that it only makes sense to call this function if the column is
|
||||||
|
used for sorting at all, i.e. if IsSortKey() returns @true.
|
||||||
|
*/
|
||||||
|
virtual bool IsSortOrderAscending() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class wxSettableHeaderColumn
|
||||||
|
|
||||||
|
Adds methods to set the column attributes to wxHeaderColumn.
|
||||||
|
|
||||||
|
This class adds setters for the column attributes defined by
|
||||||
|
wxHeaderColumn. It is still an abstract base class and needs to be
|
||||||
|
implemented before using it with wxHeaderCtrl.
|
||||||
|
|
||||||
|
@library{wxcore}
|
||||||
|
@category{ctrl}
|
||||||
|
*/
|
||||||
|
class wxSettableHeaderColumn : public wxHeaderColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
Set the text to display in the column header.
|
||||||
|
*/
|
||||||
|
virtual void SetTitle(const wxString& title) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the bitmap to be displayed in the column header.
|
Set the bitmap to be displayed in the column header.
|
||||||
|
|
||||||
@ -70,13 +195,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) = 0;
|
virtual void SetBitmap(const wxBitmap& bitmap) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the bitmap in the header of the column, if any.
|
|
||||||
|
|
||||||
If the column has no associated bitmap, wxNullBitmap is returned.
|
|
||||||
*/
|
|
||||||
virtual wxBitmap GetBitmap() const = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the column width.
|
Set the column width.
|
||||||
|
|
||||||
@ -86,14 +204,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void SetWidth(int width) = 0;
|
virtual void SetWidth(int width) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the current width of the column.
|
|
||||||
|
|
||||||
@return
|
|
||||||
Width of the column in pixels, never wxCOL_WIDTH_DEFAULT.
|
|
||||||
*/
|
|
||||||
virtual int GetWidth() const = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the minimal column width.
|
Set the minimal column width.
|
||||||
|
|
||||||
@ -108,14 +218,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void SetMinWidth(int minWidth) = 0;
|
virtual void SetMinWidth(int minWidth) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
Return the minimal column width.
|
|
||||||
|
|
||||||
@return
|
|
||||||
The value previously set by SetMinWidth() or 0 by default.
|
|
||||||
*/
|
|
||||||
virtual int GetMinWidth() const = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the alignment of the column header.
|
Set the alignment of the column header.
|
||||||
|
|
||||||
@ -129,14 +231,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void SetAlignment(wxAlignment align) = 0;
|
virtual void SetAlignment(wxAlignment align) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the current column alignment.
|
|
||||||
|
|
||||||
@return
|
|
||||||
One of wxALIGN_CENTRE, wxALIGN_LEFT or wxALIGN_RIGHT.
|
|
||||||
*/
|
|
||||||
virtual wxAlignment GetAlignment() const = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the column flags.
|
Set the column flags.
|
||||||
@ -189,22 +283,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void ToggleFlag(int flag);
|
void ToggleFlag(int flag);
|
||||||
|
|
||||||
/**
|
|
||||||
Get the column flags.
|
|
||||||
|
|
||||||
This method retrieves all the flags at once, you can also use HasFlag()
|
|
||||||
to test for any individual flag or IsResizeable(), IsSortable(),
|
|
||||||
IsReorderable() and IsHidden() to test for particular flags.
|
|
||||||
|
|
||||||
@see SetFlags()
|
|
||||||
*/
|
|
||||||
virtual int GetFlags() const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return @true if the specified flag is currently set for this column.
|
|
||||||
*/
|
|
||||||
bool HasFlag(int flag) const;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Call this to enable or disable interactive resizing of the column by
|
Call this to enable or disable interactive resizing of the column by
|
||||||
@ -216,13 +294,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void SetResizeable(bool resizeable);
|
virtual void SetResizeable(bool resizeable);
|
||||||
|
|
||||||
/**
|
|
||||||
Return true if the column can be resized by the user.
|
|
||||||
|
|
||||||
Equivalent to HasFlag(wxCOL_RESIZABLE).
|
|
||||||
*/
|
|
||||||
virtual bool IsResizeable() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allow clicking the column to sort the control contents by the field in
|
Allow clicking the column to sort the control contents by the field in
|
||||||
this column.
|
this column.
|
||||||
@ -235,16 +306,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void SetSortable(bool sortable);
|
virtual void SetSortable(bool sortable);
|
||||||
|
|
||||||
/**
|
|
||||||
Returns @true if the column can be clicked by user to sort the control
|
|
||||||
contents by the field in this column.
|
|
||||||
|
|
||||||
This corresponds to wxCOL_SORTABLE flag which is off by default.
|
|
||||||
|
|
||||||
@see SetSortable()
|
|
||||||
*/
|
|
||||||
virtual bool IsSortable() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allow changing the column order by dragging it.
|
Allow changing the column order by dragging it.
|
||||||
|
|
||||||
@ -252,15 +313,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void SetReorderable(bool reorderable);
|
virtual void SetReorderable(bool reorderable);
|
||||||
|
|
||||||
/**
|
|
||||||
Returns @true if the column can be dragged by user to change its order.
|
|
||||||
|
|
||||||
This corresponds to wxCOL_REORDERABLE flag which is on by default.
|
|
||||||
|
|
||||||
@see SetReorderable()
|
|
||||||
*/
|
|
||||||
virtual bool IsReorderable() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Hide or show the column.
|
Hide or show the column.
|
||||||
|
|
||||||
@ -271,21 +323,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void SetHidden(bool hidden);
|
virtual void SetHidden(bool hidden);
|
||||||
|
|
||||||
/**
|
|
||||||
Returns @true if the column is currently hidden.
|
|
||||||
|
|
||||||
This corresponds to wxCOL_HIDDEN flag which is off by default.
|
|
||||||
*/
|
|
||||||
virtual bool IsHidden() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns @true if the column is currently shown.
|
|
||||||
|
|
||||||
This corresponds to the absence of wxCOL_HIDDEN flag.
|
|
||||||
*/
|
|
||||||
bool IsShown() const;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets this column as the sort key for the associated control.
|
Sets this column as the sort key for the associated control.
|
||||||
@ -312,16 +349,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void UnsetAsSortKey();
|
void UnsetAsSortKey();
|
||||||
|
|
||||||
/**
|
|
||||||
Returns @true if the column is currently used for sorting.
|
|
||||||
|
|
||||||
Notice that this function simply returns the value last passed to
|
|
||||||
SetAsSortKey() (or @false if SetAsSortKey() had never been called), it
|
|
||||||
is up to the associated control to use this information to actually
|
|
||||||
sort its contents.
|
|
||||||
*/
|
|
||||||
virtual bool IsSortKey() const = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the sort order for this column.
|
Sets the sort order for this column.
|
||||||
|
|
||||||
@ -345,16 +372,6 @@ public:
|
|||||||
@see SetSortOrder(), IsSortOrderAscending()
|
@see SetSortOrder(), IsSortOrderAscending()
|
||||||
*/
|
*/
|
||||||
void ToggleSortOrder();
|
void ToggleSortOrder();
|
||||||
|
|
||||||
/**
|
|
||||||
Returns @true, if the sort order is ascending.
|
|
||||||
|
|
||||||
Notice that it only makes sense to call this function if the column is
|
|
||||||
used for sorting at all, i.e. if IsSortKey() returns @true.
|
|
||||||
|
|
||||||
@see SetSortOrder()
|
|
||||||
*/
|
|
||||||
virtual bool IsSortOrderAscending() const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -362,9 +379,9 @@ public:
|
|||||||
|
|
||||||
Simple container for the information about the column.
|
Simple container for the information about the column.
|
||||||
|
|
||||||
This is a concrete class implementing all base wxHeaderColumn class methods
|
This is a concrete class implementing all wxSettableHeaderColumn class
|
||||||
in a trivial way, i.e. by just storing the information in the object
|
methods in a trivial way, i.e. by just storing the information in the
|
||||||
itself. It is used by and with wxHeaderCtrlSimple, e.g.
|
object itself. It is used by and with wxHeaderCtrlSimple, e.g.
|
||||||
@code
|
@code
|
||||||
wxHeaderCtrlSimple * header = new wxHeaderCtrlSimple(...);
|
wxHeaderCtrlSimple * header = new wxHeaderCtrlSimple(...);
|
||||||
wxHeaderColumnSimple col("Title");
|
wxHeaderColumnSimple col("Title");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: src/common/headercolcmn.cpp
|
// Name: src/common/headercolcmn.cpp
|
||||||
// Purpose: wxHeaderColumnBase implementation
|
// Purpose: wxHeaderColumn implementation
|
||||||
// Author: Vadim Zeitlin
|
// Author: Vadim Zeitlin
|
||||||
// Created: 2008-12-02
|
// Created: 2008-12-02
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
@ -29,18 +29,10 @@
|
|||||||
#include "wx/headercol.h"
|
#include "wx/headercol.h"
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxHeaderColumnBase implementation
|
// wxHeaderColumn implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
void wxHeaderColumnBase::SetIndividualFlags(int flags)
|
int wxHeaderColumn::GetFromIndividualFlags() const
|
||||||
{
|
|
||||||
SetResizeable((flags & wxCOL_RESIZABLE) != 0);
|
|
||||||
SetSortable((flags & wxCOL_SORTABLE) != 0);
|
|
||||||
SetReorderable((flags & wxCOL_REORDERABLE) != 0);
|
|
||||||
SetHidden((flags & wxCOL_HIDDEN) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxHeaderColumnBase::GetFromIndividualFlags() const
|
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
@ -56,27 +48,39 @@ int wxHeaderColumnBase::GetFromIndividualFlags() const
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHeaderColumnBase::ChangeFlag(int flag, bool set)
|
// ============================================================================
|
||||||
|
// wxSettableHeaderColumn implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
void wxSettableHeaderColumn::SetIndividualFlags(int flags)
|
||||||
|
{
|
||||||
|
SetResizeable((flags & wxCOL_RESIZABLE) != 0);
|
||||||
|
SetSortable((flags & wxCOL_SORTABLE) != 0);
|
||||||
|
SetReorderable((flags & wxCOL_REORDERABLE) != 0);
|
||||||
|
SetHidden((flags & wxCOL_HIDDEN) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxSettableHeaderColumn::ChangeFlag(int flag, bool set)
|
||||||
{
|
{
|
||||||
if ( HasFlag(flag) != set )
|
if ( HasFlag(flag) != set )
|
||||||
ToggleFlag(flag);
|
ToggleFlag(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHeaderColumnBase::SetFlag(int flag)
|
void wxSettableHeaderColumn::SetFlag(int flag)
|
||||||
{
|
{
|
||||||
int flags = GetFlags();
|
int flags = GetFlags();
|
||||||
if ( !(flags & flag) )
|
if ( !(flags & flag) )
|
||||||
SetFlags(flags | flag);
|
SetFlags(flags | flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHeaderColumnBase::ClearFlag(int flag)
|
void wxSettableHeaderColumn::ClearFlag(int flag)
|
||||||
{
|
{
|
||||||
int flags = GetFlags();
|
int flags = GetFlags();
|
||||||
if ( flags & flag )
|
if ( flags & flag )
|
||||||
SetFlags(flags & ~flag);
|
SetFlags(flags & ~flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHeaderColumnBase::ToggleFlag(int flag)
|
void wxSettableHeaderColumn::ToggleFlag(int flag)
|
||||||
{
|
{
|
||||||
int flags = GetFlags();
|
int flags = GetFlags();
|
||||||
if ( flags & flag )
|
if ( flags & flag )
|
||||||
|
@ -149,7 +149,7 @@ void wxHeaderCtrlSimple::Init()
|
|||||||
m_sortKey = wxNO_COLUMN;
|
m_sortKey = wxNO_COLUMN;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxHeaderColumnBase& wxHeaderCtrlSimple::GetColumn(unsigned int idx)
|
wxHeaderColumn& wxHeaderCtrlSimple::GetColumn(unsigned int idx)
|
||||||
{
|
{
|
||||||
return m_cols[idx];
|
return m_cols[idx];
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// implement/override wxHeaderCtrl functions by forwarding them to the main
|
// implement/override wxHeaderCtrl functions by forwarding them to the main
|
||||||
// control
|
// control
|
||||||
virtual wxHeaderColumnBase& GetColumn(unsigned int idx)
|
virtual wxHeaderColumn& GetColumn(unsigned int idx)
|
||||||
{
|
{
|
||||||
return *(GetOwner()->GetColumn(idx));
|
return *(GetOwner()->GetColumn(idx));
|
||||||
}
|
}
|
||||||
@ -176,8 +176,10 @@ private:
|
|||||||
|
|
||||||
void OnEndResize(wxHeaderCtrlEvent& event)
|
void OnEndResize(wxHeaderCtrlEvent& event)
|
||||||
{
|
{
|
||||||
|
wxDataViewCtrl * const owner = GetOwner();
|
||||||
|
|
||||||
const unsigned col = event.GetColumn();
|
const unsigned col = event.GetColumn();
|
||||||
GetColumn(col).SetWidth(event.GetWidth());
|
owner->GetColumn(col)->SetWidth(event.GetWidth());
|
||||||
GetOwner()->OnColumnChange(col);
|
GetOwner()->OnColumnChange(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ int wxHeaderCtrl::GetColStart(unsigned int idx) const
|
|||||||
if ( i == idx )
|
if ( i == idx )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const wxHeaderColumnBase& col = self->GetColumn(i);
|
const wxHeaderColumn& col = self->GetColumn(i);
|
||||||
if ( col.IsShown() )
|
if ( col.IsShown() )
|
||||||
pos += col.GetWidth();
|
pos += col.GetWidth();
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ unsigned int wxHeaderCtrl::FindColumnAtPoint(int x, bool *onSeparator) const
|
|||||||
for ( unsigned n = 0; n < count; n++ )
|
for ( unsigned n = 0; n < count; n++ )
|
||||||
{
|
{
|
||||||
const unsigned idx = m_colIndices[n];
|
const unsigned idx = m_colIndices[n];
|
||||||
const wxHeaderColumnBase& col = self->GetColumn(idx);
|
const wxHeaderColumn& col = self->GetColumn(idx);
|
||||||
if ( col.IsHidden() )
|
if ( col.IsHidden() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -531,7 +531,7 @@ void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
for ( unsigned int i = 0; i < count; i++ )
|
for ( unsigned int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
const unsigned idx = m_colIndices[i];
|
const unsigned idx = m_colIndices[i];
|
||||||
const wxHeaderColumnBase& col = GetColumn(idx);
|
const wxHeaderColumn& col = GetColumn(idx);
|
||||||
if ( col.IsHidden() )
|
if ( col.IsHidden() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -2706,7 +2706,7 @@ bool wxDataViewColumn::IsSortable() const
|
|||||||
|
|
||||||
void wxDataViewColumn::SetAsSortKey( bool WXUNUSED(sort) )
|
void wxDataViewColumn::SetAsSortKey( bool WXUNUSED(sort) )
|
||||||
{
|
{
|
||||||
// it might not make sense to have this function in wxHeaderColumnBase at
|
// it might not make sense to have this function in wxHeaderColumn at
|
||||||
// all in fact, changing of the sort order should only be done using the
|
// all in fact, changing of the sort order should only be done using the
|
||||||
// associated control API
|
// associated control API
|
||||||
wxFAIL_MSG( "not implemented" );
|
wxFAIL_MSG( "not implemented" );
|
||||||
|
@ -172,7 +172,7 @@ void wxHeaderCtrl::DoUpdate(unsigned int idx)
|
|||||||
|
|
||||||
void wxHeaderCtrl::DoInsertItem(unsigned int idx, int order)
|
void wxHeaderCtrl::DoInsertItem(unsigned int idx, int order)
|
||||||
{
|
{
|
||||||
const wxHeaderColumnBase& col = GetColumn(idx);
|
const wxHeaderColumn& col = GetColumn(idx);
|
||||||
|
|
||||||
wxHDITEM hdi;
|
wxHDITEM hdi;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user