]> git.saurik.com Git - wxWidgets.git/commitdiff
Big wxDataViewCtrl renderer classes refactoring.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 10 Nov 2009 17:40:58 +0000 (17:40 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 10 Nov 2009 17:40:58 +0000 (17:40 +0000)
This commit adds no changes in functionality but paves way for the upcoming
improvements of wxDataViewCustomRenderer.

First, introduce wxDataViewCustomRendererBase class in order to allow
implementing behaviour common to custom renderers in all ports in this class
instead of triplicating it.

This required splitting monolithic dataview.h in more parts, now we have
wx/dvrenderer.h which defines wxDataViewRendererBase and the new
wxDataViewCustomRendererBase and includes wx/port/dvrenderer.h which define
wxDataViewRenderer and wx/port/dvrenderers.h which defines all the other
renderer classes.

Also bring renderers hierarchy in the generic version closer to other ports:
all standard renderer classes now inherit from wxDataViewRenderer and not
wxDataViewCustomRenderer in for consistency with the other ports.
wxDataViewRenderer itself still does derive from wxDataViewCustomRendererBase,
unlike elsewhere, but this is unavoidable considering that all generic
renderers are custom ones.

Finally do some cleanup in OS X part of the code: correct indentation,
spacing, comment style.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62589 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

25 files changed:
Makefile.in
build/bakefiles/files.bkl
build/msw/wx_adv.dsp
build/msw/wx_core.dsp
build/msw/wx_vc7_adv.vcproj
build/msw/wx_vc7_core.vcproj
build/msw/wx_vc8_adv.vcproj
build/msw/wx_vc8_core.vcproj
build/msw/wx_vc9_adv.vcproj
build/msw/wx_vc9_core.vcproj
include/wx/dataview.h
include/wx/dvrenderers.h [new file with mode: 0644]
include/wx/generic/dataview.h
include/wx/generic/dvrenderer.h [new file with mode: 0644]
include/wx/generic/dvrenderers.h [new file with mode: 0644]
include/wx/gtk/dataview.h
include/wx/gtk/dvrenderer.h [new file with mode: 0644]
include/wx/gtk/dvrenderers.h [new file with mode: 0644]
include/wx/osx/dataview.h
include/wx/osx/dvrenderer.h [new file with mode: 0644]
include/wx/osx/dvrenderers.h [new file with mode: 0644]
src/generic/datavgen.cpp
src/gtk/dataview.cpp
src/osx/carbon/dataview.cpp
src/osx/cocoa/dataview.mm

index 096a307fe37c1cc7feb80ab3a83215ba81adacc5..6d634b5985426a31486e8aa8e26c2eae4fd36968 100644 (file)
@@ -3400,6 +3400,8 @@ COND_TOOLKIT_MOTIF_ADVANCED_PLATFORM_HDR =  \
 COND_TOOLKIT_OSX_CARBON_ADVANCED_PLATFORM_HDR =  \
        wx/generic/animate.h \
        wx/osx/dataview.h \
+       wx/osx/dvrenderer.h \
+       wx/osx/dvrenderers.h \
        wx/osx/joystick.h \
        wx/osx/sound.h \
        wx/osx/taskbarosx.h \
@@ -3410,6 +3412,8 @@ COND_TOOLKIT_OSX_CARBON_ADVANCED_PLATFORM_HDR =  \
 COND_TOOLKIT_OSX_COCOA_ADVANCED_PLATFORM_HDR =  \
        wx/generic/animate.h \
        wx/osx/dataview.h \
+       wx/osx/dvrenderer.h \
+       wx/osx/dvrenderers.h \
        wx/osx/joystick.h \
        wx/osx/sound.h \
        wx/osx/taskbarosx.h \
@@ -3427,6 +3431,8 @@ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_ADVANCED_PLATFORM_NATIVE_HDR =  \
        wx/gtk/bmpcbox.h \
        wx/gtk/calctrl.h \
        wx/gtk/dataview.h \
+       wx/gtk/dvrenderer.h \
+       wx/gtk/dvrenderers.h \
        wx/gtk/hyperlink.h \
        wx/gtk/infobar.h
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ADVANCED_PLATFORM_NATIVE_HDR = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_ADVANCED_PLATFORM_NATIVE_HDR)
@@ -3445,12 +3451,15 @@ COND_WXUNIV_0_ADVANCED_HDR =  \
        wx/datectrl.h \
        wx/dateevt.h \
        wx/dcbuffer.h \
+       wx/dvrenderers.h \
        wx/editlbox.h \
        wx/generic/aboutdlgg.h \
        wx/generic/bmpcbox.h \
        wx/generic/calctrlg.h \
        wx/generic/datectrl.h \
        wx/generic/dataview.h \
+       wx/generic/dvrenderer.h \
+       wx/generic/dvrenderers.h \
        wx/generic/grid.h \
        wx/generic/gridctrl.h \
        wx/generic/grideditors.h \
@@ -3490,12 +3499,15 @@ COND_WXUNIV_1_ADVANCED_HDR =  \
        wx/datectrl.h \
        wx/dateevt.h \
        wx/dcbuffer.h \
+       wx/dvrenderers.h \
        wx/editlbox.h \
        wx/generic/aboutdlgg.h \
        wx/generic/bmpcbox.h \
        wx/generic/calctrlg.h \
        wx/generic/datectrl.h \
        wx/generic/dataview.h \
+       wx/generic/dvrenderer.h \
+       wx/generic/dvrenderers.h \
        wx/generic/grid.h \
        wx/generic/gridctrl.h \
        wx/generic/grideditors.h \
index 763e0eff83ec49dfae1f2a5e944150fca1eba04f..c4946e00d0dea3bedb6e351325671050cbe6f606 100644 (file)
@@ -2865,12 +2865,15 @@ src/osx/iphone/window.mm
     wx/datectrl.h
     wx/dateevt.h
     wx/dcbuffer.h
+    wx/dvrenderers.h
     wx/editlbox.h
     wx/generic/aboutdlgg.h
     wx/generic/bmpcbox.h
     wx/generic/calctrlg.h
     wx/generic/datectrl.h
     wx/generic/dataview.h
+    wx/generic/dvrenderer.h
+    wx/generic/dvrenderers.h
     wx/generic/grid.h
     wx/generic/gridctrl.h
     wx/generic/grideditors.h
@@ -2952,6 +2955,8 @@ src/osx/iphone/window.mm
 <set var="ADVANCED_OSX_CARBON_HDR" hints="files">
     wx/generic/animate.h
     wx/osx/dataview.h
+    wx/osx/dvrenderer.h
+    wx/osx/dvrenderers.h
     wx/osx/joystick.h
     wx/osx/sound.h
     wx/osx/taskbarosx.h
@@ -2976,6 +2981,8 @@ src/osx/iphone/window.mm
 <set var="ADVANCED_OSX_COCOA_HDR" hints="files">
     wx/generic/animate.h
     wx/osx/dataview.h
+    wx/osx/dvrenderer.h
+    wx/osx/dvrenderers.h
     wx/osx/joystick.h
     wx/osx/sound.h
     wx/osx/taskbarosx.h
@@ -3051,6 +3058,8 @@ src/osx/iphone/window.mm
     wx/gtk/bmpcbox.h
     wx/gtk/calctrl.h
     wx/gtk/dataview.h
+    wx/gtk/dvrenderer.h
+    wx/gtk/dvrenderers.h
     wx/gtk/hyperlink.h
     wx/gtk/infobar.h
 </set>
index fa36d2fb32c27b382d3b800a407b9e9257fffa6c..1a2bc5ae712b615f2f31c318575d78a5a4cff298 100644 (file)
@@ -858,6 +858,14 @@ SOURCE=..\..\include\wx\generic\datectrl.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\include\wx\generic\dvrenderer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\wx\generic\dvrenderers.h
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\include\wx\generic\grid.h\r
 # End Source File\r
 # Begin Source File\r
@@ -946,6 +954,10 @@ SOURCE=..\..\include\wx\dcbuffer.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\include\wx\dvrenderers.h
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\include\wx\editlbox.h\r
 # End Source File\r
 # Begin Source File\r
index edff22967e5d57da71e1e67dcdfeaffa6a3ab823..991b462004daefcca498b86a9145baa6b0578682 100644 (file)
@@ -5275,6 +5275,14 @@ SOURCE=..\..\include\wx\generic\dragimgg.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\include\wx\generic\dvrenderer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\wx\generic\dvrenderers.h
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\include\wx\generic\fdrepdlg.h\r
 # End Source File\r
 # Begin Source File\r
@@ -5927,6 +5935,10 @@ SOURCE=..\..\include\wx\dragimag.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\include\wx\dvrenderers.h
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\include\wx\editlbox.h\r
 # End Source File\r
 # Begin Source File\r
index ef4603bbb0500d51d23dfbb50cf899c66858632b..5d26bd763e07b2d91db32e21fd73452f3ac7c43d 100644 (file)
                                RelativePath="..\..\include\wx\generic\datectrl.h">\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\generic\dvrenderer.h">
+                       </File>
+                       <File
+                               RelativePath="..\..\include\wx\generic\dvrenderers.h">
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\generic\grid.h">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\include\wx\dcbuffer.h">\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\dvrenderers.h">
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\editlbox.h">\r
                        </File>\r
                        <File\r
index b25d850049c52415e6e9d2cea6ef7a9432b37f4f..abe1d2f1587f24d4a4fc2c4540da8a35b0d2e1ea 100644 (file)
                                RelativePath="..\..\include\wx\generic\dragimgg.h">\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\generic\dvrenderer.h">
+                       </File>
+                       <File
+                               RelativePath="..\..\include\wx\generic\dvrenderers.h">
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\generic\fdrepdlg.h">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\include\wx\dragimag.h">\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\dvrenderers.h">
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\editlbox.h">\r
                        </File>\r
                        <File\r
index f2806513e355b0e11a684b70149a331036027c6e..6ad1565bde63b67dede87783dfb3ee5cc89a8ae7 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\generic\dvrenderer.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\include\wx\generic\dvrenderers.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\generic\grid.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\dvrenderers.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\editlbox.h"\r
                                >\r
                        </File>\r
index ce6040a55ae300f3351efcf8905f664f35fb8064..8e168f0ebf5a813d9223694c3d04a721f5e05799 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\generic\dvrenderer.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\include\wx\generic\dvrenderers.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\generic\fdrepdlg.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\dvrenderers.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\editlbox.h"\r
                                >\r
                        </File>\r
