From c7074d44198d548dd19e7906b697d019b3c01770 Mon Sep 17 00:00:00 2001
From: Robert Roebling <robert@roebling.de>
Date: Wed, 22 Aug 2007 13:39:32 +0000
Subject: [PATCH] Let various AppendXXXColumn helplers return the column
 created within

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48330 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/dataviewcolumn.tex | 10 +---
 docs/latex/wx/dataviewctrl.tex   | 42 ++++++++------
 include/wx/dataview.h            | 21 +++----
 src/common/datavcmn.cpp          | 94 +++++++++++++++++++++-----------
 4 files changed, 101 insertions(+), 66 deletions(-)

diff --git a/docs/latex/wx/dataviewcolumn.tex b/docs/latex/wx/dataviewcolumn.tex
index 79abe67545..bf8e50e407 100644
--- a/docs/latex/wx/dataviewcolumn.tex
+++ b/docs/latex/wx/dataviewcolumn.tex
@@ -11,7 +11,7 @@ this class to render its data.
 
 \wxheading{Constants}
 
-These flags define behavi
+These flags define behaviour of the column:
 
 {\small
 \begin{verbatim}
@@ -122,9 +122,7 @@ Set the bitmap of the column header.
 
 Indicate the sort order if the implementation of the
 wxDataViewCtrl supports it, most commonly by showing
-a little arrow. Use this in conjunction with 
-\helpref{wxDataViewSortedListModel::SetAscending}{wxdataviewsortedlistmodelsetascending}
-to sort the actual data.
+a little arrow. 
 
 \membersection{wxDataViewColumn::SetSortable}\label{wxdataviewcolumnsetsortable}
 
@@ -132,9 +130,7 @@ to sort the actual data.
 
 Indicate that the column is sortable. This is only to provide a
 visual hint in the column (such as a sort order indicator). It
-will not actually sort the data. Use a 
-\helpref{wxDataViewSortedListModel}{wxdataviewsortedlistmodel}
-to so the sorting.
+will not actually sort the data. 
 
 \membersection{wxDataViewColumn::SetTitle}\label{wxdataviewcolumnsettitle}
 
diff --git a/docs/latex/wx/dataviewctrl.tex b/docs/latex/wx/dataviewctrl.tex
index 8bcc68f847..f9f99941c5 100644
--- a/docs/latex/wx/dataviewctrl.tex
+++ b/docs/latex/wx/dataviewctrl.tex
@@ -88,51 +88,57 @@ Destructor.
 
 \func{virtual bool}{AppendColumn}{\param{wxDataViewColumn* }{col}}
 
-Add a \helpref{wxDataViewColumn}{wxdataviewcolumn} to the control. Note
-that there is a number of short cut methods which implicitly create
+Add a \helpref{wxDataViewColumn}{wxdataviewcolumn} to the control. Returns
+{\it true} on success.
+
+Note that there is a number of short cut methods which implicitly create
 a \helpref{wxDataViewColumn}{wxdataviewcolumn} and a 
 \helpref{wxDataViewRenderer}{wxdataviewrenderer} for it (see below).
 
-
 \membersection{wxDataViewCtrl::AppendBitmapColumn}\label{wxdataviewctrlappendbitmapcolumn}
 
-\func{bool}{AppendBitmapColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
+\func{wxDataViewColumn*}{AppendBitmapColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
 
-\func{bool}{AppendBitmapColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
+\func{wxDataViewColumn*}{AppendBitmapColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
 
-Appends a column for rendering a bitmap.
+Appends a column for rendering a bitmap. Returns the wxDataViewColumn
+created in the function or NULL on failure.
 
 \membersection{wxDataViewCtrl::AppendDateColumn}\label{wxdataviewctrlappenddatecolumn}
 
-\func{bool}{AppendDateColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}, \param{int }{width = -1}}
+\func{wxDataViewColumn*}{AppendDateColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}, \param{int }{width = -1}}
 
-\func{bool}{AppendDateColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}, \param{int }{width = -1}}
+\func{wxDataViewColumn*}{AppendDateColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}, \param{int }{width = -1}}
 
-Appends a column for rendering a date.
+Appends a column for rendering a date. Returns the wxDataViewColumn
+created in the function or NULL on failure.
 
 \membersection{wxDataViewCtrl::AppendProgressColumn}\label{wxdataviewctrlappendprogresscolumn}
 
-\func{bool}{AppendProgressColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 80}}
+\func{wxDataViewColumn*}{AppendProgressColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 80}}
 
