#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
-#endif
-
// ----------------------------------------------------------------------------
// 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
// the default minimal width of the columns:
#define wxDVC_DEFAULT_MINWIDTH 30
-// the default alignment of wxDataViewRenderers:
-#define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL)
+// The default alignment of wxDataViewRenderers is to take
+// the alignment from the column it owns.
+#define wxDVR_DEFAULT_ALIGNMENT -1
// ---------------------------------------------------------
virtual void Resort() = 0;
void SetOwner( wxDataViewModel *owner ) { m_owner = owner; }
- wxDataViewModel *GetOwner() { return m_owner; }
+ wxDataViewModel *GetOwner() const { return m_owner; }
private:
wxDataViewModel *m_owner;
virtual bool HasDefaultCompare() const { return false; }
// internal
- virtual bool IsIndexListModel() const { return false; }
+ virtual bool IsVirtualListModel() const { return false; }
protected:
// the user should not delete this class directly: he should use DecRef() instead!
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
// internal
- virtual bool IsIndexListModel() const { return true; }
+ virtual bool IsVirtualListModel() const { return false; }
unsigned int GetLastIndex() const { return m_lastIndex; }
private:
wxDataViewItemArray m_hash;
unsigned int m_lastIndex;
bool m_ordered;
- bool m_useHash;
};
+// ---------------------------------------------------------
+// wxDataViewVirtualListModel
+// ---------------------------------------------------------
+
+#ifdef __WXMAC__
+// better than nothing
+typedef wxDataViewIndexListModel wxDataViewVirtualListModel;
+#else
+
+class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewModel
+{
+public:
+ wxDataViewVirtualListModel( unsigned int initial_size = 0 );
+ ~wxDataViewVirtualListModel();
+
+ virtual void GetValue( wxVariant &variant,
+ unsigned int row, unsigned int col ) const = 0;
+
+ virtual bool SetValue( const wxVariant &variant,
+ unsigned int row, unsigned int col ) = 0;
+
+ virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
+ { return false; }
+
+ void RowPrepended();
+ void RowInserted( unsigned int before );
+ void RowAppended();
+ void RowDeleted( unsigned int row );
+ void RowsDeleted( const wxArrayInt &rows );
+ void RowChanged( unsigned int row );
+ void RowValueChanged( unsigned int row, unsigned int col );
+ void Reset( unsigned int new_size );
+
+ // convert to/from row/wxDataViewItem
+
+ unsigned int GetRow( const wxDataViewItem &item ) const;
+ wxDataViewItem GetItem( unsigned int row ) const;
+
+ // compare based on index
+
+ virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
+ unsigned int column, bool ascending );
+ virtual bool HasDefaultCompare() const;
+
+ // implement base methods
+
+ virtual void GetValue( wxVariant &variant,
+ const wxDataViewItem &item, unsigned int col ) const;
+ virtual bool SetValue( const wxVariant &variant,
+ const wxDataViewItem &item, unsigned int col );
+ virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
+ virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
+ virtual bool IsContainer( const wxDataViewItem &item ) const;
+ virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
+
+ // internal
+ virtual bool IsVirtualListModel() const { return true; }
+ unsigned int GetLastIndex() const { return m_lastIndex; }
+
+private:
+ wxDataViewItemArray m_hash;
+ unsigned int m_lastIndex;
+ bool m_ordered;
+};
+#endif
//-----------------------------------------------------------------------------
// wxDataViewEditorCtrlEvtHandler
protected:
void OnChar( wxKeyEvent &event );
+ void OnTextEnter( wxCommandEvent &event );
void OnKillFocus( wxFocusEvent &event );
void OnIdle( wxIdleEvent &event );
wxDataViewRendererBase( const wxString &varianttype,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int alignment = wxDVR_DEFAULT_ALIGNMENT );
+ ~wxDataViewRendererBase();
virtual bool Validate( wxVariant& WXUNUSED(value) )
{ return true; }
void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
- wxDataViewColumn* GetOwner() { return m_owner; }
+ wxDataViewColumn* GetOwner() const { return m_owner; }
// renderer properties:
protected:
wxString m_variantType;
wxDataViewColumn *m_owner;
- wxControl *m_editorCtrl;
+ wxWeakRef<wxControl> m_editorCtrl;
wxDataViewItem m_item; // for m_editorCtrl
// internal utility:
: 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; }
#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
{
virtual bool PrependColumn( wxDataViewColumn *col );
+ virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
virtual bool AppendColumn( wxDataViewColumn *col );
virtual unsigned int GetColumnCount() const = 0;
#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)
- #include "wx/generic/dataview.h"
-#elif defined(__WXGTK20__)
+
+#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/dataview.h"
-#elif defined(__WXMAC__)
- #include "wx/mac/dataview.h"
+#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
+ #include "wx/osx/dataview.h"
#else
+ #define wxUSE_GENERICDATAVIEWCTRL
#include "wx/generic/dataview.h"
#endif
long m_min,m_max;
};
+#ifndef __WXGTK20__
+
+// -------------------------------------
+// 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
//-----------------------------------------------------------------------------