index 05ab959d7b11cb4624cd37f6f21fe10a40b6e69b..a12393ae07a7997824df0e333501e4eb887e7732 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\generic\dvrenderer.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\include\wx\generic\dvrenderers.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\generic\grid.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\dvrenderers.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\editlbox.h"\r
                                >\r
                        </File>\r
index f7fecff88751847ec2c08d3bcb90cb6c01342550..c6f961fc0b628cb23737e2fa07fc8655d0333540 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\generic\dvrenderer.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\include\wx\generic\dvrenderers.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\generic\fdrepdlg.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\include\wx\dvrenderers.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\include\wx\editlbox.h"\r
                                >\r
                        </File>\r
index 66ef3ea532366714c359ec2c249b419f268f790d..fd2ec0b4d7a45d3d669cb4ef61679bfa601b19fb 100644 (file)
@@ -32,6 +32,14 @@ class WXDLLIMPEXP_FWD_CORE wxImageList;
     #define wxHAS_GENERIC_DATAVIEWCTRL
 #endif
 
+#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
+#endif
+
 // ----------------------------------------------------------------------------
 // wxDataViewCtrl globals
 // ----------------------------------------------------------------------------
@@ -436,134 +444,11 @@ private:
     DECLARE_EVENT_TABLE()
 };
 
-// ---------------------------------------------------------
-// wxDataViewRendererBase
-// ---------------------------------------------------------
-
-enum wxDataViewCellMode
-{
-    wxDATAVIEW_CELL_INERT,
-    wxDATAVIEW_CELL_ACTIVATABLE,
-    wxDATAVIEW_CELL_EDITABLE
-};
-
-enum wxDataViewCellRenderState
-{
-    wxDATAVIEW_CELL_SELECTED    = 1,
-    wxDATAVIEW_CELL_PRELIT      = 2,
-    wxDATAVIEW_CELL_INSENSITIVE = 4,
-    wxDATAVIEW_CELL_FOCUSED     = 8
-};
-
-class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
-{
-public:
-    wxDataViewRendererBase( const wxString &varianttype,
-                            wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                            int alignment = wxDVR_DEFAULT_ALIGNMENT );
-    virtual ~wxDataViewRendererBase();
-
-    virtual bool Validate( wxVariant& WXUNUSED(value) )
-        { return true; }
-
-    void SetOwner( wxDataViewColumn *owner )    { m_owner = owner; }
-    wxDataViewColumn* GetOwner() const          { return m_owner; }
-
-    // renderer properties:
-
-    virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
-    virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
-
-    wxString GetVariantType() const             { return m_variantType; }
-
-    virtual void SetMode( wxDataViewCellMode mode ) = 0;
-    virtual wxDataViewCellMode GetMode() const = 0;
-
-    // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
-    //       rather an "int"; that's because for rendering cells it's allowed
-    //       to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
-    virtual void SetAlignment( int align ) = 0;
-    virtual int GetAlignment() const = 0;
-
-    // enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of
-    // the item text (hence this only makes sense for renderers showing
-    // text...) with ellipsis in order to make it fit the column width
-    virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) = 0;
-    void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE); }
-
-    virtual wxEllipsizeMode GetEllipsizeMode() const = 0;
-
-    // in-place editing
-    virtual bool HasEditorCtrl() const
-        { return false; }
-    virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
-                                        wxRect WXUNUSED(labelRect),
-                                        const wxVariant& WXUNUSED(value))
-        { return NULL; }
-    virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
-                                        wxVariant& WXUNUSED(value))
-        { return false; }
-
-    virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
-    virtual void CancelEditing();
-    virtual bool FinishEditing();
-
-    wxControl *GetEditorCtrl() { return m_editorCtrl; }
-
-protected:
-    wxString                m_variantType;
-    wxDataViewColumn       *m_owner;
-    wxWeakRef<wxControl>    m_editorCtrl;
-    wxDataViewItem          m_item; // for m_editorCtrl
-
-    // internal utility:
-    const wxDataViewCtrl* GetView() const;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
-};
-
-//-----------------------------------------------------------------------------
-// wxDataViewIconText
-//-----------------------------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject
-{
-public:
-    wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon )
-        : 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; }
-    wxString GetText() const             { return m_text; }
-    void SetIcon( const wxIcon &icon )   { m_icon = icon; }
-    const wxIcon &GetIcon() const        { return m_icon; }
-
-private:
-    wxString    m_text;
-    wxIcon      m_icon;
-
-private:
-    DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
-};
-
-inline
-bool operator==(const wxDataViewIconText& left, const wxDataViewIconText& right)
-{
-    return left.GetText() == right.GetText() &&
-             left.GetIcon().IsSameAs(right.GetIcon());
-}
-
-inline
-bool operator!=(const wxDataViewIconText& left, const wxDataViewIconText& right)
-{
-    return !(left == right);
-}
+// ----------------------------------------------------------------------------
+// wxDataViewRenderer and related classes
+// ----------------------------------------------------------------------------
 
-DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
+#include "wx/dvrenderers.h"
 
 // ---------------------------------------------------------
 // wxDataViewColumnBase
@@ -998,12 +883,6 @@ typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
 
 #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"
@@ -1013,60 +892,6 @@ typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
     #error "unknown native wxDataViewCtrl implementation"
 #endif
 
-// -------------------------------------
-// wxDataViewSpinRenderer
-// -------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewSpinRenderer( int min, int max,
-                            wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
-                            int alignment = wxDVR_DEFAULT_ALIGNMENT );
-    virtual bool HasEditorCtrl() const { 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:
-    long    m_data;
-    long    m_min,m_max;
-};
-
-#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__)
-
-// -------------------------------------
-// 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() const { 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
-
-// this class is obsolete, its functionality was merged in
-// wxDataViewTextRenderer itself now, don't use it any more
-#define wxDataViewTextRendererAttr wxDataViewTextRenderer
-
 //-----------------------------------------------------------------------------
 // wxDataViewListStore
 //-----------------------------------------------------------------------------