-\func{bool}{AppendProgressColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 80}}
+\func{wxDataViewColumn*}{AppendProgressColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 80}}
 
-Appends a column for rendering a progress indicator.
+Appends a column for rendering a progress indicator. Returns the wxDataViewColumn
+created in the function or NULL on failure.
 
 \membersection{wxDataViewCtrl::AppendTextColumn}\label{wxdataviewctrlappendtextcolumn}
 
-\func{bool}{AppendTextColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
+\func{wxDataViewColumn*}{AppendTextColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
 
-\func{bool}{AppendTextColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
+\func{wxDataViewColumn*}{AppendTextColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
 
-Appends a column for rendering text.
+Appends a column for rendering text. Returns the wxDataViewColumn
+created in the function or NULL on failure.
 
 \membersection{wxDataViewCtrl::AppendToggleColumn}\label{wxdataviewctrlappendtogglecolumn}
 
-\func{bool}{AppendToggleColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}}
+\func{wxDataViewColumn*}{AppendToggleColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}}
 
-\func{bool}{AppendToggleColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}}
+\func{wxDataViewColumn*}{AppendToggleColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}}
 
-Appends a column for rendering a toggle.
+Appends a column for rendering a toggle. Returns the wxDataViewColumn
+created in the function or NULL on failure.
 
 \membersection{wxDataViewCtrl::AssociateModel}\label{wxdataviewctrlassociatemodel}
 
diff --git a/include/wx/dataview.h b/include/wx/dataview.h
index df1aff2852..2286965603 100644
--- a/include/wx/dataview.h
+++ b/include/wx/dataview.h
@@ -413,43 +413,44 @@ public:
     wxDataViewModel* GetModel();
 
     // short cuts
-    bool AppendTextColumn( const wxString &label, unsigned int model_column, 
+    wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, 
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
-    bool AppendToggleColumn( const wxString &label, unsigned int model_column,
+    wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
-    bool AppendProgressColumn( const wxString &label, unsigned int model_column, 
+    wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, 
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
-    bool AppendDateColumn( const wxString &label, unsigned int model_column,
+    wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
-    bool AppendBitmapColumn( const wxString &label, unsigned int model_column,
+    wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
-    bool AppendTextColumn( const wxBitmap &label, unsigned int model_column,
+    wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
-    bool AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
+    wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
-    bool AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
+    wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
-    bool AppendDateColumn( const wxBitmap &label, unsigned int model_column,
+    wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
-    bool AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
+    
+    wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
                     wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
                     wxAlignment align = wxALIGN_CENTER,
                     int flags = wxDATAVIEW_COL_RESIZABLE );
diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp
index 87e5d3b807..d7c44d97e0 100644
--- a/src/common/datavcmn.cpp
+++ b/src/common/datavcmn.cpp
@@ -579,87 +579,119 @@ wxDataViewModel* wxDataViewCtrlBase::GetModel()
     return m_model;
 }
 
-bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
+wxDataViewColumn *
+wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
 {
-    return AppendColumn( new wxDataViewColumn( label,
+    wxDataViewColumn *ret = new wxDataViewColumn( label,
         new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
-        model_column, width, align, flags ) );
+        model_column, width, align, flags );
+    AppendColumn( ret );
+    return ret;
 }
 
-bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
+bool
+wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
 {
     m_cols.Append( (wxObject*) col );
     col->SetOwner( (wxDataViewCtrl*) this );
-- 
2.50.0

