+bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const
+{
+#ifdef __WXGTK26__
+ if (!gtk_check_version(2,6,0))
+ {
+ GValue gvalue = { 0, };
+ g_value_init( &gvalue, G_TYPE_STRING );
+ g_object_get_property( G_OBJECT(m_renderer), "text", &gvalue );
+ wxString temp = wxGTK_CONV_BACK_FONT(g_value_get_string(&gvalue),
+ GetOwner()->GetOwner()->GetFont());
+ g_value_unset( &gvalue );
+ value = temp;
+
+ //wxPrintf( "temp %s\n", temp );
+ // TODO: remove this code
+ }
+ else
+#endif
+ value = m_data;
+
+ return true;
+}
+
+void wxDataViewChoiceRenderer::SetAlignment( int align )
+{
+ wxDataViewCustomRenderer::SetAlignment(align);
+
+ if (gtk_check_version(2,10,0))
+ return;
+
+ // horizontal alignment:
+ PangoAlignment pangoAlign = PANGO_ALIGN_LEFT;
+ if (align & wxALIGN_RIGHT)
+ pangoAlign = PANGO_ALIGN_RIGHT;
+ else if (align & wxALIGN_CENTER_HORIZONTAL)
+ pangoAlign = PANGO_ALIGN_CENTER;
+
+ GValue gvalue = { 0, };
+ g_value_init( &gvalue, gtk_cell_renderer_mode_get_type() );
+ g_value_set_enum( &gvalue, pangoAlign );
+ g_object_set_property( G_OBJECT(m_renderer), "alignment", &gvalue );
+ g_value_unset( &gvalue );
+}
+
+// ----------------------------------------------------------------------------
+// wxDataViewChoiceByIndexRenderer
+// ----------------------------------------------------------------------------
+
+wxDataViewChoiceByIndexRenderer::wxDataViewChoiceByIndexRenderer( const wxArrayString &choices,
+ wxDataViewCellMode mode, int alignment ) :
+ wxDataViewChoiceRenderer( choices, mode, alignment )
+{
+}
+
+void wxDataViewChoiceByIndexRenderer::GtkOnTextEdited(const gchar *itempath, const wxString& str)
+{
+ wxVariant value( (long) GetChoices().Index( str ) );
+
+ if (!Validate( value ))
+ return;
+
+ wxDataViewItem
+ item(GetOwner()->GetOwner()->GTKPathToItem(wxGtkTreePath(itempath)));
+
+ GtkOnCellChanged(value, item, GetOwner()->GetModelColumn());
+}
+
+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;
+}
+
+// ---------------------------------------------------------
+// wxDataViewDateRenderer
+// ---------------------------------------------------------
+
+class wxDataViewDateRendererPopupTransient: public wxPopupTransientWindow
+{
+public:
+ wxDataViewDateRendererPopupTransient( wxWindow* parent, wxDateTime *value,
+ wxDataViewModel *model, const wxDataViewItem &item, unsigned int col ) :
+ wxPopupTransientWindow( parent, wxBORDER_SIMPLE )
+ {
+ m_model = model;
+ m_item = item;
+ m_col = col;
+ m_cal = new wxCalendarCtrl( this, -1, *value );
+ wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
+ sizer->Add( m_cal, 1, wxGROW );
+ SetSizer( sizer );
+ sizer->Fit( this );
+ }
+
+ virtual void OnDismiss()
+ {
+ }
+
+ void OnCalendar( wxCalendarEvent &event );
+
+ wxCalendarCtrl *m_cal;
+ wxDataViewModel *m_model;
+ wxDataViewItem m_item;
+ unsigned int m_col;
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient,wxPopupTransientWindow)
+ EVT_CALENDAR( -1, wxDataViewDateRendererPopupTransient::OnCalendar )
+END_EVENT_TABLE()
+
+void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent &event )
+{
+ m_model->ChangeValue( event.GetDate(), m_item, m_col );
+ DismissAndNotify();
+}
+
+IMPLEMENT_CLASS(wxDataViewDateRenderer, wxDataViewCustomRenderer)
+
+wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString &varianttype,
+ wxDataViewCellMode mode, int align ) :
+ wxDataViewCustomRenderer( varianttype, mode, align )
+{
+ SetMode(mode);
+ SetAlignment(align);
+}
+
+bool wxDataViewDateRenderer::SetValue( const wxVariant &value )
+{
+ m_date = value.GetDateTime();
+
+ return true;
+}
+
+bool wxDataViewDateRenderer::GetValue( wxVariant &WXUNUSED(value) ) const
+{
+ return false;
+}
+
+bool wxDataViewDateRenderer::Render( wxRect cell, wxDC *dc, int state )
+{
+ dc->SetFont( GetOwner()->GetOwner()->GetFont() );
+ wxString tmp = m_date.FormatDate();
+ RenderText( tmp, 0, cell, dc, state );
+ return true;
+}
+
+wxSize wxDataViewDateRenderer::GetSize() const
+{
+ wxString tmp = m_date.FormatDate();
+ wxCoord x,y,d;
+ GetView()->GetTextExtent( tmp, &x, &y, &d );
+ return wxSize(x,y+d);
+}
+
+bool wxDataViewDateRenderer::Activate( const wxRect& WXUNUSED(cell), wxDataViewModel *model,
+ const wxDataViewItem &item, unsigned int col )