diff --git a/include/wx/dvrenderers.h b/include/wx/dvrenderers.h
new file mode 100644 (file)
index 0000000..94a4330
--- /dev/null
@@ -0,0 +1,309 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/dvrenderers.h
+// Purpose:     Declare all wxDataViewCtrl classes
+// Author:      Robert Roebling, Vadim Zeitlin
+// Created:     2009-11-08 (extracted from wx/dataview.h)
+// RCS-ID:      $Id: wxhead.h,v 1.11 2009-06-29 10:23:04 zeitlin Exp $
+// Copyright:   (c) 2006 Robert Roebling
+//              (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_DVRENDERERS_H_
+#define _WX_DVRENDERERS_H_
+
+/*
+    Note about the structure of various headers: they're organized in a more
+    complicated way than usual because of the various dependencies which are
+    different for different ports. In any case the only public header, i.e. the
+    one which can be included directly is wx/dataview.h. It, in turn, includes
+    this one to define all the renderer classes.
+
+    We define the base wxDataViewRendererBase class first and then include a
+    port-dependent wx/xxx/dvrenderer.h which defines wxDataViewRenderer itself.
+    After this we can define wxDataViewRendererCustomBase (and maybe in the
+    future base classes for other renderers if the need arises, i.e. if there
+    is any non-trivial code or API which it makes sense to keep in common code)
+    and include wx/xxx/dvrenderers.h (notice the plural) which defines all the
+    rest of the renderer classes.
+ */
+
+class WXDLLIMPEXP_FWD_ADV wxDataViewCustomRenderer;
+
+// ----------------------------------------------------------------------------
+// wxDataViewIconText: helper class used by wxDataViewIconTextRenderer
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewIconText : public wxObject
+{
+public:
+    wxDataViewIconText( const wxString &text = wxEmptyString,
+                        const wxIcon& icon = wxNullIcon )
+        : m_text(text),
+          m_icon(icon)
+    { }
+
+    wxDataViewIconText( const wxDataViewIconText &other )
+        : wxObject(),
+          m_text(other.m_text),
+          m_icon(other.m_icon)
+    { }
+
+    void SetText( const wxString &text ) { m_text = text; }
+    wxString GetText() const             { return m_text; }
+    void SetIcon( const wxIcon &icon )   { m_icon = icon; }
+    const wxIcon &GetIcon() const        { return m_icon; }
+
+private:
+    wxString    m_text;
+    wxIcon      m_icon;
+
+    DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
+};
+
+inline
+bool operator==(const wxDataViewIconText& left, const wxDataViewIconText& right)
+{
+    return left.GetText() == right.GetText() &&
+             left.GetIcon().IsSameAs(right.GetIcon());
+}
+
+inline
+bool operator!=(const wxDataViewIconText& left, const wxDataViewIconText& right)
+{
+    return !(left == right);
+}
+
+DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
+
+// ----------------------------------------------------------------------------
+// wxDataViewRendererBase
+// ----------------------------------------------------------------------------
+
+enum wxDataViewCellMode
+{
+    wxDATAVIEW_CELL_INERT,
+    wxDATAVIEW_CELL_ACTIVATABLE,
+    wxDATAVIEW_CELL_EDITABLE
+};
+
+enum wxDataViewCellRenderState
+{
+    wxDATAVIEW_CELL_SELECTED    = 1,
+    wxDATAVIEW_CELL_PRELIT      = 2,
+    wxDATAVIEW_CELL_INSENSITIVE = 4,
+    wxDATAVIEW_CELL_FOCUSED     = 8
+};
+
+class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
+{
+public:
+    wxDataViewRendererBase( const wxString &varianttype,
+                            wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                            int alignment = wxDVR_DEFAULT_ALIGNMENT );
+    virtual ~wxDataViewRendererBase();
+
+    virtual bool Validate( wxVariant& WXUNUSED(value) )
+        { return true; }
+
+    void SetOwner( wxDataViewColumn *owner )    { m_owner = owner; }
+    wxDataViewColumn* GetOwner() const          { return m_owner; }
+
+    // renderer properties:
+
+    virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
+    virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
+
+    wxString GetVariantType() const             { return m_variantType; }
+
+    virtual void SetMode( wxDataViewCellMode mode ) = 0;
+    virtual wxDataViewCellMode GetMode() const = 0;
+
+    // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
+    //       rather an "int"; that's because for rendering cells it's allowed
+    //       to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
+    virtual void SetAlignment( int align ) = 0;
+    virtual int GetAlignment() const = 0;
+
+    // enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of
+    // the item text (hence this only makes sense for renderers showing
+    // text...) with ellipsis in order to make it fit the column width
+    virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) = 0;
+    void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE); }
+
+    virtual wxEllipsizeMode GetEllipsizeMode() const = 0;
+
+    // in-place editing
+    virtual bool HasEditorCtrl() const
+        { return false; }
+    virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
+                                        wxRect WXUNUSED(labelRect),
+                                        const wxVariant& WXUNUSED(value))
+        { return NULL; }
+    virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
+                                        wxVariant& WXUNUSED(value))
+        { return false; }
+
+    virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
+    virtual void CancelEditing();
+    virtual bool FinishEditing();
+
+    wxControl *GetEditorCtrl() { return m_editorCtrl; }
+
+protected:
+    wxString                m_variantType;
+    wxDataViewColumn       *m_owner;
+    wxWeakRef<wxControl>    m_editorCtrl;
+    wxDataViewItem          m_item; // for m_editorCtrl
+
+    // internal utility:
+    const wxDataViewCtrl* GetView() const;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
+};
+
+// include the real wxDataViewRenderer declaration for the native ports
+#ifdef wxHAS_GENERIC_DATAVIEWCTRL
+    // in the generic implementation there is no real wxDataViewRenderer, all
+    // renderers are custom so it's the same as wxDataViewCustomRenderer and
+    // wxDataViewCustomRendererBase derives from wxDataViewRendererBase directly
+    //
+    // this is a rather ugly hack but unfortunately it just doesn't seem to be
+    // possible to have the same class hierarchy in all ports and avoid
+    // duplicating the entire wxDataViewCustomRendererBase in the generic
+    // wxDataViewRenderer class (well, we could use a mix-in but this would
+    // make classes hierarchy non linear and arguably even more complex)
+    #define wxDataViewCustomRendererRealBase wxDataViewRendererBase
+#else
+    #if defined(__WXGTK20__)
+        #include "wx/gtk/dvrenderer.h"
+    #elif defined(__WXMAC__)
+        #include "wx/osx/dvrenderer.h"
+    #else
+        #error "unknown native wxDataViewCtrl implementation"
+    #endif
+    #define wxDataViewCustomRendererRealBase wxDataViewRenderer
+#endif
+
+// ----------------------------------------------------------------------------
+// wxDataViewCustomRendererBase
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewCustomRendererBase
+    : public wxDataViewCustomRendererRealBase
+{
+public:
+    // Constructor must specify the usual renderer parameters which we simply
+    // pass to the base class
+    wxDataViewCustomRendererBase(const wxString& varianttype = "string",
+                                 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                                 int align = wxDVR_DEFAULT_ALIGNMENT)
+        : wxDataViewCustomRendererRealBase(varianttype, mode, align)
+    {
+    }
+
+
+    // Define virtual function which are called when the item is activated
+    // (double-clicked or Enter is pressed on it), clicked or the user starts
+    // to drag it: by default they all simply return false indicating that the
+    // events are not handled
+
+    virtual bool Activate(wxRect WXUNUSED(cell),
+                          wxDataViewModel *WXUNUSED(model),
+                          const wxDataViewItem & WXUNUSED(item),
+                          unsigned int WXUNUSED(col))
+        { return false; }
+
+    virtual bool LeftClick(wxPoint WXUNUSED(cursor),
+                           wxRect WXUNUSED(cell),
+                           wxDataViewModel *WXUNUSED(model),
+                           const wxDataViewItem & WXUNUSED(item),
+                           unsigned int WXUNUSED(col) )
+        { return false; }
+
+    virtual bool StartDrag(wxPoint WXUNUSED(cursor),
+                           wxRect WXUNUSED(cell),
+                           wxDataViewModel *WXUNUSED(model),
+                           const wxDataViewItem & WXUNUSED(item),
+                           unsigned int WXUNUSED(col) )
+        { return false; }
+
+
+private:
+    wxDECLARE_NO_COPY_CLASS(wxDataViewCustomRendererBase);
+};
+
+// include the declaration of all the other renderers to get the real
+// wxDataViewCustomRenderer from which we need to inherit below
+#ifdef wxHAS_GENERIC_DATAVIEWCTRL
+    // because of the different renderer classes hierarchy in the generic
+    // version, as explained above, we can include the header defining
+    // wxDataViewRenderer only here and not before wxDataViewCustomRendererBase
+    // declaration as for the native ports
+    #include "wx/generic/dvrenderer.h"
+    #include "wx/generic/dvrenderers.h"
+#elif defined(__WXGTK20__)
+    #include "wx/gtk/dvrenderers.h"
+#elif defined(__WXMAC__)
+    #include "wx/osx/dvrenderers.h"
+#else
+    #error "unknown native wxDataViewCtrl implementation"
+#endif
+
+// ----------------------------------------------------------------------------
+// wxDataViewSpinRenderer
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer
+{
+public:
+    wxDataViewSpinRenderer( int min, int max,
+                            wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
+                            int alignment = wxDVR_DEFAULT_ALIGNMENT );
+    virtual bool HasEditorCtrl() const { 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:
+    long    m_data;
+    long    m_min,m_max;
+};
+
+#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__)
+
+// ----------------------------------------------------------------------------
+// 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() const { 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 // generic or Carbon versions
+
+// this class is obsolete, its functionality was merged in
+// wxDataViewTextRenderer itself now, don't use it any more
+#define wxDataViewTextRendererAttr wxDataViewTextRenderer
+
+#endif // _WX_DVRENDERERS_H_
+
index 23d6fe531ca28453ae85424b3f8a509b8eee9a88..d8b141f0f96c58e555dd2b08038d3e6569b43521 100644 (file)
 #include "wx/scrolwin.h"
 #include "wx/icon.h"
 
-// ---------------------------------------------------------
-// classes
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
 class WXDLLIMPEXP_FWD_ADV wxDataViewMainWindow;
 class WXDLLIMPEXP_FWD_ADV wxDataViewHeaderWindow;
 
-// ---------------------------------------------------------
-// wxDataViewRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
-{
-public:
-    wxDataViewRenderer( const wxString &varianttype,
-                        wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                        int align = wxDVR_DEFAULT_ALIGNMENT );
-    virtual ~wxDataViewRenderer();
-
-    // these methods are used to draw the cell contents, Render() doesn't care
-    // about the attributes while RenderWithAttr() does -- override it if you
-    // want to take the attributes defined for this cell into account, otherwise
-    // overriding Render() is enough
-    virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
-
-    // NB: RenderWithAttr() also has more standard parameter order and types
-    virtual bool
-    RenderWithAttr(wxDC& dc,
-                   const wxRect& rect,
-                   int align,   // combination of horizontal and vertical
-                   const wxDataViewItemAttr *attr, // may be NULL if none
-                   int state);
-
-    virtual wxSize GetSize() const = 0;
-
-    virtual void SetAlignment( int align );
-    virtual int GetAlignment() const;
-
-    virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE)
-        { m_ellipsizeMode = mode; }
-    virtual wxEllipsizeMode GetEllipsizeMode() const
-        { return m_ellipsizeMode; }
-
-    virtual void SetMode( wxDataViewCellMode mode )
-        { m_mode=mode; }
-    virtual wxDataViewCellMode GetMode() const
-        { return m_mode; }
-
-    virtual bool Activate( wxRect WXUNUSED(cell),
-                           wxDataViewModel *WXUNUSED(model),
-                           const wxDataViewItem & WXUNUSED(item),
-                           unsigned int WXUNUSED(col) )
-                           { return false; }
-
-    virtual bool LeftClick( wxPoint WXUNUSED(cursor),
-                            wxRect WXUNUSED(cell),
-                            wxDataViewModel *WXUNUSED(model),
-                            const wxDataViewItem & WXUNUSED(item),
-                            unsigned int WXUNUSED(col) )
-                            { return false; }
-    virtual bool StartDrag( wxPoint WXUNUSED(cursor),
-                            wxRect WXUNUSED(cell),
-                            wxDataViewModel *WXUNUSED(model),
-                            const wxDataViewItem & WXUNUSED(item),
-                            unsigned int WXUNUSED(col) )
-                            { return false; }
-
-    // Create DC on request
-    virtual wxDC *GetDC();
-
-    // implementation
-    int CalculateAlignment() const;
-
-protected:
-    // This is just a convenience for the derived classes overriding
-    // RenderWithAttr() to avoid repeating the same wxFAIL_MSG() in all of them
-    bool DummyRender(wxRect WXUNUSED(cell),
-                     wxDC * WXUNUSED(dc),
-                     int WXUNUSED(state))
-    {
-        wxFAIL_MSG("shouldn't be called at all, use RenderWithAttr() instead");
-
-        return false;
-    }
-
-private:
-    wxDC                        *m_dc;
-    int                          m_align;
-    wxDataViewCellMode           m_mode;
-
-    wxEllipsizeMode m_ellipsizeMode;
-
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewCustomRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
-{
-public:
-    wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
-                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                              int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    // Draw the text using the provided attributes
-    void RenderText(wxDC& dc,
-                    const wxRect& rect,
-                    int align,
-                    const wxString& text,
-                    const wxDataViewItemAttr *attr, // may be NULL if none
-                    int state,
-                    int xoffset = 0);
-
-    // Overload using standard attributes
-    void RenderText(const wxString& text,
-                    int xoffset,
-                    wxRect cell,
-                    wxDC *dc,
-                    int state)
-    {
-        RenderText(*dc, cell, wxALIGN_NOT, text, NULL, state, xoffset);
-    }
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
-};
-
-
-// ---------------------------------------------------------
-// wxDataViewTextRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
-                            wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                            int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant &value ) const;
-
-    virtual bool RenderWithAttr(wxDC& dc,
-                                const wxRect& rect,
-                                int align,
-                                const wxDataViewItemAttr *attr,
-                                int state);
-    virtual bool Render(wxRect cell, wxDC *dc, int state)
-    {
-        return DummyRender(cell, dc, state);
-    }
-
-    wxSize GetSize() const;
-
-    // in-place editing
-    virtual bool HasEditorCtrl() const;
-    virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
-                                         const wxVariant &value );
-    virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
-
-protected:
-    wxString   m_text;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewBitmapRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
-                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                              int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant &value ) const;
-
-    bool Render( wxRect cell, wxDC *dc, int state );
-    wxSize GetSize() const;
-
-private:
-    wxIcon m_icon;
-    wxBitmap m_bitmap;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewToggleRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
-                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                              int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant &value ) const;
-
-    bool Render( wxRect cell, wxDC *dc, int state );
-    bool Activate( wxRect cell, wxDataViewModel *model, const wxDataViewItem & item,
-                            unsigned int col );
-    wxSize GetSize() const;
-
-private:
-    bool    m_toggle;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewProgressRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
-                                const wxString &varianttype = wxT("long"),
-                                wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                                int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant& value ) const;
-
-    virtual bool RenderWithAttr(wxDC& dc,
-                                const wxRect& rect,
-                                int align,
-                                const wxDataViewItemAttr *attr,
-                                int state);
-    virtual bool Render(wxRect cell, wxDC *dc, int state)
-    {
-        return DummyRender(cell, dc, state);
-    }
-    virtual wxSize GetSize() const;
-
-private:
-    wxString    m_label;
-    int         m_value;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewIconTextRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
-                                wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                                int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant &value ) const;
-
-    virtual bool RenderWithAttr(wxDC& dc,
-                                const wxRect& rect,
-                                int align,
-                                const wxDataViewItemAttr *attr,
-                                int state);
-    virtual bool Render(wxRect cell, wxDC *dc, int state)
-    {
-        return DummyRender(cell, dc, state);
-    }
-    virtual wxSize GetSize() const;
-
-    virtual bool HasEditorCtrl() const { return true; }
-    virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
-                                         const wxVariant &value );
-    virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
-
-private:
-    wxDataViewIconText   m_value;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewDateRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
-                            wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
-                            int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant& value ) const;
-
-    virtual bool Render( wxRect cell, wxDC *dc, int state );
-    virtual wxSize GetSize() const;
-    virtual bool Activate( wxRect cell,
-                           wxDataViewModel *model,
-                           const wxDataViewItem& item,
-                           unsigned int col );
-
-private:
-    wxDateTime    m_date;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
-};
-
 // ---------------------------------------------------------
 // wxDataViewColumn
 // ---------------------------------------------------------
