]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datavcmn.cpp
Fix wxListCtrlXmlHandler so that it accepts icon with wxLC_LIST and wxLC_REPORT style...
[wxWidgets.git] / src / common / datavcmn.cpp
index fa3d3563d5e562ca254aec5be87ce75d2acfca87..57c175af8ccb19eff35fd750f31bab2bdb95018d 100644 (file)
@@ -728,12 +728,15 @@ bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect la
 
 void wxDataViewRendererBase::DestroyEditControl()
 {
+    // Remove our event handler first to prevent it from (recursively) calling
+    // us again as it would do via a call to FinishEditing() when the editor
+    // loses focus when we hide it below.
+    wxEvtHandler * const handler = m_editorCtrl->PopEventHandler();
+
     // Hide the control immediately but don't delete it yet as there could be
     // some pending messages for it.
     m_editorCtrl->Hide();
 
-    wxEvtHandler * const handler = m_editorCtrl->PopEventHandler();
-
     wxPendingDelete.Append(handler);
     wxPendingDelete.Append(m_editorCtrl);
 }
@@ -743,8 +746,6 @@ void wxDataViewRendererBase::CancelEditing()
     if (!m_editorCtrl)
         return;
 
-    GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
-
     DestroyEditControl();
 }
 
@@ -1455,7 +1456,15 @@ bool wxDataViewSpinRenderer::Render( wxRect rect, wxDC *dc, int state )
 
 wxSize wxDataViewSpinRenderer::GetSize() const
 {
-    return wxSize(80,16);
+    wxSize sz = GetTextExtent(wxString::Format("%d", (int)m_data));
+
+    // Allow some space for the spin buttons, which is approximately the size
+    // of a scrollbar (and getting pixel-exact value would be complicated).
+    // Also add some whitespace between the text and the button:
+    sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
+    sz.x += GetTextExtent("M").x;
+
+    return sz;
 }
 
 bool wxDataViewSpinRenderer::SetValue( const wxVariant &value )
@@ -1513,7 +1522,18 @@ bool wxDataViewChoiceRenderer::Render( wxRect rect, wxDC *dc, int state )
 
 wxSize wxDataViewChoiceRenderer::GetSize() const
 {
-    return wxSize(80,16);
+    wxSize sz;
+
+    for ( wxArrayString::const_iterator i = m_choices.begin(); i != m_choices.end(); ++i )
+        sz.IncTo(GetTextExtent(*i));
+
+    // Allow some space for the right-side button, which is approximately the
+    // size of a scrollbar (and getting pixel-exact value would be complicated).
+    // Also add some whitespace between the text and the button:
+    sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
+    sz.x += GetTextExtent("M").x;
+
+    return sz;
 }
 
 bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value )