void CreateRectFunc::execute() { const int x0 = 0; const int y0 = 1; const int x1 = 2; const int y1 = 3; const int n = 4; int coords[n]; ComValue& vect = stack_arg(0); 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++) { coords[j] = avl->GetAttrVal(i)->int_val(); avl->Next(i); } AttributeList* al = stack_keys(); Resource::ref(al); reset_stack(); PasteCmd* cmd = nil; if (coords[x0] != coords[x1] || coords[y0] != coords[y1]) { BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar"); PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar"); ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar"); Transformer* rel = get_transformer(al); SF_Rect* rect = new SF_Rect(coords[x0], coords[y0], coords[x1], coords[y1], stdgraphic); if (brVar != nil) rect->SetBrush(brVar->GetBrush()); if (patVar != nil) rect->SetPattern(patVar->GetPattern()); if (colVar != nil) { rect->FillBg(!colVar->GetBgColor()->None()); rect->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } rect->SetTransformer(rel); Unref(rel); RectOvComp* comp = new RectOvComp(rect); comp->SetAttributeList(al); if (PasteModeFunc::paste_mode()==0) cmd = new PasteCmd(_ed, new Clipboard(comp)); ComValue compval(new OverlayViewRef(comp), symbol_add("RectComp")); push_stack(compval); execute_log(cmd); } else push_stack(ComValue::nullval()); Unref(al); }
void RectComp::Read (istream& in) { GraphicComp::Read(in); Coord x0, y0, x1, y1; in >> x0 >> y0 >> x1 >> y1; SF_Rect* rect = new SF_Rect(x0, y0, x1, y1); rect->FillBg(ReadBgFilled(in)); PSColor* fg = ReadColor(in); PSColor* bg = ReadColor(in); rect->SetColors(fg, bg); rect->SetBrush(ReadBrush(in)); rect->SetPattern(ReadPattern(in)); Transformer* t = ReadTransformer(in); rect->SetTransformer(t); Unref(t); SetGraphic(rect); }