diff --git a/include/wx/generic/dvrenderer.h b/include/wx/generic/dvrenderer.h
new file mode 100644 (file)
index 0000000..6726b0f
--- /dev/null
@@ -0,0 +1,116 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/generic/dvrenderer.h
+// Purpose:     wxDataViewRenderer for generic wxDataViewCtrl implementation
+// Author:      Robert Roebling, Vadim Zeitlin
+// Created:     2009-11-07 (extracted from wx/generic/dataview.h)
+// RCS-ID:      $Id: wxhead.h,v 1.11 2009-06-29 10:23:04 zeitlin Exp $
+// Copyright:   (c) 2006 Robert Roebling
+//              (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_GENERIC_DVRENDERER_H_
+#define _WX_GENERIC_DVRENDERER_H_
+
+// ----------------------------------------------------------------------------
+// wxDataViewRenderer
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewCustomRendererBase
+{
+public:
+    wxDataViewRenderer( const wxString &varianttype,
+                        wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                        int align = wxDVR_DEFAULT_ALIGNMENT );
+    virtual ~wxDataViewRenderer();
+
+    // these methods are used to draw the cell contents, Render() doesn't care
+    // about the attributes while RenderWithAttr() does -- override it if you
+    // want to take the attributes defined for this cell into account, otherwise
+    // overriding Render() is enough
+    virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
+
+    // NB: RenderWithAttr() also has more standard parameter order and types
+    virtual bool
+    RenderWithAttr(wxDC& dc,
+                   const wxRect& rect,
+                   int align,   // combination of horizontal and vertical
+                   const wxDataViewItemAttr *attr, // may be NULL if none
+                   int state);
+
+    virtual wxSize GetSize() const = 0;
+    virtual wxDC *GetDC();
+
+    // Draw the text using the provided attributes
+    void RenderText(wxDC& dc,
+                    const wxRect& rect,
+                    int align,
+                    const wxString& text,
+                    const wxDataViewItemAttr *attr, // may be NULL if none
+                    int state,
+                    int xoffset = 0);
+
+    // Overload using standard attributes
+    void RenderText(const wxString& text,
+                    int xoffset,
+                    wxRect cell,
+                    wxDC *dc,
+                    int state)
+    {
+        RenderText(*dc, cell, wxALIGN_NOT, text, NULL, state, xoffset);
+    }
+
+
+    virtual void SetAlignment( int align );
+    virtual int GetAlignment() const;
+
+    virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE)
+        { m_ellipsizeMode = mode; }
+    virtual wxEllipsizeMode GetEllipsizeMode() const
+        { return m_ellipsizeMode; }
+
+    virtual void SetMode( wxDataViewCellMode mode )
+        { m_mode = mode; }
+    virtual wxDataViewCellMode GetMode() const
+        { return m_mode; }
+
+    // implementation
+    int CalculateAlignment() const;
+
+    // this is a replacement for dynamic_cast<wxDataViewCustomRenderer> in the
+    // code checking whether the renderer is interested in mouse events, it's
+    // overridden in wxDataViewCustomRenderer to return the object itself but
+    // intentionally returns NULL for all the other renderer classes as the
+    // user should _not_ be able to override Activate/LeftClick() when deriving
+    // from them for consistency with the other ports and while we can't
+    // prevent this from working at compile-time because all renderer are
+    // custom renderers in the generic implementation, we at least make sure
+    // that it doesn't work at run-time because Activate/LeftClick() would
+    // never be called
+    virtual wxDataViewCustomRenderer *WXGetAsCustom() { return NULL; }
+
+protected:
+    // This is just a convenience for the derived classes overriding
+    // RenderWithAttr() to avoid repeating the same wxFAIL_MSG() in all of them
+    bool DummyRender(wxRect WXUNUSED(cell),
+                     wxDC * WXUNUSED(dc),
+                     int WXUNUSED(state))
+    {
+        wxFAIL_MSG("shouldn't be called at all, use RenderWithAttr() instead");
+
+        return false;
+    }
+
+private:
+    int                          m_align;
+    wxDataViewCellMode           m_mode;
+
+    wxEllipsizeMode m_ellipsizeMode;
+
+    wxDC *m_dc;
+
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
+};
+
+#endif // _WX_GENERIC_DVRENDERER_H_
+
diff --git a/include/wx/generic/dvrenderers.h b/include/wx/generic/dvrenderers.h
new file mode 100644 (file)
index 0000000..6159225
--- /dev/null
@@ -0,0 +1,224 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/generic/dvrenderers.h
+// Purpose:     All generic wxDataViewCtrl renderer classes
+// Author:      Robert Roebling, Vadim Zeitlin
+// Created:     2009-11-07 (extracted from wx/generic/dataview.h)
+// RCS-ID:      $Id: wxhead.h,v 1.11 2009-06-29 10:23:04 zeitlin Exp $
+// Copyright:   (c) 2006 Robert Roebling
+//              (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_GENERIC_DVRENDERERS_H_
+#define _WX_GENERIC_DVRENDERERS_H_
+
+// ---------------------------------------------------------
+// wxDataViewCustomRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
+                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                              int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    virtual wxDataViewCustomRenderer *WXGetAsCustom() { return this; }
+
+private:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
+};
+
+
+// ---------------------------------------------------------
+// wxDataViewTextRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
+                            wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                            int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant &value ) const;
+
+    virtual bool RenderWithAttr(wxDC& dc,
+                                const wxRect& rect,
+                                int align,
+                                const wxDataViewItemAttr *attr,
+                                int state);
+    virtual bool Render(wxRect cell, wxDC *dc, int state)
+    {
+        return DummyRender(cell, dc, state);
+    }
+
+    wxSize GetSize() const;
+
+    // in-place editing
+    virtual bool HasEditorCtrl() const;
+    virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
+                                         const wxVariant &value );
+    virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
+
+protected:
+    wxString   m_text;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewBitmapRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
+                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                              int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant &value ) const;
+
+    bool Render( wxRect cell, wxDC *dc, int state );
+    wxSize GetSize() const;
+
+private:
+    wxIcon m_icon;
+    wxBitmap m_bitmap;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewToggleRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
+                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                              int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant &value ) const;
+
+    bool Render( wxRect cell, wxDC *dc, int state );
+    bool Activate( wxRect cell, wxDataViewModel *model, const wxDataViewItem & item,
+                            unsigned int col );
+    wxSize GetSize() const;
+
+private:
+    bool    m_toggle;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewProgressRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
+                                const wxString &varianttype = wxT("long"),
+                                wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                                int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant& value ) const;
+
+    virtual bool RenderWithAttr(wxDC& dc,
+                                const wxRect& rect,
+                                int align,
+                                const wxDataViewItemAttr *attr,
+                                int state);
+    virtual bool Render(wxRect cell, wxDC *dc, int state)
+    {
+        return DummyRender(cell, dc, state);
+    }
+    virtual wxSize GetSize() const;
+
+private:
+    wxString    m_label;
+    int         m_value;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewIconTextRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
+                                wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                                int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant &value ) const;
+
+    virtual bool RenderWithAttr(wxDC& dc,
+                                const wxRect& rect,
+                                int align,
+                                const wxDataViewItemAttr *attr,
+                                int state);
+    virtual bool Render(wxRect cell, wxDC *dc, int state)
+    {
+        return DummyRender(cell, dc, state);
+    }
+    virtual wxSize GetSize() const;
+
+    virtual bool HasEditorCtrl() const { return true; }
+    virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
+                                         const wxVariant &value );
+    virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
+
+private:
+    wxDataViewIconText   m_value;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewDateRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
+                            wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
+                            int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant& value ) const;
+
+    virtual bool Render( wxRect cell, wxDC *dc, int state );
+    virtual wxSize GetSize() const;
+    virtual bool Activate( wxRect cell,
+                           wxDataViewModel *model,
+                           const wxDataViewItem& item,
+                           unsigned int col );
+
+private:
+    wxDateTime    m_date;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
+};
+
+
+#endif // _WX_GENERIC_DVRENDERERS_H_
+
index 589da74a9a5d6e64f741bfdc3389b0f4834f238e..e01b0ece10785da37009885f6e9c5eb9da389630 100644 (file)
 
 #include "wx/list.h"
 
