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 #ifndef RESOURCES_H 20 #define RESOURCES_H 21 22 #if defined HAVE_CONFIG_H && !defined VERSION 23 #include "config.h" 24 #endif 25 26 #include <limits.h> /* PATH_MAX, below */ 27 #include <sys/types.h> 28 #include <X11/Intrinsic.h> 29 #ifdef USE_XPM 30 #include <X11/xpm.h> 31 #endif 32 #include "paintop.h" 33 34 #ifndef PATH_MAX 35 #define PATH_MAX 1024 36 #endif 37 38 #define NUMSHADEPATS 21 39 #define NUMTINTPATS 20 40 #define NUMPATTERNS 22 41 #define NUMFILLPATS NUMSHADEPATS+NUMTINTPATS+NUMPATTERNS 42 43 /* page sizes used when imported EPS has no bounding box or pdf has no /MediaBox */ 44 #define LETTER_WIDTH 10200 45 #define LETTER_HEIGHT 13200 46 #define A4_WIDTH 9921 47 #define A4_HEIGHT 14031 48 49 /* min, max zoom allowed */ 50 #define MIN_ZOOM 0.01 51 #define MAX_ZOOM 100 52 53 /* starting, min, max depth of objects on canvas */ 54 #define DEF_DEPTH 50 55 #define MIN_DEPTH 0 56 #define MAX_DEPTH 999 57 58 /* min, max font size (points) */ 59 #define MIN_FONT_SIZE 1 60 #define MAX_FONT_SIZE 500 61 62 /* min, max font size on the display (after zooming) */ 63 /* this is necessary because some X servers crash completely 64 when rendering very small fonts */ 65 #define MIN_X_FONT_SIZE 5 66 #define MAX_X_FONT_SIZE MAX_FONT_SIZE 67 68 /* maximum width of lines (Fig units) */ 69 #define MAX_LINE_WIDTH 500 70 71 /* max number of sides for regular polygon */ 72 #define MIN_POLY_SIDES 3 73 #define MAX_POLY_SIDES 200 74 75 /* min, max vertical spacing when entering text (fraction of font size) */ 76 #define MIN_TEXT_STEP 0 77 #define MAX_TEXT_STEP 100 78 79 /* min, max arc-box corner radius (1/80 inch) */ 80 #define MIN_BOX_RADIUS 2 81 #define MAX_BOX_RADIUS 1000 82 83 /* min, max tangent/normal line length */ 84 #define MIN_TANGNORMLEN 0 85 #define MAX_TANGNORMLEN 20 86 87 /* number of standard colors */ 88 #define NUM_STD_COLS 32 89 /* max number of user-defined colors */ 90 #define MAX_USR_COLS 512 91 92 /* number of paper sizes (A4, B5, letter, etc. [see resources.c]) */ 93 #define NUMPAPERSIZES 29 94 95 /* define these positions so we can start with default paper size */ 96 #define PAPER_LETTER 0 97 #define PAPER_A4 13 98 99 #define Color int 100 101 /* default number of colors to use for GIF/XPM */ 102 /* this can be overridden in resources or command-line arg */ 103 #define DEF_MAX_IMAGE_COLS 64 104 105 /* max and default number of recently used files for File menu */ 106 #define MAX_RECENT_FILES 9 107 #define DEF_RECENT_FILES 5 108 109 /* for picture files */ 110 #define MAX_COLORMAP_SIZE 256 111 112 /* for JPEG export */ 113 #define DEF_JPEG_QUALITY 75 114 115 /* default border margin for export */ 116 #define DEF_EXPORT_MARGIN 0 117 118 /* how often to check for external file change, milliseconds (-autorefresh) */ 119 120 #define CHECK_REFRESH_TIME 1000 121 122 /* for screen capture */ 123 124 #define IMAGE_PALETTE 0 /* colormapped screen capture */ 125 #define IMAGE_RGB 1 /* RGB (TrueColor) screen capture */ 126 127 struct Cmap { 128 unsigned short red, green, blue; 129 unsigned long pixel; 130 }; 131 132 typedef struct { 133 char *name, 134 *rgb; 135 } fig_colors ; 136 137 /* for the xfig icon */ 138 extern Pixmap fig_icon; 139 140 /* version string for xfig (generated in main() )*/ 141 extern char xfig_version[]; 142 143 /* these are allocated in main() in case we aren't using default colormap 144 (so we can't use BlackPixelOfScreen... */ 145 146 extern XColor black_color, white_color; 147 148 /* original directory where xfig started */ 149 extern char orig_dir[PATH_MAX+2]; 150 151 /* whether user is updating Fig files or loading one to view */ 152 extern Boolean update_figs; 153 154 #ifdef USE_XPM 155 extern XpmAttributes xfig_icon_attr; 156 #endif 157 extern fig_colors colorNames[NUM_STD_COLS + 1]; 158 extern char *short_clrNames[NUM_STD_COLS + 1]; 159 extern Pixel colors[NUM_STD_COLS+MAX_USR_COLS]; 160 extern XColor user_colors[MAX_USR_COLS]; 161 extern XColor undel_user_color; 162 extern XColor n_user_colors[MAX_USR_COLS]; 163 extern XColor save_colors[MAX_USR_COLS]; 164 extern int num_usr_cols, n_num_usr_cols; 165 extern int current_memory; 166 extern Boolean colorUsed[MAX_USR_COLS]; 167 extern Boolean colorFree[MAX_USR_COLS]; 168 extern Boolean n_colorFree[MAX_USR_COLS]; 169 extern Boolean all_colors_available; 170 extern Pixel dark_gray_color, med_gray_color, lt_gray_color; 171 extern Pixel pageborder_color; 172 extern Pixel axis_lines_color; 173 extern int max_depth, min_depth; 174 extern char tool_name[200]; 175 extern int export_background_color; /* current export/print background color */ 176 extern Boolean display_fractions; /* whether to display fractions in lengths */ 177 extern char *userhome; /* user's home directory */ 178 extern struct _pics *pictures; /* common repository to share imported pictures */ 179 extern float scale_factor; /* scale drawing as it is read in */ 180 extern char minor_grid[40], major_grid[40]; /* export/print grid values */ 181 extern Boolean draw_parent_gray; /* in open compound, draw rest in gray */ 182 183 /* number of colors we want to use for GIF/XPM images */ 184 extern int avail_image_cols; 185 /* colormap used for same */ 186 extern XColor image_cells[MAX_COLORMAP_SIZE]; 187 188 /* resources structure */ 189 190 typedef struct _appres { 191 Boolean write_v40; /* flag to save figure in V4.0 format */ 192 Boolean allownegcoords; /* allow negative x/y coordinates for panning */ 193 int balloon_delay; /* delay (ms) before balloon pops up on */ 194 char *boldFont; 195 char *browser; /* browser for viewing html docs */ 196 int but_per_row; /* number of buttons wide for the mode panel */ 197 char *buttonFont; 198 char *canvasbackground; 199 char *canvasforeground; 200 Boolean DEBUG; 201 Boolean dontswitchcmap; /* don't allow switching of colormap */ 202 Boolean installowncmap; /* install our own private colormap */ 203 Boolean showaxislines; /* draw axis lines through 0,0 (useful w/allow_neg_coords) */ 204 Boolean smallicons; /* draw axis lines through 0,0 (useful w/allow_neg_coords) */ 205 char *exportLanguage; 206 Boolean flushleft; /* center/flush-left printing */ 207 char *geometry; 208 char *iconGeometry; 209 char *image_editor; /* image editor (xv, etc) */ 210 Boolean INCHES; 211 int internalborderwidth; 212 int jpeg_quality; /* jpeg image quality */ 213 char *keyFile; 214 Boolean landscape; 215 Boolean latexfonts; 216 char *library_dir; /* for object library path */ 217 float magnification; /* export/print magnification */ 218 int max_image_colors; /* max colors to use for GIF/XPM images */ 219 Boolean monochrome; 220 Boolean multiple; /* multiple/single page for export/print */ 221 char *normalFont; 222 char *pageborder; /* color of page border */ 223 char *paper_size; /* ASCII size of paper (from command-line) */ 224 int papersize; /* size of paper */ 225 Boolean RHS_PANEL; 226 char *pdf_viewer; /* viewer for pdf docs */ 227 int rulerthick; /* thickness of rulers */ 228 Boolean scalablefonts; /* whether user wants scalable fonts or not */ 229 Boolean showallbuttons; 230 Boolean showballoons; /* show popup messages when user passes over buttons */ 231 Boolean showlengths; /* length/width lines when drawing or moving */ 232 Boolean shownums; /* print vertex numbers above polyline points */ 233 Boolean show_pageborder; /* show page border in color on canvas */ 234 Boolean specialtext; 235 char *spellcheckcommand; /* spell check command e.g. 236 "spell %s" or "ispell -l < %s | sort -u" */ 237 int spinner_delay; /* delay (ms) before spinner counts automatically */ 238 int spinner_rate; /* rate (ms) at which spinner counts */ 239 int startfillstyle; /* starting fill style */ 240 float startfontsize; /* ges 6 Feb 91 */ 241 int startgridmode; /* starting grid mode */ 242 int startgridtype; /* starting grid type */ // isometric grid 243 int startarrowtype; /* starting arrow type */ 244 float startarrowthick; /* starting arrow thick */ 245 float startarrowwidth; /* starting arrow width */ 246 float startarrowlength; /* starting arrow length (height) */ 247 char *startlatexFont; /* bab 11 Jan 92 */ 248 int startlinewidth; /* starting line width */ 249 int startposnmode; /* starting point position mode */ 250 char *startpsFont; /* bab 11 Jan 92 */ 251 float starttextstep; /* starting multi-line text spacing */ 252 Boolean tablet; /* input tablet extension */ 253 float tmp_height; 254 float tmp_width; 255 Boolean tracking; /* mouse tracking in rulers */ 256 int transparent; /* transparent color for GIF export 257 (-2=none, -1=background) */ 258 float userscale; /* scale screen units to user units */ 259 char *userunit; /* user defined unit name */ 260 float zoom; /* starting zoom scale */ 261 char *version; /* version of the app-defaults file (compared with 262 the version/patchlevel of xfig when starting */ 263 int export_margin; /* size of border around figure for export */ 264 Boolean flipvisualhints; /* switch left/right mouse indicator messages */ 265 Boolean rigidtext; 266 Boolean hiddentext; 267 Boolean showdepthmanager; /* whether or not to display the depth manager */ 268 char *grid_color; /* color of grid (when on) */ 269 int smooth_factor; /* smoothing factor when export to bitmap formats */ 270 Boolean icon_view; /* icon or list view of library objects */ 271 int library_icon_size; /* size of those icons */ 272 Boolean splash; /* whether or not to show the splash screen on startup */ 273 char *axislines; /* color of axis lines on canvas */ 274 int freehand_resolution; /* minimum spacing of points when drawing freehand */ 275 char *tgrid_unit; /* units of grid/point positioning (1/10" or 1/16") */ 276 Boolean overlap; /* overlap/no-overlap multiple pages for export/print */ 277 char *ghostscript; /* name of ghostscript (e.g. gs or gswin32) */ 278 char *gslib; /* name of ghostscript library */ 279 Boolean correct_font_size; /* adjust for difference in Fig screen res vs points (80/72) */ 280 int encoding; /* encoding for latex escape translation */ 281 Boolean save8bit; /* save 8bit files */ 282 Boolean crosshair; /* draw crosshair cursor wherever the pointer is */ 283 Boolean autorefresh; /* automatically redraw figure when file has changed */ 284 Boolean write_bak; /* automatically rename current to .bak when saving */ 285 286 #ifdef I18N 287 Boolean international; 288 String font_menu_language; 289 Boolean euc_encoding; 290 Boolean locale_encoding; 291 Boolean latin_keyboard; 292 Boolean always_use_fontset; 293 XFontSet fixed_fontset; 294 int fontset_size; 295 String xim_input_style; 296 String fig2dev_localize_option; 297 #ifdef I18N_USE_PREEDIT 298 String text_preedit; 299 #endif /* I18N_USE_PREEDIT */ 300 #endif /* I18N */ 301 302 } appresStruct, *appresPtr; 303 extern appresStruct appres; 304 305 typedef struct { 306 int length, ascent, descent; 307 } pr_size; 308 309 typedef struct { 310 unsigned int r_width, r_height, r_left, r_top; 311 } RectRec; 312 313 typedef struct { 314 int type; 315 char *label; 316 caddr_t info; 317 } MenuItemRec; 318 319 struct Menu { 320 int m_imagetype; 321 #define MENU_IMAGESTRING 0x00 /* imagedata is char * */ 322 #define MENU_GRAPHIC 0x01 /* imagedata is pixrect * */ 323 caddr_t m_imagedata; 324 int m_itemcount; 325 MenuItemRec *m_items; 326 struct Menu *m_next; 327 caddr_t m_data; 328 }; 329 330 /* def for paper size list */ 331 struct paper_def { 332 char *sname; /* short name e.g. 'A' */ 333 char *fname; /* full name e.g. 'A (8.5" x 11")' */ 334 int width,height; /* size in Fig units e.g. 10200 13200 */ 335 }; 336 337 typedef struct Menu MenuRec; 338 339 typedef XImage *PIXRECT; 340 typedef pr_size PR_SIZE; 341 typedef RectRec RECT; 342 343 extern float ZOOM_FACTOR; 344 extern float PIC_FACTOR; 345 346 extern Window main_canvas; /* main canvas window */ 347 extern Window canvas_win; /* current canvas */ 348 extern Window msg_win, sideruler_win, topruler_win; 349 350 extern Cursor cur_cursor; 351 extern Cursor arrow_cursor, bull_cursor, buster_cursor, crosshair_cursor, 352 null_cursor, text_cursor, pick15_cursor, pick9_cursor, 353 panel_cursor, l_arrow_cursor, lr_arrow_cursor, r_arrow_cursor, 354 u_arrow_cursor, ud_arrow_cursor, d_arrow_cursor, wait_cursor, 355 magnify_cursor; 356 357 extern Widget tool; 358 extern XtAppContext tool_app; 359 360 extern Widget canvas_sw, ps_fontmenu, /* printer font menu tool */ 361 latex_fontmenu, /* printer font menu tool */ 362 msg_form, msg_panel, name_panel, cmd_form, mode_panel, 363 d_label, e_label, mousefun, 364 ind_panel, ind_box, upd_ctrl, /* indicator panel */ 365 unitbox_sw, sideruler_sw, topruler_sw; 366 367 extern Display *tool_d; 368 extern Screen *tool_s; 369 extern Window tool_w; 370 extern Widget tool_form; 371 extern int tool_sn; 372 extern int tool_vclass; 373 extern Visual *tool_v; 374 extern int tool_dpth; 375 extern int tool_cells; 376 extern int image_bpp; /* # of bytes-per-pixel for images at this visual */ 377 extern int screen_wd, screen_ht; /* width and height of screen */ 378 extern Colormap tool_cm, newcmap; 379 extern Boolean swapped_cmap; 380 extern Atom wm_delete_window; 381 extern int num_recent_files; /* number of recent files in list */ 382 extern int max_recent_files; /* user max number of recent files */ 383 extern int splash_onscreen; /* flag used to clear off splash graphic */ 384 extern time_t figure_timestamp; /* last time file was written externally (for -autorefresh) */ 385 386 extern GC border_gc, button_gc, ind_button_gc, mouse_button_gc, pic_gc, 387 fill_color_gc, pen_color_gc, blank_gc, ind_blank_gc, 388 mouse_blank_gc, gccache[NUMOPS], grid_gc, 389 fillgc, fill_gc[NUMFILLPATS], /* fill style gc's */ 390 tr_gc, tr_xor_gc, tr_erase_gc, /* for the rulers */ 391 sr_gc, sr_xor_gc, sr_erase_gc; 392 393 extern Color grid_color; 394 extern Pixmap fill_pm[NUMFILLPATS],fill_but_pm[NUMPATTERNS]; 395 extern float fill_pm_zoom[NUMFILLPATS],fill_but_pm_zoom[NUMFILLPATS]; 396 extern XColor x_fg_color, x_bg_color; 397 extern unsigned long but_fg, but_bg; 398 extern unsigned long ind_but_fg, ind_but_bg; 399 extern unsigned long mouse_but_fg, mouse_but_bg; 400 401 /* will contain environment variable XFIGTMPDIR, if any */ 402 extern char *TMPDIR; 403 404 /* will contain environment variable FIG2DEV_DIR, if any */ 405 extern char *fig2dev_path; 406 extern char fig2dev_cmd[PATH_MAX]; 407 408 extern String text_translations; 409 410 /* for w_export.c and w_print.c */ 411 412 extern char *orient_items[2]; 413 extern char *just_items[2]; 414 extern struct paper_def paper_sizes[NUMPAPERSIZES]; 415 extern char *multiple_pages[2], *overlap_pages[2]; 416 417 /* for w_file.c and w_export.c */ 418 419 extern char *offset_unit_items[3]; 420 421 extern int RULER_WD; 422 423 /* environment variable name definition for image editor used for screen capture */ 424 425 #define XFIG_ENV_GIF_EDITOR getenv("XFIG_GIF_EDITOR") 426 427 /* flag for when picture object is read in merge_file to see if need to remap 428 existing picture colors */ 429 430 extern Boolean pic_obj_read; 431 432 typedef struct _recent_file_struct { 433 char *name; 434 Widget menu; 435 } _recent_files; 436 437 extern _recent_files recent_files[]; 438 439 #endif /* RESOURCES_H */ 440