extract (and expand and clean up and document) the header window implementation used inside the generic wxDataViewCtrl in a separate wxHeaderCtrl class which could be reused in (generic) wxListCtrl and, most importantly, wxGrid later
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57093 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -18,13 +18,17 @@
|
||||
|
||||
#include "wx/control.h"
|
||||
#include "wx/textctrl.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/headercol.h"
|
||||
#include "wx/variant.h"
|
||||
#include "wx/dynarray.h"
|
||||
#include "wx/icon.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/weakref.h"
|
||||
|
||||
#if !(defined(__WXGTK20__) || defined(__WXMAC__)) || defined(__WXUNIVERSAL__)
|
||||
#define wxHAS_GENERIC_DATAVIEWCTRL
|
||||
#endif
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxDataFormat;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -495,15 +499,25 @@ DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
|
||||
// wxDataViewColumnBase
|
||||
// ---------------------------------------------------------
|
||||
|
||||
// for compatibility only, do not use
|
||||
enum wxDataViewColumnFlags
|
||||
{
|
||||
wxDATAVIEW_COL_RESIZABLE = 1,
|
||||
wxDATAVIEW_COL_SORTABLE = 2,
|
||||
wxDATAVIEW_COL_REORDERABLE = 4,
|
||||
wxDATAVIEW_COL_HIDDEN = 8
|
||||
wxDATAVIEW_COL_RESIZABLE = wxCOL_RESIZABLE,
|
||||
wxDATAVIEW_COL_SORTABLE = wxCOL_SORTABLE,
|
||||
wxDATAVIEW_COL_REORDERABLE = wxCOL_REORDERABLE,
|
||||
wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
|
||||
class WXDLLIMPEXP_ADV wxDataViewColumnBase : public
|
||||
// native implementations of wxDataViewCtrl have their own implementations of
|
||||
// wxDataViewColumnBase and so they need to only inherit from
|
||||
// wxHeaderColumnBase to provide the same interface as the generic port which
|
||||
// uses the platform native (if any) wxHeaderColumn
|
||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
wxHeaderColumn
|
||||
#else
|
||||
wxHeaderColumnBase
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
|
||||
@@ -517,49 +531,27 @@ public:
|
||||
virtual ~wxDataViewColumnBase();
|
||||
|
||||
// setters:
|
||||
|
||||
virtual void SetTitle( const wxString &title ) = 0;
|
||||
virtual void SetAlignment( wxAlignment align ) = 0;
|
||||
virtual void SetSortable( bool sortable ) = 0;
|
||||
virtual void SetReorderable(bool reorderable) = 0;
|
||||
virtual void SetResizeable( bool resizeable ) = 0;
|
||||
virtual void SetHidden( bool hidden ) = 0;
|
||||
virtual void SetSortOrder( bool ascending ) = 0;
|
||||
virtual void SetFlags( int flags );
|
||||
virtual void SetOwner( wxDataViewCtrl *owner )
|
||||
{ m_owner = owner; }
|
||||
virtual void SetBitmap( const wxBitmap &bitmap )
|
||||
{ m_bitmap=bitmap; }
|
||||
|
||||
virtual void SetMinWidth( int minWidth ) = 0;
|
||||
virtual void SetWidth( int width ) = 0;
|
||||
|
||||
|
||||
// getters:
|
||||
|
||||
virtual wxString GetTitle() const = 0;
|
||||
virtual wxAlignment GetAlignment() const = 0;
|
||||
virtual int GetWidth() const = 0;
|
||||
virtual int GetMinWidth() const = 0;
|
||||
|
||||
virtual int GetFlags() const;
|
||||
|
||||
virtual bool IsHidden() const = 0;
|
||||
virtual bool IsReorderable() const = 0;
|
||||
virtual bool IsResizeable() const = 0;
|
||||
virtual bool IsSortable() const = 0;
|
||||
virtual bool IsSortOrderAscending() const = 0;
|
||||
|
||||
const wxBitmap &GetBitmap() const { return m_bitmap; }
|
||||
unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
|
||||
|
||||
unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
|
||||
wxDataViewCtrl *GetOwner() const { return m_owner; }
|
||||
wxDataViewRenderer* GetRenderer() const { return m_renderer; }
|
||||
|
||||
#ifndef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
// implement some of base class pure virtuals (the rest is port-dependent
|
||||
// and done differently in generic and native versions)
|
||||
virtual void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
|
||||
virtual wxBitmap GetBitmap() const { return m_bitmap; }
|
||||
#endif // !wxHAS_GENERIC_DATAVIEWCTRL
|
||||
|
||||
protected:
|
||||
wxDataViewRenderer *m_renderer;
|
||||
int m_model_column;
|
||||
#ifndef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
wxBitmap m_bitmap;
|
||||
#endif // !wxHAS_GENERIC_DATAVIEWCTRL
|
||||
wxDataViewCtrl *m_owner;
|
||||
|
||||
protected:
|
||||
@@ -593,11 +585,11 @@ public:
|
||||
// short cuts
|
||||
wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
||||
@@ -609,7 +601,7 @@ public:
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
@@ -617,11 +609,11 @@ public:
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
||||
@@ -633,7 +625,7 @@ public:
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
@@ -642,11 +634,11 @@ public:
|
||||
|
||||
wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
||||
@@ -658,7 +650,7 @@ public:
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
@@ -666,11 +658,11 @@ public:
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
||||
@@ -682,7 +674,7 @@ public:
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
||||
wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
@@ -850,13 +842,20 @@ typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
|
||||
#define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
|
||||
|
||||
|
||||
#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
|
||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
// this symbol doesn't follow the convention for wxUSE_XXX symbols which
|
||||
// are normally always defined as either 0 or 1, so its use is deprecated
|
||||
// and it only exists for backwards compatibility, don't use it any more
|
||||
// and use wxHAS_GENERIC_DATAVIEWCTRL instead
|
||||
#define wxUSE_GENERICDATAVIEWCTRL
|
||||
|
||||
#include "wx/generic/dataview.h"
|
||||
#elif defined(__WXGTK20__)
|
||||
#include "wx/gtk/dataview.h"
|
||||
#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/osx/dataview.h"
|
||||
#else
|
||||
#define wxUSE_GENERICDATAVIEWCTRL
|
||||
#include "wx/generic/dataview.h"
|
||||
#error "unknown native wxDataViewCtrl implementation"
|
||||
#endif
|
||||
|
||||
// -------------------------------------
|
||||
|
@@ -299,12 +299,8 @@ protected:
|
||||
// wxDataViewColumn
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
|
||||
class WXDLLIMPEXP_ADV wxDataViewColumn : public wxDataViewColumnBase
|
||||
{
|
||||
friend class wxDataViewHeaderWindowBase;
|
||||
friend class wxDataViewHeaderWindow;
|
||||
friend class wxDataViewHeaderWindowMSW;
|
||||
|
||||
public:
|
||||
wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer,
|
||||
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
|
||||
@@ -314,59 +310,25 @@ public:
|
||||
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
virtual ~wxDataViewColumn();
|
||||
|
||||
// setters:
|
||||
// override some methods to notify the owner about changes
|
||||
virtual void SetFlags(int flags);
|
||||
virtual void SetWidth(int width);
|
||||
virtual void SetSortOrder(bool ascending);
|
||||
|
||||
virtual void SetTitle( const wxString &title )
|
||||
{ m_title=title; }
|
||||
virtual void SetAlignment( wxAlignment align )
|
||||
{ m_align=align; }
|
||||
virtual void SetMinWidth( int minWidth )
|
||||
{ m_minWidth=minWidth; }
|
||||
virtual void SetWidth( int width );
|
||||
virtual void SetSortable( bool sortable );
|
||||
virtual void SetResizeable( bool resizeable );
|
||||
virtual void SetHidden( bool hidden );
|
||||
virtual void SetSortOrder( bool ascending );
|
||||
virtual void SetReorderable( bool reorderable );
|
||||
|
||||
// getters:
|
||||
|
||||
virtual wxString GetTitle() const
|
||||
{ return m_title; }
|
||||
virtual wxAlignment GetAlignment() const
|
||||
{ return m_align; }
|
||||
virtual int GetWidth() const
|
||||
{ return m_width; }
|
||||
virtual int GetMinWidth() const
|
||||
{ return m_minWidth; }
|
||||
virtual bool IsSortable() const
|
||||
{ return (m_flags & wxDATAVIEW_COL_SORTABLE) != 0; }
|
||||
virtual bool IsResizeable() const
|
||||
{ return (m_flags & wxDATAVIEW_COL_RESIZABLE) != 0; }
|
||||
virtual bool IsHidden() const
|
||||
{ return (m_flags & wxDATAVIEW_COL_HIDDEN) != 0; }
|
||||
virtual bool IsSortOrderAscending() const;
|
||||
virtual bool IsReorderable() const
|
||||
{ return (m_flags & wxDATAVIEW_COL_REORDERABLE) != 0; }
|
||||
// override this one to return our default width for columns whose width
|
||||
// was not explicitly set
|
||||
virtual int GetWidth() const;
|
||||
|
||||
private:
|
||||
int m_width;
|
||||
int m_minWidth;
|
||||
int m_flags;
|
||||
wxAlignment m_align;
|
||||
wxString m_title;
|
||||
bool m_ascending;
|
||||
bool m_autosize;
|
||||
|
||||
void Init(int width);
|
||||
|
||||
// like SetWidth() but does not ask the header window of the
|
||||
// wxDataViewCtrl to reflect the width-change.
|
||||
void SetInternalWidth(int width);
|
||||
|
||||
protected:
|
||||
friend class wxDataViewHeaderWindowBase;
|
||||
friend class wxDataViewHeaderWindow;
|
||||
friend class wxDataViewHeaderWindowMSW;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
|
||||
};
|
||||
|
||||
|
@@ -323,6 +323,8 @@ public:
|
||||
|
||||
virtual void SetReorderable( bool reorderable );
|
||||
|
||||
virtual void SetFlags(int flags) { SetIndividualFlags(flags); }
|
||||
|
||||
// getters:
|
||||
|
||||
virtual wxString GetTitle() const;
|
||||
@@ -338,6 +340,8 @@ public:
|
||||
|
||||
virtual bool IsReorderable() const;
|
||||
|
||||
virtual int GetFlags() const { return GetFromIndividualFlags(); }
|
||||
|
||||
// implementation
|
||||
GtkWidget* GetGtkHandle() { return m_column; }
|
||||
GtkWidget* GetConstGtkHandle() const { return m_column; }
|
||||
|
172
include/wx/headercol.h
Normal file
172
include/wx/headercol.h
Normal file
@@ -0,0 +1,172 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/headercol.h
|
||||
// Purpose: declaration of wxHeaderColumn class
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-12-02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_HEADERCOL_H_
|
||||
#define _WX_HEADERCOL_H_
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
// special value for column width meaning unspecified/default
|
||||
wxCOL_WIDTH_DEFAULT = -1
|
||||
};
|
||||
|
||||
// bit masks for the various column attributes
|
||||
enum
|
||||
{
|
||||
// column can be resized (included in default flags)
|
||||
wxCOL_RESIZABLE = 1,
|
||||
|
||||
// column can be clicked to toggle the sort order by its contents
|
||||
wxCOL_SORTABLE = 2,
|
||||
|
||||
// column can be dragged to change its order (included in default)
|
||||
wxCOL_REORDERABLE = 4,
|
||||
|
||||
// column is not shown at all
|
||||
wxCOL_HIDDEN = 8,
|
||||
|
||||
// default flags for wxHeaderColumn ctor
|
||||
wxCOL_DEFAULT_FLAGS = wxCOL_RESIZABLE | wxCOL_REORDERABLE
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxHeaderColumnBase: interface for a column in a header of controls such as
|
||||
// wxListCtrl, wxDataViewCtrl or wxGrid
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxHeaderColumnBase : public wxObject
|
||||
{
|
||||
public:
|
||||
// ctors and dtor
|
||||
// --------------
|
||||
|
||||
/*
|
||||
Derived classes must provide ctors with the following signatures
|
||||
(notice that they shouldn't be explicit to allow passing strings/bitmaps
|
||||
directly to methods such wxHeaderCtrl::AppendColumn()):
|
||||
wxHeaderColumn(const wxString& title,
|
||||
int width = wxCOL_WIDTH_DEFAULT,
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxCOL_DEFAULT_FLAGS);
|
||||
wxHeaderColumn(const wxBitmap &bitmap,
|
||||
int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxCOL_DEFAULT_FLAGS);
|
||||
*/
|
||||
|
||||
|
||||
// setters and getters for various attributes
|
||||
// ------------------------------------------
|
||||
|
||||
// title is the string shown for this column
|
||||
virtual void SetTitle(const wxString& title) = 0;
|
||||
virtual wxString GetTitle() const = 0;
|
||||
|
||||
// bitmap shown (instead of text) in the column header
|
||||
virtual void SetBitmap(const wxBitmap& bitmap) = 0;
|
||||
virtual wxBitmap GetBitmap() const = 0; \
|
||||
|
||||
// width of the column in pixels, can be set to wxCOL_WIDTH_DEFAULT meaning
|
||||
// unspecified/default
|
||||
virtual void SetWidth(int width) = 0;
|
||||
virtual int GetWidth() const = 0;
|
||||
|
||||
// minimal width can be set for resizeable columns to forbid resizing them
|
||||
// below the specified size (set to 0 to remove)
|
||||
virtual void SetMinWidth(int minWidth) = 0;
|
||||
virtual int GetMinWidth() const = 0;
|
||||
|
||||
// alignment of the text: wxALIGN_CENTRE, wxALIGN_LEFT or wxALIGN_RIGHT
|
||||
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()
|
||||
// below to implement Set/GetFlags()
|
||||
|
||||
// set or retrieve all column flags at once: combination of wxCOL_XXX
|
||||
// values above
|
||||
virtual void SetFlags(int flags) = 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; }
|
||||
|
||||
|
||||
// wxCOL_RESIZABLE
|
||||
virtual void SetResizeable(bool resizeable)
|
||||
{ ChangeFlag(wxCOL_RESIZABLE, resizeable); }
|
||||
virtual bool IsResizeable() const
|
||||
{ return HasFlag(wxCOL_RESIZABLE); }
|
||||
|
||||
// wxCOL_SORTABLE
|
||||
virtual void SetSortable(bool sortable)
|
||||
{ ChangeFlag(wxCOL_SORTABLE, sortable); }
|
||||
virtual bool IsSortable() const
|
||||
{ return HasFlag(wxCOL_SORTABLE); }
|
||||
|
||||
// wxCOL_REORDERABLE
|
||||
virtual void SetReorderable(bool reorderable)
|
||||
{ ChangeFlag(wxCOL_REORDERABLE, reorderable); }
|
||||
virtual bool IsReorderable() const
|
||||
{ return HasFlag(wxCOL_REORDERABLE); }
|
||||
|
||||
// wxCOL_HIDDEN
|
||||
virtual void SetHidden(bool hidden)
|
||||
{ ChangeFlag(wxCOL_HIDDEN, hidden); }
|
||||
virtual bool IsHidden() const
|
||||
{ return HasFlag(wxCOL_HIDDEN); }
|
||||
|
||||
// for sortable columns indicate whether we should sort in ascending or
|
||||
// descending order
|
||||
virtual void SetSortOrder(bool ascending) = 0;
|
||||
void ToggleSortOrder() { SetSortOrder(!IsSortOrderAscending()); }
|
||||
virtual bool IsSortOrderAscending() const = 0;
|
||||
|
||||
protected:
|
||||
// helpers for the class overriding Set/IsXXX()
|
||||
void SetIndividualFlags(int flags);
|
||||
int GetFromIndividualFlags() const;
|
||||
};
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/msw/headercol.h"
|
||||
#else
|
||||
#define wxHAS_GENERIC_HEADERCOL
|
||||
#include "wx/generic/headercolg.h"
|
||||
#endif
|
||||
|
||||
#endif // _WX_HEADERCOL_H_
|
||||
|
142
include/wx/headerctrl.h
Normal file
142
include/wx/headerctrl.h
Normal file
@@ -0,0 +1,142 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/headerctrl.h
|
||||
// Purpose: wxHeaderCtrlBase class: interface of wxHeaderCtrl
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-12-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_HEADERCTRL_H_
|
||||
#define _WX_HEADERCTRL_H_
|
||||
|
||||
#include "wx/control.h"
|
||||
|
||||
#include "wx/headercol.h"
|
||||
|
||||
// notice that the classes in this header are defined in the core library even
|
||||
// although currently they're only used by wxGrid which is in wxAdv because we
|
||||
// plan to use it in wxListCtrl which is in core too in the future
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
// allow column drag and drop
|
||||
wxHD_DRAGDROP = 0x0001,
|
||||
|
||||
// style used by default when creating the control
|
||||
wxHD_DEFAULT_STYLE = wxHD_DRAGDROP
|
||||
};
|
||||
|
||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxHeaderCtrlNameStr[];
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxHeaderColumn;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxHeaderCtrlBase defines the interface of a header control
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxHeaderCtrlBase : public wxControl
|
||||
{
|
||||
public:
|
||||
/*
|
||||
Derived classes must provide default ctor as well as a ctor and
|
||||
Create() function with the following signatures:
|
||||
|
||||
wxHeaderCtrl(wxWindow *parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxHeaderCtrlNameStr);
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxHeaderCtrlNameStr);
|
||||
*/
|
||||
|
||||
// managing the columns
|
||||
// --------------------
|
||||
|
||||
// return the number of columns in the control
|
||||
unsigned int GetColumnCount() const { return DoGetCount(); }
|
||||
|
||||
// return whether the control has any columns
|
||||
bool IsEmpty() const { return GetColumnCount() == 0; }
|
||||
|
||||
// insert the column at the given position, using GetColumnCount() as
|
||||
// position appends it at the end
|
||||
void InsertColumn(const wxHeaderColumn& col, unsigned int idx)
|
||||
{
|
||||
wxCHECK_RET( idx <= GetColumnCount(), "invalid column index" );
|
||||
|
||||
DoInsert(col, idx);
|
||||
}
|
||||
|
||||
// append the column to the end of the control
|
||||
void AppendColumn(const wxHeaderColumn& col)
|
||||
{
|
||||
DoInsert(col, GetColumnCount());
|
||||
}
|
||||
|
||||
// delete the column at the given index
|
||||
void DeleteColumn(unsigned int idx)
|
||||
{
|
||||
wxCHECK_RET( idx < GetColumnCount(), "invalid column index" );
|
||||
|
||||
DoDelete(idx);
|
||||
}
|
||||
|
||||
// delete all the existing columns
|
||||
void DeleteAllColumns();
|
||||
|
||||
|
||||
// modifying columns
|
||||
// -----------------
|
||||
|
||||
// indicate that the column is used for sorting in ascending order if
|
||||
// sortOrder is true, for sorting in descending order if it is false or not
|
||||
// used for sorting at all if it is -1
|
||||
void ShowSortIndicator(unsigned int idx, int sortOrder)
|
||||
{
|
||||
wxCHECK_RET( sortOrder == 0 || sortOrder == 1 || sortOrder == -1,
|
||||
"invalid sort order value" );
|
||||
|
||||
DoShowSortIndicator(idx, sortOrder);
|
||||
}
|
||||
|
||||
// remove the sort indicator from the given column
|
||||
void RemoveSortIndicator(unsigned int idx)
|
||||
{
|
||||
DoShowSortIndicator(idx, -1);
|
||||
}
|
||||
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
// the user doesn't need to TAB to this control
|
||||
virtual bool AcceptsFocusFromKeyboard() const { return false; }
|
||||
|
||||
private:
|
||||
virtual unsigned int DoGetCount() const = 0;
|
||||
virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx) = 0;
|
||||
virtual void DoDelete(unsigned int idx) = 0;
|
||||
virtual void DoShowSortIndicator(unsigned int idx, int sortOrder) = 0;
|
||||
};
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/msw/headerctrl.h"
|
||||
#else // !native MSW
|
||||
#define wxHAS_GENERIC_HEADERCTRL
|
||||
#include "wx/generic/headerctrl.h"
|
||||
#endif // platform
|
||||
|
||||
#endif // _WX_HEADERCTRL_H_
|
77
include/wx/msw/headercol.h
Normal file
77
include/wx/msw/headercol.h
Normal file
@@ -0,0 +1,77 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/msw/headercol.h
|
||||
// Purpose: wxHeaderColumn implementation for MSW
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-12-02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_MSW_HEADERCOL_H_
|
||||
#define _WX_MSW_HEADERCOL_H_
|
||||
|
||||
struct wxHDITEM;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxHeaderColumn
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxHeaderColumn : public wxHeaderColumnBase
|
||||
{
|
||||
public:
|
||||
// ctors and dtor
|
||||
wxHeaderColumn(const wxString& title,
|
||||
int width = wxCOL_WIDTH_DEFAULT,
|
||||
wxAlignment align = wxALIGN_NOT,
|
||||
int flags = wxCOL_DEFAULT_FLAGS);
|
||||
wxHeaderColumn(const wxBitmap &bitmap,
|
||||
int width = wxCOL_WIDTH_DEFAULT,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxCOL_DEFAULT_FLAGS);
|
||||
|
||||
virtual ~wxHeaderColumn();
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual void SetTitle(const wxString& title);
|
||||
virtual wxString GetTitle() const;
|
||||
|
||||
virtual void SetBitmap(const wxBitmap& bitmap);
|
||||
wxBitmap GetBitmap() const;
|
||||
|
||||
virtual void SetWidth(int width);
|
||||
virtual int GetWidth() const;
|
||||
|
||||
virtual void SetMinWidth(int minWidth);
|
||||
virtual int GetMinWidth() const;
|
||||
|
||||
virtual void SetAlignment(wxAlignment align);
|
||||
virtual wxAlignment GetAlignment() const;
|
||||
|
||||
virtual void SetClientData(wxUIntPtr data);
|
||||
virtual wxUIntPtr GetClientData() const;
|
||||
|
||||
virtual void SetFlags(int flags);
|
||||
virtual int GetFlags() const;
|
||||
|
||||
|
||||
virtual void SetSortOrder(bool ascending);
|
||||
virtual bool IsSortOrderAscending() const;
|
||||
|
||||
|
||||
// MSW-specific implementation helpers
|
||||
wxHDITEM& GetHDI();
|
||||
const wxHDITEM& GetHDI() const
|
||||
{
|
||||
return const_cast<wxHeaderColumn *>(this)->GetHDI();
|
||||
}
|
||||
|
||||
private:
|
||||
// initialize m_impl
|
||||
void Init();
|
||||
|
||||
struct wxMSWHeaderColumnImpl *m_impl;
|
||||
};
|
||||
|
||||
#endif // _WX_MSW_HEADERCOL_H_
|
||||
|
72
include/wx/msw/headerctrl.h
Normal file
72
include/wx/msw/headerctrl.h
Normal file
@@ -0,0 +1,72 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/msw/headerctrl.h
|
||||
// Purpose: wxMSW native wxHeaderCtrl
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-12-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_MSW_HEADERCTRL_H_
|
||||
#define _WX_MSW_HEADERCTRL_H_
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxHeaderCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase
|
||||
{
|
||||
public:
|
||||
wxHeaderCtrl()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
wxHeaderCtrl(wxWindow *parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxHD_DEFAULT_STYLE,
|
||||
const wxString& name = wxHeaderCtrlNameStr)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxHD_DEFAULT_STYLE,
|
||||
const wxString& name = wxHeaderCtrlNameStr);
|
||||
|
||||
virtual ~wxHeaderCtrl();
|
||||
|
||||
private:
|
||||
// implement base class pure virtuals
|
||||
virtual unsigned int DoGetCount() const;
|
||||
virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx);
|
||||
virtual void DoDelete(unsigned int idx);
|
||||
virtual void DoShowSortIndicator(unsigned int idx, int sortOrder);
|
||||
|
||||
// override wxWindow methods which must be implemented by a new control
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
// override MSW-specific methods needed for new control
|
||||
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
||||
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// the image list: initially NULL, created on demand
|
||||
wxImageList *m_imageList;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxHeaderCtrl)
|
||||
};
|
||||
|
||||
#endif // _WX_MSW_HEADERCTRL_H_
|
||||
|
@@ -359,9 +359,13 @@ typedef struct _OSVERSIONINFOEX {
|
||||
#define NMHEADER HD_NOTIFY
|
||||
#endif
|
||||
|
||||
#ifndef HDS_FULLDRAG
|
||||
#define HDS_FULLDRAG 128
|
||||
#ifndef HDS_DRAGDROP
|
||||
#define HDS_DRAGDROP 0x0040
|
||||
#endif
|
||||
#ifndef HDS_FULLDRAG
|
||||
#define HDS_FULLDRAG 0x0080
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HDN_BEGINDRAG
|
||||
#define HDN_BEGINDRAG (HDN_FIRST - 11)
|
||||
|
@@ -242,8 +242,10 @@ private:
|
||||
// the common part of all ctors
|
||||
void Init();
|
||||
|
||||
// helper functions
|
||||
// helper functions: DoGetItem() doesn't work for hidden virtual root item
|
||||
// while DoGetPossiblyRootItem() does
|
||||
bool DoGetItem(wxTreeViewItem *tvItem) const;
|
||||
bool DoGetPossiblyRootItem(wxTreeViewItem *tvItem) const;
|
||||
void DoSetItem(wxTreeViewItem *tvItem);
|
||||
|
||||
void DoExpand(const wxTreeItemId& item, int flag);
|
||||
|
@@ -35,6 +35,17 @@ inline void wxSetCCUnicodeFormat(HWND WXUNUSED_IN_WINCE(hwnd))
|
||||
// this is implemented in msw/settings.cpp
|
||||
class wxFont;
|
||||
extern wxFont wxGetCCDefaultFont();
|
||||
#endif
|
||||
|
||||
// this is just a wrapper for HDITEM which we can't use in the public header
|
||||
// because we don't want to include commctrl.h (and hence windows.h) from there
|
||||
struct wxHDITEM : public HDITEM
|
||||
{
|
||||
wxHDITEM()
|
||||
{
|
||||
::ZeroMemory(this, sizeof(*this));
|
||||
}
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#endif // _WX_MSW_WRAPCCTL_H_
|
||||
|
@@ -387,18 +387,6 @@ public:
|
||||
{
|
||||
return false; // not implemented
|
||||
}
|
||||
virtual bool IsReorderable() const
|
||||
{
|
||||
return ((this->m_flags & wxDATAVIEW_COL_REORDERABLE) != 0);
|
||||
}
|
||||
virtual bool IsResizeable() const
|
||||
{
|
||||
return ((this->m_flags & wxDATAVIEW_COL_RESIZABLE) != 0);
|
||||
}
|
||||
virtual bool IsSortable() const
|
||||
{
|
||||
return ((this->m_flags & wxDATAVIEW_COL_SORTABLE) != 0);
|
||||
}
|
||||
virtual bool IsSortOrderAscending() const
|
||||
{
|
||||
return this->m_ascending;
|
||||
|
Reference in New Issue
Block a user