void popup_print_panel(Widget w) { char buf[30]; /* turn off Compose key LED */ setCompLED(0); set_temp_cursor(wait_cursor); if (print_popup) { /* the print popup already exists, but the magnification may have been changed in the export popup */ sprintf(buf,"%.1f",appres.magnification); FirstArg(XtNstring, buf); SetValues(print_mag_text); /* also the figure size (magnification * bounding_box) */ print_update_figure_size(); /* now set the color and name in the background button */ set_but_col(print_background_panel, export_background_color); /* and the background color menu */ XtDestroyWidget(background_menu); background_menu = make_color_popup_menu(print_background_panel, "Background Color", background_select, NO_TRANSP, INCL_BACKG); } else { create_print_panel(w); } XtPopup(print_popup, XtGrabNone); /* now that the popup is realized, put in the name of the first printer */ if (printer_names[0] != NULL) { FirstArg(XtNlabel, printer_names[0]); SetValues(printer_menu_button); } /* insure that the most recent colormap is installed */ set_cmap(XtWindow(print_popup)); (void) XSetWMProtocols(tool_d, XtWindow(print_popup), &wm_delete_window, 1); reset_cursor(); }
static void get_magnif(void) { char buf[60]; appres.magnification = (float) atof(panel_get_value(print_mag_text)); if (appres.magnification <= 0.0) appres.magnification = 100.0; /* write it back to the widget in case it had a bad value */ sprintf(buf,"%.1f",appres.magnification); FirstArg(XtNstring, buf); SetValues(print_mag_text); }
void print_grid_major_select(Widget w, XtPointer new_grid_choice, XtPointer garbage) { char *val; grid_major = (int) new_grid_choice; /* put selected grid value in the text area */ /* first get rid of any "mm" following the value */ val = strtok(strdup(grid_choices[grid_major]), " "); FirstArg(XtNstring, val); SetValues(print_grid_major_text); free(val); }
static XtCallbackProc switch_print_layers(Widget w, XtPointer closure, XtPointer call_data) { Boolean state; int which; /* check state of the toggle and set/remove checkmark */ FirstArg(XtNstate, &state); GetValues(w); if (state ) { FirstArg(XtNbitmap, sm_check_pm); } else { FirstArg(XtNbitmap, sm_null_check_pm); } SetValues(w); /* set the sensitivity of the toggle button to the opposite of its state so that the user must press the other one now */ XtSetSensitive(w, !state); /* and make the *other* button the opposite state */ if (w == printalltoggle) { XtSetSensitive(printactivetoggle, state); } else { XtSetSensitive(printalltoggle, state); } /* which button */ which = (int) XawToggleGetCurrent(w); if (which == 0) /* no buttons on, in transition so return now */ return; if (which == 2) /* "blank" button, invert state */ state = !state; /* set global state */ print_all_layers = state; update_figure_size(); return; }
static void show_spell_msg(char *format,...) { va_list ap; static char tmpstr[300]; va_start(ap, format); vsprintf(tmpstr, format, ap ); va_end(ap); FirstArg(XtNlabel, tmpstr); SetValues(spell_msg_win); }
static void update_figure_size(void) { char buf[60]; print_update_figure_size(); /* update the export panel's indicators too */ if (export_popup) { export_update_figure_size(); sprintf(buf,"%.1f",appres.magnification); FirstArg(XtNstring, buf); SetValues(export_mag_text); } }
static void papersize_select(Widget w, XtPointer new_papersize, XtPointer garbage) { int papersize = (int) new_papersize; FirstArg(XtNlabel, paper_sizes[papersize].fname); SetValues(print_papersize_panel); /* change export papersize if it exists */ if (export_papersize_panel) SetValues(export_papersize_panel); appres.papersize = papersize; /* update the red line showing the new page size */ update_pageborder(); }
static void background_select(Widget w, XtPointer closure, XtPointer call_data) { Pixel bgcolor, fgcolor; /* get the colors from the color button just pressed */ FirstArg(XtNbackground, &bgcolor); NextArg(XtNforeground, &fgcolor); GetValues(w); /* get the colorname from the color button and put it and the colors in the menu button */ FirstArg(XtNlabel, XtName(w)); NextArg(XtNbackground, bgcolor); NextArg(XtNforeground, fgcolor); SetValues(print_background_panel); /* update the export panel too if it exists */ if (export_background_panel) SetValues(export_background_panel); export_background_color = (int)closure; XtPopdown(background_menu); }
static void spell_select_word(Widget widget, XtPointer closure, XtPointer call_data) { XawListReturnStruct *ret_struct = (XawListReturnStruct *) call_data; /* make correct button and correction entry sensitive */ XtSetSensitive(correct_button, True); XtSetSensitive(correct_word, True); /* save the selected word */ strcpy(selected_word, ret_struct->string); /* copy the word to the correct_word ascii widget */ FirstArg(XtNstring, ret_struct->string); NextArg(XtNeditType, XawtextEdit); /* make editable now */ NextArg(XtNsensitive, True); /* and sensitive */ SetValues(correct_word); }
static void fit_page(void) { int lx,ly,ux,uy; float wd,ht,pwd,pht; char buf[60]; /* get current size of figure */ compound_bound(&objects, &lx, &ly, &ux, &uy); wd = ux-lx; ht = uy-ly; /* if there is no figure, return now */ if (wd == 0 || ht == 0) return; /* get paper size minus a half inch margin all around */ pwd = paper_sizes[appres.papersize].width - PIX_PER_INCH; pht = paper_sizes[appres.papersize].height - PIX_PER_INCH; /* swap height and width if landscape */ if (appres.landscape) { ux = pwd; pwd = pht; pht = ux; } /* make magnification lesser of ratio of: page height / figure height or page width/figure width */ if (pwd/wd < pht/ht) appres.magnification = 100.0*pwd/wd; else appres.magnification = 100.0*pht/ht; /* adjust for difference in real metric vs "xfig metric" */ if(!appres.INCHES) appres.magnification *= PIX_PER_CM * 2.54/PIX_PER_INCH; /* update the magnification widget */ sprintf(buf,"%.1f",appres.magnification); FirstArg(XtNstring, buf); SetValues(print_mag_text); /* and figure size */ update_figure_size(); }
void print_update_figure_size(void) { float mult; char *unit; char buf[40]; int ux,uy,lx,ly; if (!print_popup) return; mult = appres.INCHES? PIX_PER_INCH : PIX_PER_CM; unit = appres.INCHES? "in": "cm"; active_compound_bound(&objects, &lx, &ly, &ux, &uy, bound_active_layers && !print_all_layers); 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); SetValues(size_lab); }
void Rescan(Widget widget, XEvent *event, String *params, Cardinal *num_params) { char *dir; /* * get the mask string from the File or Export mask widget and put in * dirmask */ if (browse_up) { FirstArg(XtNstring, &dirmask); GetValues(browse_mask); FirstArg(XtNstring, &dir); GetValues(browse_dir); if (change_directory(dir)) /* make sure we are there */ return; strcpy(cur_browse_dir,dir); /* save in global var */ (void) MakeFileList(dir, dirmask, &dir_list, &file_list); NewList(browse_flist, file_list); NewList(browse_dlist, dir_list); } else if (file_up) { FirstArg(XtNstring, &dirmask); GetValues(file_mask); FirstArg(XtNstring, &dir); GetValues(file_dir); if (change_directory(dir)) /* make sure we are there */ return; strcpy(cur_file_dir,dir); /* save in global var */ strcpy(cur_export_dir,dir); /* set export directory to file directory */ (void) MakeFileList(dir, dirmask, &dir_list, &file_list); NewList(file_flist,file_list); NewList(file_dlist,dir_list); } else if (export_up) { FirstArg(XtNstring, &dirmask); GetValues(exp_mask); FirstArg(XtNstring, &dir); GetValues(exp_dir); if (change_directory(dir)) /* make sure we are there */ return; strcpy(cur_export_dir,dir); /* save in global var */ (void) MakeFileList(dir, dirmask, &dir_list, &file_list); NewList(exp_flist, file_list); NewList(exp_dlist, dir_list); } }
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)); }
void setup_fontmenu(void) { register int i; DeclareArgs(2); Pixel bg, fg; /* get the foreground/background of the widget */ FirstArg(XtNforeground, &fg); NextArg(XtNbackground, &bg); GetValues(ps_fontpane[0]); /* Create the bitmaps */ #ifdef I18N if (appres.international) { char *lang; lang = appres.font_menu_language; if (lang[0] == '\0') lang = setlocale(LC_CTYPE, NULL); if (strncasecmp(lang, "japanese", 2) == 0) { extern unsigned char Japanese_Times_Roman_bits[], Japanese_Roman_bits[]; extern unsigned char Japanese_Times_Bold_bits[], Japanese_Bold_bits[]; psfont_menu_bits[1] = Japanese_Times_Roman_bits; latexfont_menu_bits[1] = Japanese_Roman_bits; psfont_menu_bits[3] = Japanese_Times_Bold_bits; latexfont_menu_bits[2] = Japanese_Bold_bits; } else if (strncasecmp(lang, "korean", 2) == 0) { extern unsigned char Korean_Times_Roman_bits[], Korean_Roman_bits[]; extern unsigned char Korean_Times_Bold_bits[], Korean_Bold_bits[]; psfont_menu_bits[1] = Korean_Times_Roman_bits; latexfont_menu_bits[1] = Korean_Roman_bits; psfont_menu_bits[3] = Korean_Times_Bold_bits; latexfont_menu_bits[2] = Korean_Bold_bits; } } #endif /* I18N */ for (i = 0; i < NUM_FONTS + 1; i++) psfont_menu_bitmaps[i] = XCreatePixmapFromBitmapData(tool_d, XtWindow(ind_panel), (char *) psfont_menu_bits[i], PS_FONTPANE_WD, PS_FONTPANE_HT, fg, bg, tool_dpth); for (i = 0; i < NUM_LATEX_FONTS; i++) latexfont_menu_bitmaps[i] = XCreatePixmapFromBitmapData(tool_d, XtWindow(ind_panel), (char *) latexfont_menu_bits[i], LATEX_FONTPANE_WD, LATEX_FONTPANE_HT, fg, bg, tool_dpth); /* Store the bitmaps in the menu panes */ for (i = 0; i < NUM_FONTS + 1; i++) { FirstArg(XtNbitmap, psfont_menu_bitmaps[i]); SetValues(ps_fontpane[i]); } for (i = 0; i < NUM_LATEX_FONTS; i++) { FirstArg(XtNbitmap, latexfont_menu_bitmaps[i]); SetValues(latex_fontpane[i]); } XtRealizeWidget(ps_fontmenu); XtRealizeWidget(latex_fontmenu); /* at this point the windows are realized but not drawn */ XDefineCursor(tool_d, XtWindow(ps_fontpanes), arrow_cursor); XDefineCursor(tool_d, XtWindow(latex_fontpanes), arrow_cursor); }
Widget make_layer_choice(char *label_all, char *label_active, Widget parent, Widget below, Widget beside, int hdist, int vdist) { Widget form; FirstArg(XtNborderWidth, 0); NextArg(XtNfromVert, below); NextArg(XtNvertDistance, vdist); NextArg(XtNfromHoriz, beside); NextArg(XtNhorizDistance, hdist); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); form = XtCreateManagedWidget("layer_choice_form", formWidgetClass, parent, Args, ArgCount); FirstArg(XtNbitmap, (print_all_layers? sm_check_pm : sm_null_check_pm)); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); NextArg(XtNinternalWidth, 1); NextArg(XtNinternalHeight, 1); NextArg(XtNlabel, " "); NextArg(XtNsensitive, (print_all_layers? False : True)); /* make opposite button sens */ NextArg(XtNstate, print_all_layers); /* initial state */ NextArg(XtNradioData, 1); /* when this is pressed the value is 1 */ printalltoggle = XtCreateManagedWidget("printalltoggle", toggleWidgetClass, form, Args, ArgCount); XtAddCallback(printalltoggle, XtNcallback, (XtCallbackProc) switch_print_layers, (XtPointer) NULL); /* label - " XXXX all layers" */ FirstArg(XtNlabel, label_all); NextArg(XtNborderWidth, 0); NextArg(XtNfromHoriz, printalltoggle); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); below = XtCreateManagedWidget("print_all_layers", labelWidgetClass, form, Args, ArgCount); /* radio for printing only active layers */ FirstArg(XtNbitmap, (print_all_layers? sm_null_check_pm : sm_check_pm)); NextArg(XtNfromVert, printalltoggle); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); NextArg(XtNinternalWidth, 1); NextArg(XtNinternalHeight, 1); NextArg(XtNlabel, " "); NextArg(XtNsensitive, (print_all_layers? True : False)); /* make opposite button sens */ NextArg(XtNstate, !print_all_layers); /* initial state */ NextArg(XtNradioData, 2); /* when this is pressed the value is 2 */ NextArg(XtNradioGroup, printalltoggle); /* this is the other radio button in the group */ printactivetoggle = XtCreateManagedWidget("printactivetoggle", toggleWidgetClass, form, Args, ArgCount); XtAddCallback(printactivetoggle, XtNcallback, (XtCallbackProc) switch_print_layers, (XtPointer) NULL); /* label - "XXXX only active" */ FirstArg(XtNlabel, label_active); NextArg(XtNborderWidth, 0); NextArg(XtNfromVert, printalltoggle); NextArg(XtNfromHoriz, printactivetoggle); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); /* make it stay on left side */ NextArg(XtNright, XtChainLeft); below = XtCreateManagedWidget("print_active_layers", labelWidgetClass, form, Args, ArgCount); /* now make checkbox to compute bounding box for whole figure or only exported part */ FirstArg(XtNbitmap, (bound_active_layers? sm_check_pm : sm_null_check_pm)); NextArg(XtNfromVert, printalltoggle); NextArg(XtNfromHoriz, below); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); NextArg(XtNinternalWidth, 1); NextArg(XtNinternalHeight, 1); NextArg(XtNlabel, " "); NextArg(XtNstate, bound_active_layers); /* initial state */ boundactivetoggle = XtCreateManagedWidget("boundactivetoggle", toggleWidgetClass, form, Args, ArgCount); XtAddCallback(boundactivetoggle, XtNcallback, (XtCallbackProc) switch_bound, (XtPointer) NULL); FirstArg(XtNlabel, "Boundary only active layers"); NextArg(XtNborderWidth, 0); NextArg(XtNfromVert, printalltoggle); NextArg(XtNfromHoriz, boundactivetoggle); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); /* make it stay on left side */ NextArg(XtNright, XtChainLeft); below = XtCreateManagedWidget("bound_active_layers", labelWidgetClass, form, Args, ArgCount); return form; }
bool FCBondage::SBTracker::HandleCommand(const char* pCommandStr) { // All custom commands start with "//" if (pCommandStr[1] != 0x2F) return false; // Get the first argument or null if no argument. auto firstArg = FirstArg(pCommandStr); // Console toggle command if (strstr(pCommandStr, "//console")) { if (firstArg == NULL) return false; if (!strcmp(firstArg,"on")) { ToggleConsole(true); std::async(std::launch::async, &FCBondage::SBTracker::SendCommand,this,"/echo Console Opened."); } else if (!strcmp(firstArg,"off")) { ToggleConsole(false); std::async(std::launch::async, &FCBondage::SBTracker::SendCommand,this,"/echo Console Closed."); } return true; } // AutoUpdate toggle command if (strstr(pCommandStr, "//autoupdate")) { if (firstArg == NULL) return false; if (!strcmp(firstArg,"on")) { AutoUpdateFlag = true; std::async(std::launch::async, &FCBondage::SBTracker::SendCommand,this,"/echo Auto Updating Values."); } else if (!strcmp(firstArg,"off")) { AutoUpdateFlag = false; std::async(std::launch::async, &FCBondage::SBTracker::SendCommand,this,"/echo Not Auto Updating Values."); } return true; } // ShowAll toggle command if (strstr(pCommandStr, "//showall")) { if (firstArg == NULL) return false; if (!strcmp(firstArg,"on")) { ShowAllFlag = true; std::async(std::launch::async, &FCBondage::SBTracker::SendCommand,this,"/echo Showing All Items."); } else if (!strcmp(firstArg,"off")) { ShowAllFlag = false; std::async(std::launch::async, &FCBondage::SBTracker::SendCommand,this,"/echo Showing Only Novus Items."); } return true; } // Invoke DisplayCurrentValues if (strstr(pCommandStr, "//showcur")) { std::async(std::launch::async, &FCBondage::SBTracker::DisplayCurrentValues,this); return true; } // Set all values to 0. if (strstr(pCommandStr, "//reset")) { std::async(std::launch::async, &FCBondage::SBTracker::ClearValues,this); std::async(std::launch::async, &FCBondage::SBTracker::SendCommand,this,"/echo Values Cleared."); return true; } // Toggle value display mode if (strstr(pCommandStr, "//rawview")) { if (firstArg == NULL) return false; if (!strcmp(firstArg,"on")) { RawView = true; std::async(std::launch::async, &FCBondage::SBTracker::SendCommand,this,"/echo Showing values as raw integers."); } else if (!strcmp(firstArg,"off")) { RawView = false; std::async(std::launch::async, &FCBondage::SBTracker::SendCommand,this,"/echo Showing values as decimals."); } return true; } // Badly formatted command. return false; }
virtual void RunTest (TestResult& result_) { CHECK_EQUAL (FirstArg(), SecondArg()); }
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 DoChangeDir(char *dir) { char *p; char ndir[PATH_MAX]; if (browse_up) { strcpy(ndir, cur_browse_dir); } else if (file_up) { strcpy(ndir, cur_file_dir); } else if (export_up) { strcpy(ndir, cur_export_dir); } if (dir != NULL && dir[0] != '/') { /* relative path, prepend current dir */ if (dir[strlen(dir) - 1] == '/') dir[strlen(dir) - 1] = '\0'; if (strcmp(dir, "..")==0) { /* Parent directory. */ if (*ndir == '\0') return; /* no current directory, */ /* can't do anything unless absolute path */ p = strrchr(ndir, '/'); *p = EOS; if (ndir[0] == EOS) strcpy(ndir, "/"); } else if (strcmp(dir, ".")!=0) { if (strcmp(ndir, "/")) /* At the root already */ strcat(ndir, "/"); strcat(ndir, dir); } } else { strcpy(ndir, dir); /* abs path copy to ndir */ } if (change_directory(ndir) != 0 ) { return; /* some problem, return */ } else if (MakeFileList(ndir, dirmask, &dirlist, &filelist) == False) { file_msg("Unable to list directory %s", ndir); return; } FirstArg(XtNstring, ndir); /* update the current directory and file/dir list widgets */ if (browse_up) { SetValues(browse_dir); strcpy(cur_browse_dir,ndir); /* update global var */ XawTextSetInsertionPoint(browse_dir, strlen(ndir)); NewList(browse_flist, filelist); NewList(browse_dlist, dirlist); } else if (file_up) { SetValues(file_dir); strcpy(cur_file_dir,ndir); /* update global var */ strcpy(cur_export_dir,ndir); /* set export directory to file directory */ XawTextSetInsertionPoint(file_dir, strlen(ndir)); NewList(file_flist,filelist); NewList(file_dlist,dirlist); } else if (export_up) { SetValues(exp_dir); strcpy(cur_export_dir,ndir); /* update global var */ XawTextSetInsertionPoint(exp_dir, strlen(ndir)); NewList(exp_flist, filelist); NewList(exp_dlist, dirlist); } CurrentSelectionName[0] = '\0'; }
void popup_search_panel(void) { static Boolean actions_added = False; Widget below = None; Widget form, label, dismiss_button; int rx,ry; /* turn off Compose key LED */ setCompLED(0); /* don't paste if in the middle of drawing/editing */ if (check_action_on()) return; /* don't make another one if one already exists */ if (search_panel) { return; } put_msg("Search & Replace"); get_pointer_root_xy(&rx, &ry); FirstArg(XtNx, (Position) rx); NextArg(XtNy, (Position) ry); NextArg(XtNcolormap, tool_cm); NextArg(XtNtitle, "Xfig: Search & Replace"); search_panel = XtCreatePopupShell("search_panel", transientShellWidgetClass, tool, Args, ArgCount); XtOverrideTranslations(search_panel, XtParseTranslationTable(search_panel_translations)); if (!actions_added) { XtAppAddActions(tool_app, search_actions, XtNumber(search_actions)); actions_added = True; } form = XtCreateManagedWidget("form", formWidgetClass, search_panel, NULL, 0) ; FirstArg(XtNlabel, " Search for:"); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); label = XtCreateManagedWidget("search_lab", labelWidgetClass, form, Args, ArgCount); FirstArg(XtNfromHoriz, label); NextArg(XtNeditType, XawtextEdit); NextArg(XtNwidth, 200); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); search_text_widget = XtCreateManagedWidget("search_text", asciiTextWidgetClass, form, Args, ArgCount); XtOverrideTranslations(search_text_widget, XtParseTranslationTable(search_text_translations)); /* search button */ FirstArg(XtNlabel, "Search "); NextArg(XtNfromHoriz, search_text_widget); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); search_button = XtCreateManagedWidget("search", commandWidgetClass, form, Args, ArgCount); XtAddCallback(search_button, XtNcallback, (XtCallbackProc) search_and_replace_text, (XtPointer) NULL); (void) CreateCheckbutton("Case sensitive", "case_sensitive", form, NULL, search_button, MANAGE, SMALL_CHK, &case_sensitive, 0, 0); below = label; FirstArg(XtNfromVert, below); NextArg(XtNvertDistance, 6); NextArg(XtNborderWidth, 0); NextArg(XtNlabel, "Replace with:"); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); replace_text_label = XtCreateManagedWidget("replace_lab", labelWidgetClass, form, Args, ArgCount); FirstArg(XtNfromVert, below); NextArg(XtNvertDistance, 6); NextArg(XtNfromHoriz, replace_text_label); NextArg(XtNeditType, XawtextEdit); NextArg(XtNwidth, 200); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); replace_text_widget = XtCreateManagedWidget("replace_text", asciiTextWidgetClass, form, Args, ArgCount); XtOverrideTranslations(replace_text_widget, XtParseTranslationTable(replace_text_translations)); FirstArg(XtNfromVert, below); NextArg(XtNfromHoriz, replace_text_widget); NextArg(XtNlabel, "Replace"); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); do_replace_button = XtCreateManagedWidget("do_replace", commandWidgetClass, form, Args, ArgCount); XtAddCallback(do_replace_button, XtNcallback, (XtCallbackProc) do_replace, (XtPointer) NULL); FirstArg(XtNfromVert, below); NextArg(XtNfromHoriz, do_replace_button); NextArg(XtNlabel, "UPDATE settings"); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); do_update_button = XtCreateManagedWidget("dismiss", commandWidgetClass, form, Args, ArgCount); XtAddCallback(do_update_button, XtNcallback, (XtCallbackProc) do_update, (XtPointer) NULL); below = replace_text_widget; /* make a label to report if no match for search */ FirstArg(XtNlabel, "Enter search string and press \"Search\""); NextArg(XtNfromVert, below); NextArg(XtNjustify, XtJustifyLeft); NextArg(XtNwidth, SEARCH_WIDTH); NextArg(XtNheight, 20); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); search_msg_win = XtCreateManagedWidget("search_msg_win", labelWidgetClass, form, Args, ArgCount); below = search_msg_win; /* make a text window to hold search results */ FirstArg(XtNwidth, SEARCH_WIDTH); NextArg(XtNfromVert, below); NextArg(XtNheight, 200); NextArg(XtNeditType, XawtextRead); NextArg(XtNdisplayCaret, False); NextArg(XtNscrollHorizontal, XawtextScrollWhenNeeded); NextArg(XtNscrollVertical, XawtextScrollAlways); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); search_results_win = XtCreateManagedWidget("search_results_win", asciiTextWidgetClass, form, Args, ArgCount); XtOverrideTranslations(search_results_win, XtParseTranslationTable(search_results_translations)); below = search_results_win; /* make a dismiss button */ FirstArg(XtNfromVert, below); NextArg(XtNlabel, "Dismiss"); 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) search_panel_dismiss, (XtPointer) NULL); /* make update/replace buttons insensitive to start */ XtSetSensitive(replace_text_label, False); XtSetSensitive(do_replace_button, False); XtSetSensitive(do_update_button, False); XtPopup(search_panel, XtGrabNone); XSetWMProtocols(tool_d, XtWindow(search_panel), &wm_delete_window, 1); set_cmap(XtWindow(search_panel)); }
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 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; }