Exemplo n.º 1
0
void XYView_helper::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if (MyMath::inside(h.left(), h.bottom(), v_->left(), v_->bottom(),
                       v_->right(), v_->top())) {
        if (h.event()->grabber()) { // fixes a bug but I dont know why
#if 1
//The above fix broke the handling of keystrokes for crosshairs and Rotate3D
//It was needed so that buttons would appear normal when moving quickly from
// a button through a box to a scene. Now we put in the right handler in
//case event was a keystroke.
            if (h.event()->type() == Event::key) {
                h.target(depth, this, 0, h.event()->grabber());
            }
#endif
            return;
        }
        current_pick_view_ = v_;
        MonoGlyph::pick(c, a, depth, h);
        if (h.event()->type() == Event::down) {
#if 0
            printf("XYView_helper hit (%g, %g)  event (%g, %g)\n", h.left(), h.bottom(),
                   h.event()->pointer_x(), h.event()->pointer_y());
            printf(" allocation lb=(%g, %g), rt=(%g,%g)\n", a.left(), a.bottom(), a.right(), a.top());
#endif
        }
    }
}
Exemplo n.º 2
0
void Background::draw(Canvas* c, const Allocation& a) const {
    Extension ext;
    ext.set(c, a);
    if (c->damaged(ext)) {
        c->fill_rect(a.left(), a.bottom(), a.right(), a.top(), color_);
    }
    MonoGlyph::draw(c, a);
}
Exemplo n.º 3
0
void MonoKitFrame::draw(Canvas* c, const Allocation& a) const {
    BevelFrame::draw(c, a);
    if (!state_->test(TelltaleState::is_enabled)) {
        c->fill_rect(
            a.left(), a.bottom(), a.right(), a.top(), info_->gray_out()
        );
    }
}
Exemplo n.º 4
0
void Space::pick(Canvas*, const Allocation& a, int depth, Hit& h) {
    Coord x = h.left();
    Coord left = a.left();
    Coord right = a.right();
    if (x >= left && x < right) {
        h.target(depth, this, (x > (left+right)/2) ? 1 : 0);
    }
}
Exemplo n.º 5
0
void FieldStringEditor::pick(
    Canvas*, const Allocation& a, int depth, Hit& h
) {
    const Event* ep = h.event();
    if (ep != nil && h.left() < a.right() && h.right() >= a.left() &&
	h.bottom() < a.top() && h.top() >= a.bottom()
    ) {
	h.target(depth, this, 0);
    }
}
Exemplo n.º 6
0
void Slider::draw(Canvas* c, const Allocation& a) const {
    SliderImpl& s = *impl_;
    c->push_clipping();
    c->clip_rect(a.left(), a.bottom(), a.right(), a.top());
    if (s.showing_old_thumb_) {
        s.old_thumb_->draw(c, s.old_thumb_->allocation());
    }
    s.thumb_patch_->draw(c, s.thumb_patch_->allocation());
    c->pop_clipping();
}
Exemplo n.º 7
0
void MonoKitFrame::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if (target_) {
        Coord x = h.left();
        Coord y = h.bottom();
        if (x >= a.left() && x < a.right() && y >= a.bottom() && y < a.top()) {
            h.target(depth, this, 0);
        }
    } else {
        BevelFrame::pick(c, a, depth, h);
    }
}
Exemplo n.º 8
0
void Space::draw(Canvas* c, const Allocation& a) const {
    if (count_ > 0) {
        Coord x = a.x();
        Coord y = a.y();
        Coord each = (a.right() - a.left()) / count_;
        for (int i = 0; i < count_; ++i) {
            c->character(font_, ' ', each, color_, x, y);
            x += each;
        }
    }
}
Exemplo n.º 9
0
void FieldStringEditor::print(Printer* p, const Allocation& a) const {
    const Font* f = output_->GetFont();
    const Color* fg = output_->GetFgColor();
    FontBoundingBox b;
    f->font_bbox(b);
    Coord x = a.left(), y = a.bottom() + b.font_descent();
    FieldStringEditor* e = (FieldStringEditor*)this;
    for (const char* s = e->Text(); *s != '\0'; s++) {
	Coord w = f->width(*s);
	p->character(f, *s, w, fg, x, y);
	x += w;
    }
}
Exemplo n.º 10
0
void Text::pick(Canvas*, const Allocation&, int depth, Hit& h) {
  const Event* e = h.event();
  EventButton t = (e == nil) ? Event::none : e->pointer_button();
  EventType t1 = (e == nil) ? Event::undefined : e->type();
  if (t == Event::left || t == Event::right ||
      t == Event::middle || t1 == Event::key) {
    Coord x = e->pointer_x();
    Coord y = e->pointer_y();
    Allocation* a = allocation_;
    if (x >= a->left() && x <= a->right() && y >= a->bottom() && y <= a->top()) {
      h.target(depth, this, 0, handler());
    }
  }
}
Exemplo n.º 11
0
void XYView::scene2view(const Allocation& a) const {
    float m00 = width()/a.x_allotment().span();
    float m11 = height()/a.y_allotment().span();

    //takes a canvas transformation from scene to parent glyph coordinates
    // transforms vectors from original to xyview
    XYView* xyv = (XYView*)this;
    xyv->scene2viewparent_ = Transformer(
                                 m00, 0,
                                 0, m11,
                                 left() - a.left()*m00,
                                 bottom() - a.bottom()*m11
                             );
//print_t("scene2view", scene2viewparent_);
}
Exemplo n.º 12
0
void MonoKitFrame::draw_frame(Canvas* c, const Allocation& a, Coord t) const {
    const MonoKitInfo& i = info();
    const Color* c1, * c2, * c3;
    c2 = i.flat();
    if (state_->test(TelltaleState::is_enabled_active)) {
        c1 = i.light();
        c3 = i.dark();
    } else if (choosable_ && state_->test(TelltaleState::is_enabled_chosen)) {
        c1 = i.dark();
        c3 = i.light();
    } else {
        c1 = c2;
        c3 = c2;
    }
    Bevel::rect(c, c1, c2, c3, t, a.left(), a.bottom(), a.right(), a.top());
}
Exemplo n.º 13
0
boolean GlyphGrabber::event (Event& e) {
    Graphic31* root = _gviewer->root();
    Tool31& tool = _gviewer->tool();
    Canvas* c = e.window()->canvas();
    c->push_clipping();
    c->clip_rect(_a->left(), _a->bottom(), _a->right(), _a->top());
    boolean ok = root->grasp(e, tool);
    Event ev;
    Session* s = Session::instance();
    while(ok) {
        s->read(ev);
        ok = root->manipulating(ev, tool);
    }
    ok = root->effect(ev, tool);
    c->pop_clipping();
    return ok;
}    
Exemplo n.º 14
0
void TBScrollBox::print(Printer* c, const Allocation& a) const {
    TBScrollBoxImpl& sb = *impl_;
    sb.check(c, a);
    Extension& e = sb.extension_;
    if (sb.canvas_->damaged(e)) {
	if (sb.changed_) {
	    sb.refresh();
	}
	c->push_clipping();
	c->clip_rect(a.left(), a.bottom(), a.right(), a.top());
	for (ListItr(TBScrollBoxList) i(sb.visible_); i.more(); i.next()) {
	    const TBScrollBoxInfo& info = i.cur_ref();
	    Glyph* g = info.glyph_;
	    g->print(c, info.allocation_);
	}
	c->pop_clipping();
    }
}
Exemplo n.º 15
0
void Page::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if (background_ != nil) {
        background_->pick(c, a, depth, h);
    }
    GlyphIndex count = info_->count();
    for (GlyphIndex index = 0; index < count; ++index) {
        PageInfo& info = info_->item_ref(index);
        if (info.glyph_ != nil && !(info.status_ & PageInfoHidden)) {
            Allocation& a = info.allocation_;
            if (h.right() >= a.left() && h.left() < a.right() &&
                h.top() >= a.bottom() && h.bottom() < a.top()
            ) {
		h.begin(depth, this, index);
                info.glyph_->pick(c, a, depth + 1, h);
		h.end();
            }
        }
    }
}
Exemplo n.º 16
0
Arquivo: box.cpp Projeto: PNCG/neuron
void Box::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if (h.right() >= a.left() && h.left() < a.right() &&
            h.top() >= a.bottom() && h.bottom() < a.top()
       ) {
        BoxImpl* b = impl_;
        Extension ext;
        ext.clear();
        AllocationInfo& info = b->info(c, a, ext);
        Allocation* aa = info.component_allocations();
        GlyphIndex n = count();
        for (GlyphIndex i = 0; i < n; i++) {
            Glyph* g = component(i);
            if (g != nil) {
                h.begin(depth, this, i);
                g->pick(c, aa[i], depth + 1, h);
                h.end();
            }
        }
    }
}
Exemplo n.º 17
0
void TBScrollBox::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    TBScrollBoxImpl& sb = *impl_;
    sb.check(c, a);
    if (h.left() < a.right() && h.right() >= a.left() &&
	h.bottom() < a.top() && h.top() >= a.bottom()
    ) {
	if (sb.changed_) {
	    sb.refresh();
	}
	GlyphIndex n = sb.start_;
	for (ListItr(TBScrollBoxList) i(sb.visible_); i.more(); i.next()) {
	    const TBScrollBoxInfo& info = i.cur_ref();
	    Glyph* g = info.glyph_;
	    h.begin(depth, this, n);
	    g->pick(c, info.allocation_, depth + 1, h);
	    h.end();
	    ++n;
	}
    }
}
Exemplo n.º 18
0
void PageBorder::draw(Canvas* c, const Allocation& a) const {
    if (c != nil) {
        Coord left = a.left();
        Coord bottom = a.bottom();
        Coord right = a.right();
        Coord top = a.top();
        if (c->damaged(left + 1, bottom + 5, right - 5, top - 1)) {
            c->fill_rect(left + 1, bottom + 5, right - 5, top - 1, bg_);
        }
        if (c->damaged(left, bottom + 5, left + 1, top)) {
            c->fill_rect(left + 1, bottom + 5, left, top, fg_);
        }
        if (c->damaged(left + 1, top - 1, right - 4, top)) {
            c->fill_rect(left + 1, top - 1, right - 4, top, fg_);
        }
        if (c->damaged(right - 5, bottom, right, top - 1)) {
            c->fill_rect(right - 5, top - 1, right - 4, bottom + 4, fg_);
            c->fill_rect(right - 4, top - 3, right - 2, top - 2, fg_);
            c->fill_rect(right - 4, top - 3, right - 3, bottom + 3, bg_);
            c->fill_rect(right - 3, top - 3, right - 2, bottom + 2, fg_);
            c->fill_rect(right - 2, top - 5, right, top - 4, fg_);
            c->fill_rect(right - 2, top - 5, right - 1, bottom + 1, bg_);
            c->fill_rect(right - 1, top - 5, right, bottom, fg_);
        }
        if (c->damaged(left, bottom, right - 1, bottom + 5)) {
            c->fill_rect(right - 5, bottom + 5, left, bottom + 4, fg_);
            c->fill_rect(left + 3, bottom + 3, right - 4, bottom + 4, bg_);
            c->fill_rect(right - 3, bottom + 3, left + 2, bottom + 2, fg_);
            c->fill_rect(left + 3, bottom + 3, left + 2, bottom + 4, fg_);
            c->fill_rect(left + 5, bottom + 1, right - 1, bottom + 2, bg_);
            c->fill_rect(right - 1, bottom + 1, left + 4, bottom, fg_);
            c->fill_rect(left + 5, bottom + 1, left + 4, bottom + 2, fg_);
        }
    }
    MonoGlyph::draw(c, a);
}
Exemplo n.º 19
0
void Character::draw(Canvas* c, const Allocation& a) const {
    c->character(font_, c_, a.right() - a.left(), color_, a.x(), a.y());
}
Exemplo n.º 20
0
void MonoKitForeground::draw(Canvas* c, const Allocation& a) const {
    MonoGlyph::draw(c, a);
    c->fill_rect(a.left(), a.bottom(), a.right(), a.top(), foreground_);
}
Exemplo n.º 21
0
void Extension::merge(Canvas* c, const Allocation& a) {
    merge_xy(c, a.left(), a.bottom(), a.right(), a.top());
}
Exemplo n.º 22
0
void Bevel::draw_frame(Canvas* c, const Allocation& a, Coord t) const {
    (*beveler_)(
	c, light_, medium_, dark_, t, a.left(), a.bottom(), a.right(), a.top()
    );
}
Exemplo n.º 23
0
void Background::print(Printer* p, const Allocation& a) const {
    p->fill_rect(a.left(), a.bottom(), a.right(), a.top(), color_);
    MonoGlyph::print(p, a);
}
Exemplo n.º 24
0
void Extension::set(Canvas* c, const Allocation& a) {
    set_xy(c, a.left(), a.bottom(), a.right(), a.top());
}
Exemplo n.º 25
0
void Rule::draw(Canvas* c, const Allocation& a) const {
    c->fill_rect(a.left(), a.bottom(), a.right(), a.top(), color_);
}