示例#1
0
void VMouse::Sim_Press(Graphic* orig, Graphic* porig, Event& e) {
    Canvas* screen = _myglass->GetCanvas();
    Graphic* parent;
    if (e.eventType == DownEvent) {
        parent = orig->Parent();
        if (parent != nil) {
            orig->Erase(screen);
            parent->Remove(orig);
            parent->Append(porig);
            porig->Draw(screen);
            if (e.leftmouse) {
                _vwriter->Request(1);

            } else if (e.middlemouse) {
                _vwriter->Request(2);

            } else if (e.rightmouse) {
                _vwriter->Request(3);
            }
        }
            
    } else if (e.eventType == UpEvent) {
        parent = porig->Parent();
        if (parent != nil) {
            porig->Erase(screen);
            parent->Remove(porig);
            parent->Append(orig);
            orig->Draw(screen);
        }
    }
}
示例#2
0
文件: link.c 项目: barak/ivtools-cvs
LinkComp::LinkComp (Line* line) {
    if (line != nil) {
        Coord x0, y0, x1, y1;
        float fx0, fy0, fx1, fy1;

        line->GetOriginal(x0, y0, x1, y1);
        Transformer* t = line->GetTransformer();
        Graphic* parent = new Picture(line);
        parent->SetTransformer(nil);

        if (t == nil) {
            fx0 = x0; fy0 = y0; fx1 = x1; fy1 = y1;
        } else {
            t->Transform(float(x0), float(y0), fx0, fy0);
            t->Transform(float(x1), float(y1), fx1, fy1);
        }
        delete line;
        line = new Line(0, 0, 1, 1);
        InitLine(line, fx0, fy0, fx1, fy1);

        PinGraphic* pg1 = new PinGraphic;
        PinGraphic* pg2 = new PinGraphic;
        pg1->SetBrush(psnonebr);
        pg2->SetBrush(psnonebr);
        pg1->Translate(fx0, fy0);
        pg2->Translate(fx1, fy1);

        _conn1 = new PinComp(pg1);
        _conn2 = new PinComp(pg2);

        parent->Append(line, pg1, pg2);
        SetGraphic(parent);
    }
}
示例#3
0
文件: link.c 项目: barak/ivtools-cvs
void LinkComp::Read (istream& in) {
    GraphicComp::Read(in);

    Line* line = new Line(0, 0, 1, 1);

    Transformer* t = ReadTransformer(in);
    line->SetTransformer(t);
    Unref(t);

    _conn1 = (Connector*) unidraw->GetCatalog()->ReadComponent(in);
    _conn2 = (Connector*) unidraw->GetCatalog()->ReadComponent(in);

    Graphic* parent = new Picture;
    parent->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    parent->SetColors(fg, bg);
    parent->SetBrush(ReadBrush(in));

    t = ReadTransformer(in);
    parent->SetTransformer(t);
    Unref(t);

    parent->Append(line, _conn1->GetGraphic(), _conn2->GetGraphic());
    SetGraphic(parent);
}
示例#4
0
文件: link.c 项目: barak/ivtools-cvs
Graphic* LinkView::GetGraphic () {
    Graphic* gr = GraphicView::GetGraphic();

    if (gr == nil) {
        LinkComp* linkComp = GetLinkComp();
        gr = new Picture(linkComp->GetGraphic());
        gr->Append(linkComp->GetLine()->Copy());
        SetGraphic(gr);

        Connector* c1, *c2;
        linkComp->GetConnectors(c1, c2);
        _connView1 = (ConnectorView*) c1->Create(COMPONENT_VIEW);
        _connView2 = (ConnectorView*) c2->Create(COMPONENT_VIEW);

        c1->Attach(_connView1);
        c2->Attach(_connView2);
        _connView1->Update();
        _connView2->Update();

        gr->Append(_connView1->GetGraphic(), _connView2->GetGraphic());
    }
    return gr;
}