Esempio n. 1
0
File: menu.cpp Progetto: PNCG/neuron
void Menu::close() {
    MenuImpl& i = *impl_;
    GlyphIndex index = i.item_;
    if (index >= 0) {
		MenuItem* mi = item(index);
#if MAC
		Window* w = mi->window();
		if (w != nil) {
	    	w->unmap();
#if carbon
		--iv_carbon_in_menu_;
#endif
		}
#endif
		TelltaleState* t = mi->state();
		if (t != nil && t->test(TelltaleState::is_enabled)) {
	    	t->set(TelltaleState::is_active, false);
		}
		if (mi->menu() != nil) {
	   	 mi->menu_->unselect();
		}
#if !MAC
		Window* w = mi->window();
		if (w != nil) {
	    	w->unmap();
		}
#endif
    }
}
Esempio n. 2
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());
}
Esempio n. 3
0
File: menu.cpp Progetto: PNCG/neuron
void Menu::open() {
    MenuImpl& i = *impl_;
    GlyphIndex index = i.item_;
    if (index >= 0) {
	MenuItem* mi = item(index);
	TelltaleState* t = mi->state();
	if (t != nil && t->test(TelltaleState::is_enabled)) {
	    t->set(TelltaleState::is_active, true);
	    if (mi->menu() != nil) {
		mi->menu()->unselect();
		Action* a = mi->action();
		if (a != nil) {
		    a->execute();
		}
	    }
	    if ((mi->window() != nil) && (mi->patch_->canvas() != nil)) {
		const Window& rel = *mi->patch_->canvas()->window();
		const Allocation& a = mi->patch_->allocation();
		Window& w = *mi->window();
		w.display(rel.display());
#if defined(WIN32) || defined(MAC)
		if (!w.bound()) { // got to get it sized before align
			w.place(-10000, 10000); // will work
			w.map();
			w.unmap();
		}
#endif
		w.place(
			rel.left() + (1 - i.x1_) * a.left() + i.x1_ * a.right(),
			rel.bottom() + (1 - i.y1_) * a.bottom() + i.y1_ * a.top()
		);
		w.align(i.x2_, i.y2_);
#ifdef WIN32
// force onto screen. Well, almost, there is a problem if menu items overlay
// previous menus. so only check if bottom is negative.
		if (w.bottom() < 0) {
			w.place(w.left(), 0);
		}
#endif
		w.map();
#if carbon
		++iv_carbon_in_menu_;
#endif
	    }
	}
    }
}
Esempio n. 4
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()
        );
    }
}
Esempio n. 5
0
void ScenePicker::exec_item(const char* name) {
	long i;
	Scene* s = spi_->scene_;
	if (s->view_count()) {
		XYView* v = s->sceneview(0);
		XYView::current_pick_view(v);
		if (v->canvas()) {
			ScenePickerImpl::window_ = (DismissableWindow*)v->canvas()->window();
		}
	}else{
		XYView::current_pick_view(NULL);
		ScenePickerImpl::window_ = NULL;
	}		
	i = spi_->info_index(name);
	if (i > -1) {
		ButtonItemInfo* b = spi_->bil_->item(i);
		TelltaleState* t = b->s_;
		bool chosen = t->test(TelltaleState::is_chosen);
		bool act = !chosen;
		if (t->test(TelltaleState::is_toggle)) {
			t->set(TelltaleState::is_chosen, act);
			act = true;
		}else if (t->test(TelltaleState::is_choosable)) {
			t->set(TelltaleState::is_chosen, true);
		}
		t->notify();
		if (act && b->a_ != NULL) {
			b->a_->execute();
		}
	}
}
Esempio n. 6
0
void MonoKitMenuItem::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if (state_->test(TelltaleState::is_chosen)) {
        MonoGlyph::pick(c, a, depth, h);
    }
}
Esempio n. 7
0
void MonoKitMenuItem::draw(Canvas* c, const Allocation& a) const {
    if (state_->test(TelltaleState::is_chosen)) {
        MonoGlyph::draw(c, a);
    }
}
Esempio n. 8
0
File: menu.cpp Progetto: PNCG/neuron
void Menu::release(const Event& e) {
#if carbon
	extern bool session_deactivating_;
	if (session_deactivating_) {
		unselect();
		return;
	}
#endif
    Menu* m = this;
    GlyphIndex index;
    for (;;) {
	index = m->selected();
	if (index < 0) {
	    break;
	}
	Menu* submenu = m->item(index)->menu();
	if (submenu == nil) {
	    break;
	}
	m = submenu;
    }
    if (index >= 0) {
	GlyphIndex top_index = selected();
	TelltaleState* top_t = item(top_index)->state();
	Resource::ref(top_t);
	top_t->set(TelltaleState::is_running, true);
	impl_->ungrab(this, e);
	Canvas* c = canvas();
	if (c != nil) {
	    impl_->restore_cursor(c);
	}
	unselect();
	MenuItem* mi = m->item(index);
	TelltaleState* t = mi->state();
	Action* a = mi->action();
	if (t != nil && t->test(TelltaleState::is_enabled)) {
	    bool act = !t->test(TelltaleState::is_chosen);
	    if (t->test(TelltaleState::is_toggle)) {
		t->set(TelltaleState::is_chosen, act);
		act = true;
	    } else if (t->test(TelltaleState::is_choosable)) {
		t->set(TelltaleState::is_chosen, true);
	    }
	    if (act && a != nil) {
		a->execute();
	    }
	}
	top_t->set(TelltaleState::is_running, false);
	Resource::unref(top_t);
    } else {
	/*
	 * If we hit an item with a submenu, then we leave
	 * the submenu open (with item 0 selected), grab, and return.
	 */
	Canvas* c;
	Menu* submenu;
	for (m = this, c = canvas(); c != nil; m = submenu, c = m->canvas()) {
	    Window* w = c->window();
	    Hit hit(
		e.pointer_root_x() - w->left(),
		e.pointer_root_y() - w->bottom()
	    );
	    m->pick(c, m->allocation(), 0, hit);
	    if (hit.any()) {
		m = m->item(hit.index(0))->menu();
		if (m != nil) {
		    m->select(0);
#if 0 && defined(WIN32)
//twice clicking on a menu that opens a submenu gets it into a state
//where it is hard to close except by clicking on a submenu item and
//dragging the mouse off the subment and releasing.
// or clicking on any neuron window. Unfortunately, this fix broke the
// ability to click on an item with submenus and have the submenu persist.
// Therefore we are backing out of it.
		    impl_->ungrab(this, e);
#endif
		    impl_->grab(this, e);
		    return;
		}
		break;
	    }
	    submenu = m->impl_->selected_menu();
	    if (submenu == nil) {
		break;
	    }
	}
	impl_->ungrab(this, e);
	c = canvas();
	if (c != nil) {
	    impl_->restore_cursor(c);
	}
	unselect();
    }
}
Esempio n. 9
0
void Browser::active(GlyphIndex i, bool b) {
    TelltaleState* t = items_->item(i);
    t->attach(this);
    t->set(TelltaleState::is_active, b);
    t->detach(this);
}