]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datavcmn.cpp
Allow user code to override key events in generic wxListCtrl.
[wxWidgets.git] / src / common / datavcmn.cpp
index dca9eaab7d2716fcae95006a1b37eb5d93a5ffe7..f7e5749ed1f4313973749465e45a4aced1163969 100644 (file)
@@ -1391,14 +1391,9 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString& choices
 
 wxControl* wxDataViewChoiceRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value )
 {
-    wxString s = value;
-    wxSize size = labelRect.GetSize();
-#ifdef __WXMAC__
-    size = wxSize( wxMax(70,labelRect.width ), -1 );
-#endif
-    wxChoice *c = new wxChoice( parent, wxID_ANY, labelRect.GetTopLeft(), size, m_choices );
+    wxChoice* c = new wxChoice(parent, wxID_ANY, labelRect.GetTopLeft(), wxDefaultSize, m_choices );
+    c->Move(labelRect.GetRight() - c->GetRect().width, wxDefaultCoord);
     c->SetStringSelection( value.GetString() );
-
     return c;
 }
 
@@ -1433,6 +1428,49 @@ bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const
     return true;
 }
 
+// ----------------------------------------------------------------------------
+// wxDataViewChoiceByIndexRenderer
+// ----------------------------------------------------------------------------
+
+wxDataViewChoiceByIndexRenderer::wxDataViewChoiceByIndexRenderer( const wxArrayString &choices,
+                                  wxDataViewCellMode mode, int alignment ) :
+      wxDataViewChoiceRenderer( choices, mode, alignment )
+{
+}
+                            
+wxControl* wxDataViewChoiceByIndexRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value )
+{
+    wxVariant string_value = GetChoice( value.GetLong() );
+    
+    return wxDataViewChoiceRenderer::CreateEditorCtrl( parent, labelRect, string_value );
+}
+
+bool wxDataViewChoiceByIndexRenderer::GetValueFromEditorCtrl( wxControl* editor, wxVariant &value )
+{
+    wxVariant string_value;
+    if (!wxDataViewChoiceRenderer::GetValueFromEditorCtrl( editor, string_value ))
+        return false;
+
+    value = (long) GetChoices().Index( string_value.GetString() );
+    return true;
+}
+
+bool wxDataViewChoiceByIndexRenderer::SetValue( const wxVariant &value )
+{
+    wxVariant string_value = GetChoice( value.GetLong() );
+    return wxDataViewChoiceRenderer::SetValue( string_value );
+}
+    
+bool wxDataViewChoiceByIndexRenderer::GetValue( wxVariant &value ) const
+{
+    wxVariant string_value;
+    if (!wxDataViewChoiceRenderer::GetValue( string_value ))
+        return false;
+            
+    value = (long) GetChoices().Index( string_value.GetString() );
+    return true;
+}
+
 #endif
 
 //-----------------------------------------------------------------------------