Esempio n. 1
0
void CreateTextFunc::execute() {
    const int x0 = 0;  
    const int y0 = 1;  
    const int n = 2;
    int args[n];
    ComValue& vect = stack_arg(0);
    ComValue& txtv = stack_arg(1);
    if (!vect.is_type(ComValue::ArrayType) || vect.array_len() != n) {
        reset_stack();
	push_stack(ComValue::nullval());
	return;
    }

    ALIterator i;
    AttributeValueList* avl = vect.array_val();
    avl->First(i);
    for (int j=0; j<n && !avl->Done(i); j++) {
        args[j] = avl->GetAttrVal(i)->int_val();
	avl->Next(i);
    }

    const char* txt = symbol_pntr( txtv.symbol_ref() );

    AttributeList* al = stack_keys();
    Resource::ref(al);
    reset_stack();
   
    PasteCmd* cmd = nil;
    
    if (txt) {
	ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar");
	FontVar* fntVar = (FontVar*) _ed->GetState("FontVar");
	
        Transformer* rel = get_transformer(al);
	
	TextGraphic* text = new TextGraphic(txt, stdgraphic);

	if (colVar != nil) {
	    text->FillBg(!colVar->GetBgColor()->None());
	    text->SetColors(colVar->GetFgColor(), colVar->GetBgColor());
            }
	if (fntVar != nil) text->SetFont(fntVar->GetFont());
	text->SetTransformer(new Transformer());
	text->Translate(args[x0], args[y0]);
	text->GetTransformer()->postmultiply(rel);
	Unref(rel);
	TextOvComp* comp = new TextOvComp(text);
	comp->SetAttributeList(al);
	if (PasteModeFunc::paste_mode()==0)
	  cmd = new PasteCmd(_ed, new Clipboard(comp));
	ComValue compval(new OverlayViewRef(comp), symbol_add("TextComp"));
	push_stack(compval);
	execute_log(cmd);
    } else
        push_stack(ComValue::nullval());

    Unref(al);
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
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();
}
Esempio n. 4
0
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();
}
Esempio n. 5
0
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();
}