-// ---------------------------------------------------------
-// classes
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal;
 
-typedef struct _GtkTreeViewColumn      GtkTreeViewColumn;
-
-// ---------------------------------------------------------
-// wxDataViewRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
-{
-public:
-    wxDataViewRenderer( const wxString &varianttype,
-                        wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                        int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    virtual void SetMode( wxDataViewCellMode mode );
-    virtual wxDataViewCellMode GetMode() const;
-
-    virtual void SetAlignment( int align );
-    virtual int GetAlignment() const;
-
-    virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
-    virtual wxEllipsizeMode GetEllipsizeMode() const;
-
-    // GTK-specific implementation
-    // ---------------------------
-
-    // pack the GTK cell renderers used by this renderer to the given column
-    //
-    // by default only a single m_renderer is used but some renderers use more
-    // than one GTK cell renderer
-    virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
-
-    // called when the cell value was edited by user with the new value
-    //
-    // it validates the new value and notifies the model about the change by
-    // calling GtkOnCellChanged() if it was accepted
-    void GtkOnTextEdited(const gchar *itempath, const wxString& value);
-
-    GtkCellRenderer* GetGtkHandle() { return m_renderer; }
-    void GtkInitHandlers();
-    void GtkUpdateAlignment();
-
-    bool GtkIsUsingDefaultAttrs() const { return m_usingDefaultAttrs; }
-    void GtkSetUsingDefaultAttrs(bool def) { m_usingDefaultAttrs = def; }
-
-protected:
-    virtual void GtkOnCellChanged(const wxVariant& value,
-                                  const wxDataViewItem& item,
-                                  unsigned col);
-
-
-    GtkCellRenderer   *m_renderer;
-    int                m_alignment;
-
-    // true if we hadn't changed any visual attributes or restored them since
-    // doing this
-    bool m_usingDefaultAttrs;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewTextRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
-{
-public:
-    wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
-                            wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                            int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    virtual bool SetValue( const wxVariant &value )
-    {
-        return SetTextValue(value);
-    }
-
-    virtual bool GetValue( wxVariant &value ) const
-    {
-        wxString str;
-        if ( !GetTextValue(str) )
-            return false;
-
-        value = str;
-
-        return true;
-    }
-
-    virtual void SetAlignment( int align );
-
-protected:
-    // implementation of Set/GetValue()
-    bool SetTextValue(const wxString& str);
-    bool GetTextValue(wxString& str) const;
-
-
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewBitmapRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
-{
-public:
-    wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
-                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                              int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant &value ) const;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewToggleRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
-{
-public:
-    wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
-                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                              int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant &value ) const;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewCustomRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
-{
-public:
-    wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
-                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                              int align = wxDVR_DEFAULT_ALIGNMENT,
-                              bool no_init = false );
-    virtual ~wxDataViewCustomRenderer();
-
-
-    virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
-
-    void RenderText( const wxString &text, int xoffset,  wxRect cell, wxDC *dc, int state );
-
-    virtual wxSize GetSize() const = 0;
-
-    virtual bool Activate( wxRect WXUNUSED(cell),
-                           wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) )
-                           { return false; }
-
-    virtual bool LeftClick( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell),
-                           wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) )
-                           { return false; }
-    virtual bool StartDrag( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell),
-                           wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) )
-                           { return false; }
-
-    // Create DC on request
-    virtual wxDC *GetDC();
-
-
-protected:
-
-    bool Init(wxDataViewCellMode mode, int align);
-
-private:
-    wxDC        *m_dc;
-
-public:
-    // Internal, temporary for RenderText.
-    GtkCellRenderer      *m_text_renderer;
-    GdkWindow            *window;
-    GtkWidget            *widget;
-    void                 *background_area;
-    void                 *cell_area;
-    void                 *expose_area;
-    int                   flags;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewProgressRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
-                                const wxString &varianttype = wxT("long"),
-                                wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                                int align = wxDVR_DEFAULT_ALIGNMENT );
-    virtual ~wxDataViewProgressRenderer();
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant &value ) const;
-
-    virtual bool Render( wxRect cell, wxDC *dc, int state );
-    virtual wxSize GetSize() const;
-
-private:
-    wxString    m_label;
-    int         m_value;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewIconTextRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
-{
-public:
-    wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
-                                wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
-                                int align = wxDVR_DEFAULT_ALIGNMENT );
-    virtual ~wxDataViewIconTextRenderer();
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant &value ) const;
-
-    virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
-
-protected:
-    virtual void GtkOnCellChanged(const wxVariant& value,
-                                  const wxDataViewItem& item,
-                                  unsigned col);
-
-private:
-    wxDataViewIconText   m_value;
-
-    // we use the base class m_renderer for the text and this one for the icon
-    GtkCellRenderer *m_rendererIcon;
-
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewDateRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
-                            wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
-                            int align = wxDVR_DEFAULT_ALIGNMENT );
-
-    bool SetValue( const wxVariant &value );
-    bool GetValue( wxVariant &value ) const;
-
-    virtual bool Render( wxRect cell, wxDC *dc, int state );
-    virtual wxSize GetSize() const;
-    virtual bool Activate( wxRect cell,
-                           wxDataViewModel *model, const wxDataViewItem &item, unsigned int col );
-
-private:
-    wxDateTime    m_date;
-
-protected:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
-};
-
-// -------------------------------------
-// wxDataViewChoiceRenderer
-// -------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
-{
-public:
-    wxDataViewChoiceRenderer( const wxArrayString &choices,
-                            wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
-                            int alignment = wxDVR_DEFAULT_ALIGNMENT );
-    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;
-
-    void SetAlignment( int align );
-private:
-    wxArrayString m_choices;
-    wxString      m_data;
-};
-
 // ---------------------------------------------------------
 // wxDataViewColumn
 // ---------------------------------------------------------
