void create_print_panel(Widget w) { Widget image; Widget entry,mag_spinner, below, fitpage; Pixmap p; unsigned long fg, bg; char *printer_val; char buf[100]; char *unit; int ux,uy,lx,ly; int i,len,maxl; float mult; XtTranslateCoords(tool, (Position) 0, (Position) 0, &xposn, &yposn); FirstArg(XtNx, xposn+50); NextArg(XtNy, yposn+50); NextArg(XtNtitle, "Xfig: Print menu"); NextArg(XtNcolormap, tool_cm); print_popup = XtCreatePopupShell("print_popup", transientShellWidgetClass, tool, Args, ArgCount); XtOverrideTranslations(print_popup, XtParseTranslationTable(prn_translations)); XtAppAddActions(tool_app, prn_actions, XtNumber(prn_actions)); print_panel = XtCreateManagedWidget("print_panel", formWidgetClass, print_popup, NULL, ZERO); /* start with the picture of the printer */ FirstArg(XtNlabel, " "); NextArg(XtNwidth, printer_ic.width); NextArg(XtNheight, printer_ic.height); NextArg(XtNborderWidth, 0); NextArg(XtNinternalWidth, 0); NextArg(XtNinternalHeight, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); image = XtCreateManagedWidget("printer_image", labelWidgetClass, print_panel, Args, ArgCount); FirstArg(XtNforeground, &fg); NextArg(XtNbackground, &bg); GetValues(image); p = XCreatePixmapFromBitmapData(tool_d, XtWindow(canvas_sw), printer_ic.bits, printer_ic.width, printer_ic.height, fg, bg, tool_dpth); FirstArg(XtNbitmap, p); SetValues(image); FirstArg(XtNlabel, "Print to PostScript Printer"); NextArg(XtNfromHoriz, image); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); (void) XtCreateManagedWidget("print_label", labelWidgetClass, print_panel, Args, ArgCount); FirstArg(XtNlabel, " Magnification %"); NextArg(XtNfromVert, image); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); beside = XtCreateManagedWidget("mag_label", labelWidgetClass, print_panel, Args, ArgCount); /* make a spinner entry for the mag */ /* note: this was called "magnification" */ sprintf(buf, "%.1f", appres.magnification); mag_spinner = MakeFloatSpinnerEntry(print_panel, &print_mag_text, "magnification", image, beside, update_mag, buf, 0.0, 10000.0, 1.0, 45); /* we want to track typing here to update figure size label */ XtOverrideTranslations(print_mag_text, XtParseTranslationTable(print_translations)); /* Fit Page to the right of the magnification window */ FirstArg(XtNlabel, "Fit to Page"); NextArg(XtNfromVert, image); NextArg(XtNfromHoriz, mag_spinner); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); fitpage = XtCreateManagedWidget("fitpage", commandWidgetClass, print_panel, Args, ArgCount); XtAddEventHandler(fitpage, ButtonReleaseMask, False, (XtEventHandler)fit_page, (XtPointer) NULL); /* Figure Size to the right of the fit page window */ mult = appres.INCHES? PIX_PER_INCH : PIX_PER_CM; unit = appres.INCHES? "in": "cm"; /* get the size of the figure */ compound_bound(&objects, &lx, &ly, &ux, &uy); sprintf(buf, "Fig Size: %.1f%s x %.1f%s ", (float)(ux-lx)/mult*appres.magnification/100.0,unit, (float)(uy-ly)/mult*appres.magnification/100.0,unit); FirstArg(XtNlabel, buf); NextArg(XtNfromVert, image); NextArg(XtNfromHoriz, fitpage); NextArg(XtNhorizDistance, 5); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); size_lab = XtCreateManagedWidget("size_label", labelWidgetClass, print_panel, Args, ArgCount); /* paper size */ FirstArg(XtNlabel, " Paper Size"); NextArg(XtNborderWidth, 0); NextArg(XtNfromVert, fitpage); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); beside = XtCreateManagedWidget("papersize_label", labelWidgetClass, print_panel, Args, ArgCount); FirstArg(XtNlabel, paper_sizes[appres.papersize].fname); NextArg(XtNfromHoriz, beside); NextArg(XtNfromVert, fitpage); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNresizable, True); NextArg(XtNrightBitmap, menu_arrow); /* use menu arrow for pull-down */ NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); print_papersize_panel = XtCreateManagedWidget("papersize", menuButtonWidgetClass, print_panel, Args, ArgCount); papersize_menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, print_papersize_panel, NULL, ZERO); /* make the menu items */ for (i = 0; i < XtNumber(paper_sizes); i++) { entry = XtCreateManagedWidget(paper_sizes[i].fname, smeBSBObjectClass, papersize_menu, NULL, ZERO); XtAddCallback(entry, XtNcallback, papersize_select, (XtPointer) i); } /* Orientation */ FirstArg(XtNlabel, " Orientation"); NextArg(XtNborderWidth, 0); NextArg(XtNfromVert, print_papersize_panel); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); beside = XtCreateManagedWidget("orient_label", labelWidgetClass, print_panel, Args, ArgCount); FirstArg(XtNfromHoriz, beside); NextArg(XtNfromVert, print_papersize_panel); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNleftBitmap, menu_arrow); /* use menu arrow for pull-down */ NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); print_orient_panel = XtCreateManagedWidget(orient_items[appres.landscape], menuButtonWidgetClass, print_panel, Args, ArgCount); make_pulldown_menu(orient_items, XtNumber(orient_items), -1, "", print_orient_panel, orient_select); FirstArg(XtNlabel, "Justification"); NextArg(XtNborderWidth, 0); NextArg(XtNfromHoriz, print_orient_panel); NextArg(XtNfromVert, print_papersize_panel); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); just_lab = XtCreateManagedWidget("just_label", labelWidgetClass, print_panel, Args, ArgCount); FirstArg(XtNlabel, just_items[appres.flushleft? 1 : 0]); NextArg(XtNfromHoriz, just_lab); NextArg(XtNfromVert, print_papersize_panel); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNleftBitmap, menu_arrow); /* use menu arrow for pull-down */ NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); print_just_panel = XtCreateManagedWidget("justify", menuButtonWidgetClass, print_panel, Args, ArgCount); make_pulldown_menu(just_items, XtNumber(just_items), -1, "", print_just_panel, just_select); /* multiple/single page */ FirstArg(XtNlabel, " Pages"); NextArg(XtNborderWidth, 0); NextArg(XtNfromVert, print_just_panel); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); beside = XtCreateManagedWidget("multiple_label", labelWidgetClass, print_panel, Args, ArgCount); FirstArg(XtNlabel, multiple_pages[appres.multiple? 1:0]); NextArg(XtNfromHoriz, beside); NextArg(XtNfromVert, print_just_panel); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNleftBitmap, menu_arrow); /* use menu arrow for pull-down */ NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); print_multiple_panel = XtCreateManagedWidget("multiple_pages", menuButtonWidgetClass, print_panel, Args, ArgCount); make_pulldown_menu(multiple_pages, XtNumber(multiple_pages), -1, "", print_multiple_panel, multiple_select); FirstArg(XtNlabel, overlap_pages[appres.overlap? 1:0]); NextArg(XtNfromHoriz, print_multiple_panel); NextArg(XtNfromVert, print_just_panel); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNleftBitmap, menu_arrow); /* use menu arrow for pull-down */ NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); print_overlap_panel = XtCreateManagedWidget("overlap_pages", menuButtonWidgetClass, print_panel, Args, ArgCount); make_pulldown_menu(overlap_pages, XtNumber(overlap_pages), -1, "", print_overlap_panel, overlap_select); /* background color */ FirstArg(XtNlabel, "Background"); NextArg(XtNfromHoriz, print_overlap_panel); NextArg(XtNfromVert, print_just_panel); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); beside = XtCreateManagedWidget("background_label", labelWidgetClass, print_panel, Args, ArgCount); FirstArg(XtNfromHoriz, beside); NextArg(XtNfromVert, print_just_panel); NextArg(XtNresize, False); NextArg(XtNwidth, 80); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); print_background_panel = XtCreateManagedWidget("background", menuButtonWidgetClass, print_panel, Args, ArgCount); /* now set the color and name in the background button */ set_but_col(print_background_panel, export_background_color); /* make color menu */ background_menu = make_color_popup_menu(print_background_panel, "Background Color", background_select, NO_TRANSP, INCL_BACKG); /* grid options */ FirstArg(XtNlabel, " Grid"); NextArg(XtNfromVert, print_background_panel); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); beside = XtCreateManagedWidget("grid_label", labelWidgetClass, print_panel, Args, ArgCount); below = make_grid_options(print_panel, print_background_panel, beside, minor_grid, major_grid, &print_grid_minor_menu_button, &print_grid_major_menu_button, &print_grid_minor_menu, &print_grid_major_menu, &print_grid_minor_text, &print_grid_major_text, &print_grid_unit_label, print_grid_major_select, print_grid_minor_select); /* printer name */ FirstArg(XtNlabel, " Printer"); NextArg(XtNfromVert, below); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); beside = XtCreateManagedWidget("printer_label", labelWidgetClass, print_panel, Args, ArgCount); /* * don't SetValue the XtNstring so the user may specify the default * printer in a resource, e.g.: *printer*string: at6 */ FirstArg(XtNwidth, 200); NextArg(XtNleftMargin, 4); NextArg(XtNfromVert, below); NextArg(XtNfromHoriz, beside); NextArg(XtNeditType, XawtextEdit); NextArg(XtNinsertPosition, 0); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); printer_text = XtCreateManagedWidget("printer", asciiTextWidgetClass, print_panel, Args, ArgCount); XtOverrideTranslations(printer_text, XtParseTranslationTable(print_translations)); /* put the printer name in the label if resource isn't set */ FirstArg(XtNstring, &printer_val); GetValues(printer_text); /* no printer name specified in resources, get PRINTER environment var and put it into the widget */ if (emptyname(printer_val)) { printer_val=getenv("PRINTER"); if ((printer_val!=NULL) && strchr(printer_val,'\\')) { buf[0]='\0'; len=0; for (i=0; i<strlen(printer_val); i++) { buf[len++] = printer_val[i]; if (printer_val[i]=='\\') buf[len++]='\\'; } buf[len++]='\0'; printer_val = buf; } if (printer_val == NULL) { printer_val = ""; } else { FirstArg(XtNstring, printer_val); SetValues(printer_text); } } /* parse /etc/printcap for printernames for the pull-down menu */ numprinters = parse_printcap(printer_names); /* find longest name */ maxl = 0; for (i=0; i<numprinters; i++) { len=strlen(printer_names[i]); if (len > maxl) { maxl = len; } } /* make string of blanks the length of the longest printer name */ buf[0] = '\0'; for (i=0; i<maxl; i++) strcat(buf," "); if (numprinters > 0) { FirstArg(XtNlabel, buf); NextArg(XtNfromHoriz, printer_text); NextArg(XtNfromVert, below); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNleftBitmap, menu_arrow); /* use menu arrow for pull-down */ NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); printer_menu_button = XtCreateManagedWidget("printer_names", menuButtonWidgetClass, print_panel, Args, ArgCount); make_pulldown_menu(printer_names, numprinters, -1, "", printer_menu_button, printer_select); } FirstArg(XtNlabel, "Print Job Params"); NextArg(XtNfromVert, printer_text); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); beside = XtCreateManagedWidget("job_params_label", labelWidgetClass, print_panel, Args, ArgCount); /* * don't SetValue the XtNstring so the user may specify the default * job parameters in a resource, e.g.: *param*string: -K2 */ FirstArg(XtNwidth, 200); NextArg(XtNfromVert, printer_text); NextArg(XtNfromHoriz, beside); NextArg(XtNeditType, XawtextEdit); NextArg(XtNinsertPosition, 0); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); param_text = XtCreateManagedWidget("job_params", asciiTextWidgetClass, print_panel, Args, ArgCount); XtOverrideTranslations(param_text, XtParseTranslationTable(print_translations)); FirstArg(XtNlabel, "Figures in batch"); NextArg(XtNfromVert, param_text); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); beside = XtCreateManagedWidget("num_batch_label", labelWidgetClass, print_panel, Args, ArgCount); FirstArg(XtNwidth, 30); NextArg(XtNlabel, " 0"); NextArg(XtNfromVert, param_text); NextArg(XtNfromHoriz, beside); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); num_batch = XtCreateManagedWidget("num_batch", labelWidgetClass, print_panel, Args, ArgCount); FirstArg(XtNlabel, "Dismiss"); NextArg(XtNfromVert, num_batch); NextArg(XtNvertDistance, 10); NextArg(XtNhorizDistance, 6); NextArg(XtNheight, 35); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); dismiss = XtCreateManagedWidget("dismiss", commandWidgetClass, print_panel, Args, ArgCount); XtAddEventHandler(dismiss, ButtonReleaseMask, False, (XtEventHandler)print_panel_dismiss, (XtPointer) NULL); /* radio for printing all layers */ beside = make_layer_choice("Print all layers ", "Print only active", print_panel, num_batch, dismiss, 6, 6); /* print buttons */ FirstArg(XtNlabel, "Print FIGURE\nto Printer"); NextArg(XtNfromVert, num_batch); NextArg(XtNfromHoriz, beside); NextArg(XtNresize, False); /* must not allow resize because the label changes */ NextArg(XtNheight, 35); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNvertDistance, 10); NextArg(XtNhorizDistance, 6); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); print = XtCreateManagedWidget("print", commandWidgetClass, print_panel, Args, ArgCount); XtAddEventHandler(print, ButtonReleaseMask, False, (XtEventHandler)do_print, (XtPointer) NULL); FirstArg(XtNlabel, "Print FIGURE\nto Batch"); NextArg(XtNfromVert, num_batch); NextArg(XtNfromHoriz, print); NextArg(XtNheight, 35); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNvertDistance, 10); NextArg(XtNhorizDistance, 6); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); print_batch = XtCreateManagedWidget("print_batch", commandWidgetClass, print_panel, Args, ArgCount); XtAddEventHandler(print_batch, ButtonReleaseMask, False, (XtEventHandler)do_print_batch, (XtPointer) NULL); FirstArg(XtNlabel, "Clear\nBatch"); NextArg(XtNfromVert, num_batch); NextArg(XtNfromHoriz, print_batch); NextArg(XtNheight, 35); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNvertDistance, 10); NextArg(XtNhorizDistance, 6); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); clear_batch = XtCreateManagedWidget("clear_batch", commandWidgetClass, print_panel, Args, ArgCount); XtAddEventHandler(clear_batch, ButtonReleaseMask, False, (XtEventHandler)do_clear_batch, (XtPointer) NULL); /* install accelerators for the following functions */ XtInstallAccelerators(print_panel, dismiss); XtInstallAccelerators(print_panel, print_batch); XtInstallAccelerators(print_panel, clear_batch); XtInstallAccelerators(print_panel, print); update_batch_count(); /* if multiple pages is on, desensitive justification panels */ if (appres.multiple) { XtSetSensitive(just_lab, False); XtSetSensitive(print_just_panel, False); if (export_just_panel) { XtSetSensitive(just_lab, False); XtSetSensitive(export_just_panel, False); } } else { XtSetSensitive(just_lab, True); XtSetSensitive(print_just_panel, True); if (export_just_panel) { XtSetSensitive(just_lab, True); XtSetSensitive(export_just_panel, True); } } }
void popup_spell_check_panel(char **list, int nitems) { static Boolean actions_added = False; Widget form, dismiss_button, below, label; int x_val, y_val; /* if panel already exists, just replace the list of words */ if (spell_check_panel != None) { XawListChange(word_list, list, nitems, 0, False); } else { /* must create it */ get_pointer_root_xy(&x_val, &y_val); FirstArg(XtNx, (Position) x_val); NextArg(XtNy, (Position) y_val); NextArg(XtNcolormap, tool_cm); NextArg(XtNtitle, "Xfig: Misspelled words"); spell_check_panel = XtCreatePopupShell("spell_check_panel", transientShellWidgetClass, tool, Args, ArgCount); XtOverrideTranslations(spell_check_panel, XtParseTranslationTable(spell_panel_translations)); if (!actions_added) { XtAppAddActions(tool_app, spell_actions, XtNumber(spell_actions)); actions_added = True; } form = XtCreateManagedWidget("form", formWidgetClass, spell_check_panel, NULL, ZERO); /* make a label to report either "No misspelled words" or "Misspelled words:" */ FirstArg(XtNlabel, "Spell checker"); NextArg(XtNjustify, XtJustifyLeft); NextArg(XtNwidth, 375); NextArg(XtNheight, 20); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); spell_msg_win = XtCreateManagedWidget("spell_msg_win", labelWidgetClass, form, Args, ArgCount); /* labels for list and correct word entry */ FirstArg(XtNlabel, "Misspelled words "); NextArg(XtNfromVert, spell_msg_win); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); label = XtCreateManagedWidget("misspelled_label", labelWidgetClass, form, Args, ArgCount); below = label; FirstArg(XtNlabel, "Correction"); NextArg(XtNfromVert, spell_msg_win); NextArg(XtNfromHoriz, label); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); label = XtCreateManagedWidget("correction_label", labelWidgetClass, form, Args, ArgCount); /* make a viewport to hold the list widget containing the misspelled words */ FirstArg(XtNallowVert, True); NextArg(XtNfromVert, below); NextArg(XtNvertDistance, 1); NextArg(XtNwidth, 150); NextArg(XtNheight, 200); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); spell_viewport = XtCreateManagedWidget("spellvport", viewportWidgetClass, form, Args, ArgCount); /* now make the list widget */ FirstArg(XtNlist, list); NextArg(XtNnumberStrings, nitems); NextArg(XtNforceColumns, True); /* force to one column */ NextArg(XtNdefaultColumns, 1); /* ditto */ NextArg(XtNwidth, 150); NextArg(XtNheight, 200); word_list = XtCreateManagedWidget("word_list", figListWidgetClass, spell_viewport, Args, ArgCount); XtAddCallback(word_list, XtNcallback, spell_select_word, (XtPointer) NULL); /* now an ascii widget to put the correct word into */ FirstArg(XtNeditType, XawtextRead); /* make uneditable until user selects a misspelled word */ NextArg(XtNsensitive, False); /* start insensitive */ NextArg(XtNfromVert, below); NextArg(XtNvertDistance, 1); NextArg(XtNfromHoriz, spell_viewport); /* to the right of the viewport */ NextArg(XtNwidth, 150); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); correct_word = XtCreateManagedWidget("correct_word", asciiTextWidgetClass, form, Args, ArgCount); /* "Return" corrects word */ XtOverrideTranslations(correct_word, XtParseTranslationTable(spell_text_translations)); /* focus keyboard on text widget */ XtSetKeyboardFocus(form, correct_word); /* now "Correct" button to the right */ FirstArg(XtNlabel, "Correct"); NextArg(XtNsensitive, False); /* start insensitive */ NextArg(XtNfromVert, below); NextArg(XtNvertDistance, 1); NextArg(XtNfromHoriz, correct_word); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); correct_button = XtCreateManagedWidget("correct", commandWidgetClass, form, Args, ArgCount); XtAddCallback(correct_button, XtNcallback, (XtCallbackProc) spell_correct_word, (XtPointer) NULL); /* make a re-check spelling button at bottom of whole panel */ FirstArg(XtNlabel, "Recheck"); NextArg(XtNfromVert, spell_viewport); NextArg(XtNsensitive, False); /* insensitive to start */ NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); recheck_button = XtCreateManagedWidget("recheck", commandWidgetClass, form, Args, ArgCount); XtAddCallback(recheck_button, XtNcallback, (XtCallbackProc) spell_check, (XtPointer) NULL); /* make dismiss button to the right of the recheck button */ FirstArg(XtNlabel, "Dismiss"); NextArg(XtNfromVert, spell_viewport); NextArg(XtNfromHoriz, recheck_button); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); dismiss_button = XtCreateManagedWidget("dismiss", commandWidgetClass, form, Args, ArgCount); XtAddCallback(dismiss_button, XtNcallback, (XtCallbackProc) spell_panel_dismiss, (XtPointer) NULL); /* install accelerators for the dismiss function */ XtInstallAccelerators(form, dismiss_button); XtInstallAccelerators(word_list, dismiss_button); } XtPopup(spell_check_panel, XtGrabExclusive); /* if the file message window is up add it to the grab */ file_msg_add_grab(); XSetWMProtocols(tool_d, XtWindow(spell_check_panel), &wm_delete_window, 1); set_cmap(XtWindow(spell_check_panel)); }
static Object P_Install_Accelerators (Object dst, Object src) { Check_Widget (dst); Check_Widget (src); XtInstallAccelerators (WIDGET(dst)->widget, WIDGET(src)->widget); return Void; }
void create_browse_panel(Widget w) { Widget file, beside, below; XFontStruct *temp_font; static Boolean actions_added=False; XtTranslateCoords(w, (Position) 0, (Position) 0, &xposn, &yposn); FirstArg(XtNx, xposn); NextArg(XtNy, yposn + 50); NextArg(XtNtitle, "Xfig: Browse files for picture import"); browse_popup = XtCreatePopupShell("xfig_browse_menu", transientShellWidgetClass, tool, Args, ArgCount); XtOverrideTranslations(browse_popup, XtParseTranslationTable(file_translations)); browse_panel = XtCreateManagedWidget("browse_panel", formWidgetClass, browse_popup, NULL, ZERO); FirstArg(XtNlabel, " Filename"); NextArg(XtNvertDistance, 15); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); file = XtCreateManagedWidget("file_label", labelWidgetClass, browse_panel, Args, ArgCount); FirstArg(XtNfont, &temp_font); GetValues(file); FirstArg(XtNwidth, 250); NextArg(XtNheight, max_char_height(temp_font) * 2 + 4); NextArg(XtNeditType, "edit"); NextArg(XtNstring, browse_filename); NextArg(XtNinsertPosition, strlen(browse_filename)); NextArg(XtNfromHoriz, file); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNvertDistance, 15); NextArg(XtNfromVert, cfile_lab); NextArg(XtNscrollHorizontal, XawtextScrollWhenNeeded); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); browse_selfile = XtCreateManagedWidget("file_name", asciiTextWidgetClass, browse_panel, Args, ArgCount); XtOverrideTranslations(browse_selfile, XtParseTranslationTable(text_translations)); if (!actions_added) { XtAppAddActions(tool_app, file_actions, XtNumber(file_actions)); actions_added = True; /* add action to apply file */ XtAppAddActions(tool_app, file_name_actions, XtNumber(file_name_actions)); } create_dirinfo(False, browse_panel, browse_selfile, &beside, &below, &browse_mask, &browse_dir, &browse_flist, &browse_dlist, E_FILE_WIDTH, False); /* make <return> in the filename window apply the file */ XtOverrideTranslations(browse_selfile, XtParseTranslationTable(file_name_translations)); /* make <return> and a double click in the file list window apply the file and close */ XtAugmentTranslations(browse_flist, XtParseTranslationTable(file_list_translations)); FirstArg(XtNlabel, " Close "); NextArg(XtNvertDistance, 15); NextArg(XtNhorizDistance, 25); NextArg(XtNheight, 25); NextArg(XtNfromHoriz, beside); NextArg(XtNfromVert, below); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); closebtn = XtCreateManagedWidget("close", commandWidgetClass, browse_panel, Args, ArgCount); XtAddEventHandler(closebtn, ButtonReleaseMask, False, (XtEventHandler)browse_panel_close, (XtPointer) NULL); FirstArg(XtNlabel, " Apply "); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNfromHoriz, closebtn); NextArg(XtNfromVert, below); NextArg(XtNvertDistance, 15); NextArg(XtNhorizDistance, 25); NextArg(XtNheight, 25); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); apply = XtCreateManagedWidget("apply", commandWidgetClass, browse_panel, Args, ArgCount); XtAddEventHandler(apply, ButtonReleaseMask, False, (XtEventHandler)got_browse, (XtPointer) NULL); XtInstallAccelerators(browse_panel, closebtn); XtInstallAccelerators(browse_panel, apply); }
void create_dirinfo(Boolean file_exp, Widget parent, Widget below, Widget *ret_beside, Widget *ret_below, Widget *mask_w, Widget *dir_w, Widget *flist_w, Widget *dlist_w, int file_width, Boolean file_panel) { Widget w,dir_alt,home; Widget file_viewport; Widget dir_viewport; XFontStruct *temp_font; int char_ht,char_wd; char *dir; dir_entry_cnt = NENTRIES; file_entry_cnt = NENTRIES; filelist = (char **) calloc(file_entry_cnt, sizeof(char *)); dirlist = (char **) calloc(dir_entry_cnt, sizeof(char *)); if (browse_up) { get_directory(cur_browse_dir); dir = cur_browse_dir; } else if (export_up) { get_directory(cur_export_dir); dir = cur_export_dir; } else { get_directory(cur_file_dir); dir = cur_file_dir; } if (file_up) { FirstArg(XtNlabel, "Fig files"); } else { FirstArg(XtNlabel, " Existing"); } NextArg(XtNfromVert, below); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); w = XtCreateManagedWidget("file_alt_label", labelWidgetClass, parent, Args, ArgCount); FirstArg(XtNfont, &temp_font); GetValues(w); char_ht = max_char_height(temp_font) + 2; char_wd = char_width(temp_font) + 2; /* make a viewport to hold the list widget of filenames */ FirstArg(XtNallowVert, True); if (file_up) { /* for the file panel, put the viewport below the Alternatives label */ NextArg(XtNfromVert, w); NextArg(XtNheight, char_ht * 15); /* show first 15 filenames */ } else { /* for the export or browse panel, put the viewport beside the Alternatives label */ NextArg(XtNfromVert, below); NextArg(XtNfromHoriz, w); if (browse_up) { NextArg(XtNheight, char_ht * 10); /* show 10 lines for existing browse files */ } else { NextArg(XtNheight, char_ht * 4); /* show 4 lines for existing export files */ } } NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNwidth, file_width); NextArg(XtNtop, XtChainTop); /* chain so the viewport resizes fully */ NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); file_viewport = XtCreateManagedWidget("vport", viewportWidgetClass, parent, Args, ArgCount); /* label for filename mask */ FirstArg(XtNlabel, "Filename Mask"); NextArg(XtNborderWidth, 0); NextArg(XtNfromVert, file_viewport); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); w = XtCreateManagedWidget("mask_label", labelWidgetClass, parent, Args, ArgCount); /* text widget for the filename mask */ FirstArg(XtNeditType, XawtextEdit); NextArg(XtNleftMargin, 4); NextArg(XtNheight, char_ht * 2); NextArg(XtNscrollHorizontal, XawtextScrollWhenNeeded); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNwidth, file_panel? F_FILE_WIDTH: E_FILE_WIDTH); NextArg(XtNfromHoriz, w); NextArg(XtNfromVert, file_viewport); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); *mask_w = XtCreateManagedWidget("mask", asciiTextWidgetClass, parent, Args, ArgCount); XtOverrideTranslations(*mask_w, XtParseTranslationTable(mask_text_translations)); /* get the first directory listing */ FirstArg(XtNstring, &dirmask); GetValues(*mask_w); if (MakeFileList(dir, dirmask, &dir_list, &file_list) == False) file_msg("No files in directory?"); FirstArg(XtNlabel, " Current Dir"); NextArg(XtNborderWidth, 0); NextArg(XtNfromVert, *mask_w); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); w = XtCreateManagedWidget("dir_label", labelWidgetClass, parent, Args, ArgCount); FirstArg(XtNstring, dir); NextArg(XtNleftMargin, 4); NextArg(XtNinsertPosition, strlen(dir)); NextArg(XtNheight, char_ht * 2); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNscrollHorizontal, XawtextScrollWhenNeeded); NextArg(XtNeditType, XawtextEdit); NextArg(XtNfromVert, *mask_w); NextArg(XtNfromHoriz, w); NextArg(XtNwidth, file_panel? F_FILE_WIDTH: E_FILE_WIDTH); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); *dir_w = XtCreateManagedWidget("dir_name", asciiTextWidgetClass, parent, Args, ArgCount); XtOverrideTranslations(*dir_w, XtParseTranslationTable(dir_translations)); /* directory alternatives */ FirstArg(XtNlabel, " Directories"); NextArg(XtNborderWidth, 0); NextArg(XtNfromVert, *dir_w); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); dir_alt = XtCreateManagedWidget("dir_alt_label", labelWidgetClass, parent, Args, ArgCount); /* put a Home button to the left of the list of directories */ FirstArg(XtNlabel, "Home"); NextArg(XtNfromVert, dir_alt); NextArg(XtNfromHoriz, dir_alt); NextArg(XtNhorizDistance, -(char_wd * 5)); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); home = XtCreateManagedWidget("home", commandWidgetClass, parent, Args, ArgCount); XtAddCallback(home, XtNcallback, GoHome, (XtPointer) NULL); /* put a button for showing/hiding hidden files below the Home button */ FirstArg(XtNlabel, show_hidden? "Hide Hidden": "Show Hidden"); NextArg(XtNfromVert, home); NextArg(XtNfromHoriz, dir_alt); NextArg(XtNhorizDistance, (int) -(char_wd * 10.5)); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); hidden = XtCreateManagedWidget("hidden", commandWidgetClass, parent, Args, ArgCount); XtAddCallback(hidden, XtNcallback, ShowHidden, (XtPointer) NULL); FirstArg(XtNallowVert, True); NextArg(XtNforceBars, True); NextArg(XtNfromHoriz, dir_alt); NextArg(XtNfromVert, *dir_w); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNwidth, file_panel? F_FILE_WIDTH: E_FILE_WIDTH); NextArg(XtNheight, char_ht * 5); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainRight); dir_viewport = XtCreateManagedWidget("dirvport", viewportWidgetClass, parent, Args, ArgCount); FirstArg(XtNlist, file_list); /* for file panel use only one column */ if (file_panel) { NextArg(XtNdefaultColumns, 1); NextArg(XtNforceColumns, True); } *flist_w = XtCreateManagedWidget("file_list_panel", figListWidgetClass, file_viewport, Args, ArgCount); XtAddCallback(*flist_w, XtNcallback, FileSelected, (XtPointer) NULL); XtOverrideTranslations(*flist_w, XtParseTranslationTable(list_panel_translations)); FirstArg(XtNlist, dir_list); *dlist_w = XtCreateManagedWidget("dir_list_panel", figListWidgetClass, dir_viewport, Args, ArgCount); XtOverrideTranslations(*dlist_w, XtParseTranslationTable(list_panel_translations)); XtAddCallback(*dlist_w, XtNcallback, DirSelected, (XtPointer) NULL); if (!actions_added) { XtAppAddActions(tool_app, actionTable, XtNumber(actionTable)); actions_added = True; } FirstArg(XtNlabel, "Rescan"); NextArg(XtNfromVert, dir_viewport); NextArg(XtNvertDistance, 15); NextArg(XtNborderWidth, INTERNAL_BW); NextArg(XtNhorizDistance, 45); NextArg(XtNheight, 25); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); w = XtCreateManagedWidget("rescan", commandWidgetClass, parent, Args, ArgCount); XtAddCallback(w, XtNcallback, CallbackRescan, (XtPointer) NULL); /* install accelerators so they can be used from each window */ XtInstallAccelerators(parent, w); XtInstallAccelerators(*flist_w, parent); XtInstallAccelerators(*dlist_w, parent); *ret_beside = w; *ret_below = dir_viewport; return; }