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(); }
static void goc_component_set_property (GObject *obj, guint param_id, GValue const *value, GParamSpec *pspec) { GocComponent *component = GOC_COMPONENT (obj); switch (param_id) { case COMPONENT_PROP_X: { double x = g_value_get_double (value); if (x == component->x) return; component->x = x; return; } case COMPONENT_PROP_Y: { double y = g_value_get_double (value); if (y == component->y) return; component->y = y; break; } /* NOTE: it is allowed to set width and height even if the component is not resizable * but this should be only used to convert the size in inches to pixels. * The default is 1 pixel == 1 point. */ case COMPONENT_PROP_H: { double h = g_value_get_double (value); if (!component->component || h == component->h) return; component->h = h; break; } case COMPONENT_PROP_W: { double w = g_value_get_double (value); if (!component->component || w == component->w) return; component->w = w; break; } case COMPONENT_PROP_ROTATION: { double r = g_value_get_double (value) / 180. * M_PI; if (!component->component || r == component->rotation) return; component->rotation = r; break; } case COMPONENT_PROP_OBJECT: if (component->component != NULL) g_object_unref (component->component); component->component = GO_COMPONENT (g_value_get_object (value)); if (component->component != NULL) { g_object_ref (component->component); /* set default or fixed size */ if (component->w == 0 || component->h == 0 || !go_component_is_resizable (component->component)) { go_component_get_size (component->component, &component->w, &component->h); component->w = GO_IN_TO_PT (component->w); component->h = GO_IN_TO_PT (component->h); } } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec); return; /* NOTE : RETURN */ } goc_item_bounds_changed (GOC_ITEM (component)); }