/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ int main(int argc, char *argv[]) { char window_title[MAX_TITLE_CMD_LENGTH + 1 + 25 + 1]; static String fallback_res[] = { ".show_cmd*mwmDecorations : 110", ".show_cmd*mwmFunctions : 30", ".show_cmd.mainform_w.cmd_outputSW*XmText.fontList : fixed", ".show_cmd*background : NavajoWhite2", ".show_cmd.mainform_w.cmd_outputSW.cmd_output.background : NavajoWhite1", ".show_cmd.mainform_w.buttonbox_w*background : PaleVioletRed2", ".show_cmd.mainform_w.buttonbox_w*foreground : Black", ".show_cmd.mainform_w.buttonbox_w*highlightColor : Black", ".show_cmd.Print Data*background : NavajoWhite2", ".show_cmd.Print Data*XmText.background : NavajoWhite1", ".show_cmd.Print Data.main_form.buttonbox*background : PaleVioletRed2", ".show_cmd.Print Data.main_form.buttonbox*foreground : Black", ".show_cmd.Print Data.main_form.buttonbox*highlightColor : Black", NULL }; Widget mainform_w, button, buttonbox_w, separator_w; Arg args[MAXARGS]; Cardinal argcount; XmFontListEntry entry; XmFontList fontlist; uid_t euid, /* Effective user ID. */ ruid; /* Real user ID. */ CHECK_FOR_VERSION(argc, argv); p_work_dir = work_dir; init_cmd(&argc, argv, window_title); /* * SSH wants to look at .Xauthority and with setuid flag * set we cannot do that. So when we initialize X lets temporaly * disable it. After XtAppInitialize() we set it back. */ euid = geteuid(); ruid = getuid(); if (euid != ruid) { if (seteuid(ruid) == -1) { (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n", ruid, strerror(errno)); } } argcount = 0; XtSetArg(args[argcount], XmNtitle, window_title); argcount++; appshell = XtAppInitialize(&app, "AFD", NULL, 0, &argc, argv, fallback_res, args, argcount); disable_drag_drop(appshell); if (euid != ruid) { if (seteuid(euid) == -1) { (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n", euid, strerror(errno)); } } if ((display = XtDisplay(appshell)) == NULL) { (void)fprintf(stderr, "ERROR : Could not open Display : %s (%s %d)\n", strerror(errno), __FILE__, __LINE__); exit(INCORRECT); } #ifdef HAVE_XPM /* Setup AFD logo as icon. */ setup_icon(display, appshell); #endif /* Create managing widget. */ mainform_w = XmCreateForm(appshell, "mainform_w", NULL, 0); /* Prepare the font. */ entry = XmFontListEntryLoad(XtDisplay(appshell), font_name, XmFONT_IS_FONT, "TAG1"); fontlist = XmFontListAppendEntry(NULL, entry); XmFontListEntryFree(&entry); argcount = 0; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNfractionBase, 31); argcount++; buttonbox_w = XmCreateForm(mainform_w, "buttonbox_w", args, argcount); button = XtVaCreateManagedWidget("Repeat", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 10, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 30, NULL); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)repeat_button, 0); button = XtVaCreateManagedWidget("Print", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 11, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 20, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 30, NULL); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)print_button, 0); button = XtVaCreateManagedWidget("Close", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 21, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 30, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 30, NULL); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)close_button, 0); XtManageChild(buttonbox_w); /*-----------------------------------------------------------------------*/ /* Horizontal Separator */ /*-----------------------------------------------------------------------*/ argcount = 0; XtSetArg(args[argcount], XmNorientation, XmHORIZONTAL); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, buttonbox_w); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; separator_w = XmCreateSeparator(mainform_w, "separator", args, argcount); XtManageChild(separator_w); /*-----------------------------------------------------------------------*/ /* Status Box */ /* ---------- */ /* The status of the output log is shown here. If eg. no files are found */ /* it will be shown here. */ /*-----------------------------------------------------------------------*/ statusbox_w = XtVaCreateManagedWidget(" ", xmLabelWidgetClass, mainform_w, XmNfontList, fontlist, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, separator_w, NULL); /*-----------------------------------------------------------------------*/ /* Horizontal Separator */ /*-----------------------------------------------------------------------*/ argcount = 0; XtSetArg(args[argcount], XmNorientation, XmHORIZONTAL); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, statusbox_w); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; separator_w = XmCreateSeparator(mainform_w, "separator", args, argcount); XtManageChild(separator_w); /* Create cmd_output as a ScrolledText window. */ argcount = 0; XtSetArg(args[argcount], XmNrows, 18); argcount++; XtSetArg(args[argcount], XmNcolumns, 80); argcount++; XtSetArg(args[argcount], XmNeditable, False); argcount++; XtSetArg(args[argcount], XmNeditMode, XmMULTI_LINE_EDIT); argcount++; XtSetArg(args[argcount], XmNwordWrap, False); argcount++; XtSetArg(args[argcount], XmNscrollHorizontal, True); argcount++; XtSetArg(args[argcount], XmNcursorPositionVisible, True); argcount++; XtSetArg(args[argcount], XmNautoShowCursorPosition, False); argcount++; XtSetArg(args[argcount], XmNfontList, fontlist); argcount++; XtSetArg(args[argcount], XmNtopAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, separator_w); argcount++; cmd_output = XmCreateScrolledText(mainform_w, "cmd_output", args, argcount); XtManageChild(cmd_output); XtManageChild(mainform_w); #ifdef WITH_EDITRES XtAddEventHandler(appshell, (EventMask)0, True, _XEditResCheckMessages, NULL); #endif /* Realize all widgets. */ XtRealizeWidget(appshell); /* Set some signal handlers. */ if ((signal(SIGBUS, sig_bus) == SIG_ERR) || (signal(SIGSEGV, sig_segv) == SIG_ERR)) { (void)xrec(WARN_DIALOG, "Failed to set signal handler's for %s : %s", SHOW_CMD, strerror(errno)); } xexec_cmd(cmd); /* We want the keyboard focus on the cmd output. */ XmProcessTraversal(cmd_output, XmTRAVERSE_CURRENT); /* Start the main event-handling loop. */ XtAppMainLoop(app); exit(SUCCESS); }
/*<----------------------------------------------------------------------------------------->*/ void InitPanneauEdition() { Arg args[10]; XmString label; XmStringTable labelTable; register int n; char nomShell[128]; int lng = 0; Xinit("xrec"); lng = c_getulng(); memset(&champOriginal, '\000', sizeof(_Champ)); n = 0; strcpy(nomShell, XtName(SuperWidget.topLevel)); strcat(nomShell, nomPanneauEdition[lng]); peTopLevel = XtAppCreateShell(nomShell, nomShell, applicationShellWidgetClass, XtDisplay(SuperWidget.topLevel), args, n); peForme = (Widget) XmCreateForm(peTopLevel, "form", NULL, 0); XtManageChild(peForme); n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; peFermer = (Widget)XmCreatePushButton(peForme, labelFermer[lng], args, n); XtAddCallback(peFermer, XmNactivateCallback, (XtCallbackProc) PeFermer, NULL); XtManageChild(peFermer); n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNrightWidget, peFermer); n++; peAfficher = (Widget)XmCreatePushButton(peForme, labelAfficher[lng], args, n); XtAddCallback(peAfficher, XmNactivateCallback, (XtCallbackProc) PeAfficher, NULL); XtManageChild(peAfficher); n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, peFermer); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; peFrame = (Widget) XmCreateFrame(peForme, "form", args, n); XtManageChild(peFrame); n = 0; XtSetArg (args[n], XmNorientation, XmVERTICAL); n++; XtSetArg (args[n], XmNnumColumns, 1); n++; peRC = (Widget) XmCreateRowColumn(peFrame, "RC", args, n); XtManageChild(peRC); n=0; XtSetArg (args[n], XmNorientation, XmVERTICAL); n++; XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); n++; XtSetArg (args[n], XmNnumColumns, 2); n++; peRCBoutons = (Widget) XmCreateRowColumn(peRC, "RCBoutons", args, n); XtManageChild(peRCBoutons); label = XmStringCreateLtoR(EditerValeurs[lng], XmSTRING_DEFAULT_CHARSET); n = 0; XtSetArg(args[n], XmNlabelString, label); n++; XtSetArg (args[n], XmNsensitive, False); n++; peEditerValeurs = (Widget) XmCreatePushButton(peRCBoutons, EditerValeurs[lng], args, n); XtAddCallback(peEditerValeurs, XmNactivateCallback, (XtCallbackProc) PeEditerValeurs, MODIFIER); XtManageChild(peEditerValeurs); XmStringFree(label); label = XmStringCreateLtoR(AnnulerEdition[lng], XmSTRING_DEFAULT_CHARSET); n = 0; XtSetArg(args[n], XmNlabelString, label); n++; XtSetArg (args[n], XmNsensitive, False); n++; peAnnulerEdition = (Widget) XmCreatePushButton(peRCBoutons, AnnulerEdition[lng], args, n); XtAddCallback(peAnnulerEdition, XmNactivateCallback, (XtCallbackProc) PeAnnulerEdition, NULL); XtManageChild(peAnnulerEdition); XmStringFree(label); label = XmStringCreateLtoR(Enregistrer[lng], XmSTRING_DEFAULT_CHARSET); n = 0; XtSetArg(args[n], XmNlabelString, label); n++; XtSetArg (args[n], XmNsensitive, False); n++; peEnregistrer = (Widget) XmCreatePushButton(peRCBoutons, Enregistrer[lng], args, n); XtAddCallback(peEnregistrer, XmNactivateCallback, (XtCallbackProc) PeEnregistrer, NULL); XtManageChild(peEnregistrer); XmStringFree(label); label = XmStringCreateLtoR(RemettreValeurs[lng], XmSTRING_DEFAULT_CHARSET); n = 0; XtSetArg(args[n], XmNlabelString, label); n++; XtSetArg(args[n], XmNsensitive, False); n++; peRemettreValeurs = (Widget) XmCreatePushButton(peRCBoutons, RemettreValeurs[lng], args, n); XtAddCallback(peRemettreValeurs, XmNactivateCallback, (XtCallbackProc) PeEditerValeurs, (XtPointer) REMETTRE); XtManageChild(peRemettreValeurs); XmStringFree(label); label = XmStringCreateLtoR(RefaireEdition[lng], XmSTRING_DEFAULT_CHARSET); n = 0; XtSetArg(args[n], XmNlabelString, label); n++; XtSetArg (args[n], XmNsensitive, False); n++; peRefaireEdition = (Widget) XmCreatePushButton(peRCBoutons, RefaireEdition[lng], args, n); XtAddCallback(peRefaireEdition, XmNactivateCallback, (XtCallbackProc) PeRefaireEdition, NULL); XtManageChild(peRefaireEdition); XmStringFree(label); label = XmStringCreateLtoR(AnnulerToutesModifs[lng], XmSTRING_DEFAULT_CHARSET); n = 0; XtSetArg(args[n], XmNlabelString, label); n++; XtSetArg (args[n], XmNsensitive, False); n++; peAnnulerToutesModifs = (Widget) XmCreatePushButton(peRCBoutons, AnnulerToutesModifs[lng], args, n); XtAddCallback(peAnnulerToutesModifs, XmNactivateCallback, (XtCallbackProc) PeAnnulerToutesModifs, NULL); XtManageChild(peAnnulerToutesModifs); XmStringFree(label); n = 0; peSeparateurs[0] = (Widget) XmCreateSeparator(peRC, "sep 1", args, n); XtManageChild(peSeparateurs[0]); labelTable = (XmString *)calloc(1, sizeof(XmString *)); labelTable[0] = label; n=0; XtSetArg (args[n], XmNorientation, XmVERTICAL); n++; XtSetArg (args[n], XmNnumColumns, 1); n++; peRCValRemplacement = (Widget) XmCreateRowColumn(peRC, "Val", args, n); XtManageChild(peRCValRemplacement); label = XmStringCreateLtoR(NouvelleValeur[lng], XmSTRING_DEFAULT_CHARSET); n=0; peLabelValRemplacement = (Widget) XmCreateLabel(peRCValRemplacement, NouvelleValeur[lng], args, n); XtManageChild(peLabelValRemplacement); XmStringFree(label); n = 0; XtSetArg (args[n], XmNvalue, "0.0000"); n++; XtSetArg (args[n], XmNblinkRate, 0); n++; peTextValRemplacement = (Widget) XmCreateTextField(peRCValRemplacement, "text", args, n); XtManageChild(peTextValRemplacement); n = 0; peSeparateurs[2] = (Widget) XmCreateSeparator(peRC, "sep 2", args, n); XtManageChild(peSeparateurs[2]); n=0; XtSetArg (args[n], XmNorientation, XmVERTICAL); n++; XtSetArg (args[n], XmNnumColumns, 1); n++; peRCEtikRemplacement = (Widget) XmCreateRowColumn(peRC, "Etik", args, n); XtManageChild(peRCEtikRemplacement); label = XmStringCreateLtoR(NouvelleEtiquette[lng], XmSTRING_DEFAULT_CHARSET); n=0; peLabelEtikRemplacement = (Widget) XmCreateLabel(peRCEtikRemplacement, NouvelleEtiquette[lng], args, n); XtManageChild(peLabelEtikRemplacement); XmStringFree(label); n = 0; XtSetArg (args[n], XmNmaxLength, 8); n++; XtSetArg (args[n], XmNvalue, EtiquetteDefaut[lng]); n++; XtSetArg (args[n], XmNblinkRate, 0); n++; peTextEtikRemplacement = (Widget) XmCreateTextField(peRCEtikRemplacement, "text", args, n); XtManageChild(peTextEtikRemplacement); peInfo = (Widget) CreateInfoDialog(peTopLevel); peWarning = (Widget) CreateWarningDialog(peTopLevel); peWarningWithCancel = (Widget) CreateWarningDialogWithCancelBox(peTopLevel); }
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ int main(int argc, char *argv[]) { int glyph_height, max_vertical_lines; char window_title[100], work_dir[MAX_PATH_LENGTH]; static String fallback_res[] = { "*mwmDecorations : 42", "*mwmFunctions : 12", ".view_dc.form*background : NavajoWhite2", ".view_dc.form.buttonbox2.searchbox*background : NavajoWhite1", ".view_dc.form.dc_textSW.dc_text.background : NavajoWhite1", ".view_dc.form.buttonbox*background : PaleVioletRed2", ".view_dc.form.buttonbox*foreground : Black", ".view_dc.form.buttonbox*highlightColor : Black", NULL }; Widget form_w, button_w, buttonbox_w, h_separator_w; XmFontListEntry entry; XFontStruct *font_struct; XmFontList fontlist; XmFontType dummy; Arg args[MAXARGS]; Cardinal argcount; uid_t euid, /* Effective user ID. */ ruid; /* Real user ID. */ CHECK_FOR_VERSION(argc, argv); /* Initialise global values. */ p_work_dir = work_dir; init_view_dc(&argc, argv); /* * SSH uses wants to look at .Xauthority and with setuid flag * set we cannot do that. So when we initialize X lets temporaly * disable it. After XtAppInitialize() we set it back. */ euid = geteuid(); ruid = getuid(); if (euid != ruid) { if (seteuid(ruid) == -1) { (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n", ruid, strerror(errno)); } } (void)strcpy(window_title, "DIR_CONFIG "); (void)strcat(window_title, p_title); argcount = 0; XtSetArg(args[argcount], XmNtitle, window_title); argcount++; appshell = XtAppInitialize(&app, "AFD", NULL, 0, &argc, argv, fallback_res, args, argcount); disable_drag_drop(appshell); if (euid != ruid) { if (seteuid(euid) == -1) { (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n", euid, strerror(errno)); } } /* Get display pointer. */ if ((display = XtDisplay(appshell)) == NULL) { (void)fprintf(stderr, "ERROR : Could not open Display : %s (%s %d)\n", strerror(errno), __FILE__, __LINE__); exit(INCORRECT); } #ifdef HAVE_XPM /* Setup AFD logo as icon. */ setup_icon(display, appshell); #endif /* Create managing widget. */ form_w = XmCreateForm(appshell, "form", NULL, 0); if ((entry = XmFontListEntryLoad(XtDisplay(form_w), font_name, XmFONT_IS_FONT, "TAG1")) == NULL) { if ((entry = XmFontListEntryLoad(XtDisplay(form_w), "fixed", XmFONT_IS_FONT, "TAG1")) == NULL) { (void)fprintf(stderr, "Failed to load font with XmFontListEntryLoad() : %s (%s %d)\n", strerror(errno), __FILE__, __LINE__); exit(INCORRECT); } } font_struct = (XFontStruct *)XmFontListEntryGetFont(entry, &dummy); glyph_height = font_struct->ascent + font_struct->descent; fontlist = XmFontListAppendEntry(NULL, entry); XmFontListEntryFree(&entry); /* Calculate the maximum lines to show. */ max_vertical_lines = (8 * (DisplayHeight(display, DefaultScreen(display)) / glyph_height)) / 10; if (max_y > max_vertical_lines) { max_y = max_vertical_lines; } argcount = 0; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNfractionBase, 21); argcount++; buttonbox_w = XmCreateForm(form_w, "buttonbox", args, argcount); /* Create a horizontal separator. */ argcount = 0; XtSetArg(args[argcount], XmNorientation, XmHORIZONTAL); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, buttonbox_w); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; h_separator_w = XmCreateSeparator(form_w, "h_separator", args, argcount); XtManageChild(h_separator_w); button_w = XtVaCreateManagedWidget("Close", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 2, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 19, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 20, NULL); XtAddCallback(button_w, XmNactivateCallback, (XtCallbackProc)close_button, (XtPointer)0); XtManageChild(buttonbox_w); /* Create DIR_CONFIG data as a ScrolledText window. */ argcount = 0; XtSetArg(args[argcount], XmNfontList, fontlist); argcount++; XtSetArg(args[argcount], XmNeditable, False); argcount++; XtSetArg(args[argcount], XmNeditMode, XmMULTI_LINE_EDIT); argcount++; XtSetArg(args[argcount], XmNwordWrap, False); argcount++; XtSetArg(args[argcount], XmNscrollHorizontal, False); argcount++; XtSetArg(args[argcount], XmNcursorPositionVisible, False); argcount++; XtSetArg(args[argcount], XmNautoShowCursorPosition, False); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNleftOffset, 3); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightOffset, 3); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, h_separator_w); argcount++; XtSetArg(args[argcount], XmNbottomOffset, 3); argcount++; XtSetArg(args[argcount], XmNrows, max_y); argcount++; XtSetArg(args[argcount], XmNcolumns, max_x); argcount++; XtSetArg(args[argcount], XmNvalue, view_buffer); argcount++; text_w = XmCreateScrolledText(form_w, "dc_text", args, argcount); XtManageChild(text_w); /* Create a horizontal separator. */ argcount = 0; XtSetArg(args[argcount], XmNorientation, XmHORIZONTAL); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, text_w); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; h_separator_w = XmCreateSeparator(form_w, "h_separator", args, argcount); XtManageChild(h_separator_w); argcount = 0; XtSetArg(args[argcount], XmNtopAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNtopOffset, 1); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, h_separator_w); argcount++; XtSetArg(args[argcount], XmNbottomOffset, 1); argcount++; XtSetArg(args[argcount], XmNfractionBase, 31); argcount++; buttonbox_w = XmCreateForm(form_w, "buttonbox2", args, argcount); searchbox_w = XtVaCreateWidget("searchbox", xmTextWidgetClass, buttonbox_w, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 5, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 26, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 20, XmNfontList, fontlist, XmNrows, 1, XmNeditable, True, XmNcursorPositionVisible, True, XmNmarginHeight, 1, XmNmarginWidth, 1, XmNshadowThickness, 1, XmNhighlightThickness, 0, NULL); XtManageChild(searchbox_w); button_w = XtVaCreateManagedWidget("Search", xmPushButtonWidgetClass, buttonbox_w, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 22, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 28, XmNtopAttachment, XmATTACH_FORM, XmNfontList, fontlist, NULL); XtAddCallback(button_w, XmNactivateCallback, (XtCallbackProc)search_button, (XtPointer)0); XtManageChild(buttonbox_w); XtManageChild(form_w); /* Free font list. */ XmFontListFree(fontlist); #ifdef WITH_EDITRES XtAddEventHandler(appshell, (EventMask)0, True, _XEditResCheckMessages, NULL); #endif /* Realize all widgets. */ XtRealizeWidget(appshell); /* We want the keyboard focus on the Close button. */ XmProcessTraversal(button_w, XmTRAVERSE_CURRENT); /* Write window ID, so afd_ctrl can set focus if it is called again. */ write_window_id(XtWindow(appshell), getpid(), VIEW_DC); /* Start the main event-handling loop. */ XtAppMainLoop(app); exit(SUCCESS); }
/*SF-------------------------------------------------------------------------- * Function: xUIoptionCreateActionbar () * -create option action bar with some functions * In: -the parent widget * out: - * Return: -a widget *--------------------------------------------------------------------------- */ static Widget xUIoptionCreateActionbar( Widget parent) { extern XtTranslations softkeytrans; extern char * xuiLabelTable[][XUILABMAXTEXTS]; Widget rowcol, separator; Widget child[8]; char bez[_CHAR30+1], fez[_CHAR30+1] ; char bezdummy[_LABELLEN+1], fezdummy[_LABELLEN+1]; Arg arglist[10]; int ac; int i; XmString xmStr, xmStrDum ; /*--- Framed part -------------------------------------*/ ac = 0; (void)sprintf(bez, "%s%d", ROWCOLMOD, _OPTIONNR); XtSetArg(arglist[ac], XmNpacking, XmPACK_COLUMN); ac++; XtSetArg(arglist[ac], XmNorientation, XmHORIZONTAL); ac++; rowcol = XtCreateManagedWidget(bez, xmRowColumnWidgetClass, parent, arglist, ac); /*--- preparation for dummies -------------------------*/ (void)sprintf(bezdummy, "%s", BUTTONDUMMY); (void)sprintf(fezdummy, "%s", " "); xmStrDum = XmStringCreateLtoR( fezdummy, XmSTRING_DEFAULT_CHARSET); /*--- HELP/Info ACTION --------*/ (void)sprintf(bez, "%s%d", BUTTONHELP, _BMDLNNR); (void)sprintf(fez, "%s\n%s", LABEL_HELP_1, LABEL_HELP_2 ); xmStr = XmStringCreateLtoR( fez, XmSTRING_DEFAULT_CHARSET); XtSetArg(arglist[0], XmNlabelString, xmStr ); child[0] = XmCreatePushButton(rowcol, bez, arglist, 1); WoptionButtonHelp = child[0]; XmStringFree( xmStr); XtAddCallback(child[0], XmNactivateCallback, (XtCallbackProc)xUIinfo, (XtPointer)NULL); /*--- Dummy button --------*/ XtSetArg(arglist[0], XmNlabelString, xmStrDum ); child[1] = XmCreatePushButton(rowcol, bezdummy, arglist, 1); /*--- Dummy button --------*/ XtSetArg(arglist[0], XmNlabelString, xmStrDum ); child[2] = XmCreatePushButton(rowcol, bezdummy, arglist, 1); /*--- Dummy button --------*/ XtSetArg(arglist[0], XmNlabelString, xmStrDum ); child[3] = XmCreatePushButton(rowcol, bezdummy, arglist, 1); /*--- Separator --------------------------------------------------------*/ (void)sprintf(bez, "%s%d", SEPAR, _BMDLNNR); XtSetArg(arglist[0], XmNseparatorType, XmNO_LINE ); XtSetArg(arglist[1], XmNorientation, XmVERTICAL ); XtSetArg(arglist[2], XmNwidth, 25 ); separator = XmCreateSeparator( rowcol, bez, arglist, 3); XtManageChild(separator); /*--- Dummy button --------*/ XtSetArg(arglist[0], XmNlabelString, xmStrDum ); child[4] = XmCreatePushButton(rowcol, bezdummy, arglist, 1); /*--- Dummy button --------*/ XtSetArg(arglist[0], XmNlabelString, xmStrDum ); child[5] = XmCreatePushButton(rowcol, bezdummy, arglist, 1); /*--- Dummy button --------*/ XtSetArg(arglist[0], XmNlabelString, xmStrDum ); child[6] = XmCreatePushButton(rowcol, bezdummy, arglist, 1); /*--- [Exit] create pushbutton exit ---------------------*/ ac = 0; (void)sprintf(bez, "%s", BUTTONQUIT ); (void)sprintf(fez, "%s\n%s", LABEL_QUITMENU_1, LABEL_QUITMENU_2 ); xmStr = XmStringCreateLtoR( fez, XmSTRING_DEFAULT_CHARSET); XtSetArg(arglist[ac], XmNlabelString, xmStr); ac++; child[7] = XmCreatePushButton( rowcol, bez, arglist, ac); XmStringFree( xmStr); XtAddCallback(child[7], XmNactivateCallback, (XtCallbackProc)xUIoptionPopdown, (XtPointer)NULL ); WoptionButtonQuit = child[7]; /* used in softkey() */ /*--- common stuff -----*/ for (i=0; i<8; i++) XtOverrideTranslations(child[i], softkeytrans); XtManageChildren(child, 8); XmStringFree( xmStrDum); return (rowcol); }
/********************************************************* * createAndPopupProductDescriptionShell * * function to create, set and popup an EPICS product description shell * widget hierarchy: * * productDescriptionShell * form * nameLabel * separator * descriptionLabel * versionInfoLabel * developedAtLabel * okButton *********************************************************/ Widget createAndPopupProductDescriptionShell( XtAppContext appContext, /* application context */ Widget topLevelShell, /* application's topLevel shell */ char *name, /* product/program name */ XmFontList nameFontList, /* and font list (or NULL) */ Pixmap namePixmap, /* name Pixmap (or NULL) */ char *description, /* product description */ XmFontList descriptionFontList,/* and font list (or NULL) */ char *versionInfo, /* product version number */ char *developedAt, /* at and by... */ XmFontList otherFontList, /* and font list (or NULL) */ int background, /* background color (or -1) */ int foreground, /* foreground color (or -1) */ int seconds) /* seconds to leave posted */ { Display *display; Widget productDescriptionShell, form; Arg args[15]; Widget children[6], nameLabel, descriptionLabel, versionInfoLabel, separator, developedAtLabel; XmString nameXmString = (XmString)NULL, descriptionXmString = (XmString)NULL, versionInfoXmString = (XmString)NULL, developedAtXmString = (XmString)NULL, okXmString = (XmString)NULL; Dimension formHeight, nameHeight; Dimension shellHeight, shellWidth; Dimension screenHeight, screenWidth; Position newY, newX; int n, offset, screen; /* Create the shell */ n = 0; if (background >= 0) { XtSetArg(args[n],XmNbackground,(unsigned long)background); n++; } if (foreground >= 0) { XtSetArg(args[n],XmNforeground,(unsigned long)foreground); n++; } XtSetArg(args[n],XmNmwmDecorations, MWM_DECOR_ALL| MWM_DECOR_BORDER|MWM_DECOR_RESIZEH|MWM_DECOR_TITLE|MWM_DECOR_MENU| MWM_DECOR_MINIMIZE|MWM_DECOR_MAXIMIZE); n++; XtSetArg(args[n],XmNtitle,"Version"); n++; productDescriptionShell = XtCreatePopupShell("productDescriptionShell", topLevelShellWidgetClass,topLevelShell,args, n); display=XtDisplay(productDescriptionShell); screen=DefaultScreen(display); n = 0; if (background >= 0) { XtSetArg(args[n],XmNbackground,(unsigned long)background); n++; } if (foreground >= 0) { XtSetArg(args[n],XmNforeground,(unsigned long)foreground); n++; } XtSetArg(args[n],XmNnoResize,True); n++; XtSetArg(args[n],XmNshadowThickness,2); n++; XtSetArg(args[n],XmNshadowType,XmSHADOW_OUT); n++; XtSetArg(args[n],XmNautoUnmanage,False); n++; form = XmCreateForm(productDescriptionShell,"form",args,n); /* Generate XmStrings */ if (name != NULL) nameXmString = XmStringCreateLtoR(name, XmFONTLIST_DEFAULT_TAG); if (description != NULL) descriptionXmString = XmStringCreateLtoR(description,XmFONTLIST_DEFAULT_TAG); if (versionInfo != NULL) versionInfoXmString = XmStringCreateLtoR(versionInfo,XmFONTLIST_DEFAULT_TAG); if (developedAt != NULL) developedAtXmString = XmStringCreateLtoR(developedAt,XmFONTLIST_DEFAULT_TAG); /* Create the label children */ /* Name */ n = 0; if (namePixmap == (Pixmap) NULL) { XtSetArg(args[n],XmNlabelString,nameXmString); n++; if (nameFontList != NULL) { XtSetArg(args[n],XmNfontList,nameFontList); n++; } } else { XtSetArg(args[n],XmNlabelType,XmPIXMAP); n++; XtSetArg(args[n],XmNlabelPixmap,namePixmap); n++; } XtSetArg(args[n],XmNalignment,XmALIGNMENT_BEGINNING); n++; XtSetArg(args[n],XmNleftAttachment,XmATTACH_POSITION); n++; XtSetArg(args[n],XmNleftPosition,1); n++; XtSetArg(args[n],XmNresizable,False); n++; if (background >= 0) { XtSetArg(args[n],XmNbackground,(unsigned long)background); n++; } if (foreground >= 0) { XtSetArg(args[n],XmNforeground,(unsigned long)foreground); n++; } nameLabel = XmCreateLabel(form,"nameLabel",args,n); /* Separator */ n = 0; XtSetArg(args[n],XmNtopAttachment,XmATTACH_FORM); n++; XtSetArg(args[n],XmNbottomAttachment,XmATTACH_FORM); n++; XtSetArg(args[n],XmNleftAttachment,XmATTACH_WIDGET); n++; XtSetArg(args[n],XmNleftWidget,nameLabel); n++; XtSetArg(args[n],XmNorientation,XmVERTICAL); n++; XtSetArg(args[n],XmNshadowThickness,2); n++; XtSetArg(args[n],XmNseparatorType,XmSHADOW_ETCHED_IN); n++; if (background >= 0) { XtSetArg(args[n],XmNbackground,(unsigned long)background); n++; } if (foreground >= 0) { XtSetArg(args[n],XmNforeground,(unsigned long)foreground); n++; } separator = XmCreateSeparator(form,"separator",args,n); /* Description */ n = 0; XtSetArg(args[n],XmNalignment,XmALIGNMENT_BEGINNING); n++; XtSetArg(args[n],XmNlabelString,descriptionXmString); n++; XtSetArg(args[n],XmNtopAttachment,XmATTACH_POSITION); n++; XtSetArg(args[n],XmNtopPosition,5); n++; XtSetArg(args[n],XmNleftAttachment,XmATTACH_WIDGET); n++; XtSetArg(args[n],XmNleftWidget,separator); n++; XtSetArg(args[n],XmNrightAttachment,XmATTACH_POSITION); n++; XtSetArg(args[n],XmNrightPosition,90); n++; if (descriptionFontList != NULL) { XtSetArg(args[n],XmNfontList,descriptionFontList); n++; } if (background >= 0) { XtSetArg(args[n],XmNbackground,(unsigned long)background); n++; } if (foreground >= 0) { XtSetArg(args[n],XmNforeground,(unsigned long)foreground); n++; } descriptionLabel = XmCreateLabel(form,"descriptionLabel",args,n); /* Version info */ n = 0; XtSetArg(args[n],XmNalignment,XmALIGNMENT_BEGINNING); n++; XtSetArg(args[n],XmNlabelString,versionInfoXmString); n++; XtSetArg(args[n],XmNtopAttachment,XmATTACH_WIDGET); n++; XtSetArg(args[n],XmNtopWidget,descriptionLabel); n++; XtSetArg(args[n],XmNleftAttachment,XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n],XmNleftWidget,descriptionLabel); n++; XtSetArg(args[n],XmNrightAttachment,XmATTACH_POSITION); n++; XtSetArg(args[n],XmNrightPosition,90); n++; if (otherFontList != NULL) { XtSetArg(args[n],XmNfontList,otherFontList); n++; } if (background >= 0) { XtSetArg(args[n],XmNbackground,(unsigned long)background); n++; } if (foreground >= 0) { XtSetArg(args[n],XmNforeground,(unsigned long)foreground); n++; } versionInfoLabel = XmCreateLabel(form,"versionInfoLabel",args,n); /* Developed at/by... */ n = 0; XtSetArg(args[n],XmNalignment,XmALIGNMENT_BEGINNING); n++; XtSetArg(args[n],XmNlabelString,developedAtXmString); n++; XtSetArg(args[n],XmNtopAttachment,XmATTACH_WIDGET); n++; XtSetArg(args[n],XmNtopWidget,versionInfoLabel); n++; XtSetArg(args[n],XmNleftAttachment,XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n],XmNleftWidget,versionInfoLabel); n++; XtSetArg(args[n],XmNrightAttachment,XmATTACH_POSITION); n++; XtSetArg(args[n],XmNrightPosition,90); n++; XtSetArg(args[n],XmNbottomAttachment,XmATTACH_POSITION); n++; XtSetArg(args[n],XmNbottomPosition,90); n++; if (otherFontList != NULL) { XtSetArg(args[n],XmNfontList,otherFontList); n++; } if (background >= 0) { XtSetArg(args[n],XmNbackground,(unsigned long)background); n++; } if (foreground >= 0) { XtSetArg(args[n],XmNforeground,(unsigned long)foreground); n++; } developedAtLabel = XmCreateLabel(form,"developedAtLabel",args,n); /* OK button */ okXmString = XmStringCreateLocalized("OK"); n = 0; XtSetArg(args[n],XmNlabelString,okXmString); n++; XtSetArg(args[n],XmNtopAttachment,XmATTACH_FORM); n++; XtSetArg(args[n],XmNtopOffset,8); n++; XtSetArg(args[n],XmNrightAttachment,XmATTACH_FORM); n++; XtSetArg(args[n],XmNrightOffset,8); n++; if (otherFontList != NULL) { XtSetArg(args[n],XmNfontList,otherFontList); n++; } if (background >= 0) { XtSetArg(args[n],XmNbackground,(unsigned long)background); n++; } if (foreground >= 0) { XtSetArg(args[n],XmNforeground,(unsigned long)foreground); n++; } okButton = XmCreatePushButton(form,"okButton",args,n); XtAddCallback(okButton,XmNactivateCallback, (XtCallbackProc)closeProductDescriptionCallback, (XtPointer)productDescriptionShell); n++; XmStringFree(okXmString); children[0] = nameLabel; children[1] = descriptionLabel; children[2] = versionInfoLabel; children[3] = developedAtLabel; children[4] = separator; XtManageChildren(children,5); XtManageChild(form); XtPopup(productDescriptionShell,XtGrabNone); /* Center nameLabel vertically in form space */ XtSetArg(args[0],XmNheight,&nameHeight); XtGetValues(nameLabel,args,1); XtSetArg(args[0],XmNheight,&formHeight); XtGetValues(form,args,1); offset = (formHeight - nameHeight); offset = offset/2; XtSetArg(args[0],XmNtopOffset,offset); XtSetValues(nameLabel,args,1); /* Center the whole thing on the screen */ screenHeight=DisplayHeight(display,screen); screenWidth=DisplayWidth(display,screen); n=0; XtSetArg(args[n],XmNheight,&shellHeight); n++; XtSetArg(args[n],XmNwidth,&shellWidth); n++; XtGetValues(productDescriptionShell,args,n); newY=(screenHeight-shellHeight)/2; newX=(screenWidth-shellWidth)/2; n=0; XtSetArg(args[n],XmNy,newY); n++; XtSetArg(args[n],XmNx,newX); n++; XtSetValues(productDescriptionShell,args,n); #ifdef WIN32 /* Seems to be an Exceed bug that it doesn't get set the first time */ n=0; XtSetArg(args[n],XmNy,newY); n++; XtSetArg(args[n],XmNx,newX); n++; XtSetValues(productDescriptionShell,args,n); #endif #if DEBUG_POSITION { Position newx, newy; printf("createAndPopupProductDescriptionShell:\n"); printf(" sizeof(XtArgVal)=%d sizeof(Position)=%d sizeof(Dimension)=%d sizeof(100)=%d\n", sizeof(XtArgVal),sizeof(Position),sizeof(Dimension),sizeof(100)); printf(" shellHeight=%d shellWidth=%d\n",shellHeight,shellWidth); printf(" screenHeight=%d screenWidth=%d\n",screenHeight,screenWidth); printf(" newY=%hd newX=%hd\n",newY,newX); printf(" newY=%hx newX=%hx\n",newY,newX); printf(" newY=%x newX=%x\n",newY,newX); printf("(1) args[0].value=%4x args[1].value=%4x\n",args[0].value,args[1].value); n=0; XtSetArg(args[n],XmNy,&newy); n++; XtSetArg(args[n],XmNx,&newx); n++; XtGetValues(productDescriptionShell,args,n); printf("(1) newy=%d newx=%d\n",newy,newx); n=0; XtSetArg(args[n],XmNy,474); n++; XtSetArg(args[n],XmNx,440); n++; XtSetValues(productDescriptionShell,args,n); printf("(2) args[0].value=%4x args[1].value=%4x\n",args[0].value,args[1].value); n=0; XtSetArg(args[n],XmNy,&newy); n++; XtSetArg(args[n],XmNx,&newx); n++; XtGetValues(productDescriptionShell,args,n); printf("(2) newy=%d newx=%d\n",newy,newx); n=0; XtSetArg(args[n],XmNy,newY); n++; XtSetArg(args[n],XmNx,newX); n++; XtSetValues(productDescriptionShell,args,n); printf("(3) args[0].value=%4x args[1].value=%4x\n",args[0].value,args[1].value); n=0; XtSetArg(args[n],XmNy,&newy); n++; XtSetArg(args[n],XmNx,&newx); n++; XtGetValues(productDescriptionShell,args,n); printf("(3) newy=%d newx=%d\n",newy,newx); } #endif /* Free strings */ if (nameXmString != (XmString)NULL) XmStringFree(nameXmString); if (descriptionXmString != (XmString)NULL) XmStringFree(descriptionXmString); if (versionInfoXmString != (XmString)NULL) XmStringFree(versionInfoXmString); if (developedAtXmString != (XmString)NULL) XmStringFree(developedAtXmString); /* Register timeout procedure to make the dialog go away after N seconds */ XtAppAddTimeOut(appContext,(unsigned long)(1000*seconds), (XtTimerCallbackProc)popdownProductDescriptionShell, (XtPointer)productDescriptionShell); return(productDescriptionShell); }