]> git.saurik.com Git - wxWidgets.git/commitdiff
Add convenient wxListCtrl::AppendColumn() wrapper.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Jan 2012 15:09:47 +0000 (15:09 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Jan 2012 15:09:47 +0000 (15:09 +0000)
In the vast majority of cases, columns are just appended to the end and not
inserted at arbitrary positions in wxListCtrl so provide a convenient wrapper
to do this, especially as it's really trivial to do it now when it can be done
only once at wxListCtrlBase level.

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

include/wx/listbase.h
interface/wx/listctrl.h
src/common/listctrlcmn.cpp

index 85450e236ced47cdafe709dc426f679aa2a69a6f..fe247e8299e92797d4868c154cfe504f94c5112a 100644 (file)
@@ -410,6 +410,13 @@ public:
 
     // All these methods can only be used in report view mode.
 
+    // Appends a new column.
+    //
+    // Returns the index of the newly inserted column or -1 on error.
+    long AppendColumn(const wxString& heading,
+                      int format = wxLIST_FORMAT_LEFT,
+                      int width = -1);
+
     // Add a new column to the control at the position "col".
     //
     // Returns the index of the newly inserted column or -1 on error.
index 3c285a12ea2ac46265ea68ecf26dcc6f87ddfc31..3103be6b2fc5fed747a02aaf308a8f9b3d098317 100644 (file)
@@ -197,6 +197,19 @@ public:
     */
     virtual ~wxListCtrl();
 
+    /**
+        Adds a new column to the list control in report view mode.
+
+        This is just a convenient wrapper for InsertColumn() which adds the new
+        column after all the existing ones without having to specify its
+        position explicitly.
+
+        @since 2.9.4
+     */
+    long AppendColumn(const wxString& heading,
+                      int format = wxLIST_FORMAT_LEFT,
+                      int width = -1);
+
     /**
         Arranges the items in icon or small icon view.
         This only has effect on Win32. @a flag is one of:
index 861beef99454112132f73f330a6cc641057ae219..b19ed6e38cb42d7ca401e5f53ff9e8ab9c82e335 100644 (file)
@@ -136,6 +136,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent)
 // wxListCtrlBase implementation
 // ----------------------------------------------------------------------------
 
+long
+wxListCtrlBase::AppendColumn(const wxString& heading,
+                             int format,
+                             int width)
+{
+    return InsertColumn(GetColumnCount(), heading, format, width);
+}
+
 long
 wxListCtrlBase::InsertColumn(long col,
                              const wxString& heading,