+wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
+{
+}
+
+void wxDataViewProgressRenderer::GTKSetLabel()
+{
+ GValue gvalue = { 0, };
+ g_value_init( &gvalue, G_TYPE_STRING );
+
+ // Take care to not use GetOwner() here if the label is empty, we can be
+ // called from ctor when GetOwner() is still NULL in this case.
+ g_value_set_string( &gvalue,
+ m_label.empty() ? ""
+ : wxGTK_CONV_FONT(m_label,
+ GetOwner()->GetOwner()->GetFont())
+ );
+ g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue );
+ g_value_unset( &gvalue );
+
+#if !wxUSE_UNICODE
+ m_needsToSetLabel = false;
+#endif // !wxUSE_UNICODE
+}
+
+bool wxDataViewProgressRenderer::SetValue( const wxVariant &value )
+{
+#ifdef __WXGTK26__
+ if (!gtk_check_version(2,6,0))
+ {
+#if !wxUSE_UNICODE
+ if ( m_needsToSetLabel )
+ GTKSetLabel();
+#endif // !wxUSE_UNICODE
+
+ gint tmp = (long) value;
+ GValue gvalue = { 0, };
+ g_value_init( &gvalue, G_TYPE_INT );
+ g_value_set_int( &gvalue, tmp );
+ g_object_set_property( G_OBJECT(m_renderer), "value", &gvalue );
+ g_value_unset( &gvalue );
+ }
+ else
+#endif
+ {
+ m_value = (long) value;
+
+ if (m_value < 0) m_value = 0;
+ if (m_value > 100) m_value = 100;
+ }
+
+ return true;
+}
+
+bool wxDataViewProgressRenderer::GetValue( wxVariant &WXUNUSED(value) ) const
+{
+ return false;
+}
+
+bool wxDataViewProgressRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
+{
+ double pct = (double)m_value / 100.0;
+ wxRect bar = cell;
+ bar.width = (int)(cell.width * pct);
+ dc->SetPen( *wxTRANSPARENT_PEN );
+ dc->SetBrush( *wxBLUE_BRUSH );
+ dc->DrawRectangle( bar );
+
+ dc->SetBrush( *wxTRANSPARENT_BRUSH );
+ dc->SetPen( *wxBLACK_PEN );
+ dc->DrawRectangle( cell );
+
+ return true;
+}
+
+wxSize wxDataViewProgressRenderer::GetSize() const
+{
+ return wxSize(40,12);
+}
+
+// -------------------------------------
+// wxDataViewChoiceRenderer
+// -------------------------------------
+
+wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString &choices,
+ wxDataViewCellMode mode, int alignment ) :
+ wxDataViewCustomRenderer( "string", mode, alignment, true )
+{
+ m_choices = choices;
+
+#ifdef __WXGTK26__
+ if (!gtk_check_version(2,6,0))
+ {
+ m_renderer = (GtkCellRenderer*) gtk_cell_renderer_combo_new();
+
+ GtkListStore *store = gtk_list_store_new( 1, G_TYPE_STRING );
+ for (size_t n = 0; n < m_choices.GetCount(); n++)
+ {
+ gtk_list_store_insert_with_values(
+ store, NULL, n, 0,
+ static_cast<const char *>(m_choices[n].utf8_str()), -1 );
+ }
+
+ g_object_set (m_renderer,
+ "model", store,
+ "text-column", 0,
+ "has-entry", FALSE,
+ NULL);
+
+ bool editable = (mode & wxDATAVIEW_CELL_EDITABLE);
+ g_object_set (m_renderer, "editable", editable, NULL);
+
+ SetAlignment(alignment);
+
+ g_signal_connect_after( m_renderer, "edited", G_CALLBACK(wxGtkTextRendererEditedCallback), this );
+
+ GtkInitHandlers();
+ }
+ else
+#endif
+ {
+ // Use custom cell code
+ wxDataViewCustomRenderer::Init(mode, alignment);
+ }
+}
+
+bool wxDataViewChoiceRenderer::Render( wxRect rect, wxDC *dc, int state )
+{
+ RenderText( m_data, 0, rect, dc, state );
+ return true;
+}
+
+wxSize wxDataViewChoiceRenderer::GetSize() const
+{
+ return wxSize(70,20);
+}
+
+bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value )
+{
+
+#ifdef __WXGTK26__
+ if (!gtk_check_version(2,6,0))
+ {
+ GValue gvalue = { 0, };
+ g_value_init( &gvalue, G_TYPE_STRING );
+ g_value_set_string(&gvalue,
+ wxGTK_CONV_FONT(value.GetString(),
+ GetOwner()->GetOwner()->GetFont()));
+ g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue );
+ g_value_unset( &gvalue );
+ }
+ else
+#endif
+ m_data = value.GetString();
+
+ return true;
+}
+
+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 )