static void goc_component_draw (GocItem const *item, cairo_t *cr) { GocComponent *component = GOC_COMPONENT (item); GocCanvas *canvas = item->canvas; double x0, y0 = component->y; if (goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL) { x0 = component->x + component->w; goc_group_adjust_coords (item->parent, &x0, &y0); x0 = canvas->width - (int) (x0 - canvas->scroll_x1); } else { x0 = component->x; goc_group_adjust_coords (item->parent, &x0, &y0); x0 = (int) (x0 - canvas->scroll_x1); } cairo_save (cr); _goc_item_transform (item, cr, TRUE); if (component->rotation == 0.) cairo_translate (cr, x0, (int) (y0 - canvas->scroll_y1)); else { cairo_translate (cr, x0 + component->w / 2, (int) (y0 - canvas->scroll_y1 + component->h / 2)); cairo_rotate (cr, -component->rotation); cairo_translate (cr, -component->w / 2, -component->h / 2); } cairo_rectangle (cr, 0., 0., component->w, component->h); cairo_clip (cr); go_component_render (component->component, cr, component->w, component->h); cairo_restore (cr); }
void GOComponentView::render(UT_Rect & rec) { UT_return_if_fail (component); if (rec.width == 0 || rec.height == 0) // Nothing to render return; GR_CairoGraphics *pUGG = static_cast<GR_CairoGraphics*>(m_pGOMan->getGraphics()); UT_sint32 myWidth = pUGG->tdu(rec.width); UT_sint32 myHeight = pUGG->tdu(rec.height); UT_sint32 x = pUGG->tdu(rec.left), y; if ((width != rec.width || ascent + descent != rec.height) && go_component_is_resizable (component)) { double _ascent, _descent; go_component_set_size (component, (double) rec.width / UT_LAYOUT_RESOLUTION, (double) rec.height / UT_LAYOUT_RESOLUTION); g_object_get (G_OBJECT (component), "ascent", &_ascent, "descent", &_descent, NULL); ascent = (UT_sint32) rint (_ascent * UT_LAYOUT_RESOLUTION); descent = (UT_sint32) rint (_descent * UT_LAYOUT_RESOLUTION); } y = pUGG->tdu(rec.top - ascent); pUGG->beginPaint(); cairo_t *cr = pUGG->getCairo (); cairo_save (cr); cairo_translate (cr, x, y); go_component_render (component, cr, myWidth, myHeight); cairo_new_path (cr); // just in case a path has not been ended cairo_restore (cr); pUGG->endPaint(); }