1 /* 2 * FIG : Facility for Interactive Generation of figures 3 * Copyright (c) 1985-1988 by Supoj Sutanthavibul 4 * Parts Copyright (c) 1989-2015 by Brian V. Smith 5 * Parts Copyright (c) 1991 by Paul King 6 * Parts Copyright (c) 2016-2020 by Thomas Loimer 7 * 8 * Any party obtaining a copy of these files is granted, free of charge, a 9 * full and unrestricted irrevocable, world-wide, paid up, royalty-free, 10 * nonexclusive right and license to deal in this software and documentation 11 * files (the "Software"), including without limitation the rights to use, 12 * copy, modify, merge, publish, distribute, sublicense and/or sell copies of 13 * the Software, and to permit persons who receive copies from any such 14 * party to do so, with the only requirement being that the above copyright 15 * and this permission notice remain intact. 16 * 17 */ 18 19 #ifdef HAVE_CONFIG_H 20 #include "config.h" 21 #endif 22 #include "resources.h" 23 24 #include <sys/types.h> 25 26 #include "object.h" 27 28 29 fig_colors colorNames[] = { 30 {"Default", "NULL"}, 31 {"Black", "black"}, 32 {"Blue", "blue"}, 33 {"Green", "green"}, 34 {"Cyan", "cyan"}, 35 {"Red", "red"}, 36 {"Magenta", "magenta"}, 37 {"Yellow", "yellow"}, 38 {"White", "white"}, 39 {"Blue4", "#000090"}, /* NOTE: hex colors must be 6 digits */ 40 {"Blue3", "#0000b0"}, 41 {"Blue2", "#0000d0"}, 42 {"LtBlue", "#87ceff"}, 43 {"Green4", "#009000"}, 44 {"Green3", "#00b000"}, 45 {"Green2", "#00d000"}, 46 {"Cyan4", "#009090"}, 47 {"Cyan3", "#00b0b0"}, 48 {"Cyan2", "#00d0d0"}, 49 {"Red4", "#900000"}, 50 {"Red3", "#b00000"}, 51 {"Red2", "#d00000"}, 52 {"Magenta4", "#900090"}, 53 {"Magenta3", "#b000b0"}, 54 {"Magenta2", "#d000d0"}, 55 {"Brown4", "#803000"}, 56 {"Brown3", "#a04000"}, 57 {"Brown2", "#c06000"}, 58 {"Pink4", "#ff8080"}, 59 {"Pink3", "#ffa0a0"}, 60 {"Pink2", "#ffc0c0"}, 61 {"Pink", "#ffe0e0"}, 62 {"Gold", "gold" } 63 }; 64 65 char *short_clrNames[] = { 66 "Default", 67 "Blk", "Blu", "Grn", "Cyn", "Red", "Mag", "Yel", "Wht", 68 "Bl4", "Bl3", "Bl2", "LBl", "Gr4", "Gr3", "Gr2", 69 "Cn4", "Cn3", "Cn2", "Rd4", "Rd3", "Rd2", 70 "Mg4", "Mg3", "Mg2", "Br4", "Br3", "Br2", 71 "Pk4", "Pk3", "Pk2", "Pnk", "Gld" }; 72 73 /* current export/print background color */ 74 int export_background_color = COLOR_NONE; 75 76 /* these are allocated in main() in case we aren't using default colormap 77 (so we can't use BlackPixelOfScreen...) */ 78 79 XColor black_color, white_color; 80 81 /* for the xfig icon */ 82 Pixmap fig_icon; 83 84 /* version string - generated in main() */ 85 char xfig_version[100]; 86 87 /* original directory where xfig started */ 88 char orig_dir[PATH_MAX+2]; 89 90 /* whether user is updating Fig files or loading one to view */ 91 Boolean update_figs = False; 92 93 #ifdef USE_XPM 94 XpmAttributes xfig_icon_attr; 95 #endif /* USE_XPM */ 96 Pixel colors[NUM_STD_COLS+MAX_USR_COLS]; 97 XColor user_colors[MAX_USR_COLS]; 98 XColor undel_user_color; 99 XColor n_user_colors[MAX_USR_COLS]; 100 XColor save_colors[MAX_USR_COLS]; 101 int num_usr_cols=0; 102 int n_num_usr_cols; 103 int current_memory; 104 Boolean colorUsed[MAX_USR_COLS]; 105 Boolean colorFree[MAX_USR_COLS]; 106 Boolean n_colorFree[MAX_USR_COLS]; 107 Boolean all_colors_available; 108 Pixel dark_gray_color, med_gray_color, lt_gray_color; 109 Pixel pageborder_color; 110 Pixel axis_lines_color; 111 int max_depth=-1; 112 int min_depth=-1; 113 char tool_name[200]; 114 Boolean display_fractions=True; /* whether to display fractions in lengths */ 115 char *userhome=NULL; /* user's home directory */ 116 float scale_factor=1.0; /* scale drawing as it is read in */ 117 char minor_grid[40], major_grid[40]; /* export/print grid values */ 118 Boolean draw_parent_gray; /* in open compound, draw rest in gray */ 119 120 /* number of colors we want to use for pictures */ 121 /* this will be determined when the first picture is used. We will take 122 min(number_of_free_colorcells, 100, appres.maximagecolors) */ 123 124 int avail_image_cols = -1; 125 126 /* colormap used for same */ 127 XColor image_cells[MAX_COLORMAP_SIZE]; 128 129 appresStruct appres; 130 Window main_canvas; /* main canvas window */ 131 Window canvas_win; /* current canvas */ 132 Window msg_win, sideruler_win, topruler_win; 133 134 Cursor cur_cursor; 135 Cursor arrow_cursor, bull_cursor, buster_cursor, crosshair_cursor, 136 null_cursor, text_cursor, pick15_cursor, pick9_cursor, 137 panel_cursor, l_arrow_cursor, lr_arrow_cursor, r_arrow_cursor, 138 u_arrow_cursor, ud_arrow_cursor, d_arrow_cursor, wait_cursor, 139 magnify_cursor; 140 141 Widget tool; 142 XtAppContext tool_app; 143 144 Widget canvas_sw, ps_fontmenu, /* printer font menu tool */ 145 latex_fontmenu, /* printer font menu tool */ 146 msg_panel, name_panel, cmd_form, mode_panel, 147 d_label, e_label, mousefun, 148 ind_panel, ind_box, upd_ctrl, /* indicator panel */ 149 snap_indicator_panel, /* snap indicator */ 150 unitbox_sw, sideruler_sw, topruler_sw; 151 152 Display *tool_d; 153 Screen *tool_s; 154 Window tool_w; 155 Widget tool_form; 156 int tool_sn; 157 int tool_vclass; 158 Visual *tool_v; 159 int tool_dpth; 160 int tool_cells; 161 int image_bpp; /* # of bytes-per-pixel for images at this visual */ 162 int screen_wd, screen_ht; /* width and height of screen */ 163 Colormap tool_cm, newcmap; 164 Boolean swapped_cmap = False; 165 Atom wm_delete_window; 166 int num_recent_files; /* number of recent files in list */ 167 int max_recent_files; /* user max number of recent files */ 168 int splash_onscreen = False; /* flag used to clear off splash graphic */ 169 time_t figure_timestamp; /* last time file was written externally (for -autorefresh) */ 170 171 GC border_gc, button_gc, ind_button_gc, mouse_button_gc, pic_gc, 172 fill_color_gc, pen_color_gc, blank_gc, ind_blank_gc, 173 mouse_blank_gc, gccache[NUMOPS], grid_gc, 174 fillgc, fill_gc[NUMFILLPATS], /* fill style gc's */ 175 tr_gc, tr_xor_gc, tr_erase_gc, /* for the rulers */ 176 sr_gc, sr_xor_gc, sr_erase_gc; 177 178 Color grid_color; 179 Pixmap fill_pm[NUMFILLPATS],fill_but_pm[NUMPATTERNS]; 180 float fill_pm_zoom[NUMFILLPATS],fill_but_pm_zoom[NUMFILLPATS]; 181 XColor x_fg_color, x_bg_color; 182 unsigned long but_fg, but_bg; 183 unsigned long ind_but_fg, ind_but_bg; 184 unsigned long mouse_but_fg, mouse_but_bg; 185 186 float ZOOM_FACTOR; /* assigned in main.c */ 187 float PIC_FACTOR; /* assigned in main.c, updated in unit_panel_set() and 188 update_settings() when reading figure file */ 189 190 /* will be filled in with environment variable XFIGTMPDIR */ 191 char *TMPDIR; 192 193 /* will contain environment variable FIG2DEV_DIR, if any */ 194 char *fig2dev_path; 195 char fig2dev_cmd[PATH_MAX]; 196 197 /***** translations used for asciiTextWidgets in general windows *****/ 198 String text_translations = 199 "<Key>Return: no-op()\n\ 200 Ctrl<Key>J: no-op()\n\ 201 Ctrl<Key>M: no-op()\n\ 202 Ctrl<Key>X: EmptyTextKey()\n\ 203 Ctrl<Key>U: multiply(4)\n\ 204 <Key>F18: PastePanelKey()\n"; 205 206 /* for w_export.c and w_print.c */ 207 208 char *orient_items[] = { 209 " Portrait ", 210 "Landscape "}; 211 212 char *just_items[] = { 213 "Centered ", 214 "Flush left"}; 215 216 /* IMPORTANT: if the number or order of this table is changed be sure 217 to change the PAPER_xx definitions in resources.h */ 218 219 struct paper_def paper_sizes[NUMPAPERSIZES] = { 220 {"Letter" , "Letter (8.5\" x 11\" / 216 x 279 mm)", LETTER_WIDTH, LETTER_HEIGHT}, 221 {"Legal" , "Legal (8.5\" x 14\" / 216 x 356 mm)", 10200, 16800}, 222 {"Tabloid" , "Tabloid ( 11\" x 17\" / 279 x 432 mm)", 13200, 20400}, 223 {"A" , "ANSI A (8.5\" x 11\" / 216 x 279 mm)", 10200, 13200}, 224 {"B" , "ANSI B ( 11\" x 17\" / 279 x 432 mm)", 13200, 20400}, 225 {"C" , "ANSI C ( 17\" x 22\" / 432 x 559 mm)", 20400, 26400}, 226 {"D" , "ANSI D ( 22\" x 34\" / 559 x 864 mm)", 26400, 40800}, 227 {"E" , "ANSI E ( 34\" x 44\" / 864 x 1118mm)", 40800, 52800}, 228 {"A9" , "ISO A9 ( 37 x 52 mm) ", 1748, 2467}, 229 {"A8" , "ISO A8 ( 52 x 74 mm) ", 2457, 3500}, 230 {"A7" , "ISO A7 ( 74 x 105 mm) ", 3496, 4960}, 231 {"A6" , "ISO A6 ( 105 x 148 mm) ", 4960, 6992}, 232 {"A5" , "ISO A5 ( 148 x 210 mm) ", 6992, 9921}, 233 {"A4" , "ISO A4 ( 210 x 297 mm) ", A4_WIDTH, A4_HEIGHT}, 234 {"A3" , "ISO A3 ( 297 x 420 mm) ", 14031, 19843}, 235 {"A2" , "ISO A2 ( 420 x 594 mm) ", 19843, 28063}, 236 {"A1" , "ISO A1 ( 594 x 841 mm) ", 28063, 39732}, 237 {"A0" , "ISO A0 ( 841 x 1189 mm) ", 39732, 56173}, 238 {"B9" , "JIS B9 ( 45 x 64 mm) ", 2117, 3017}, 239 {"B8" , "JIS B8 ( 64 x 91 mm) ", 3017, 4300}, 240 {"B7" , "JIS B7 ( 91 x 128 mm) ", 4300, 6050}, 241 {"B6" , "JIS B6 ( 128 x 182 mm) ", 6050, 8598}, 242 {"B5" , "JIS B5 ( 182 x 257 mm) ", 8598, 12150}, 243 {"B4" , "JIS B4 ( 257 x 364 mm) ", 12150, 17200}, 244 {"B3" , "JIS B3 ( 364 x 515 mm) ", 17200, 24333}, 245 {"B2" , "JIS B2 ( 515 x 728 mm) ", 24333, 34400}, 246 {"B1" , "JIS B1 ( 728 x 1030 mm) ", 34400, 48666}, 247 {"B0" , "JIS B0 (1030 x 1456 mm) ", 48666, 68783}, 248 {"B10" , "JIS B10 ( 32 x 45 mm) ", 1516, 2117}, 249 }; 250 251 char *multiple_pages[] = { 252 " Single ", 253 " Multiple "}; 254 255 char *overlap_pages[] = { 256 " No Overlap", 257 " Overlap "}; 258 259 /* for w_file.c and w_export.c */ 260 261 char *offset_unit_items[] = { 262 " Inches ", " Centim. ", "Fig Units" }; 263 264 int RULER_WD; 265 266 /* flag for when picture object is read in merge_file to see if need to remap 267 existing picture colors */ 268 269 Boolean pic_obj_read; 270 271 /* recent file structure/array */ 272 _recent_files recent_files[MAX_RECENT_FILES]; 273