// ----------------------------------------------------------------------------
// menuCallback() - called anytime a menu selection is made
// ----------------------------------------------------------------------------
static void menuCallback(Fl_Widget* w, void* data) {
    Fl_Menu_* m = (Fl_Menu_*)w;
    const Fl_Menu_Item* mi = m->mvalue();
    if (mi != nullptr) {
        (static_cast<MainWindow*>(data))->menuCB(mi->label());
    }
}
예제 #2
0
//-----------------------------------------------------------------------------
void test_cb(Fl_Widget* w, void*) {
	Fl_Menu_* mw = (Fl_Menu_*)w;
	const Fl_Menu_Item* m = mw->mvalue();
	if (!m)
		printf("NULL\n");
	else if (m->shortcut())
		printf("%s - %s\n", m->label(), fl_shortcut_label(m->shortcut()));
	else
		printf("%s\n", m->label());
}
예제 #3
0
파일: gui.cpp 프로젝트: hanxi/MineSweeping
void GUI::menuCB(Fl_Widget* w, void*)
{
	Fl_Menu_* mw = (Fl_Menu_*)w;
	const Fl_Menu_Item* m = mw->mvalue();
	if (!m) printf("no MenuItem\n");
	else
	{
		GUI* gui = GUI::getInstance();
		if (strcmp(m->label(),menuItems[1].text)==0)
		{
			gui->updateMap();//
		}
		else if (strcmp(m->label(),menuItems[2].text)==0)
		{
			gui->setLevel(1);
		}
		else if (strcmp(m->label(),menuItems[3].text)==0)
		{
			gui->setLevel(2);
		}
		else if (strcmp(m->label(),menuItems[4].text)==0)
		{
			gui->setLevel(3);
		}
		else if (strcmp(m->label(),menuItems[5].text)==0)
		{
			DialogWindow* dialog = DialogWindow::getInstance();
			Fl_Group::current(dialog);
			dialog->show();
			dialog->set_visible();
			dialog->active();
		}
		else if (strcmp(m->label(),menuItems[6].text)==0)
		{
			//给出信息对话框
			gui->RankingsDialog();
		}
		else if (strcmp(m->label(),menuItems[7].text)==0)
		{//发送退出信息给主窗体
			Fl::handle_(FL_CLOSE,gui->m_pWindow.get());
		}
		printf("%s\n", m->label());
	}
}
예제 #4
0
파일: demons.c 프로젝트: gennady-em/y-zone
/*----------------------------------------------------*/
void 
test_cb (Fl_Widget* w, void*) 
{
  Fl_Menu_* mw = (Fl_Menu_*)w;
  const Fl_Menu_Item* m = mw->mvalue();

  if (!m) {
    printf("NULL\n");
		return;
	}

	if      (strcmp(m->label(), "Exit")==0) 
		exit(0);
	else if (strcmp(m->label(), "Min Menu")==0) {
		printf("-- Min Menu -- \n");
		window->make_current();
		fl_color(FL_RED);  
		fl_rectf(50, 50, 20, 20);

		static Fl_Button b1(60, 100, 80, 25, "&Beep");                       
		window->add(b1);

		window->redraw();
		

		/* mw->menu(big_menu); */
		/* (w->parent())->redraw(); */
		/* redraw(); */
		/* w->show(); */ /* ??? */
	} else {
		MessageBox (m->label());
	}

  if (m->shortcut())
    printf("%s - %s\n", m->label(), fl_shortcut_label(m->shortcut()));
  else
    printf("%s\n", m->label());

	/* char buffer[80]; */

}