diff --git a/include/wx/gtk/dvrenderer.h b/include/wx/gtk/dvrenderer.h
new file mode 100644 (file)
index 0000000..9513104
--- /dev/null
@@ -0,0 +1,77 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/gtk/dvrenderer.h
+// Purpose:     wxDataViewRenderer for GTK wxDataViewCtrl implementation
+// Author:      Robert Roebling, Vadim Zeitlin
+// Created:     2009-11-07 (extracted from wx/gtk/dataview.h)
+// RCS-ID:      $Id: wxhead.h,v 1.11 2009-06-29 10:23:04 zeitlin Exp $
+// Copyright:   (c) 2006 Robert Roebling
+//              (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_GTK_DVRENDERER_H_
+#define _WX_GTK_DVRENDERER_H_
+
+typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
+
+// ----------------------------------------------------------------------------
+// wxDataViewRenderer
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
+{
+public:
+    wxDataViewRenderer( const wxString &varianttype,
+                        wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                        int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    virtual void SetMode( wxDataViewCellMode mode );
+    virtual wxDataViewCellMode GetMode() const;
+
+    virtual void SetAlignment( int align );
+    virtual int GetAlignment() const;
+
+    virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
+    virtual wxEllipsizeMode GetEllipsizeMode() const;
+
+    // GTK-specific implementation
+    // ---------------------------
+
+    // pack the GTK cell renderers used by this renderer to the given column
+    //
+    // by default only a single m_renderer is used but some renderers use more
+    // than one GTK cell renderer
+    virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
+
+    // called when the cell value was edited by user with the new value
+    //
+    // it validates the new value and notifies the model about the change by
+    // calling GtkOnCellChanged() if it was accepted
+    void GtkOnTextEdited(const gchar *itempath, const wxString& value);
+
+    GtkCellRenderer* GetGtkHandle() { return m_renderer; }
+    void GtkInitHandlers();
+    void GtkUpdateAlignment();
+
+    bool GtkIsUsingDefaultAttrs() const { return m_usingDefaultAttrs; }
+    void GtkSetUsingDefaultAttrs(bool def) { m_usingDefaultAttrs = def; }
+
+protected:
+    virtual void GtkOnCellChanged(const wxVariant& value,
+                                  const wxDataViewItem& item,
+                                  unsigned col);
+
+
+    GtkCellRenderer   *m_renderer;
+    int                m_alignment;
+
+    // true if we hadn't changed any visual attributes or restored them since
+    // doing this
+    bool m_usingDefaultAttrs;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
+};
+
+#endif // _WX_GTK_DVRENDERER_H_
+
diff --git a/include/wx/gtk/dvrenderers.h b/include/wx/gtk/dvrenderers.h
new file mode 100644 (file)
index 0000000..667de36
--- /dev/null
@@ -0,0 +1,243 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/gtk/dvrenderers.h
+// Purpose:     All GTK wxDataViewCtrl renderer classes
+// Author:      Robert Roebling, Vadim Zeitlin
+// Created:     2009-11-07 (extracted from wx/gtk/dataview.h)
+// RCS-ID:      $Id: wxhead.h,v 1.11 2009-06-29 10:23:04 zeitlin Exp $
+// Copyright:   (c) 2006 Robert Roebling
+//              (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_GTK_DVRENDERERS_H_
+#define _WX_GTK_DVRENDERERS_H_
+
+// ---------------------------------------------------------
+// wxDataViewTextRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewTextRenderer( const wxString &varianttype = "string",
+                            wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                            int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    virtual bool SetValue( const wxVariant &value )
+    {
+        return SetTextValue(value);
+    }
+
+    virtual bool GetValue( wxVariant &value ) const
+    {
+        wxString str;
+        if ( !GetTextValue(str) )
+            return false;
+
+        value = str;
+
+        return true;
+    }
+
+    virtual void SetAlignment( int align );
+
+protected:
+    // implementation of Set/GetValue()
+    bool SetTextValue(const wxString& str);
+    bool GetTextValue(wxString& str) const;
+
+
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewBitmapRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewBitmapRenderer( const wxString &varianttype = "wxBitmap",
+                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                              int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant &value ) const;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewToggleRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewToggleRenderer( const wxString &varianttype = "bool",
+                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                              int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant &value ) const;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewCustomRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewCustomRendererBase
+{
+public:
+    wxDataViewCustomRenderer( const wxString &varianttype = "string",
+                              wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                              int align = wxDVR_DEFAULT_ALIGNMENT,
+                              bool no_init = false );
+    virtual ~wxDataViewCustomRenderer();
+
+
+    virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
+
+    void RenderText( const wxString &text, int xoffset,  wxRect cell, wxDC *dc, int state );
+
+    virtual wxSize GetSize() const = 0;
+
+    // Create DC on request
+    virtual wxDC *GetDC();
+
+
+protected:
+
+    bool Init(wxDataViewCellMode mode, int align);
+
+private:
+    wxDC        *m_dc;
+
+public:
+    // Internal, temporary for RenderText.
+    GtkCellRenderer      *m_text_renderer;
+    GdkWindow            *window;
+    GtkWidget            *widget;
+    void                 *background_area;
+    void                 *cell_area;
+    void                 *expose_area;
+    int                   flags;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewProgressRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
+{
+public:
+    wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
+                                const wxString &varianttype = "long",
+                                wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                                int align = wxDVR_DEFAULT_ALIGNMENT );
+    virtual ~wxDataViewProgressRenderer();
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant &value ) const;
+
+    virtual bool Render( wxRect cell, wxDC *dc, int state );
+    virtual wxSize GetSize() const;
+
+private:
+    wxString    m_label;
+    int         m_value;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewIconTextRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
+{
+public:
+    wxDataViewIconTextRenderer( const wxString &varianttype = "wxDataViewIconText",
+                                wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                                int align = wxDVR_DEFAULT_ALIGNMENT );
+    virtual ~wxDataViewIconTextRenderer();
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant &value ) const;
+
+    virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
+
+protected:
+    virtual void GtkOnCellChanged(const wxVariant& value,
+                                  const wxDataViewItem& item,
+                                  unsigned col);
+
+private:
+    wxDataViewIconText   m_value;
+
+    // we use the base class m_renderer for the text and this one for the icon
+    GtkCellRenderer *m_rendererIcon;
+
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewDateRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
+{
+public:
+    wxDataViewDateRenderer( const wxString &varianttype = "datetime",
+                            wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
+                            int align = wxDVR_DEFAULT_ALIGNMENT );
+
+    bool SetValue( const wxVariant &value );
+    bool GetValue( wxVariant &value ) const;
+
+    virtual bool Render( wxRect cell, wxDC *dc, int state );
+    virtual wxSize GetSize() const;
+    virtual bool Activate( wxRect cell,
+                           wxDataViewModel *model,
+                           const wxDataViewItem &item,
+                           unsigned int col );
+
+private:
+    wxDateTime    m_date;
+
+protected:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
+};
+
+// -------------------------------------
+// wxDataViewChoiceRenderer
+// -------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
+{
+public:
+    wxDataViewChoiceRenderer(const wxArrayString &choices,
+                             wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
+                             int alignment = wxDVR_DEFAULT_ALIGNMENT );
+    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;
+
+    void SetAlignment( int align );
+
+private:
+    wxArrayString m_choices;
+    wxString      m_data;
+};
+
+#endif // _WX_GTK_DVRENDERERS_H_
+
index c7f9433b68c6916a9d642aded9d203770f76e529..3aaabd5a76d877e4cd77d20473b63ea697ee8355 100644 (file)
@@ -1,4 +1,3 @@
-
 /////////////////////////////////////////////////////////////////////////////
 // Name:        wx/osx/dataview.h
 // Purpose:     wxDataViewCtrl native implementation header for OSX
 // Class declarations to mask native types
 // --------------------------------------------------------
 class wxDataViewColumnNativeData;   // class storing environment dependent data for the native implementation
-class wxDataViewRendererNativeData; // class storing environment dependent data for the native renderer
 class wxDataViewWidgetImpl;         // class used as a common interface for carbon and cocoa implementation
 
-// ---------------------------------------------------------
-// wxDataViewRenderer
-// ---------------------------------------------------------
-class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase
-{
-public:
-//
-// constructors / destructor
-//
-  wxDataViewRenderer(wxString const& varianttype, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
-  virtual ~wxDataViewRenderer();
-
-//
-// inherited methods from wxDataViewRendererBase
-//
-  virtual int GetAlignment() const
-  {
-    return m_alignment;
-  }
-  virtual wxDataViewCellMode GetMode() const
-  {
-    return m_mode;
-  }
-  virtual bool GetValue(wxVariant& value) const
-  {
-    value = m_value;
-    return true;
-  }
-
-  virtual void SetAlignment(int align); // carbon: is always identical to the header alignment;
-                                        // cocoa: cell alignment is independent from header alignment
-  virtual void SetMode(wxDataViewCellMode mode);
-  virtual bool SetValue(wxVariant const& newValue)
-  {
-    m_value = newValue;
-    return true;
-  }
-
-  virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
-  virtual wxEllipsizeMode GetEllipsizeMode() const;
-
-//
-// implementation
-//
-  wxVariant const& GetValue() const
-  {
-    return m_value;
-  }
-
-  wxDataViewRendererNativeData* GetNativeData() const
-  {
-    return m_NativeDataPtr;
-  }
-
-  virtual bool MacRender() = 0; // a call to the native data browser function to render the data;
-                             // returns true if the data value could be rendered, false otherwise
-
-  void SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr);
-
-
-#if wxOSX_USE_COCOA
-  // called when a value was edited by user
-  virtual void OSXOnCellChanged(NSObject *value,
-                                const wxDataViewItem& item,
-                                unsigned col);
-#endif // Cocoa
-
-private:
-//
-// variables
-//
-  int m_alignment; // contains the alignment flags
-
-  wxDataViewCellMode m_mode; // storing the mode that determines how the cell is going to be shown
-
-  wxDataViewRendererNativeData* m_NativeDataPtr; // data used by implementation of the native renderer
-
-  wxVariant m_value; // value that is going to be rendered
-
-//
-// wxWidget internal stuff
-//
-  DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewCustomRenderer
-// ---------------------------------------------------------
-class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
-{
-public:
-//
-// constructors / destructor
-//
-  wxDataViewCustomRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
-  virtual ~wxDataViewCustomRenderer();
-
-  void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
-
-//
-// methods handling render space
-//
-  virtual wxSize GetSize() const = 0;
-
-//
-// methods handling user actions
-//
-  virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
-
-  virtual bool Activate( wxRect WXUNUSED(cell),
-                         wxDataViewModel *WXUNUSED(model),
-                         const wxDataViewItem & WXUNUSED(item),
-                         unsigned int WXUNUSED(col) )
-                         { return false; }
-
-  virtual bool LeftClick( wxPoint WXUNUSED(cursor),
-                          wxRect WXUNUSED(cell),
-                          wxDataViewModel *WXUNUSED(model),
-                          const wxDataViewItem & WXUNUSED(item),
-                          unsigned int WXUNUSED(col) )
-                          { return false; }
-
-  virtual bool StartDrag( wxPoint WXUNUSED(cursor),
-                          wxRect WXUNUSED(cell),
-                          wxDataViewModel *WXUNUSED(model),
-                          const wxDataViewItem & WXUNUSED(item),
-                          unsigned int WXUNUSED(col) )
-                          { return false; }
-
-//
-// device context handling
-//
-  virtual wxDC* GetDC(); // creates a device context and keeps it
-
-//
-// implementation
-//
-  virtual bool MacRender();
-
-  void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
-
-protected:
-private:
-//
-// variables
-//
-  wxControl* m_editorCtrlPtr; // pointer to an in-place editor control
-
-  wxDC* m_DCPtr;
-
-//
-// wxWidget internal stuff
-//
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewTextRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
-{
-public:
-//
-// constructors / destructor
-//
-    wxDataViewTextRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
-//
-// inherited functions from wxDataViewRenderer
-//
-  virtual bool MacRender();
-
-#if wxOSX_USE_COCOA
-  virtual void OSXOnCellChanged(NSObject *value,
-                                const wxDataViewItem& item,
-                                unsigned col);
-#endif // Cocoa
-
-private:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewBitmapRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
-{
-public:
-//
-// constructors / destructor
-//
-  wxDataViewBitmapRenderer(wxString const& varianttype=wxT("wxBitmap"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
-//
-// inherited functions from wxDataViewRenderer
-//
-  virtual bool MacRender();
-
-protected:
-private:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
-};
-
-#if !defined(wxUSE_GENERICDATAVIEWCTRL) && defined(__WXOSX_COCOA__)
-
-// -------------------------------------
-// wxDataViewChoiceRenderer
-// -------------------------------------
-class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewRenderer
-{
-public:
-//
-// constructors / destructor
-//
-  wxDataViewChoiceRenderer(wxArrayString const& choices,
-                           wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
-                           int alignment = wxDVR_DEFAULT_ALIGNMENT );
-
-//
-// inherited functions from wxDataViewRenderer
-//
-  virtual bool MacRender();
-
-//
-// implementation
-//
-  wxString GetChoice(size_t index) const
-  {
-    return m_Choices[index];
-  }
-  wxArrayString const& GetChoices() const
-  {
-    return m_Choices;
-  }
-
-private:
-//
-// variables
-//
-  wxArrayString m_Choices;
-
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewChoiceRenderer)
-};
-
-#endif
-
-// ---------------------------------------------------------
-// wxDataViewIconTextRenderer
-// ---------------------------------------------------------
-class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
-{
-public:
-  wxDataViewIconTextRenderer(wxString const& varianttype = wxT("wxDataViewIconText"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
-//
-// inherited functions from wxDataViewRenderer
-//
-  virtual bool MacRender();
-
-#if wxOSX_USE_COCOA
-  virtual void OSXOnCellChanged(NSObject *value,
-                                const wxDataViewItem& item,
-                                unsigned col);
-#endif // Cocoa
-
-protected:
-private:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewToggleRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
-{
-public:
-  wxDataViewToggleRenderer(wxString const& varianttype = wxT("bool"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
-//
-// inherited functions from wxDataViewRenderer
-//
-  virtual bool MacRender();
-
-#if wxOSX_USE_COCOA
-  virtual void OSXOnCellChanged(NSObject *value,
-                                const wxDataViewItem& item,
-                                unsigned col);
-#endif // Cocoa
-
-private:
-  DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewProgressRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
-{
-public:
-  wxDataViewProgressRenderer(wxString const& label = wxEmptyString, wxString const& varianttype=wxT("long"),
-                             wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
-//
-// inherited functions from wxDataViewRenderer
-//
-  virtual bool MacRender();
-
-#if wxOSX_USE_COCOA
-  virtual void OSXOnCellChanged(NSObject *value,
-                                const wxDataViewItem& item,
-                                unsigned col);
-#endif // Cocoa
-
-private:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
-};
-
-// ---------------------------------------------------------
-// wxDataViewDateRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
-{
-public:
-  wxDataViewDateRenderer(wxString const& varianttype=wxT("datetime"), wxDataViewCellMode mode=wxDATAVIEW_CELL_ACTIVATABLE, int align=wxDVR_DEFAULT_ALIGNMENT);
-
-//
-// inherited functions from wxDataViewRenderer
-//
-  virtual bool MacRender();
-
-#if wxOSX_USE_COCOA
-  virtual void OSXOnCellChanged(NSObject *value,
-                                const wxDataViewItem& item,
-                                unsigned col);
-#endif // Cocoa
-
-private:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
-};
-
 // ---------------------------------------------------------
 // wxDataViewColumn
 // ---------------------------------------------------------
diff --git a/include/wx/osx/dvrenderer.h b/include/wx/osx/dvrenderer.h
new file mode 100644 (file)
index 0000000..cbfe4e2
--- /dev/null
@@ -0,0 +1,105 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/osx/dvrenderer.h
+// Purpose:     wxDataViewRenderer for OS X wxDataViewCtrl implementations
+// Author:      Vadim Zeitlin
+// Created:     2009-11-07 (extracted from wx/osx/dataview.h)
+// RCS-ID:      $Id: wxhead.h,v 1.11 2009-06-29 10:23:04 zeitlin Exp $
+// Copyright:   (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_OSX_DVRENDERER_H_
+#define _WX_OSX_DVRENDERER_H_
+
+class wxDataViewRendererNativeData;
+
+// ----------------------------------------------------------------------------
+// wxDataViewRenderer
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase
+{
+public:
+    // constructors / destructor
+    // -------------------------
+
+    wxDataViewRenderer(const wxString& varianttype,
+                       wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                       int align = wxDVR_DEFAULT_ALIGNMENT);
+
+    virtual ~wxDataViewRenderer();
+
+    // inherited methods from wxDataViewRendererBase
+    // ---------------------------------------------
+
+    virtual int GetAlignment() const
+    {
+        return m_alignment;
+    }
+    virtual wxDataViewCellMode GetMode() const
+    {
+        return m_mode;
+    }
+    virtual bool GetValue(wxVariant& value) const
+    {
+        value = m_value;
+        return true;
+    }
+
+    // NB: in Carbon this is always identical to the header alignment
+    virtual void SetAlignment(int align);
+    virtual void SetMode(wxDataViewCellMode mode);
+    virtual bool SetValue(const wxVariant& newValue)
+    {
+        m_value = newValue;
+        return true;
+    }
+
+    virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
+    virtual wxEllipsizeMode GetEllipsizeMode() const;
+
+    // implementation
+    // --------------
+
+    const wxVariant& GetValue() const
+    {
+        return m_value;
+    }
+
+    wxDataViewRendererNativeData* GetNativeData() const
+    {
+        return m_NativeDataPtr;
+    }
+
+    // a call to the native data browser function to render the data;
+    // returns true if the data value could be rendered, false otherwise
+    virtual bool MacRender() = 0;
+
+    void SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr);
+
+
+#if wxOSX_USE_COCOA
+    // called when a value was edited by user
+    virtual void OSXOnCellChanged(NSObject *value,
+                                  const wxDataViewItem& item,
+                                  unsigned col);
+#endif // Cocoa
+
+private:
+    // contains the alignment flags
+    int m_alignment;
+
+    // storing the mode that determines how the cell is going to be shown
+    wxDataViewCellMode m_mode;
+
+    // data used by implementation of the native renderer
+    wxDataViewRendererNativeData* m_NativeDataPtr;
+
+    // value that is going to be rendered
+    wxVariant m_value;
+
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
+};
+
+#endif // _WX_OSX_DVRENDERER_H_
+
diff --git a/include/wx/osx/dvrenderers.h b/include/wx/osx/dvrenderers.h
new file mode 100644 (file)
index 0000000..b25ca48
--- /dev/null
@@ -0,0 +1,209 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/osx/dvrenderers.h
+// Purpose:     All OS X wxDataViewCtrl renderer classes
+// Author:      Vadim Zeitlin
+// Created:     2009-11-07 (extracted from wx/osx/dataview.h)
+// RCS-ID:      $Id: wxhead.h,v 1.11 2009-06-29 10:23:04 zeitlin Exp $
+// Copyright:   (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_OSX_DVRENDERERS_H_
+#define _WX_OSX_DVRENDERERS_H_
+
+// ---------------------------------------------------------
+// wxDataViewCustomRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewCustomRenderer : public wxDataViewCustomRendererBase
+{
+public:
+    wxDataViewCustomRenderer(const wxString& varianttype = "string",
+                             wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                             int align = wxDVR_DEFAULT_ALIGNMENT);
+
+    virtual ~wxDataViewCustomRenderer();
+
+    void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
+
+    virtual wxSize GetSize() const = 0;
+
+    virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
+
+
+    // implementation only
+    // -------------------
+
+    virtual bool MacRender();
+
+    virtual wxDC* GetDC(); // creates a device context and keeps it
+    void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
+
+private:
+    wxControl* m_editorCtrlPtr; // pointer to an in-place editor control
+
+    wxDC* m_DCPtr;
+
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewTextRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewTextRenderer(const wxString& varianttype = "string",
+                           wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                           int align = wxDVR_DEFAULT_ALIGNMENT);
+
+    virtual bool MacRender();
+
+#if wxOSX_USE_COCOA
+    virtual void OSXOnCellChanged(NSObject *value,
+                                  const wxDataViewItem& item,
+                                  unsigned col);
+#endif // Cocoa
+
+private:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewBitmapRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
+                             wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                             int align = wxDVR_DEFAULT_ALIGNMENT);
+
+    virtual bool MacRender();
+
+private:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
+};
+
+#if wxOSX_USE_COCOA
+
+// -------------------------------------
+// wxDataViewChoiceRenderer
+// -------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewChoiceRenderer(const wxArrayString& choices,
+                             wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
+                             int alignment = wxDVR_DEFAULT_ALIGNMENT );
+
+    virtual bool MacRender();
+
+    wxString GetChoice(size_t index) const { return m_choices[index]; }
+    const wxArrayString& GetChoices() const { return m_choices; }
+
+private:
+    wxArrayString m_choices;
+
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewChoiceRenderer)
+};
+
+#endif // wxOSX_USE_COCOA
+
+// ---------------------------------------------------------
+// wxDataViewIconTextRenderer
+// ---------------------------------------------------------
+class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
+                               wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                               int align = wxDVR_DEFAULT_ALIGNMENT);
+
+    virtual bool MacRender();
+
+#if wxOSX_USE_COCOA
+    virtual void OSXOnCellChanged(NSObject *value,
+                                  const wxDataViewItem& item,
+                                  unsigned col);
+#endif // Cocoa
+
+private:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewToggleRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewToggleRenderer(const wxString& varianttype = "bool",
+                             wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                             int align = wxDVR_DEFAULT_ALIGNMENT);
+
+    virtual bool MacRender();
+
+#if wxOSX_USE_COCOA
+    virtual void OSXOnCellChanged(NSObject *value,
+                                  const wxDataViewItem& item,
+                                  unsigned col);
+#endif // Cocoa
+
+private:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewProgressRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
+                               const wxString& varianttype = "long",
+                               wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+                               int align = wxDVR_DEFAULT_ALIGNMENT);
+
+    virtual bool MacRender();
+
+#if wxOSX_USE_COCOA
+    virtual void OSXOnCellChanged(NSObject *value,
+                                  const wxDataViewItem& item,
+                                  unsigned col);
+#endif // Cocoa
+
+private:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
+};
+
+// ---------------------------------------------------------
+// wxDataViewDateRenderer
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
+{
+public:
+    wxDataViewDateRenderer(const wxString& varianttype = "datetime",
+                           wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
+                           int align = wxDVR_DEFAULT_ALIGNMENT);
+
+    virtual bool MacRender();
+
+#if wxOSX_USE_COCOA
+    virtual void OSXOnCellChanged(NSObject *value,
+                                  const wxDataViewItem& item,
+                                  unsigned col);
+#endif // Cocoa
+
+private:
+    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
+};
+
+#endif // _WX_OSX_DVRENDERERS_H_
+
index 04924b89dd768188e34d234c48c71ee703d739e2..fcfbbd77fc6cad310908de6d6825797669a00e99 100644 (file)
@@ -607,18 +607,54 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer, wxDataViewRendererBase)
 wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype,
                                         wxDataViewCellMode mode,
                                         int align) :
-    wxDataViewRendererBase( varianttype, mode, align )
+    wxDataViewCustomRendererBase( varianttype, mode, align )
 {
-    m_dc = NULL;
     m_align = align;
     m_mode = mode;
     m_ellipsizeMode = wxELLIPSIZE_MIDDLE;
+    m_dc = NULL;
 }
 
 wxDataViewRenderer::~wxDataViewRenderer()
 {
-    if (m_dc)
-        delete m_dc;
+    delete m_dc;
+}
+
+wxDC *wxDataViewRenderer::GetDC()
+{
+    if (m_dc == NULL)
+    {
+        if (GetOwner() == NULL)
+            return NULL;
+        if (GetOwner()->GetOwner() == NULL)
+            return NULL;
+        m_dc = new wxClientDC( GetOwner()->GetOwner() );
+    }
+
+    return m_dc;
+}
+
+void wxDataViewRenderer::SetAlignment( int align )
+{
+    m_align=align;
+}
+
+int wxDataViewRenderer::GetAlignment() const
+{
+    return m_align;
+}
+
+int wxDataViewRenderer::CalculateAlignment() const
+{
+    if (m_align == wxDVR_DEFAULT_ALIGNMENT)
+    {
+        if (GetOwner() == NULL)
+            return wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL;
+
+        return GetOwner()->GetAlignment() | wxALIGN_CENTRE_VERTICAL;
+    }
+
+    return m_align;
 }
 
 bool
@@ -669,63 +705,14 @@ wxDataViewRenderer::RenderWithAttr(wxDC& dc,
     return Render(item_rect, &dc, state);
 }
 
-wxDC *wxDataViewRenderer::GetDC()
-{
-    if (m_dc == NULL)
-    {
-        if (GetOwner() == NULL)
-            return NULL;
-        if (GetOwner()->GetOwner() == NULL)
-            return NULL;
-        m_dc = new wxClientDC( GetOwner()->GetOwner() );
-    }
-
-    return m_dc;
-}
-
-void wxDataViewRenderer::SetAlignment( int align )
-{
-    m_align=align;
-}
-
-int wxDataViewRenderer::GetAlignment() const
-{
-    return m_align;
-}
-
-int wxDataViewRenderer::CalculateAlignment() const
-{
-    if (m_align == wxDVR_DEFAULT_ALIGNMENT)
-    {
-        if (GetOwner() == NULL)
-        return wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL;
-
-        return GetOwner()->GetAlignment() | wxALIGN_CENTRE_VERTICAL;
-    }
-
-    return m_align;
-}
-
-// ---------------------------------------------------------
-// wxDataViewCustomRenderer
-// ---------------------------------------------------------
-
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
-
-wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
-                        wxDataViewCellMode mode, int align ) :
-    wxDataViewRenderer( varianttype, mode, align )
-{
-}
-
 void
-wxDataViewCustomRenderer::RenderText(wxDC& dc,
-                                     const wxRect& rect,
-                                     int align,
-                                     const wxString& text,
-                                     const wxDataViewItemAttr *attr,
-                                     int state,
-                                     int xoffset)
+wxDataViewRenderer::RenderText(wxDC& dc,
+                               const wxRect& rect,
+                               int align,
+                               const wxString& text,
+                               const wxDataViewItemAttr *attr,
+                               int state,
+                               int xoffset)
 {
     // override custom foreground with the standard one for the selected items
     // because we currently don't allow changing the selection background and
@@ -774,15 +761,27 @@ wxDataViewCustomRenderer::RenderText(wxDC& dc,
                  rectText, align);
 }
 
+// ---------------------------------------------------------
+// wxDataViewCustomRenderer
+// ---------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
+
+wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
+                        wxDataViewCellMode mode, int align ) :
+    wxDataViewRenderer( varianttype, mode, align )
+{
+}
+
 // ---------------------------------------------------------
 // wxDataViewTextRenderer
 // ---------------------------------------------------------
 
