*height = calc_height;
}
+struct wxDataViewCustomRenderer::GTKRenderParams
+{
+ GdkWindow* window;
+ GdkRectangle* expose_area;
+ GtkWidget* widget;
+ GdkRectangle* background_area;
+ int flags;
+};
+
static void
gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
GdkWindow *window,
GtkWxCellRenderer *wxrenderer = (GtkWxCellRenderer *) renderer;
wxDataViewCustomRenderer *cell = wxrenderer->cell;
- cell->GTKStashRenderParams(window, widget,
- background_area, expose_area, flags);
+ wxDataViewCustomRenderer::GTKRenderParams renderParams;
+ renderParams.window = window;
+ renderParams.expose_area = expose_area;
+ renderParams.widget = widget;
+ renderParams.background_area = background_area;
+ renderParams.flags = flags;
+ cell->GTKSetRenderParams(&renderParams);
wxRect rect(wxRectFromGDKRect(cell_area));
int xpad, ypad;
if (flags & GTK_CELL_RENDERER_FOCUSED)
state |= wxDATAVIEW_CELL_FOCUSED;
cell->WXCallRender( rect, dc, state );
+
+ cell->GTKSetRenderParams(NULL);
}
static gboolean
{
m_dc = NULL;
m_text_renderer = NULL;
+ m_renderParams = NULL;
if (no_init)
m_renderer = NULL;
cell_area.width -= xoffset;
gtk_cell_renderer_render( GTK_CELL_RENDERER(textRenderer),
- m_renderParams.window,
- m_renderParams.widget,
- m_renderParams.background_area,
+ m_renderParams->window,
+ m_renderParams->widget,
+ m_renderParams->background_area,
&cell_area,
- m_renderParams.expose_area,
- (GtkCellRendererState) m_renderParams.flags );
+ m_renderParams->expose_area,
+ GtkCellRendererState(m_renderParams->flags));
}
bool wxDataViewCustomRenderer::Init(wxDataViewCellMode mode, int align)
gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_treeview), path, NULL, FALSE);
}
-void wxDataViewCtrl::StartEditor(const wxDataViewItem& item, unsigned int column)
+wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const
+{
+ // The tree doesn't have any current item if it hadn't been created yet but
+ // it's arguably not an error to call this function in this case so just
+ // return NULL without asserting.
+ if ( !m_treeview )
+ return NULL;
+
+ GtkTreeViewColumn *col;
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(m_treeview), NULL, &col);
+ return FromGTKColumn(col);
+}
+
+void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn *column)
{
wxCHECK_RET( m_treeview,
"Current item can't be set before creating the control." );
+ wxCHECK_RET( item.IsOk(), "invalid item" );
+ wxCHECK_RET( column, "no column provided" );
// We need to make sure the model knows about this item or the path would
// be invalid and gtk_tree_view_set_cursor() would silently do nothing.
ExpandAncestors(item);
-
- wxDataViewColumn *dvcolumn = GetColumn(column);
- wxASSERT_MSG(dvcolumn, "Could not retrieve column");
- GtkTreeViewColumn *gcolumn = GTK_TREE_VIEW_COLUMN(dvcolumn->GetGtkHandle());
+
+ GtkTreeViewColumn *gcolumn = GTK_TREE_VIEW_COLUMN(column->GetGtkHandle());
// We also need to preserve the existing selection from changing.
// Unfortunately the only way to do it seems to use our own selection
// gtk_tree_view_get_path_at_pos() is the wrong function. It doesn't mind the header but returns column.
// See http://mail.gnome.org/archives/gtkmm-list/2005-January/msg00080.html
// So we have to use both of them.
- // Friedrich Haase 2010-9-20
+ item = wxDataViewItem(0);
+ column = NULL;
wxGtkTreePath path, pathScratch;
GtkTreeViewColumn* GtkColumn = NULL;
GtkTreeViewDropPosition pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
gint cell_y = 0;
// cannot directly call GtkGetTreeView(), HitTest is const and so is this pointer
- wxDataViewCtrl* ctrl = (wxDataViewCtrl*)this; // ugly workaround, ctrl is NOT const
- GtkTreeView* treeView = GTK_TREE_VIEW(ctrl->GtkGetTreeView());
+ wxDataViewCtrl* self = const_cast<wxDataViewCtrl *>(this); // ugly workaround, self is NOT const
+ GtkTreeView* treeView = GTK_TREE_VIEW(self->GtkGetTreeView());
// is there possibly a better suited function to get the column?
gtk_tree_view_get_path_at_pos( // and this is the wrong call but it delivers the column