void XYView::damage(Glyph* g, const Allocation& a, bool fixed, bool vf) { if (canvas_) { Extension e; canvas_->push_transform(); canvas_->transformer(((XYView_helper*)body())->t_); if (fixed) { Coord x, y; canvas_->transform(s2o()); if (vf) { view_ratio(a.x(), a.y(), x, y); } else { s2o().inverse_transform(a.x(), a.y(), x, y); } Allocation a_fix = a; a_fix.x_allotment().origin(x); a_fix.y_allotment().origin(y); g->allocate(canvas_, a_fix, e); } else { g->allocate(canvas_, a, e); } //printf("damage extension %g %g %g %g\n", e.left(), e.bottom(), e.right(), e.top()); //print_t("XYView::damage", canvas_->transformer()); canvas_->pop_transform(); canvas_->damage(e); } }
void Character::allocate(Canvas* c, const Allocation& a, Extension& ext) { Coord x = a.x(); Coord y = a.y(); ext.set_xy( c, x - left_bearing_, y - descent_, x + right_bearing_, y + ascent_ ); }
void Graphic31::draw(Canvas* c, const Allocation& a) const { if (c != nil) { boolean no_transformer = !_t; if (no_transformer) { ((Graphic31*)this)->_t = new Transformer(); _t->Translate(a.x(), a.y()); } Graphic31* gr = (Graphic31*) this; CanvasDamage& cd = c->rep()->damage_; gr->drawclipped( c, cd.left, cd.bottom, cd.right, cd.top ); if (no_transformer) { _t->Translate(-a.x(), -a.y()); delete _t; ((Graphic31*)this)->_t = nil; } } }
void Graphic31::allocate(Canvas* c, const Allocation& a, Extension& ext) { if (_ctrlpts > 0) { Coord w = _brush == nil ? 0 : _brush->width(); Coord x = a.x(); Coord y = a.y(); ext.merge_xy( c, x + _xmin - w, x + _xmax + w, y + _ymin - w, y + _ymax + w ); } }
void Space::draw(Canvas* c, const Allocation& a) const { if (count_ > 0) { Coord x = a.x(); Coord y = a.y(); Coord each = (a.right() - a.left()) / count_; for (int i = 0; i < count_; ++i) { c->character(font_, ' ', each, color_, x, y); x += each; } } }
void TransformFitter::transform( Transformer& t, const Allocation& a, const Allocation& natural ) const { const Allotment& natural_x = natural.x_allotment(); const Allotment& natural_y = natural.y_allotment(); if (!Math::equal(natural_x.span(), Coord(0), float(1e-2)) && !Math::equal(natural_y.span(), Coord(0), float(1e-2)) ) { const Allotment& ax = a.x_allotment(); const Allotment& ay = a.y_allotment(); t.scale( a.x_allotment().span() / natural_x.span(), a.y_allotment().span() / natural_y.span() ); } t.translate(a.x(), a.y()); }
void Page::allocate(Canvas* c, const Allocation& allocation, Extension& ext) { canvas_ = c; allocation_ = allocation; if (background_ != nil) { background_->allocate(c, allocation, ext); } GlyphIndex count = info_->count(); for (GlyphIndex index = 0; index < count; ++index) { PageInfo& info = info_->item_ref(index); if (info.glyph_ != nil) { Allocation& a = info.allocation_; Extension& b = info.extension_; Requisition s; info.glyph_->request(s); Allotment ax = Allotment( allocation.x() + info.x_, s.requirement(Dimension_X).natural(), s.requirement(Dimension_X).alignment() ); Allotment ay = Allotment( allocation.y() + info.y_, s.requirement(Dimension_Y).natural(), s.requirement(Dimension_Y).alignment() ); if ( !(info.status_ & PageInfoAllocated) || !ax.equals(a.allotment(Dimension_X), epsilon) || !ay.equals(a.allotment(Dimension_Y), epsilon) ) { if (c != nil && (info.status_ & PageInfoExtended)) { c->damage(b); } a.allot(Dimension_X, ax); a.allot(Dimension_Y, ay); b.clear(); info.glyph_->allocate(c, a, b); if (c != nil) { c->damage(b); } } info.status_ |= PageInfoAllocated|PageInfoExtended; ext.merge(b); } } }
void Character::draw(Canvas* c, const Allocation& a) const { c->character(font_, c_, a.right() - a.left(), color_, a.x(), a.y()); }
void TransformSetter::transform( Transformer& t, const Allocation& a, const Allocation& ) const { t.translate(a.x(), a.y()); }