void StrBrowserGraphic::Natural (int& w, int& h) { FullGraphic gs; totalGS(gs); PSFont* font = gs.GetFont(); w = _width - _width % font->Width("n"); h = _height - _height % font->Height(); }
boolean TextGraphic::RotatedIntersects (BoxObj& userb, Graphic* gs) { int beg, end, lineSize, nextBeg, ypos = 0; const char* s = GetOriginal(); int size = strlen(s); PSFont* f = gs->GetFont(); Coord x[4], tx[5]; Coord y[4], ty[5]; x[0] = x[1] = x[2] = x[3] = y[0] = y[1] = 0; y[2] = y[3] = f->Height(); for (beg = 0; beg < size; beg = nextBeg) { GetLine(s, size, beg, end, lineSize, nextBeg); x[1] = x[2] = f->Width(&s[beg], lineSize) - 1; transformList(x, y, 4, tx, ty, gs); tx[4] = tx[0]; ty[4] = ty[0]; FillPolygonObj fp(tx, ty, 5); if (fp.Intersects(userb)) { return true; } y[0] -= _lineHt; y[1] -= _lineHt; y[2] -= _lineHt; y[3] -= _lineHt; } return false; }
boolean ULabel::intersects (BoxObj& userb, Graphic* gs) { Transformer* t = gs->GetTransformer(); PSFont* f = gs->GetFont(); Coord xmax = f->Width(_string); Coord ymax = f->Height(); Coord tx0, ty0, tx1, ty1; if (t != nil && t->Rotated()) { Coord x[4], tx[5]; Coord y[4], ty[5]; x[0] = x[3] = y[0] = y[1] = 0; x[2] = x[1] = xmax; y[2] = y[3] = ymax; transformList(x, y, 4, tx, ty, gs); tx[4] = tx[0]; ty[4] = ty[0]; FillPolygonObj fp (tx, ty, 5); return fp.Intersects(userb); } else if (t != nil) { t->Transform(0, 0, tx0, ty0); t->Transform(xmax, ymax, tx1, ty1); BoxObj b1 (tx0, ty0, tx1, ty1); return b1.Intersects(userb); } else { BoxObj b2 (0, 0, xmax, ymax); return b2.Intersects(userb); } }
boolean ULabel::contains (PointObj& po, Graphic* gs) { PointObj pt (&po); PSFont* f = gs->GetFont(); invTransform(pt._x, pt._y, gs); BoxObj b (0, 0, f->Width(_string), f->Height()); return b.Contains(pt); }
void StrBrowserGraphic::GetRowsCols (int& rows, int& cols) { FullGraphic gs; totalGS(gs); PSFont* font = gs.GetFont(); rows = _height / font->Height(); cols = _width / font->Width("n"); rows = (rows == 0) ? 1 : rows; cols = (cols == 0) ? 1 : cols; }
boolean TextGraphic::UntransformedIntersects (BoxObj& userb, Graphic* gs) { int beg, end, lineSize, nextBeg, ypos = 0; const char* s = GetOriginal(); int size = strlen(s); PSFont* f = gs->GetFont(); BoxObj box(0, 0, 0, f->Height()); for (beg = 0; beg < size; beg = nextBeg) { GetLine(s, size, beg, end, lineSize, nextBeg); box._right = f->Width(&s[beg], lineSize) - 1; if (box.Intersects(userb)) { return true; } box._top -= _lineHt; box._bottom -= _lineHt; } return false; }
void ULabel::getExtent ( float& x0, float& y0, float& cx, float& cy, float& tol, Graphic* gs ) { PSFont* f = gs->GetFont(); float width = f->Width(_string); float height = f->Height(); if (gs->GetTransformer() == nil) { x0 = 0; y0 = 0; cx = width / 2; cy = height / 2; } else { transformRect(0, 0, width, height, x0, y0, cx, cy, gs); cx = (cx + x0)/2; cy = (cy + y0)/2; } tol = 0; }
boolean TextGraphic::contains (PointObj& po, Graphic* gs) { PointObj pt (&po); PSFont* f = gs->GetFont(); BoxObj box(0, 0, 0, f->Height()); int beg, end, lineSize, nextBeg, ypos = 0; const char* s = GetOriginal(); int size = strlen(s); invTransform(pt._x, pt._y, gs); for (beg = 0; beg < size; beg = nextBeg) { GetLine(s, size, beg, end, lineSize, nextBeg); box._right = f->Width(&s[beg], lineSize) - 1; if (box.Contains(pt)) { return true; } box._top -= _lineHt; box._bottom -= _lineHt; } return false; }
boolean TextGraphic::TransformedIntersects (BoxObj& userb, Graphic* gs) { int beg, end, lineSize, nextBeg, ypos = 0; const char* s = GetOriginal(); int size = strlen(s); PSFont* f = gs->GetFont(); Coord l, b, r, t = f->Height(); Coord tl, tb, tr, tt; l = b = r = 0; for (beg = 0; beg < size; beg = nextBeg) { GetLine(s, size, beg, end, lineSize, nextBeg); r = f->Width(&s[beg], lineSize) - 1; transform(l, b, tl, tb, gs); transform(r, t, tr, tt, gs); BoxObj box(tl, tb, tr, tt); if (box.Intersects(userb)) { return true; } b -= _lineHt; t -= _lineHt; } return false; }