Correct text position in wxDataViewCustomRenderer::RenderText() in wxGTK.
It simply ignored the passed in rectangle meaning that the text was always drawn at the top left corner of the cell rectangle. Also more code cleanup: collect all render call parameters in a single struct and provide a public function to set them all at once instead of making them public. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a923d77fc5
commit
2a454ffdbd
@ -114,24 +114,39 @@ public:
|
||||
wxDC *dc,
|
||||
int state);
|
||||
|
||||
protected:
|
||||
// store GTK render call parameters for possible later use
|
||||
void GTKStashRenderParams(GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *expose_area,
|
||||
int flags)
|
||||
{
|
||||
m_renderParams.window = window;
|
||||
m_renderParams.widget = widget;
|
||||
m_renderParams.background_area = background_area;
|
||||
m_renderParams.expose_area = expose_area;
|
||||
m_renderParams.flags = flags;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool Init(wxDataViewCellMode mode, int align);
|
||||
|
||||
private:
|
||||
wxDC *m_dc;
|
||||
|
||||
public:
|
||||
// Internal, temporary for RenderText.
|
||||
GtkCellRenderer *m_text_renderer;
|
||||
|
||||
// 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 *cell_area;
|
||||
GdkRectangle *expose_area;
|
||||
int flags;
|
||||
} m_renderParams;
|
||||
|
||||
protected:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
|
||||
};
|
||||
|
||||
|
@ -19,6 +19,14 @@ inline wxRect wxRectFromGDKRect(const GdkRectangle *r)
|
||||
return wxRect(r->x, r->y, r->width, r->height);
|
||||
}
|
||||
|
||||
inline void wxRectToGDKRect(const wxRect& rect, GdkRectangle& r)
|
||||
{
|
||||
r.x = rect.x;
|
||||
r.y = rect.y;
|
||||
r.width = rect.width;
|
||||
r.height = rect.height;
|
||||
}
|
||||
|
||||
} // namespace wxGTKImpl
|
||||
|
||||
#endif // _GTK_PRIVATE_GDKCONV_H_
|
||||
|
@ -1225,12 +1225,8 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
|
||||
GtkWxCellRenderer *wxrenderer = (GtkWxCellRenderer *) renderer;
|
||||
wxDataViewCustomRenderer *cell = wxrenderer->cell;
|
||||
|
||||
cell->window = window;
|
||||
cell->widget = widget;
|
||||
cell->background_area = background_area;
|
||||
cell->cell_area = cell_area;
|
||||
cell->expose_area = expose_area;
|
||||
cell->flags = flags;
|
||||
cell->GTKStashRenderParams(window, widget,
|
||||
background_area, expose_area, flags);
|
||||
|
||||
wxRect rect(wxRectFromGDKRect(cell_area));
|
||||
rect = rect.Deflate(renderer->xpad, renderer->ypad);
|
||||
@ -2033,17 +2029,12 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
|
||||
Init(mode, align);
|
||||
}
|
||||
|
||||
void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset,
|
||||
wxRect WXUNUSED(cell), wxDC *WXUNUSED(dc), int WXUNUSED(state) )
|
||||
void wxDataViewCustomRenderer::RenderText( const wxString &text,
|
||||
int xoffset,
|
||||
wxRect cell,
|
||||
wxDC *WXUNUSED(dc),
|
||||
int WXUNUSED(state) )
|
||||
{
|
||||
#if 0
|
||||
wxDataViewCtrl *view = GetOwner()->GetOwner();
|
||||
wxColour col = (state & wxDATAVIEW_CELL_SELECTED) ?
|
||||
wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) :
|
||||
view->GetForegroundColour();
|
||||
dc->SetTextForeground(col);
|
||||
dc->DrawText( text, cell.x + xoffset, cell.y + ((cell.height - dc->GetCharHeight()) / 2));
|
||||
#else
|
||||
if (!m_text_renderer)
|
||||
m_text_renderer = gtk_cell_renderer_text_new();
|
||||
|
||||
@ -2053,20 +2044,18 @@ void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset,
|
||||
g_object_set_property( G_OBJECT(m_text_renderer), "text", &gvalue );
|
||||
g_value_unset( &gvalue );
|
||||
|
||||
cell_area->x += xoffset;
|
||||
cell_area->width -= xoffset;
|
||||
GdkRectangle cell_area;
|
||||
wxRectToGDKRect(cell, cell_area);
|
||||
cell_area.x += xoffset;
|
||||
cell_area.width -= xoffset;
|
||||
|
||||
gtk_cell_renderer_render( m_text_renderer,
|
||||
window,
|
||||
widget,
|
||||
background_area,
|
||||
cell_area,
|
||||
expose_area,
|
||||
(GtkCellRendererState) flags );
|
||||
|
||||
cell_area->x -= xoffset;
|
||||
cell_area->width += xoffset;
|
||||
#endif
|
||||
m_renderParams.window,
|
||||
m_renderParams.widget,
|
||||
m_renderParams.background_area,
|
||||
&cell_area,
|
||||
m_renderParams.expose_area,
|
||||
(GtkCellRendererState) m_renderParams.flags );
|
||||
}
|
||||
|
||||
bool wxDataViewCustomRenderer::Init(wxDataViewCellMode mode, int align)
|
||||
|
Loading…
Reference in New Issue
Block a user