+
+ // NOTE: SetMode() and SetAlignment() needs to be called in the renderer's ctor,
+ // after the m_renderer pointer has been initialized
+}
+
+void wxDataViewRenderer::SetMode( wxDataViewCellMode mode )
+{
+ GtkCellRendererMode gtkMode;
+ switch (mode)
+ {
+ case wxDATAVIEW_CELL_INERT:
+ gtkMode = GTK_CELL_RENDERER_MODE_INERT;
+ break;
+ case wxDATAVIEW_CELL_ACTIVATABLE:
+ gtkMode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
+ break;
+ case wxDATAVIEW_CELL_EDITABLE:
+ gtkMode = GTK_CELL_RENDERER_MODE_EDITABLE;
+ break;
+ }
+
+ GValue gvalue = { 0, };
+ g_value_init( &gvalue, gtk_cell_renderer_mode_get_type() );
+ g_value_set_enum( &gvalue, gtkMode );
+ g_object_set_property( G_OBJECT(m_renderer), "mode", &gvalue );
+ g_value_unset( &gvalue );
+}
+
+wxDataViewCellMode wxDataViewRenderer::GetMode() const
+{
+ wxDataViewCellMode ret;
+
+ GValue gvalue;
+ g_object_get( G_OBJECT(m_renderer), "mode", &gvalue, NULL);
+
+ switch (g_value_get_enum(&gvalue))
+ {
+ case GTK_CELL_RENDERER_MODE_INERT:
+ ret = wxDATAVIEW_CELL_INERT;
+ break;
+ case GTK_CELL_RENDERER_MODE_ACTIVATABLE:
+ ret = wxDATAVIEW_CELL_ACTIVATABLE;
+ break;
+ case GTK_CELL_RENDERER_MODE_EDITABLE:
+ ret = wxDATAVIEW_CELL_EDITABLE;
+ break;
+ }
+
+ g_value_unset( &gvalue );
+
+ return ret;
+}
+
+void wxDataViewRenderer::SetAlignment( int align )
+{
+ // horizontal alignment:
+
+ gfloat xalign = 0.0;
+ if (align & wxALIGN_RIGHT)
+ xalign = 1.0;
+ else if (align & wxALIGN_CENTER_HORIZONTAL)
+ xalign = 0.5;
+
+ GValue gvalue = { 0, };
+ g_value_init( &gvalue, G_TYPE_FLOAT );
+ g_value_set_float( &gvalue, xalign );
+ g_object_set_property( G_OBJECT(m_renderer), "xalign", &gvalue );
+ g_value_unset( &gvalue );
+
+ // vertical alignment:
+
+ gfloat yalign = 0.0;
+ if (align & wxALIGN_BOTTOM)
+ yalign = 1.0;
+ else if (align & wxALIGN_CENTER_VERTICAL)
+ yalign = 0.5;
+
+ GValue gvalue2 = { 0, };
+ g_value_init( &gvalue2, G_TYPE_FLOAT );
+ g_value_set_float( &gvalue2, yalign );
+ g_object_set_property( G_OBJECT(m_renderer), "yalign", &gvalue2 );
+ g_value_unset( &gvalue2 );
+}
+
+int wxDataViewRenderer::GetAlignment() const
+{
+ int ret = 0;
+ GValue gvalue;
+
+ // horizontal alignment:
+
+ g_object_get( G_OBJECT(m_renderer), "xalign", &gvalue, NULL );
+ float xalign = g_value_get_float( &gvalue );
+ if (xalign < 0.5)
+ ret |= wxALIGN_LEFT;
+ else if (xalign == 0.5)
+ ret |= wxALIGN_CENTER_HORIZONTAL;
+ else
+ ret |= wxALIGN_RIGHT;
+ g_value_unset( &gvalue );
+
+
+ // vertical alignment:
+
+ g_object_get( G_OBJECT(m_renderer), "yalign", &gvalue, NULL );
+ float yalign = g_value_get_float( &gvalue );
+ if (yalign < 0.5)
+ ret |= wxALIGN_TOP;
+ else if (yalign == 0.5)
+ ret |= wxALIGN_CENTER_VERTICAL;
+ else
+ ret |= wxALIGN_BOTTOM;
+ g_value_unset( &gvalue );
+
+ return ret;