-IMPLEMENT_CLASS(wxDataViewTextRenderer, wxDataViewCustomRenderer)
+IMPLEMENT_CLASS(wxDataViewTextRenderer, wxDataViewRenderer)
 
 wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString &varianttype,
                                                 wxDataViewCellMode mode, int align ) :
-    wxDataViewCustomRenderer( varianttype, mode, align )
+    wxDataViewRenderer( varianttype, mode, align )
 {
 }
 
@@ -847,11 +846,11 @@ wxSize wxDataViewTextRenderer::GetSize() const
 // wxDataViewBitmapRenderer
 // ---------------------------------------------------------
 
-IMPLEMENT_CLASS(wxDataViewBitmapRenderer, wxDataViewCustomRenderer)
+IMPLEMENT_CLASS(wxDataViewBitmapRenderer, wxDataViewRenderer)
 
 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString &varianttype,
                                                     wxDataViewCellMode mode, int align ) :
-    wxDataViewCustomRenderer( varianttype, mode, align )
+    wxDataViewRenderer( varianttype, mode, align )
 {
 }
 
@@ -894,11 +893,11 @@ wxSize wxDataViewBitmapRenderer::GetSize() const
 // wxDataViewToggleRenderer
 // ---------------------------------------------------------
 
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer, wxDataViewCustomRenderer)
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer, wxDataViewRenderer)
 
 wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString &varianttype,
                         wxDataViewCellMode mode, int align ) :
