X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/724852daae642bbba3e02e11e972e747ed106190..51fe4b60ab4fec78eb1a67473d08b1c4740d03f5:/src/common/datavcmn.cpp diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index cbc0840fa9..c0850cbf16 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -19,6 +19,7 @@ #include "wx/dataview.h" #include "wx/spinctrl.h" +#include "wx/choice.h" #include "wx/weakref.h" @@ -30,7 +31,7 @@ #include "wx/crt.h" #endif -const wxChar wxDataViewCtrlNameStr[] = wxT("dataviewCtrl"); +const char wxDataViewCtrlNameStr[] = "dataviewCtrl"; bool operator == (const wxDataViewItem &left, const wxDataViewItem &right) @@ -671,7 +672,7 @@ wxDataViewRendererBase::~wxDataViewRendererBase() const wxDataViewCtrl* wxDataViewRendererBase::GetView() const { - return wx_const_cast(wxDataViewRendererBase*, this)->GetOwner()->GetOwner(); + return const_cast(this)->GetOwner()->GetOwner(); } class wxKillRef: public wxWindowRef @@ -721,7 +722,7 @@ bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect la void wxDataViewRendererBase::CancelEditing() { if (!m_editorCtrl) return; - + GetOwner()->GetOwner()->GetMainWindow()->SetFocus(); m_editorCtrl->Hide(); @@ -1220,7 +1221,7 @@ wxDataViewCtrlBase::PrependColumn( wxDataViewColumn *col ) return true; } -bool +bool wxDataViewCtrlBase::InsertColumn( unsigned int WXUNUSED(pos), wxDataViewColumn *col ) { col->SetOwner( (wxDataViewCtrl*) this ); @@ -1316,6 +1317,64 @@ bool wxDataViewSpinRenderer::GetValue( wxVariant &value ) const return true; } +// ------------------------------------- +// wxDataViewChoiceRenderer +// ------------------------------------- + +#ifndef __WXGTK20__ + +wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString& choices, wxDataViewCellMode mode, int alignment ) : + wxDataViewCustomRenderer(wxT("string"), mode, alignment ) +{ + m_choices = 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 ); + c->SetStringSelection( value.GetString() ); + + return c; +} + +bool wxDataViewChoiceRenderer::GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ) +{ + wxChoice *c = (wxChoice*) editor; + wxString s = c->GetStringSelection(); + value = s; + return true; +} + +bool wxDataViewChoiceRenderer::Render( wxRect rect, wxDC *dc, int state ) +{ + RenderText( m_data, 0, rect, dc, state ); + return true; +} + +wxSize wxDataViewChoiceRenderer::GetSize() const +{ + return wxSize(80,16); +} + +bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value ) +{ + m_data = value.GetString(); + return true; +} + +bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const +{ + value = m_data; + return true; +} + +#endif + //----------------------------------------------------------------------------- // wxDataViewTreeStore //-----------------------------------------------------------------------------