static void general_cancel(void *data) { hide_menu(&adm); hide_menu(&edm); _gencfg_cancel(); stb_start_clock(stb); }
bool MenuCallBack(t_x11 *x11,XEvent *event, Window w, void *data) { t_menu *m; m=(t_menu *)data; switch(event->type) { case Expose: /* Nothing to be done */ if (m->bGrabbed) m->bGrabbed= GrabOK(stderr,XGrabPointer(x11->disp,m->wd.self,True, ButtonReleaseMask,GrabModeAsync, GrabModeAsync,m->wd.self,None,CurrentTime)); break; case ButtonRelease: hide_menu(x11,m); break; case ClientMessage: event->xclient.window=m->Parent; XSendEvent(x11->disp,m->Parent,True,0,event); break; default: break; } return FALSE; }
void hide_pd(t_x11 *x11, t_pulldown *pd) { if (pd->nsel != -1) { hide_menu(x11, pd->m[pd->nsel]); } pd->nsel = -1; }
//============================================================================ // Menu initialization //============================================================================ void init_user_menu (void) { std::vector <sdkmenu::SMenuData>::const_iterator i_md; menu = new puMenuBar(-1); menu->setStyle(PUSTYLE_SHADED | PUSTYLE_BEVELLED); menu->add_submenu (gmFile, file_legends, file_cb); menu->add_submenu (gmOption, options_legends, options_cb); menu->add_submenu (gmFplan, flightplan_legends, flightplan_cb); menu->add_submenu (gmVeh, vehicle_legends, vehicle_cb); menu->add_submenu (gmMeteo, weather_legends, weather_cb); menu->add_submenu (gmWindow, windows_legends, windows_cb); // Only add debugging menus if [UI] setting debugMenus is true (=1) int i = 0; GetIniVar ("UI", "debugMenus", &i); if (i == 1) { menu->add_submenu (gmExport, export_legends, export_cb); menu->add_submenu (gmDebugDB, debugdb_legends, debugdb_cb); menu->add_submenu (gmDebug, debug_legends, debug_cb); menu->add_submenu (gmTune, tune_legends, tune_cb); CheckExportMenu(); } menu->add_submenu ("Help", help_legends, help_cb); //----Change colors ---------------------------------------------------- //---------------------------------------------------------------------- int addin_menus_counter = 0; for (i_md = globals->sdk_menu.md_.begin (); i_md != globals->sdk_menu.md_.end (); ++i_md) { // std::vector <std::string>::const_iterator i_item_str; std::vector <unsigned long>::const_iterator i_item_ID = i_md->itemID.begin (); int counter = 0; for (i_item_str = i_md->items.begin (); i_item_str != i_md->items.end (); ++i_item_str, ++i_item_ID) { if (counter < sdkmenu::MAX_SDK_SUBMENU_NUM) { sdk_menu_legends[addin_menus_counter][counter] = (char *)i_item_str->c_str (); sdk_en [addin_menus_counter][counter].windowID = 0; sdk_en [addin_menus_counter][counter].componentID = i_md->menuID; sdk_en [addin_menus_counter][counter].event = EVENT_SELECTITEM; sdk_en [addin_menus_counter][counter].subEvent = (*i_item_ID); } counter++; } // callback are yet statically done // sdk_menu_cb[0] = _0_cb; // sdk_menu_cb[1] = _1_cb; menu->add_submenu ( i_md->str.c_str (), sdk_menu_legends[addin_menus_counter], sdk_menu_cb[addin_menus_counter] ); addin_menus_counter++; } menu->close (); // Hide menu by default hide_menu (); }
static int do_pullkeys(Menuhdr *mh,SHORT *hitid) /* called to check a pull for key equivalent hits this could be * recursive to handle more levels if if gets a hit it calls the selit * function returns 0 if no keys processed Err_not_found if some keys * processed but no hits 1 if we got a hit */ { int ret; int was_hidden; Pull *cchild, *sel; int ccx, ccy; Pullwork pw; if((cchild = which_key_pull(mh->mbs, icb.inkey)) == NULL) return(0); /* did not eat key, no hits */ init_pullwork(&pw,mh); if(mh->mw == NULL) { was_hidden = 1; show_menu(mh); } else was_hidden = 0; ccx = mh->x + cchild->x; ccy = mh->y + cchild->y; pw.leaf_parent = cchild; pw.lpx = ccx; pw.lpy = ccy; cchild->flags |= PULL_HILIT; (*cchild->see)(ccx, ccy, cchild, &pw); cchild = cchild->children; ccx += cchild->x; ccy += cchild->y; if((pw.behind[pw.level] = (Raster *)savedraw_pull(ccx, ccy, cchild, &pw)) == NULL) goto nohit; hide_mouse(); wait_click(); show_mouse(); if(!JSTHIT(KEYHIT)) goto nohit; if((sel = which_key_pull(cchild->children, icb.inkey)) == NULL) goto nohit; ret = 1; /* we got a hit */ *hitid = sel->id; goto cleanup; nohit: ret = Err_not_found; cleanup: unselect(&pw); if(was_hidden) hide_menu(mh); return(ret); }
int main(int argc, char* argv[]) { #if defined PDCURSES putenv("PDC_COLS=" macro_str(MIN_W)); putenv("PDC_LINES=" macro_str(MIN_H)); resize_term(MIN_H, MIN_W); #endif srand(time(NULL)); initscr(); clear(); noecho(); cbreak(); if(!has_colors()) { endwin(); fprintf(stderr, "Error: Your terminal does not support color output.\nThis application must have color output to run.\n"); return 1; } start_color(); #ifdef Linux if(COLORS < MIN_COLS || COLOR_PAIRS < MIN_PAIRS) { endwin(); fprintf(stderr, "Warning: Your terminal lacks sufficient color support to run this game (Expected %d colors and %d pairs, got %d colors and %d pairs).\n", MIN_COLS, MIN_PAIRS, COLORS, COLOR_PAIRS); } #endif #if !defined PDCURSES if(COLORS < BEST_COLS || COLOR_PAIRS < BEST_PAIRS) { endwin(); fprintf(stderr, "Warning: Your terminal lacks sufficient color support to use the game's full range of color (Expected %d colors and %d pairs, got %d colors and %d pairs).\nThis may impact the game's graphics.\nPress any key to continue.\n", BEST_COLS, BEST_PAIRS, COLORS, COLOR_PAIRS); getch(); set_hicolor(false); } else { if(!can_change_color()) { endwin(); fprintf(stderr, "Warning: Your terminal cannot change color definitions.\nThis will negatively impact the game's graphics.\nPress any key to continue.\n"); getch(); refresh(); set_hicolor(false); } else { set_hicolor(true); } } #else set_hicolor(false); #endif int rows, cols; max_size(stdscr, rows, cols); if(rows < MIN_H || cols < MIN_W) { endwin(); fprintf(stderr, "This terminal is too small to play this game!\nRequired dimensions are %dx%d, but got %dx%d\n", MIN_W, MIN_H, cols, rows); return 1; } init_input(); bool should_continue = true; if(!init_menu()) { endwin(); fprintf(stderr, "Failed to create menu!\n"); return 1; } while(should_continue) { switch(game_state) { case STATE_MENU: { int val; if((val = update_menu())) { switch(val) { case SELECTION_PLAY: hide_menu(); game_state = STATE_GAME; init_game(); break; case SELECTION_CONTROLS: show_controls(); break; case SELECTION_QUIT: should_continue = false; break; default: endwin(); fprintf(stderr, "If you see this message, something has gone terribly wrong in the menu code!\n"); return 1; } } } break; case STATE_GAME: if(!update_game()) { end_game(); game_state = STATE_MENU; show_menu(); } break; default: endwin(); fprintf(stderr, "If you see this message, something has gone terribly wrong in general!\n"); return 1; } } endwin(); delwin(stdscr); return 0; }
void style_menu_pressed() { hide_menu(); style_menu_button.hide(); style_menu.show(); }
void dot_pressed() { change_style(Line_style::dot); hide_menu(); }
void dash_pressed() { change_style(Line_style::dash); hide_menu(); }
void solid_pressed() { change_style(Line_style::solid); hide_menu(); }
void color_menu_pressed() { hide_menu(); color_menu_button.hide(); color_menu.show(); }
void black_pressed() { change_color(Color::black); hide_menu(); }
void blue_pressed() { change_color(Color::blue); hide_menu(); }
// コールバックによって呼び出されるアクション void red_pressed() { change_color(Color::red); hide_menu(); }
static void general_save(void *data) { int r = 0; int st; int rprt = 0; int d = 0; unsigned short id = 0; hide_menu(&adm); hide_menu(&edm); if (kbar_entry_save_prepared(&gke) == 0) return; set_time(); if (strcmp(g_pa, pa)) { memcpy(g_pa, pa, 6); id = atoi(pa); ++d; } if (strcmp(g_pv, pv)) { memcpy(g_pv, pv, 4); gencfg.vol = atoi(pv); mxc_set_vol(g_vol[gencfg.vol]); ++r; } if (strcmp(g_pn, pn)) { memcpy(g_pn, pn, 4); gencfg.nrh = atoi(pn); update_hostnr(gencfg.nrh); ++r; } st = utk_widget_state(gcbx[0]); if (st != gencfg.cid) { gencfg.cid = st; ++r; } st = utk_widget_state(gcbx[1]); if (st != gencfg.aud) { gencfg.aud = st; ++r; } st = utk_widget_state(gcbx[2]); if (st != gencfg.rprt) { gencfg.rprt = st; rprt = 1; rs485_exit(); ++r; } if (gencfg.atp != atp) { gencfg.atp = atp; ++r; } if (gencfg.etp != etp) { gencfg.etp = etp; ++r; } if (memcmp(g_pusr, gencfg.user, sizeof(g_pusr))) { memcpy(g_pusr, gencfg.user, sizeof(g_pusr)); ++r; } if (r) { general_conf_save(); } if (rprt) { rs485_start(); } if (d) { devid_save(id); } }