-    wxDataViewCustomRenderer( varianttype, mode, align )
+    wxDataViewRenderer( varianttype, mode, align )
 {
     m_toggle = false;
 }
@@ -951,11 +950,11 @@ wxSize wxDataViewToggleRenderer::GetSize() const
 // wxDataViewProgressRenderer
 // ---------------------------------------------------------
 
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer, wxDataViewCustomRenderer)
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer, wxDataViewRenderer)
 
 wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString &label,
     const wxString &varianttype, wxDataViewCellMode mode, int align ) :
-    wxDataViewCustomRenderer( varianttype, mode, align )
+    wxDataViewRenderer( varianttype, mode, align )
 {
     m_label = label;
     m_value = 0;
@@ -1057,11 +1056,11 @@ void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent &event )
 
 #endif // wxUSE_DATE_RENDERER_POPUP
 
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer, wxDataViewCustomRenderer)
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer, wxDataViewRenderer)
 
 wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString &varianttype,
                         wxDataViewCellMode mode, int align ) :
-    wxDataViewCustomRenderer( varianttype, mode, align )
+    wxDataViewRenderer( varianttype, mode, align )
 {
 }
 
@@ -1118,11 +1117,11 @@ bool wxDataViewDateRenderer::Activate( wxRect WXUNUSED(cell), wxDataViewModel *m
 // wxDataViewIconTextRenderer
 // ---------------------------------------------------------
 
-IMPLEMENT_CLASS(wxDataViewIconTextRenderer, wxDataViewCustomRenderer)
+IMPLEMENT_CLASS(wxDataViewIconTextRenderer, wxDataViewRenderer)
 
 wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(
 const wxString &varianttype, wxDataViewCellMode mode, int align ) :
-    wxDataViewCustomRenderer( varianttype, mode, align )
+    wxDataViewRenderer( varianttype, mode, align )
 {
     SetMode(mode);
     SetAlignment(align);
@@ -3665,12 +3664,15 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
         {
             if ((!ignore_other_columns) && (cell->GetMode() == wxDATAVIEW_CELL_ACTIVATABLE))
             {
-                wxVariant value;
-                model->GetValue( value, item, col->GetModelColumn() );
-                cell->SetValue( value );
-                wxRect cell_rect( xpos, GetLineStart( current ),
-                                col->GetWidth(), GetLineHeight( current ) );
-                cell->Activate( cell_rect, model, item, col->GetModelColumn() );
+                if ( wxDataViewCustomRenderer *custom = cell->WXGetAsCustom() )
+                {
+                    wxVariant value;
+                    model->GetValue( value, item, col->GetModelColumn() );
+                    custom->SetValue( value );
+                    wxRect cell_rect( xpos, GetLineStart( current ),
+                                    col->GetWidth(), GetLineHeight( current ) );
+                    custom->Activate( cell_rect, model, item, col->GetModelColumn() );
+                }
             }
             else
             {
@@ -3839,14 +3841,17 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
         // Call LeftClick after everything else as under GTK+
         if (cell->GetMode() & wxDATAVIEW_CELL_ACTIVATABLE)
         {
-            // notify cell about right click
-            wxVariant value;
-            model->GetValue( value, item, col->GetModelColumn() );
-            cell->SetValue( value );
-            wxRect cell_rect( xpos, GetLineStart( current ),
-                              col->GetWidth(), GetLineHeight( current ) );
-             /* ignore ret */ cell->LeftClick( event.GetPosition(), cell_rect,
-                              model, item, col->GetModelColumn());
+            if ( wxDataViewCustomRenderer *custom = cell->WXGetAsCustom() )
+            {
+                // notify cell about click
+                wxVariant value;
+                model->GetValue( value, item, col->GetModelColumn() );
+                custom->SetValue( value );
+                wxRect cell_rect( xpos, GetLineStart( current ),
+                                  col->GetWidth(), GetLineHeight( current ) );
+                 /* ignore ret */ custom->LeftClick( event.GetPosition(), cell_rect,
+                                  model, item, col->GetModelColumn());
+            }
         }
     }
 }
index a35bbbd9f8d071dcc3c70d68e27e826f152073f8..cf0ab2efebdce43a9644d671cf28b496d2816ad6 100644 (file)
@@ -2030,9 +2030,10 @@ public:
 IMPLEMENT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
 
 wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
-                                                    wxDataViewCellMode mode, int align,
-                                                    bool no_init ) :
-    wxDataViewRenderer( varianttype, mode, align )
+                                                    wxDataViewCellMode mode,
+                                                    int align,
+                                                    bool no_init )
+    : wxDataViewCustomRendererBase( varianttype, mode, align )
 {
     m_dc = NULL;
     m_text_renderer = NULL;
index 2e19bcd1e1959fdae841c19faebb9f22b809009a..5abd1ecd4868d04a84db626a3f4e9498666d67e1 100644 (file)
@@ -2305,7 +2305,9 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase)
 // wxDataViewCustomRenderer
 // ---------------------------------------------------------
 wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align)
-                         :wxDataViewRenderer(varianttype,mode,align), m_editorCtrlPtr(NULL), m_DCPtr(NULL)
+                         :wxDataViewCustomRendererBase(varianttype,mode,align),
+                          m_editorCtrlPtr(NULL),
+                          m_DCPtr(NULL)
 {
   SetNativeData(new wxDataViewRendererNativeData(kDataBrowserCustomType));
 }
index 955b7bb1cb8b7bf673ce909c8b09160d92882875..3951253a5c7fb42acc7133973480cb8a637c6cf6 100644 (file)
@@ -2389,7 +2389,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase)
 wxDataViewCustomRenderer::wxDataViewCustomRenderer(const wxString& varianttype,
                                                    wxDataViewCellMode mode,
                                                    int align)
-    : wxDataViewRenderer(varianttype, mode, align),
+    : wxDataViewCustomRendererBase(varianttype, mode, align),
       m_editorCtrlPtr(NULL),
       m_DCPtr(NULL)
 {
@@ -2486,7 +2486,8 @@ IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
 wxDataViewChoiceRenderer::wxDataViewChoiceRenderer(const wxArrayString& choices,
                                                    wxDataViewCellMode mode,
                                                    int alignment)
-    : wxDataViewRenderer(wxT("string"),mode,alignment), m_Choices(choices)
+    : wxDataViewRenderer(wxT("string"), mode, alignment),
+      m_choices(choices)
 {
     NSPopUpButtonCell* cell;