static int motFileDlgAskUser(Widget parent, const char* message) { Widget questionbox; Arg args[3]; int ret_code = 0; XmString title; XtSetArg(args[0], XmNautoUnmanage, False); XtSetArg(args[1], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); XtSetArg(args[2], XmNnoResize, True); questionbox = XmCreateQuestionDialog(parent, "filedlg_question", args, 3); iupmotSetString(questionbox, XmNmessageString, message); XtVaGetValues(parent, XmNdialogTitle, &title, NULL); XtVaSetValues(questionbox, XmNdialogTitle, title, NULL); XtAddCallback(questionbox, XmNokCallback, (XtCallbackProc)motFileDlgAskUserCallback, (XtPointer)&ret_code); XtAddCallback(questionbox, XmNcancelCallback, (XtCallbackProc)motFileDlgAskUserCallback, (XtPointer)&ret_code); XtUnmanageChild(XmMessageBoxGetChild(questionbox, XmDIALOG_HELP_BUTTON)); XtManageChild(questionbox); while (ret_code == 0) XtAppProcessEvent(iupmot_appcontext, XtIMAll); XtUnmanageChild(questionbox); if (ret_code == 1) return 1; else return 0; }
void CoWowMotif::DisplayQuestion( void *ctx, const char *title, const char *text, void (* questionbox_ok) ( void *, void *), void (* questionbox_cancel) ( void *, void *), void *data) { Arg arg[10]; Widget question_widget, w; XmString CStr2, TitleStr, okstr, cancelstr; wow_t_question_cb *cbdata; XmFontList fontlist; XFontStruct *font; XmFontListEntry fontentry; // Set default fontlist font = XLoadQueryFont( XtDisplay(m_parent), "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1"); fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font); fontlist = XmFontListAppendEntry( NULL, fontentry); XtFree( (char *)fontentry); CStr2 = XmStringCreateLtoR( (char*) text, XmSTRING_DEFAULT_CHARSET); TitleStr = XmStringCreateLtoR( (char*) title, XmSTRING_DEFAULT_CHARSET); okstr = XmStringCreateLtoR( (char*) " Yes ", XmSTRING_DEFAULT_CHARSET ); cancelstr = XmStringCreateLtoR( (char*) " No ", XmSTRING_DEFAULT_CHARSET ); XtSetArg(arg[0],XmNheight,75); XtSetArg(arg[1],XmNwidth,200); XtSetArg(arg[2],XmNmessageString, CStr2); XtSetArg(arg[3],XmNx,400); XtSetArg(arg[4],XmNy,300); XtSetArg(arg[5],XmNdialogTitle,TitleStr); XtSetArg(arg[6], XmNokLabelString, okstr); XtSetArg(arg[7], XmNcancelLabelString, cancelstr); XtSetArg(arg[8], XmNbuttonFontList, fontlist); XtSetArg(arg[9], XmNlabelFontList, fontlist); cbdata = (wow_t_question_cb *) XtCalloc( 1, sizeof(*cbdata)); cbdata->questionbox_ok = questionbox_ok; cbdata->questionbox_cancel = questionbox_cancel; cbdata->questionbox_help = 0; cbdata->ctx = ctx; cbdata->data = data; question_widget = XmCreateQuestionDialog( m_parent,(char*) "questionDialog",arg,10); XtAddCallback( question_widget, XmNokCallback, (XtCallbackProc) question_ok_cb, cbdata); XtAddCallback( question_widget, XmNcancelCallback, (XtCallbackProc) question_cancel_cb, cbdata); XmStringFree( CStr2); XmStringFree( TitleStr); XmStringFree( okstr); XmStringFree( cancelstr); XmFontListFree( fontlist); XtManageChild( question_widget); w = XmMessageBoxGetChild( question_widget, XmDIALOG_HELP_BUTTON); XtUnmanageChild(w); }
int XmLMessageBox(Widget w, char *string, Boolean okOnly) { int status = 0; Widget dialog, shell; Arg args[3]; XtAppContext context; XmString str, titleStr; String shellTitle; Atom WM_DELETE_WINDOW; str = XmStringCreateLtoR(string, XmSTRING_DEFAULT_CHARSET); XtSetArg(args[0], XmNmessageString, str); XtSetArg(args[1], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); shell = XmLShellOfWidget(w); if (shell) XtVaGetValues(shell, XmNtitle, &shellTitle, NULL); if (shell && shellTitle) titleStr = XmStringCreateLtoR(shellTitle, XmSTRING_DEFAULT_CHARSET); else titleStr = XmStringCreateSimple("Notice"); XtSetArg(args[2], XmNdialogTitle, titleStr); if (okOnly == True) dialog = XmCreateMessageDialog(XtParent(w), "popup", args, 3); else dialog = XmCreateQuestionDialog(XtParent(w), "popup", args, 3); WM_DELETE_WINDOW = XmInternAtom(XtDisplay(w), "WM_DELETE_WINDOW", False); XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, XmLMessageBoxWMDelete, (caddr_t)&status); XmStringFree(str); XmStringFree(titleStr); XtAddCallback(dialog, XmNokCallback, XmLMessageBoxResponse, (XtPointer)&status); if (okOnly == True) { XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON)); } else { XtAddCallback(dialog, XmNcancelCallback, XmLMessageBoxResponse, (XtPointer)&status); XtAddCallback(dialog, XmNhelpCallback, XmLMessageBoxResponse, (XtPointer)&status); } XtManageChild(dialog); context = XtWidgetToApplicationContext(w); while (!status || XtAppPending(context)) XtAppProcessEvent(context, XtIMAll); XtDestroyWidget(dialog); return status; }
void display_question_message (Widget parent, char *message, char *button1, XtCallbackProc cb_button1, char *button2, XtCallbackProc cb_button2, char *button3, XtCallbackProc cb_button3) { Widget tmpw; QuestionDialog = XmCreateQuestionDialog(parent, "questionDialog", NULL, 0); tmpw = XmMessageBoxGetChild(QuestionDialog, XmDIALOG_OK_BUTTON); if (button1) { XtVaSetValues(tmpw, RES_CONVERT( XmNlabelString, button1), NULL); XtAddCallback( QuestionDialog, XmNokCallback, (XtCallbackProc) cb_button1, (XtPointer) NULL ); } else { XtUnmanageChild (tmpw); } tmpw = XmMessageBoxGetChild(QuestionDialog, XmDIALOG_CANCEL_BUTTON); if (button2) { XtVaSetValues(tmpw, RES_CONVERT( XmNlabelString, button2), NULL); XtAddCallback( QuestionDialog, XmNcancelCallback, (XtCallbackProc) cb_button2, (XtPointer) NULL ); } else { XtUnmanageChild (tmpw); } tmpw = XmMessageBoxGetChild(QuestionDialog, XmDIALOG_HELP_BUTTON); if (button3) { XtVaSetValues(tmpw, RES_CONVERT( XmNlabelString, button3), NULL); XtAddCallback( QuestionDialog, XmNhelpCallback, (XtCallbackProc) cb_button3, (XtPointer) NULL ); } else { XtUnmanageChild (tmpw); } XtVaSetValues (QuestionDialog, RES_CONVERT(XmNdialogTitle, GETMESSAGE(6, 51, "Create Action - Question")), RES_CONVERT(XmNmessageString, message), NULL); XtManageChild (QuestionDialog); return; }
bool add_running_arguments(string& cmd, Widget origin) { if (cmd == "run") cmd = gdb->rerun_command(); if (gdb->type() != JDB) return true; // Ok, perform the command if (!is_run_cmd(cmd)) return true; // Ok, perform the command strip_leading_space(cmd); string args = cmd.after(rxwhite); ProgramInfo info; if (args.empty() && gdb->has_debug_command()) { // JDB 1.1 requires at least a class name after the `run' command. cmd += " " + info.file; } if (info.running && !gdb->has_debug_command()) { // JDB 1.2 cannot rerun a program after it has been started. // Offer to restart JDB instead. static Widget restart_jdb = 0; static string saved_run_command; if (restart_jdb == 0) { restart_jdb = verify(XmCreateQuestionDialog(find_shell(origin), XMST("confirm_restart_gdb_dialog"), ArgList(0), 0)); Delay::register_shell(restart_jdb); XtAddCallback(restart_jdb, XmNhelpCallback, ImmediateHelpCB, XtPointer(0)); XtAddCallback(restart_jdb, XmNokCallback, RestartAndRunCB, (XtPointer)&saved_run_command); } saved_run_command = cmd; XtManageChild(restart_jdb); return false; // Don't perform the command yet } return true; }
void MakeDialog(Widget w, XtPointer client, XtPointer call) { Widget p = XtParent(XtParent(XtParent(w))); Widget dialog; Arg al[10]; int ac; ac = 0; XtSetArg(al[ac], XmNdefaultPosition, False); ac++; XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ac++; XtSetArg(al[ac], XmNtitle, "xephem Query"); ac++; dialog = XmCreateQuestionDialog(p, "Box", al, ac); XtAddCallback(dialog, XmNokCallback, Quit, NULL); XtManageChild(dialog); }
Boolean XltYesNo(Widget w, String Question) { static Widget Dialog = NULL; static int Result; Boolean Return; XmString string; if (Dialog == NULL) { Widget shell = w; while (XtParent(shell) && !XtIsTopLevelShell(shell)) shell = XtParent(shell); Dialog = XmCreateQuestionDialog(shell, "YesNo", NULL, 0); XtUnmanageChild(XmMessageBoxGetChild(Dialog, XmDIALOG_HELP_BUTTON)); XtAddCallback(Dialog, XmNokCallback, (XtCallbackProc)callback, &Result); XtAddCallback(Dialog, XmNcancelCallback, (XtCallbackProc)callback, &Result); XtAddCallback(Dialog, XmNunmapCallback, (XtCallbackProc)callback, &Result); } string = XmStringCreateSimple(Question); XtVaSetValues(Dialog, XmNmessageString, string, NULL); XmStringFree(string); XtManageChild(Dialog); Result = XmCR_NONE; while (Result == XmCR_NONE) { XtAppProcessEvent(XtWidgetToApplicationContext(w), XtIMAll); } switch (Result) { case XmCR_OK: Return = True; break; case XmCR_CANCEL: case XmCR_UNMAP: Return = False; break; default: fprintf(stderr, "%s(%d):XltYesNo() - Unknown result code >%i<\n", __FILE__, __LINE__, Result); Return = False; break; } return(Return); }
Widget XmCreateQuestionDialog_TNK(Widget parent, String name, ArgList arglist,Cardinal argcount) { return XmCreateQuestionDialog(parent, name, arglist, argcount);}
static void DoExportCB(Widget w, XtPointer client_data, XtPointer call_data) { SelectPlotCB(w, client_data, call_data); PlotWindowInfo *plot = (PlotWindowInfo *)client_data; string target = get_file(w, client_data, call_data); if (target.empty()) return; const StringArray& titles = plot->plotter->data_titles(); const StringArray& sources = plot->plotter->data_files(); string source = ""; string title = ""; for (int i = 0; source.empty() && i < sources.size(); i++) { if (!sources[i].empty()) { source = sources[i]; title = titles[i]; } } if (source.empty()) return; // This should not happen if (access(target.chars(), W_OK) == 0 && is_regular_file(target)) { // File exists - request confirmation static Widget confirm_overwrite_dialog = 0; if (confirm_overwrite_dialog != 0) DestroyWhenIdle(confirm_overwrite_dialog); Arg args[10]; Cardinal arg = 0; XtSetArg(args[arg], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); arg++; confirm_overwrite_dialog = verify(XmCreateQuestionDialog(plot->shell, XMST("confirm_overwrite_dialog"), args, arg)); Delay::register_shell(confirm_overwrite_dialog); bool yes = false; bool no = false; XtAddCallback(confirm_overwrite_dialog, XmNokCallback, SetCB, XtPointer(&yes)); XtAddCallback(confirm_overwrite_dialog, XmNcancelCallback, SetCB, XtPointer(&no)); XtAddCallback(confirm_overwrite_dialog, XmNhelpCallback, ImmediateHelpCB, 0); MString question = rm("Overwrite existing file " + quote(target) + "?"); XtVaSetValues (confirm_overwrite_dialog, XmNmessageString, question.xmstring(), XtPointer(0)); manage_and_raise(confirm_overwrite_dialog); XtAppContext app_context = XtWidgetToApplicationContext(plot->shell); while (!yes && !no) XtAppProcessEvent(app_context, XtIMAll); if (no) return; } StatusDelay delay("Saving " + title + " data to " + quote(target)); // Copy SOURCE to TARGET std::ifstream is(source.chars()); std::ofstream os(target.chars()); if (os.bad()) { FILE *fp = fopen(target.chars(), "w"); post_error(string("Cannot open ") + quote(target) + ": " + strerror(errno), "export_failed_error", plot->shell); if (fp) fclose(fp); delay.outcome = strerror(errno); return; } int c; while ((c = is.get()) != EOF) os.put((unsigned char) c); XtUnmanageChild(plot->export_dialog); }
void MakeDialog( DialogType dtype ) { register int i, j; int width; FILE *fp, *fopen(); char buffer[128]; char *str; Widget w, text; Dimension txt_width, txt_height; XmString ok, cancel, nw, sv; Widget tlev; /* * do things common to all dialogs... */ ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL); cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL); i = InitArg(MessageBox); XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++; XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++; XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++; XtSetArg(argt[i], XmNokLabelString, ok ); i++; XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++; XtSetArg(argt[i], XmNnoResize, False ); i++; XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++; /* * create the various dialogs... */ /* JET - check the matte widget, and if non-null, well use that as * the parent for dialogs. Otherwise use table (the original * toplevel widget for this func). This is useful for Xinerama so * that child dialogs are centered on the matte, and not the whole * SLS screen. */ if (matte != (Widget)NULL) tlev = matte; else tlev = table; switch (dtype) { case error: xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, ""); XtSetArg(argt[i], XmNmessageString, xmstr ); i++; w = XmCreateErrorDialog(tlev, "error_message", argt, i); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON)); error_message = w; break; case help: xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP); XtSetArg(argt[i], XmNmessageString, xmstr ); i++; w = XmCreateInformationDialog(tlev, "help_message", argt, i); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON)); txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w))); txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w))); txt_width = (txt_width > 850) ? 800 : txt_width - 50; txt_height = (txt_height > 900) ? 750 : txt_height - 150; i = InitArg(Text); XtSetArg(argt[i], XmNheight, txt_height); i++; XtSetArg(argt[i], XmNwidth, txt_width); i++; XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++; XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++; XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++; XtSetArg(argt[i], XmNeditable, False); i++; str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP); XtSetArg(argt[i], XmNvalue, strdup(str)); i++; text = XmCreateScrolledText(w, "help_message_text", argt, i); XtManageChild(text); XtManageChild(w); help_message = w; break; case copyright: if ((fp = fopen(COPYRIGHT,"r")) == NULL) #if defined( __hp_osf ) xmstr = XmStringCreate("Cannot open copyright file '/usr/X11/copyright'.", XmFONTLIST_DEFAULT_TAG); #else xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.", XmFONTLIST_DEFAULT_TAG); #endif else { xmstr = (XmString) NULL; while (fgets(buffer, 128, fp) != NULL) { j = strlen(buffer); if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0'; if ( xmstr != NULL ) xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate()); xmstr = XmStringConcat(xmstr, XmStringCreate(buffer, XmFONTLIST_DEFAULT_TAG)); } } fclose(fp); XtSetArg(argt[i], XmNmessageString, xmstr ); i++; w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON)); XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0); copyright_msg = w; break; case hostname: nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL); sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL); xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM); XtSetArg(argt[i], XmNmessageString, xmstr ); i++; XtSetArg(argt[i], XmNokLabelString, nw ); i++; XtSetArg(argt[i], XmNcancelLabelString, sv ); i++; w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON)); XmStringFree(nw); XmStringFree(sv); hostname_message = w; break; case expassword: xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED, MC_DEF_PASSWD_EXPIRED); XtSetArg(argt[i], XmNmessageString, xmstr ); i++; w = XmCreateQuestionDialog(tlev, "password_msg", argt, i); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON)); passwd_message = w; break; case help_chooser: xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER); w = XmCreateInformationDialog(tlev, "help_message", argt, i); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON)); txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w))); txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w))); txt_width = (txt_width > 850) ? 800 : txt_width - 50; txt_height = (txt_height > 900) ? 750 : txt_height - 150; i = InitArg(Text); XtSetArg(argt[i], XmNheight, txt_height); i++; XtSetArg(argt[i], XmNwidth, txt_width); i++; XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++; XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++; XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++; XtSetArg(argt[i], XmNeditable, False); i++; str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER); XtSetArg(argt[i], XmNvalue, strdup(str)); i++; text = XmCreateScrolledText(w, "help_message_text", argt, i); XtManageChild(text); XtManageChild(w); help_message = w; break; }
void InfoPop ( Widget parent, int type, char *message, Boolean help, Boolean cancel, void (*HelpCB)(), void (*CancelCB)() ) { Widget dialog; XmString xmstr; char buf[4096]; if ( message == NULL ) return; /* * Create an information dialog of the type requested in function call. */ switch ( type ) { case ERROR: dialog = XmCreateErrorDialog ( parent, "ERROR", NULL, 0 ); strcpy ( buf, "ERROR:\n" ); break; case INFORMATION: dialog = XmCreateInformationDialog ( parent, "INFORMATION", NULL, 0 ); strcpy ( buf, "INFORMATION:\n" ); break; case QUESTION: dialog = XmCreateQuestionDialog ( parent, "QUESTION", NULL, 0 ); strcpy ( buf, "QUESTION:\n" ); break; case WARNING: dialog = XmCreateWarningDialog ( parent, "WARNING", NULL, 0 ); strcpy ( buf, "WARNING:\n" ); break; case WORKING: dialog = XmCreateWorkingDialog ( parent, "WORKING", NULL, 0 ); strcpy ( buf, "WORKING:\n" ); break; default: break; } /* * Write message to dialog. */ strcat ( buf, message ); xmstr = XmStringCreateLtoR ( buf, XmFONTLIST_DEFAULT_TAG); XtVaSetValues ( dialog, XmNmessageString, xmstr, NULL ); XmStringFree ( xmstr ); /* * Add callbacks to buttons or, alternatively, delete the buttons. */ if ( !help ) XtUnmanageChild ( XmMessageBoxGetChild ( dialog, XmDIALOG_HELP_BUTTON ) ); else XtAddCallback ( dialog, XmNhelpCallback, HelpCB, NULL ); if ( !cancel ) XtUnmanageChild ( XmMessageBoxGetChild ( dialog, XmDIALOG_CANCEL_BUTTON ) ); else XtAddCallback ( dialog, XmNcancelCallback, CancelCB, NULL ); /* * Manage popup. */ XtManageChild ( dialog ); XtPopup ( XtParent ( dialog ), XtGrabNone ); }