#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"
-class WXDLLIMPEXP_FWD_CORE wxDataFormat;
-
-#if defined(__WXGTK20__)
- // for testing
- // #define wxUSE_GENERICDATAVIEWCTRL 1
-#elif defined(__WXMAC__)
-#else
- #define wxUSE_GENERICDATAVIEWCTRL 1
+#if !(defined(__WXGTK20__) || defined(__WXMAC__)) || defined(__WXUNIVERSAL__)
+// #if !(defined(__WXMAC__)) || defined(__WXUNIVERSAL__)
+ #define wxHAS_GENERIC_DATAVIEWCTRL
#endif
+class WXDLLIMPEXP_FWD_CORE wxDataFormat;
+
// ----------------------------------------------------------------------------
// wxDataViewCtrl flags
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
-extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[];
+extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[];
// the default width of new (text) columns:
#define wxDVC_DEFAULT_WIDTH 80
wxDataViewItemArray m_hash;
unsigned int m_lastIndex;
bool m_ordered;
- bool m_useHash;
};
// ---------------------------------------------------------
protected:
void OnChar( wxKeyEvent &event );
+ void OnTextEnter( wxCommandEvent &event );
void OnKillFocus( wxFocusEvent &event );
void OnIdle( wxIdleEvent &event );
: m_text(text), m_icon(icon)
{ }
wxDataViewIconText( const wxDataViewIconText &other )
+ : wxObject()
{ m_icon = other.m_icon; m_text = other.m_text; }
void SetText( const wxString &text ) { m_text = text; }
// 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 wxSettableHeaderColumn
{
public:
- wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
- unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
- wxAlignment align = wxALIGN_CENTER,
- int flags = wxDATAVIEW_COL_RESIZABLE );
- wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
- unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
- wxAlignment align = wxALIGN_CENTER,
- int flags = wxDATAVIEW_COL_RESIZABLE );
+ // ctor for the text columns: takes ownership of renderer
+ wxDataViewColumnBase(wxDataViewRenderer *renderer,
+ unsigned int model_column)
+ {
+ Init(renderer, model_column);
+ }
+
+ // ctor for the bitmap columns
+ wxDataViewColumnBase(const wxBitmap& bitmap,
+ wxDataViewRenderer *renderer,
+ unsigned int model_column)
+ : m_bitmap(bitmap)
+ {
+ Init(renderer, model_column);
+ }
+
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; }
+ // 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; }
+
protected:
wxDataViewRenderer *m_renderer;
int m_model_column;
wxBitmap m_bitmap;
wxDataViewCtrl *m_owner;
-protected:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
+private:
+ // common part of all ctors
+ void Init(wxDataViewRenderer *renderer, unsigned int model_column);
};
// ---------------------------------------------------------
#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
#define wxDV_ROW_LINES 0x0010 // alternating colour in rows
+#define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
{
// 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,
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,
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,
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,
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,
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,
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,
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,
virtual bool PrependColumn( wxDataViewColumn *col );
+ virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
virtual bool AppendColumn( wxDataViewColumn *col );
virtual unsigned int GetColumnCount() const = 0;
virtual void UnselectAll() = 0;
virtual void Expand( const wxDataViewItem & item ) = 0;
+ virtual void ExpandAncestors( const wxDataViewItem & item );
virtual void Collapse( const wxDataViewItem & item ) = 0;
+ virtual bool IsExpanded( const wxDataViewItem & item ) const = 0;
virtual void EnsureVisible( const wxDataViewItem & item,
const wxDataViewColumn *column = NULL ) = 0;
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
};
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED;
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent )
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED;
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent )
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU;
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent )
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED;
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent )
typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
#define wxDataViewEventHandler(func) \
- (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
+ wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
#define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
-#if defined(wxUSE_GENERICDATAVIEWCTRL)
+
+#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__)
- #include "wx/mac/dataview.h"
+ #include "wx/osx/dataview.h"
#else
- #include "wx/generic/dataview.h"
+ #error "unknown native wxDataViewCtrl implementation"
#endif
// -------------------------------------
long m_min,m_max;
};
+#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXMAC__)
+
+// -------------------------------------
+// wxDataViewChoiceRenderer
+// -------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
+{
+public:
+ wxDataViewChoiceRenderer( const wxArrayString &choices,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
+ int alignment = wxDVR_DEFAULT_ALIGNMENT );
+ virtual bool HasEditorCtrl() { return true; }
+ virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
+ virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
+ virtual bool Render( wxRect rect, wxDC *dc, int state );
+ virtual wxSize GetSize() const;
+ virtual bool SetValue( const wxVariant &value );
+ virtual bool GetValue( wxVariant &value ) const;
+
+private:
+ wxArrayString m_choices;
+ wxString m_data;
+};
+
+#endif
+
//-----------------------------------------------------------------------------
// wxDataViewTreeStore
//-----------------------------------------------------------------------------