static void show_menu (NautilusToolbar *self, GtkWidget *widget, guint button, guint32 event_time) { NautilusWindow *window; GtkWidget *menu; NautilusNavigationDirection direction; window = self->priv->window; menu = gtk_menu_new (); direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "nav-direction")); switch (direction) { case NAUTILUS_NAVIGATION_DIRECTION_FORWARD: fill_menu (window, menu, FALSE); break; case NAUTILUS_NAVIGATION_DIRECTION_BACK: fill_menu (window, menu, TRUE); break; default: g_assert_not_reached (); break; } gtk_menu_popup (GTK_MENU (menu), NULL, NULL, (GtkMenuPositionFunc) menu_position_func, widget, button, event_time); }
static void show_menu_callback (GtkMenuToolButton *button, CajaNavigationAction *action) { CajaNavigationActionPrivate *p; CajaNavigationWindow *window; GtkWidget *menu; GList *children; GList *li; p = action->priv; window = action->priv->window; menu = gtk_menu_tool_button_get_menu (button); children = gtk_container_get_children (GTK_CONTAINER (menu)); for (li = children; li; li = li->next) { gtk_container_remove (GTK_CONTAINER (menu), li->data); } g_list_free (children); switch (p->direction) { case CAJA_NAVIGATION_DIRECTION_FORWARD: fill_menu (window, menu, FALSE); break; case CAJA_NAVIGATION_DIRECTION_BACK: fill_menu (window, menu, TRUE); break; default: g_assert_not_reached (); break; } }
int do_rescan(struct params_t *params) { int i; /* Clean top menu level except system menu item */ /* FIXME should be done by some function from menu module */ kx_menu_item *mi; for (i = 1; i < params->menu->top->count; i++) { mi = params->menu->top->list[i]; if (mi) { dispose(mi->label); dispose(mi->description); free(mi); } params->menu->top->list[i] = NULL; } params->menu->top->count = 1; #ifdef USE_ICONS /* Destroy icons */ /* FIXME should be done by some function from devicescan module */ for (i = 0; i < params->bootcfg->fill; i++) { fb_destroy_picture(params->bootcfg->list[i]->icondata); } #endif free_bootcfg(params->bootcfg); params->bootcfg = NULL; scan_devices(params); return fill_menu(params); }
static void game_preferences_callback (GtkWidget *widget, void *data) { GtkWidget *menu, *omenu, *l, *hb, *cb, *f, *fv; GtkWidget *button; if (pref_dialog) return; pref_dialog = gnome_dialog_new (_("Preferences"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); gnome_dialog_set_parent (GNOME_DIALOG (pref_dialog), GTK_WINDOW (app)); gtk_signal_connect (GTK_OBJECT(pref_dialog), "delete_event", GTK_SIGNAL_FUNC (cancel), NULL); omenu = gtk_option_menu_new (); menu = gtk_menu_new (); fill_menu (menu); gtk_widget_show (omenu); gtk_option_menu_set_menu (GTK_OPTION_MENU(omenu), menu); f = gtk_frame_new (_ ("Scenario")); gtk_container_border_width (GTK_CONTAINER (f), 5); hb = gtk_hbox_new (FALSE, FALSE); gtk_widget_show (hb); l = gtk_label_new (_("Select scenario:")); gtk_widget_show (l); gtk_box_pack_start_defaults (GTK_BOX(hb), l); gtk_box_pack_start_defaults (GTK_BOX(hb), omenu); cb = gtk_check_button_new_with_label ( _("Make it the default scenario") ); gtk_signal_connect (GTK_OBJECT(cb), "clicked", (GtkSignalFunc)set_selection_def, NULL); gtk_widget_show (cb); fv = gtk_vbox_new (0, 5); gtk_container_border_width (GTK_CONTAINER (fv), 5); gtk_widget_show (fv); gtk_box_pack_start_defaults (GTK_BOX(fv), hb); gtk_box_pack_start_defaults (GTK_BOX(fv), cb); gtk_box_pack_start_defaults (GTK_BOX(GNOME_DIALOG(pref_dialog)->vbox), f); gtk_container_add (GTK_CONTAINER (f), fv); gtk_widget_show (f); gnome_dialog_button_connect (GNOME_DIALOG (pref_dialog), 0, GTK_SIGNAL_FUNC (load_scenario_callback), NULL); gnome_dialog_button_connect (GNOME_DIALOG (pref_dialog), 1, GTK_SIGNAL_FUNC (cancel), (gpointer)1); gtk_widget_show (pref_dialog); }
static void fill_menu(struct menu_item* item) { if (!item->menu_filled) { add_folder_contents(item); if (item->base) { fill_menu(item->base); } item->menu_filled = TRUE; } }
static int open_dvb_sel(menu_t* menu, char* args) { mpriv->config = dvb_get_config(); if(mpriv->config == NULL) return 0; menu->draw = menu_list_draw; menu->read_cmd = read_cmd; menu->close = close_menu; mpriv->card = 0; mpriv->level = 1; return fill_menu(menu); }
static void show_menu (NemoNavigationAction *self, guint button, guint32 event_time) { NemoWindow *window; GtkWidget *menu; window = self->priv->window; menu = gtk_menu_new (); switch (self->priv->direction) { case NEMO_NAVIGATION_DIRECTION_FORWARD: fill_menu (window, menu, FALSE); break; case NEMO_NAVIGATION_DIRECTION_BACK: fill_menu (window, menu, TRUE); break; case NEMO_NAVIGATION_DIRECTION_UP: return; case NEMO_NAVIGATION_DIRECTION_RELOAD: return; case NEMO_NAVIGATION_DIRECTION_HOME: return; case NEMO_NAVIGATION_DIRECTION_COMPUTER: return; case NEMO_NAVIGATION_DIRECTION_EDIT: return; default: g_assert_not_reached (); break; } gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time); }
void QueryEditor::update_option_menu() { WidgetList kids = WComposite(f_scope_option.SubMenuId()).Children(); int num_kids = WComposite(f_scope_option.SubMenuId()).NumChildren(); // destroy all toggle buttons in menu for (int i = 0; i < num_kids; i++) { XtUnmanageChild (kids[i]); XtDestroyWidget (kids[i]); } fill_menu(); }
LRESULT menu_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_INITMENUPOPUP: { HMENU hmenu = (HMENU)wparam; struct menu_item* item; MENUINFO mi; mi.cbSize = sizeof(mi); mi.fMask = MIM_MENUDATA; GetMenuInfo(hmenu, &mi); item = (struct menu_item*)mi.dwMenuData; if (item) fill_menu(item); return 0; } break; case WM_MENUCOMMAND: { HMENU hmenu = (HMENU)lparam; struct menu_item* item; MENUITEMINFOW mii; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA|MIIM_ID; GetMenuItemInfoW(hmenu, wparam, TRUE, &mii); item = (struct menu_item*)mii.dwItemData; if (item) exec_item(item); else if (mii.wID == MENU_ID_RUN) run_dialog(); destroy_menus(); return 0; } } return DefWindowProcW(hwnd, msg, wparam, lparam); }
ScopeMenu::ScopeMenu (Widget option_menu, bool require_current_section) : f_current_scope (NULL), f_use_current_section(require_current_section), f_option_menu(option_menu) { Arg args[1]; int n; n = 0; XtSetArg(args[n], XmNsubMenuId, &f_pull_menu); n++; XtGetValues(option_menu, args, n); fill_menu(); UAS_SearchScope::request ((UAS_Receiver<ScopeCreated> *) this); UAS_SearchScope::request ((UAS_Receiver<ScopeDeleted> *) this); UAS_SearchScope::request ((UAS_Receiver<ScopeRenamed> *) this); SearchScopeAgent::request ((UAS_Receiver<UpdateMenu> *) this); }
/* * Class: sun_awt_X11_XTaskbarPeer * Method: setNativeMenu * Signature: ([Ljava/awt/MenuItem;)V */ JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setNativeMenu (JNIEnv *env, jobject obj, jobjectArray items) { gtk->gdk_threads_enter(); if (!menu) { menu = fp_dbusmenu_menuitem_new(); fp_unity_launcher_entry_set_quicklist(entry, menu); } GList* list = fp_dbusmenu_menuitem_take_children(menu); gtk->g_list_free_full(list, gtk->g_object_unref); gtk->g_list_free_full(globalRefs, deleteGlobalRef); globalRefs = NULL; if (items) { fill_menu(env, items); } gtk->gdk_threads_leave(); }
void ScopeMenu::receive (UpdateMenu &msg, void *client_data) { xList<UAS_SearchScope *> &scope_list = search_scope_mgr().scope_list(); List_Iterator<UAS_SearchScope *> s (scope_list); int n; Arg args[2]; WidgetList kids; Cardinal num_kids; n = 0; XtSetArg(args[n], XmNnumChildren, &num_kids); n++; XtSetArg(args[n], XmNchildren, &kids); n++; XtGetValues(f_pull_menu, args, n); // destroy all toggle buttons in menu for (unsigned int i = 0; i < num_kids; i++) { XtUnmanageChild (kids[i]); XtDestroyWidget (kids[i]); } // select current scope if(f_use_current_section) f_current_scope = s.item(); else { s++; f_current_scope = s.item(); } fill_menu(); XtUnmanageChild(XtParent(f_option_menu)); XtManageChild(XtParent(f_option_menu)); XtUnmanageChild(f_option_menu); XtManageChild(f_option_menu); }
void do_startmenu(HWND hwnd) { LPITEMIDLIST pidl; MENUINFO mi; MENUITEMINFOW mii; RECT rc={0,0,0,0}; TPMPARAMS tpm; WCHAR run_label[50]; destroy_menus(); WINE_TRACE("creating start menu\n"); root_menu.menuhandle = public_startmenu.menuhandle = user_startmenu.menuhandle = CreatePopupMenu(); if (!root_menu.menuhandle) { return; } user_startmenu.parent = public_startmenu.parent = &root_menu; user_startmenu.base = &public_startmenu; user_startmenu.menu_filled = public_startmenu.menu_filled = FALSE; if (!user_startmenu.pidl) SHGetSpecialFolderLocation(NULL, CSIDL_STARTMENU, &user_startmenu.pidl); if (!user_startmenu.folder) pidl_to_shellfolder(user_startmenu.pidl, NULL, &user_startmenu.folder); if (!public_startmenu.pidl) SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_STARTMENU, &public_startmenu.pidl); if (!public_startmenu.folder) pidl_to_shellfolder(public_startmenu.pidl, NULL, &public_startmenu.folder); fill_menu(&user_startmenu); AppendMenuW(root_menu.menuhandle, MF_SEPARATOR, 0, NULL); if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_CONTROLS, &pidl))) add_shell_item(&root_menu, pidl); LoadStringW(NULL, IDS_RUN, run_label, sizeof(run_label)/sizeof(run_label[0])); mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING|MIIM_ID; mii.dwTypeData = run_label; mii.wID = MENU_ID_RUN; InsertMenuItemW(root_menu.menuhandle, -1, TRUE, &mii); mi.cbSize = sizeof(mi); mi.fMask = MIM_STYLE; mi.dwStyle = MNS_NOTIFYBYPOS; SetMenuInfo(root_menu.menuhandle, &mi); GetWindowRect(hwnd, &rc); tpm.cbSize = sizeof(tpm); tpm.rcExclude = rc; if (!TrackPopupMenuEx(root_menu.menuhandle, TPM_LEFTALIGN|TPM_BOTTOMALIGN|TPM_VERTICAL, rc.left, rc.top, hwnd, &tpm)) { WINE_ERR("couldn't display menu\n"); } }
static void read_cmd(menu_t* menu, int cmd) { list_entry_t *elem; mp_cmd_t* c; char *cmd_name; switch(cmd) { case MENU_CMD_RIGHT: case MENU_CMD_OK: { elem = mpriv->p.current; if(mpriv->level == 1) { mpriv->card = mpriv->p.current->num; mpriv->level = 2; menu_list_uninit(menu, free_entry); fill_menu(menu); } else { dvb_priv_t *dvbp = (dvb_priv_t*) mpriv->config->priv; cmd_name = malloc(25 + strlen(elem->p.txt)); if(dvbp != NULL) sprintf(cmd_name, "dvb_set_channel %d %d", elem->num, mpriv->card); else sprintf(cmd_name, "loadfile 'dvb://%d@%s'", mpriv->card+1, elem->p.txt); c = mp_input_parse_cmd(cmd_name); if(c) { if (mpriv->auto_close) mp_input_queue_cmd (mp_input_parse_cmd ("menu hide")); mp_input_queue_cmd(c); } } } break; case MENU_CMD_LEFT: case MENU_CMD_CANCEL: { elem = mpriv->p.current; menu_list_uninit(menu, free_entry); if(mpriv->config->count > 1) mpriv->level--; else mpriv->level = 0; if(mpriv->level > 0) { fill_menu(menu); break; } } default: menu_list_read_cmd(menu, cmd); } }
int main(int argc, char **argv) { int rc = 0; struct cfgdata_t cfg; struct params_t params; kx_inputs inputs; lg = log_open(16); log_msg(lg, "%s starting", PACKAGE_STRING); initmode = do_init(); /* Get cmdline parameters */ params.cfg = &cfg; init_cfgdata(&cfg); cfg.angle = 0; /* No rotation by default */ parse_cmdline(&cfg); kxb_ttydev = cfg.ttydev; setup_terminal(kxb_ttydev, &kxb_echo_state, 1); /* Setup function that will restore terminal when exit() will called */ atexit(atexit_restore_terminal); log_msg(lg, "FB angle is %d, tty is %s", cfg.angle, cfg.ttydev); #ifdef USE_MACHINE_KERNEL machine_kernel = get_machine_kernelpath(); /* FIXME should be passed as arg to get_bootinfo() */ #endif #ifdef USE_DELAY /* extra delay for initializing slow SD/CF */ sleep(USE_DELAY); #endif int no_ui = 1; /* UI presence flag */ #ifdef USE_FBMENU params.gui = NULL; if (no_ui) { params.gui = gui_init(cfg.angle); if (NULL == params.gui) { log_msg(lg, "Can't initialize GUI"); } else no_ui = 0; } #endif #ifdef USE_TEXTUI FILE *ttyfp; params.tui = NULL; if (no_ui) { if (cfg.ttydev) ttyfp = fopen(cfg.ttydev, "w"); else ttyfp = stdout; params.tui = tui_init(ttyfp); if (NULL == params.tui) { log_msg(lg, "Can't initialize TUI"); if (ttyfp != stdout) fclose(ttyfp); } else no_ui = 0; } #endif if (no_ui) exit(-1); /* Exit if no one UI was initialized */ params.menu = build_menu(¶ms); params.bootcfg = NULL; scan_devices(¶ms); if (-1 == fill_menu(¶ms)) { exit(-1); } /* Collect input devices */ inputs_init(&inputs, 8); inputs_open(&inputs); inputs_preprocess(&inputs); /* Run main event loop * Return values: <0 - error, >=0 - selected item id */ rc = do_main_loop(¶ms, &inputs); #ifdef USE_FBMENU if (params.gui) { if (rc < 0) gui_clear(params.gui); gui_destroy(params.gui); } #endif #ifdef USE_TEXTUI if (params.tui) { tui_destroy(params.tui); if (ttyfp != stdout) fclose(ttyfp); } #endif inputs_close(&inputs); inputs_clean(&inputs); log_close(lg); lg = NULL; /* rc < 0 indicate error */ if (rc < 0) exit(rc); menu_destroy(params.menu, 0); if (rc >= A_DEVICES) { start_kernel(¶ms, rc - A_DEVICES); } /* When we reach this point then some error has occured */ DPRINTF("We should not reach this point!"); exit(-1); }
void QueryEditor::create_ui() { Wait_Cursor bob; XmStringLocalized mtfstring; String string; KeySym mnemonic; f_shell = WTopLevelShell(window_system().toplevel(), WPopup, "query_editor"); window_system().register_shell (&f_shell); string = CATGETS(Set_QueryEditor, 1, "Dtinfo: Query Editor"); XtVaSetValues((Widget)f_shell, XmNtitle, string, NULL); // Main form and menu bar. WXmForm form (f_shell, "form" ); WXmMenuBar menu_bar (form, "menu_bar" ); WXmPulldownMenu scope_menu (form, "scope_menu"); Arg args[1]; int n = 0; XtSetArg(args[n], XmNsubMenuId, (Widget) scope_menu); n++; f_scope_option = WXmOptionMenu (form, "scope_option", AM, args, n); mtfstring = CATGETS(Set_AgentLabel, 212, "Scope Name"); XtVaSetValues(f_scope_option, XmNlabelString, (XmString)mtfstring, NULL); // Menu definitions. how about using AddPushButton (name, obj, fun)?? WXmCascadeButton edit_cascade (menu_bar, "edit", AM); WXmPulldownMenu edit_menu (menu_bar, "edit_menu" ); f_cut_btn = WXmPushButton (edit_menu, "cut", AM); f_copy_btn = WXmPushButton (edit_menu, "copy", AM); f_paste_btn = WXmPushButton (edit_menu, "paste", AM); f_paste_btn = WXmPushButton (edit_menu, "new_term", AM); WXmSeparator group_sep (edit_menu, "group_sep", AM); f_group_btn = WXmPushButton (edit_menu, "group", AM); f_ungroup_btn = WXmPushButton (edit_menu, "ungroup", AM); WXmSeparator undo_sep (edit_menu, "undo_sep", AM); f_undo_btn = WXmPushButton (edit_menu, "undo", AM); f_redo_btn = WXmPushButton (edit_menu, "redo", AM); mtfstring = CATGETS(Set_AgentLabel, 16, "Edit"); mnemonic = *CATGETS(Set_AgentLabel, 17, "E"); XtVaSetValues(edit_cascade, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL); mtfstring = CATGETS(Set_AgentLabel, 224, "Cut"); XtVaSetValues(f_cut_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 18, "Copy"); XtVaSetValues(f_copy_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 225, "Paste"); XtVaSetValues(f_paste_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 226, "Group"); XtVaSetValues(f_group_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 227, "Ungroup"); XtVaSetValues(f_ungroup_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 228, "Undo"); XtVaSetValues(f_undo_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 229, "Redo"); XtVaSetValues(f_redo_btn, XmNlabelString, (XmString)mtfstring, NULL); // Button area at the bottom WXmForm hform (form, "hform" ); f_hist_prev = WXmArrowButton (hform, "hist_prev", AM); f_hist_next = WXmArrowButton (hform, "hist_next", AM); WXmLabel history (hform, "history", AM); f_search_btn = WXmPushButton (form, "search", AM); WXmPushButton cancel (form, "cancel", AM); WXmPushButton clear (form, "clear", AM); WXmPushButton scope (form, "scope", AM); WXmPushButton help (form, "help", AM); WXmSeparator separator (form, "separator", AM); mtfstring = CATGETS(Set_AgentLabel, 92, "History"); XtVaSetValues(history, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 102, "Search"); XtVaSetValues(f_search_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 231, "Clear All"); XtVaSetValues(clear, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 46, "Scope Editor"); XtVaSetValues(scope, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 12, "Close"); XtVaSetValues(cancel, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 48, "Help"); XtVaSetValues(help, XmNlabelString, (XmString)mtfstring, NULL); help_agent().add_activate_help (help, "query_editor_help"); // Main "work" area WXmPanedWindow pane (form, "pane" ); WXmForm qform (pane, "qform" ); WXmLabel qlabel (qform, "qlabel", AM); mtfstring = CATGETS(Set_AgentLabel, 230, "Query"); XtVaSetValues(qlabel, XmNlabelString, (XmString)mtfstring, NULL); f_query_text = WXmScrolledText (qform, "qtext", AM); // f_query_text.SetEditable(False); f_query_area = WXmScrolledWindow (pane, "query_area", AM); XtUnmanageChild (f_query_area.HorizontalScrollBar()); edit_cascade.SubMenuId (edit_menu); // Callbacks ON_ACTIVATE (f_search_btn, search_activate); ON_ACTIVATE (cancel, cancel); ON_ACTIVATE (clear, clear); ON_ACTIVATE (scope, scope); // f_query_text.SetFocusCallback (this, // (WWL_FUN) &QueryEditor::modify_verify); // f_query_text.SetModifyVerifyCallback (this, // (WWL_FUN) &QueryEditor::modify_verify); // Set minimum sizes. qform.Manage(); pane.Manage(); // hform.Manage(); form.DefaultButton (f_search_btn); form.ShadowThickness (0); form.InitialFocus (pane); pane.InitialFocus (f_query_area); qform.PaneMinimum (f_query_text.Height()); form.Manage(); f_shell.Realize(); f_shell.MinWidth (f_shell.Width()); f_shell.MinHeight (f_shell.Height()); ON_DEBUG(printf ("Query for height = %d\n", qform.Height())); //cerr << "Query for height = " << qform.Height() << endl; //#ifndef UseFJMTF #if 1 // Swap the entries in the pane around. Have to do this now // to get initial sizes right. qform.PositionIndex (1); #endif fill_menu(); UAS_SearchScope::request ((UAS_Receiver<ScopeCreated> *) this); UAS_SearchScope::request ((UAS_Receiver<ScopeDeleted> *) this); UAS_SearchScope::request ((UAS_Receiver<ScopeRenamed> *) this); search_scope_mgr().option_menu(this); }
int main_menu(void) { MENU *my_menu = NULL; ITEM **my_items = NULL; struct tool_instance *list = NULL; const char *ret_msg = NULL; // Init at refresh for first loop. int c = 'R'; do { switch (c) { // Navigate in the menu case KEY_DOWN: case KEY_RIGHT: menu_driver(my_menu, REQ_DOWN_ITEM); break ; case KEY_UP: case KEY_LEFT: menu_driver(my_menu, REQ_UP_ITEM); break ; // Select a migration to monitor case ' ': case 13: // Enter key { if (item_count(my_menu) > 0) { ITEM *curitem = current_item(my_menu); if (view_instance(item_description(curitem)) != EXIT_SUCCESS) { ret_msg = "An error occured while trying to display the tool's data."; } } } // No break here to allow refreshing the list // when coming out of the instance display. // Refresh the list. case 'r': case 'R': if (list) clear_instance_list(list); list = get_instance_list(); if (list == NULL) mvprintw(0, 0, "cloudmig-view: No cloudmig tool is running at the moment.\n"); if (my_menu) clear_menu(my_menu, my_items); my_items = NULL; my_menu = NULL; if (fill_menu(list, &my_items, &my_menu)) return EXIT_FAILURE; post_menu(my_menu); break; // Leave the monitor case 'q': case 'Q': break ; // Ignore the others default: break ; } mvprintw(LINES - 4, 0, "Use <SPACE> or <ENTER> to select the process to monitor."); mvprintw(LINES - 3, 0, " <q> or <Q> to quit this program."); mvprintw(LINES - 2, 0, " <r> or <R> to see refresh the list manually."); if (ret_msg) { mvprintw(LINES -6, 0, "%.*s", COLS, ret_msg); ret_msg = NULL; } refresh(); } while ((c = getch()) != 'q'); return EXIT_FAILURE; }
int SameGameProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { switch (message) { case MSG_CREATE: { RECT rcClient; MENUBUTTONITEM mbi; GetClientRect (hWnd, &rcClient); CreateWindow (CTRL_STATIC, SM_ST_SCENARIO, WS_CHILD | WS_VISIBLE | SS_RIGHT, 0, 0, rcClient.bottom - GetSysCharHeight () - 4, 100, GetSysCharHeight () + 4, hWnd, 0); hwnd_menu = CreateWindow ("menubutton", SM_ST_MNB, WS_CHILD | WS_VISIBLE, 100, 100, rcClient.bottom - GetSysCharHeight () - 4, 100, GetSysCharHeight () + 4, hWnd, 0); if (fill_menu (hwnd_menu) <= 0) { fprintf (stderr, "Can not find scenario.\n"); return -1; } SendMessage (hwnd_menu, MBM_SETCURITEM, 0, 0); hwnd_score = CreateWindow (CTRL_STATIC, SM_ST_SETSCORE, WS_CHILD | WS_VISIBLE | SS_RIGHT, 0, 200, rcClient.bottom - GetSysCharHeight () - 4, rcClient.right - 200, GetSysCharHeight () + 4, hWnd, 0); mbi.which = MB_WHICH_TEXT; SendMessage (hwnd_menu, MBM_GETITEMDATA, 0, (LPARAM)&mbi); create_same_board (mbi.text); new_game (hWnd); } break; case MSG_COMMAND: if (LOWORD(wParam) == 100 && HIWORD (wParam) == MBN_CHANGED) { int sel = SendMessage (hwnd_menu, MBM_GETCURITEM, 0, 0); if (sel >= 0) sel_scenario (hWnd, sel); break; } switch (wParam) { case IDM_NEW: new_game (hWnd); break; case IDM_SCORES: break; case IDM_EXIT: SendMessage (hWnd, MSG_CLOSE, 0, 0L); break; case IDM_PREF: break; case IDM_ABOUT: break; } break; case MSG_PAINT: { HDC hdc; hdc = BeginPaint (hWnd); paint (hWnd, hdc); EndPaint (hWnd, hdc); return 0; } case MSG_LBUTTONDOWN: { int x = LOWORD (lParam); int y = HIWORD (lParam); kill_balls (hWnd, x / STONE_SIZE, y / STONE_SIZE); old_x = -1; old_y = -1; } break; case MSG_MOUSEMOVE: { int x = LOWORD (lParam); int y = HIWORD (lParam); if (PtInRect (&rcBoard, x, y)) mark_balls (hWnd, x / STONE_SIZE, y / STONE_SIZE); else unmark_balls (hWnd); } break; case MSG_NCMOUSEMOVE: if (wParam != HT_CLIENT) unmark_balls (hWnd); break; case MSG_MOUSEMOVEIN: if (!wParam) unmark_balls (hWnd); break; case MSG_TIMER: if (wParam == ID_TIMER) { HDC hdc = GetClientDC (hWnd); move_tagged_balls (hdc); ReleaseDC (hdc); } break; case MSG_CLOSE: if (MessageBox (hWnd, SM_ST_QUIT, SM_ST_SAME, MB_YESNO | MB_ICONQUESTION | MB_BASEDONPARENT) != IDYES) return 0; DestroyAllControls (hWnd); DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; } return DefaultMainWinProc (hWnd, message, wParam, lParam); }