X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2df9f4581c5ded8a80b13243df6758a95fd483cf..ab7049776d45e622f621dd06216a4c1a1ad34b15:/src/gtk/dataview.cpp?ds=sidebyside diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 266f943837..5e777e0250 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -1371,6 +1371,15 @@ gtk_wx_cell_renderer_get_size (GtkCellRenderer *renderer, *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, @@ -1384,8 +1393,13 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer, 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; @@ -1416,6 +1430,8 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer, if (flags & GTK_CELL_RENDERER_FOCUSED) state |= wxDATAVIEW_CELL_FOCUSED; cell->WXCallRender( rect, dc, state ); + + cell->GTKSetRenderParams(NULL); } static gboolean @@ -2354,6 +2370,7 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype, { m_dc = NULL; m_text_renderer = NULL; + m_renderParams = NULL; if (no_init) m_renderer = NULL; @@ -2403,12 +2420,12 @@ void wxDataViewCustomRenderer::RenderText( const wxString &text, 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) @@ -4823,18 +4840,31 @@ void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item) 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 @@ -5000,7 +5030,8 @@ void wxDataViewCtrl::HitTest(const wxPoint& point, // 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; @@ -5008,8 +5039,8 @@ void wxDataViewCtrl::HitTest(const wxPoint& point, 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(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