Exemplo n.º 1
0
boolean GraphicMaster::effect (const Event& e, Tool& tool) {
    boolean flag = true;
    Window* w = e.window();
    if (w != nil) {
        w->cursor(window_cursor);
        Canvas* c = w->canvas();
        long count = _gr_list->count();
        Coord l, b, r, t;
        for (long i = 0; i < count && flag; i++) {
            Graphic* target = _gr_list->item(i);
            target->getbounds(l, b, r, t);
            c->damage(l, b, r, t);
            flag = target->effect(e, tool);
            if (flag) {
                target->getbounds(l, b, r, t);
                c->damage(l, b, r, t);
            }
            target->flush();
            CanvasRep& rep = *c->rep();
            CanvasDamage& cd = rep.damage_;
            rep.start_repair();
            drawclipped(c, cd.left, cd.bottom, cd.right, cd.top);
            rep.finish_repair();
        }
        _gr_list->remove_all();
    } 
    return flag;
}
Exemplo n.º 2
0
boolean GraphicMaster::grasp (const Event& e, Tool& tool) {
    if (window_cursor == nil) {
        window_cursor = e.window()->cursor();
    }
    boolean flag = false;
    unsigned int tool_type = tool.tool();
    switch (tool_type) {
    case Tool::move:
    case Tool::scale:
    case Tool::rotate:
        {
            float tol = 2.0;
            BoxObj box(
                e.pointer_x()-tol, e.pointer_y()-tol, 
                e.pointer_x()+tol, e.pointer_y()+tol
            );
            Graphic* target = last_intersecting(box);
            if (target != nil) {
                Window* w = e.window();
                Canvas* c = w->canvas();
                w->cursor(grabber_cursor);

                ToolState& ts = tool.toolstate();
                total_gs(ts._gs);

                _gr_list->append(target);
                Coord l, b, r, t;
                target->getbounds(l, b, r, t);
                c->damage(l, b, r, t);
                flag = target->grasp(e, tool);
                if (flag) {
                    target->getbounds(l, b, r, t);
                    c->damage(l, b, r, t);
                }
                CanvasRep& rep = *c->rep();
                CanvasDamage& cd = rep.damage_;
                rep.start_repair();
                drawclipped(c, cd.left, cd.bottom, cd.right, cd.top);
                rep.finish_repair();
            }
            break;
        } 
    }
    return flag;
}
Exemplo n.º 3
0
boolean GraphicMaster::manipulating (const Event& e, Tool& tool) {
    boolean flag = true;
    long count = _gr_list->count();
    Coord l, b, r, t;
    Window* w = e.window();
    Canvas* c = w->canvas();
    for (long i = 0; i < count && flag; i++) {
        Graphic* target = _gr_list->item(i);
        target->getbounds(l, b, r, t);
        c->damage(l, b, r, t);
        flag = target->manipulating(e, tool);
        if (flag) {
            target->getbounds(l, b, r, t);
            c->damage(l, b, r, t);
        }
        CanvasRep& rep = *c->rep();
        CanvasDamage& cd = rep.damage_;
        rep.start_repair();
        drawclipped(c, cd.left, cd.bottom, cd.right, cd.top);
        rep.finish_repair();
        w->display()->flush();
    }
    return flag;
}
Exemplo n.º 4
0
Graphic* PolyGraphic::last_within (BoxObj& gb) {
    GlyphIndex count = _body->count();
    Coord l, b, r, t;

    for (GlyphIndex i = count-1; i >= 0; i--) {
        Graphic* gr = (Graphic*) _body->component(i);
        gr->getbounds(l, b, r, t);

        BoxObj box(l, b, r, t);
	if (box.Within(gb)) {
	    return gr;
	}
    }
    return nil;
}