From 02800dde9e8e4a947229fa83ab39f0ca331d9653 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Mon, 9 Jan 2012 06:31:07 +0000 Subject: [PATCH] move render params out of wxDataViewCustomRenderer they only need to exist for the duration of the render() call git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70300 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/dvrenderers.h | 23 +++++------------------ src/gtk/dataview.cpp | 31 ++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/include/wx/gtk/dvrenderers.h b/include/wx/gtk/dvrenderers.h index 785d7f9a2b..262f9957d7 100644 --- a/include/wx/gtk/dvrenderers.h +++ b/include/wx/gtk/dvrenderers.h @@ -117,18 +117,12 @@ public: wxDC *dc, int state); + struct GTKRenderParams; + // store GTK render call parameters for possible later use - void GTKStashRenderParams(GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *expose_area, - int flags) + void GTKSetRenderParams(GTKRenderParams* renderParams) { - m_renderParams.window = window; - m_renderParams.widget = widget; - m_renderParams.background_area = background_area; - m_renderParams.expose_area = expose_area; - m_renderParams.flags = flags; + m_renderParams = renderParams; } // we may or not support attributes, as we don't know it, return true to @@ -157,14 +151,7 @@ private: // parameters of the original render() call stored so that we could pass // them forward to m_text_renderer if our RenderText() is called - struct GTKRenderParams - { - GdkWindow *window; - GtkWidget *widget; - GdkRectangle *background_area; - GdkRectangle *expose_area; - int flags; - } m_renderParams; + GTKRenderParams* m_renderParams; DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer) }; diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 266f943837..cda0c529a5 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)