boolean TextOvComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; TextGraphic* texta = GetText(); TextGraphic* textb = ((TextOvComp&)comp).GetText(); int lha = texta->GetLineHeight(); int lhb = textb->GetLineHeight(); return lha == lhb && strcmp(texta->GetOriginal(), textb->GetOriginal()) == 0 && OverlayComp::operator==(comp); }
Manipulator* TextOvView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Manipulator* m = nil; Editor* ed = v->GetEditor(); int tabWidth = Math::round(.5*ivinch); if (tool->IsA(GRAPHIC_COMP_TOOL)) { FontVar* fontVar = (FontVar*) ed->GetState("FontVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); PSFont* font = (fontVar == nil) ? psstdfont : fontVar->GetFont(); PSColor* fg = (colVar == nil) ? psblack : colVar->GetFgColor(); int lineHt = font->GetLineHt(); Painter* painter = new Painter; painter->FillBg(false); painter->SetFont(font); painter->SetColors(fg, nil); Orientation o = v->GetOrientation(); if (o!=Rotated) painter->SetTransformer(rel); else { rel = new Transformer(rel); rel->Rotate(90.0); painter->SetTransformer(rel); Unref(rel); } m = new TextManip(v, painter, lineHt, tabWidth, tool); } else if (tool->IsA(RESHAPE_TOOL)) { TextGraphic* textgr = (TextGraphic*) GetGraphic(); Painter* painter = new Painter; int lineHt = textgr->GetLineHeight(); Coord xpos, ypos; rel = new Transformer; const char* text = textgr->GetOriginal(); int size = strlen(text); textgr->TotalTransformation(*rel); rel->Transform(0, 0, xpos, ypos); painter->FillBg(false); painter->SetFont(textgr->GetFont()); painter->SetColors(textgr->GetFgColor(), nil); painter->SetTransformer(rel); Unref(rel); m = new TextManip( v, text, size, xpos, ypos, painter, lineHt, tabWidth, tool ); } else { m = OverlayView::CreateManipulator(v, e, rel, tool); } return m; }
void TextView::Update () { TextGraphic* gview = (TextGraphic*) GetGraphic(); TextGraphic* gsubj = (TextGraphic*) GetTextComp()->GetGraphic(); IncurDamage(gview); * (Graphic*) gview = * (Graphic*) gsubj; gview->SetLineHeight(gsubj->GetLineHeight()); IncurDamage(gview); EraseHandles(); }
void TextComp::Write (ostream& out) { GraphicComp::Write(out); TextGraphic* text = GetText(); out << text->GetLineHeight() << "\n"; WriteString(text->GetOriginal(), out); WriteBgFilled(text->BgFilled(), out); WriteColor(text->GetFgColor(), out); WriteColor(text->GetBgColor(), out); WriteFont(text->GetFont(), out); WriteTransformer(text->GetTransformer(), out); }
boolean TextFileScript::Definition (ostream& out) { TextFileComp* comp = (TextFileComp*) GetSubject(); TextGraphic* g = comp->GetText(); int h = g->GetLineHeight(); out << "textfile("; out << h << ",\"" << comp->GetPathname() << "\""; if (comp->GetBegstr()) { out << " :begstr "; ParamList::output_text(out, comp->GetBegstr(), 0); } if (comp->GetEndstr()) { out << " :endstr "; ParamList::output_text(out, comp->GetEndstr(), 0); } if (comp->GetLineWidth() > -1) out << " :linewidth " << comp->GetLineWidth(); float sep = g->GetLineHeight() - 1; // correct for vert shift Transformer corrected, *t = g->GetTransformer(); corrected.Translate(0., sep); if (t == nil) { g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); } else { t->Reference(); corrected.Postmultiply(t); g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); Unref(t); } Annotation(out); Attributes(out); out << ")"; return out.good(); }
boolean TextScript::Definition (ostream& out) { TextOvComp* comp = (TextOvComp*) GetSubject(); TextGraphic* g = comp->GetText(); const char* text = g->GetOriginal(); int h = g->GetLineHeight(); out << "text("; out << h << ","; int indent_level = 0; Component* parent = comp; do { parent = parent->GetParent(); indent_level++; } while (parent != nil); ParamList::output_text(out, text, indent_level); float sep = g->GetLineHeight() - 1; // correct for vert shift Transformer corrected, *t = g->GetTransformer(); corrected.Translate(0., sep); if (t == nil) { g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); } else { t->Reference(); corrected.Postmultiply(t); g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); Unref(t); } Annotation(out); Attributes(out); out << ")"; return out.good(); }
boolean PSText::Definition (ostream& out) { TextComp* comp = (TextComp*) GetSubject(); TextGraphic* g = comp->GetText(); const char* text = g->GetOriginal(); int count = strlen(text); out << "Begin " << MARK << " Text\n"; float sep = g->GetLineHeight() - 1; // correct for vert shift Transformer corrected, *t = g->GetTransformer(); corrected.Translate(0., sep); if (t == nil) { g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); } else { t->Reference(); corrected.Postmultiply(t); g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); Unref(t); } out << MARK << "\n"; out << "[\n"; int beg, end, lineSize, nextBeg, ypos = 0; for (beg = 0; beg < count; beg = nextBeg) { GetLine(text, count, beg, end, lineSize, nextBeg); const char* string = Filter(&text[beg], end - beg + 1); out << "(" << string << ")\n"; } out << "] Text\n"; out << "End\n\n"; return out.good(); }