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,
|
wxDC *dc,
|
||||||
int state);
|
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);
|
bool Init(wxDataViewCellMode mode, int align);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDC *m_dc;
|
wxDC *m_dc;
|
||||||
|
|
||||||
public:
|
|
||||||
// Internal, temporary for RenderText.
|
|
||||||
GtkCellRenderer *m_text_renderer;
|
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;
|
GdkWindow *window;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GdkRectangle *background_area;
|
GdkRectangle *background_area;
|
||||||
GdkRectangle *cell_area;
|
|
||||||
GdkRectangle *expose_area;
|
GdkRectangle *expose_area;
|
||||||
int flags;
|
int flags;
|
||||||
|
} m_renderParams;
|
||||||
|
|
||||||
protected:
|
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
|
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);
|
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
|
} // namespace wxGTKImpl
|
||||||
|
|
||||||
#endif // _GTK_PRIVATE_GDKCONV_H_
|
#endif // _GTK_PRIVATE_GDKCONV_H_
|
||||||
|
@ -1225,12 +1225,8 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
|
|||||||
GtkWxCellRenderer *wxrenderer = (GtkWxCellRenderer *) renderer;
|
GtkWxCellRenderer *wxrenderer = (GtkWxCellRenderer *) renderer;
|
||||||
wxDataViewCustomRenderer *cell = wxrenderer->cell;
|
wxDataViewCustomRenderer *cell = wxrenderer->cell;
|
||||||
|
|
||||||
cell->window = window;
|
cell->GTKStashRenderParams(window, widget,
|
||||||
cell->widget = widget;
|
background_area, expose_area, flags);
|
||||||
cell->background_area = background_area;
|
|
||||||
cell->cell_area = cell_area;
|
|
||||||
cell->expose_area = expose_area;
|
|
||||||
cell->flags = flags;
|
|
||||||
|
|
||||||
wxRect rect(wxRectFromGDKRect(cell_area));
|
wxRect rect(wxRectFromGDKRect(cell_area));
|
||||||
rect = rect.Deflate(renderer->xpad, renderer->ypad);
|
rect = rect.Deflate(renderer->xpad, renderer->ypad);
|
||||||
@ -2033,17 +2029,12 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
|
|||||||
Init(mode, align);
|
Init(mode, align);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset,
|
void wxDataViewCustomRenderer::RenderText( const wxString &text,
|
||||||
wxRect WXUNUSED(cell), wxDC *WXUNUSED(dc), int WXUNUSED(state) )
|
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)
|
if (!m_text_renderer)
|
||||||
m_text_renderer = gtk_cell_renderer_text_new();
|
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_object_set_property( G_OBJECT(m_text_renderer), "text", &gvalue );
|
||||||
g_value_unset( &gvalue );
|
g_value_unset( &gvalue );
|
||||||
|
|
||||||
cell_area->x += xoffset;
|
GdkRectangle cell_area;
|
||||||
cell_area->width -= xoffset;
|
wxRectToGDKRect(cell, cell_area);
|
||||||
|
cell_area.x += xoffset;
|
||||||
|
cell_area.width -= xoffset;
|
||||||
|
|
||||||
gtk_cell_renderer_render( m_text_renderer,
|
gtk_cell_renderer_render( m_text_renderer,
|
||||||
window,
|
m_renderParams.window,
|
||||||
widget,
|
m_renderParams.widget,
|
||||||
background_area,
|
m_renderParams.background_area,
|
||||||
cell_area,
|
&cell_area,
|
||||||
expose_area,
|
m_renderParams.expose_area,
|
||||||
(GtkCellRendererState) flags );
|
(GtkCellRendererState) m_renderParams.flags );
|
||||||
|
|
||||||
cell_area->x -= xoffset;
|
|
||||||
cell_area->width += xoffset;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewCustomRenderer::Init(wxDataViewCellMode mode, int align)
|
bool wxDataViewCustomRenderer::Init(wxDataViewCellMode mode, int align)
|
||||||
|
Loading…
Reference in New Issue
Block a user