]> git.saurik.com Git - wxWidgets.git/commitdiff
Return the real column width from wxOSX wxDataViewColumn::GetWidth().
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 31 Oct 2009 15:57:51 +0000 (15:57 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 31 Oct 2009 15:57:51 +0000 (15:57 +0000)
Code used to return the last programmatically set width value instead of the
real column width which could have been changed by user if the column was
resizeable, fix this by returning the current NSTableColumn:width value.

Closes #11397.

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

docs/changes.txt
include/wx/osx/dataview.h
src/osx/carbon/dataview.cpp
src/osx/cocoa/dataview.mm

index 2ff3c5021168872979333ab2e4ef2126b4b89c42..6897d9d4083bb6a5874493f2f4f18bbd2c2b834f 100644 (file)
@@ -477,6 +477,7 @@ Mac:
 
 - Implement wxWindow::ShowWithEffect() in wxOSX/Cocoa.
 - Correct min/max pages display in the print dialog (Auria).
+- Fix wxDataViewColumn::GetWidth() in Cocoa (Neno Ganchev).
 
 MSW:
 
index 3ed73d59654a309ab874aa8df235aaf59d085e15..c7f9433b68c6916a9d642aded9d203770f76e529 100644 (file)
@@ -397,7 +397,7 @@ public:
     virtual int GetMaxWidth() const { return m_maxWidth; }
     virtual int GetMinWidth() const { return m_minWidth; }
     virtual wxString GetTitle() const { return m_title; }
-    virtual int GetWidth() const { return m_width; }
+    virtual int GetWidth() const;
     virtual bool IsHidden() const { return false; } // TODO
     virtual bool IsSortOrderAscending() const { return m_ascending; }
     virtual bool IsSortKey() const;
@@ -423,6 +423,10 @@ public:
     }
 
     void SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr); // class takes ownership of pointer
+    int GetWidthVariable() const
+    {
+        return m_width;
+    }
     void SetWidthVariable(int NewWidth)
     {
         m_width = NewWidth;
index 30d3d20ef1c0d60cafd22c2f48586f051cba3af5..2e19bcd1e1959fdae841c19faebb9f22b809009a 100644 (file)
@@ -2476,6 +2476,13 @@ wxDataViewColumn::~wxDataViewColumn()
   delete m_NativeDataPtr;
 }
 
+int wxDataViewColumn::GetWidth() const
+{
+    // FIXME: This returns the last programatically set width and will not work if
+    //        the user changes the column's width by dragging it with the mouse.
+    return m_width;
+}
+
 bool wxDataViewColumn::IsSortKey() const
 {
     wxDataViewCtrl * const dataViewCtrlPtr(GetOwner());
index de70d511ca13d0f466f6395006a698a4657552b7..955b7bb1cb8b7bf673ce909c8b09160d92882875 100644 (file)
@@ -258,6 +258,7 @@ NSTableColumn* CreateNativeColumn(const wxDataViewColumn *column)
     );
 
     // setting the size related parameters:
+    const int width = column->GetWidthVariable();
     if (column->IsResizeable())
     {
         [nativeColumn setResizingMask:NSTableColumnUserResizingMask];
@@ -267,10 +268,10 @@ NSTableColumn* CreateNativeColumn(const wxDataViewColumn *column)
     else
     {
         [nativeColumn setResizingMask:NSTableColumnNoResizing];
-        [nativeColumn setMinWidth:column->GetWidth()];
-        [nativeColumn setMaxWidth:column->GetWidth()];
+        [nativeColumn setMinWidth:width];
+        [nativeColumn setMaxWidth:width];
     }
-    [nativeColumn setWidth:column->GetWidth()];
+    [nativeColumn setWidth:width];
 
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
     // setting the visibility:
@@ -2773,6 +2774,11 @@ wxDataViewColumn::~wxDataViewColumn()
     delete m_NativeDataPtr;
 }
 
+int wxDataViewColumn::GetWidth() const
+{
+    return [m_NativeDataPtr->GetNativeColumnPtr() width];
+}
+
 bool wxDataViewColumn::IsSortKey() const
 {
     NSTableColumn *nsCol = GetNativeData()->GetNativeColumnPtr();