1 /*
2  * Author:      William Chia-Wei Cheng (bill.cheng@acm.org)
3  *
4  * Copyright (C) 2001-2009, William Chia-Wei Cheng.
5  *
6  * This file may be distributed under the terms of the Q Public License
7  * as defined by Trolltech AS of Norway and appearing in the file
8  * LICENSE.QPL included in the packaging of this file.
9  *
10  * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING
11  * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
12  * PURPOSE.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
13  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
14  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
16  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  *
18  * @(#)$Header: /mm2/home/cvs/bc-src/tgif/types.h,v 1.47 2011/05/16 16:22:00 william Exp $
19  */
20 
21 #ifndef _TGIF_TYPES_H_
22 #define _TGIF_TYPES_H_
23 
24 #include "const.h"
25 
26 typedef void *(NLFN)ARGS_DECL((void)); /* a NULL function template */
27 typedef void (VDFN)ARGS_DECL((void)); /* a void procedure template */
28 
29 #define DO_ALL_X_EV 0
30 #define EXPOSE_AND_ESC_X_EV_ONLY 1
31 
32 typedef int (AbortCallbackFunc)ARGS_DECL((void*)); /* returns TRUE for abort */
33 
34 typedef struct BBRec {
35    int	ltx, lty, rbx, rby;
36 } * BBRecPtr;
37 
38 typedef struct PtRec {
39    int	x, y;
40    struct PtRec	* next;
41 } * PtRecPtr;
42 
43 typedef struct {
44    int	x, y;
45 } IntPoint;
46 
47 typedef struct tagIntPointTriplet {
48    int earlier_valid, later_valid;
49    IntPoint hinge_pt;
50    IntPoint earlier_smooth_pt;
51    IntPoint later_smooth_pt; /* this point moves at first */
52    double ratio;  /* segment len earlier = (segment len later * ratio) */
53 } IntPointTriplet;
54 
55 typedef struct {
56    double	x, y;
57 } DoublePoint;
58 
59 typedef struct XfrmMtrxRec {
60    double	m[4];
61    int		t[2];
62 } * XfrmMtrxPtr;
63 
64 typedef struct ObjRec {
65    int			x, y, type, color, bg_color, id, dirty, hot_spot;
66    int			invisible, trans_pat;
67    int			rotation; /* degrees times 64 */
68    short		marked, locked;
69    struct BBRec		orig_obbox, obbox; /* object bounding box */
70    struct BBRec		bbox; /* real bounding box */
71    struct ObjRec	* next, * prev;
72    struct AttrRec	* fattr, * lattr; /* first and last attributes */
73    union {
74       struct GroupRec	* r;
75       struct PolyRec	* p;
76       struct PolygonRec	* g;
77       struct BoxRec	* b;
78       struct OvalRec	* o;
79       struct TextRec	* t;
80       struct ArcRec	* a;
81       struct RCBoxRec	* rcb;
82       struct XBmRec	* xbm;
83       struct XPmRec	* xpm;
84       struct SSRec	* ss;
85    } detail;
86    struct ObjRec	* tmp_child; /* used temporarily */
87    struct ObjRec	* tmp_parent; /* used temporarily */
88    struct XfrmMtrxRec	* ctm;
89    struct XfrmMtrxRec	* orig_ctm; /* not used, yet */
90    char			color_str[40]; /* copy of the color name in file */
91    char			bg_color_str[40]; /* copy of the color name in file */
92    XPoint		rotated_obbox[5]; /* offsets */
93    void			* userdata;
94    /* for the multicast whiteboard */
95    char	*creator_full_id; /* NULL means created locally */
96    int	unavailable; /* involved in a long transaction of some sort */
97 } * ObjRecPtr;
98 
99 typedef struct DynStrRec {
100    char	*s;
101    int	sz; /* size of the buffer, should be strlen(s)+1 */
102 } * DynStrPtr;
103 
104 typedef struct SSRec {
105    struct DynStrRec dyn_str;
106    int double_byte, double_byte_mod_bytes, double_byte_vertical;
107 } SimpleString;
108 
109 typedef struct AttrRec {
110    struct DynStrRec	attr_name; /* attribute name */
111    struct DynStrRec	attr_value; /* attribute value */
112    short		shown; /* TRUE if the attribute is shown */
113    short		nameshown; /* TRUE if the attr name is also shown */
114    short		inherited; /* TRUE if attr was inherited */
115    struct ObjRec	* obj; /* the OBJ_TEXT object that represent the attr */
116    struct ObjRec        * owner; /* ptr to owner obj of the record */
117    struct AttrRec	* next, * prev; /* next and prev attributes */
118    void			* userdata;
119    int			tgo_type; /* default to be TGO_STRING */
120    void			* tgo_data;
121 } * AttrRecPtr;
122 
123 /*
124  * Pins are not implemented yet!
125  */
126 typedef struct ConnRec {
127    struct ObjRec	* poly_obj;
128    int			at_start; /* TRUE if connect to start_conn of poly */
129    struct ObjRec	* pin_obj;
130    struct ConnRec	* next, * prev;
131 } * ConnRecPtr;
132 
133 typedef struct GroupRec {
134    struct ObjRec	* first, * last;
135    char			s[MAXPATHLENGTH+1];
136    int			rotate, flip, deck_index, pin_connected;
137    			/*
138    			 * For a pin object, if !pin_connected, first is used.
139 			 * If pin_connected, last is used.  This means that
140 			 * first is the un-connected view of a pin object
141 			 * and last is the connected view of a pin object.
142 			 *
143 			 * Please note that pins are not implemented yet!
144    			 */
145    struct ConnRec	* first_conn, * last_conn;
146 } * GroupRecPtr;
147 
148 typedef struct ArrowStyleRec {
149    int			arrow_style;
150    int			aw, ah, aindent;
151    char			aw_spec[40], ah_spec[40], aindent_spec[40];
152 } * ArrowStyleRecPtr;
153 
154 typedef struct PolyRec {
155    int			n;	/* number of points in the polyline */
156    IntPoint		* vlist; /* absolute */
157    char			* smooth;
158    int			ssn;	/* number of points in a structured spline */
159    IntPoint		* ssvlist; /* absolute */
160    char			* ssmooth;
161    int			sn;	/* number of points in the spline polyline */
162    XPoint		* svlist; /* offsets */
163    int			asn;	/* spline polyline with arrows */
164    XPoint		* asvlist; /* offsets */
165    int			intn;	/* interpolated spline original spec */
166    IntPoint		* intvlist; /* absolute */
167    int			style, width, pen, curved, fill, dash, tension;
168    char			width_spec[40];
169    int			rotated_n, rotated_asn;
170    XPoint		* rotated_vlist, * rotated_asvlist; /* offsets */
171    struct ArrowStyleRec	start_asty, end_asty;
172    			/*
173    			 * Please note that pins are not implemented yet!
174    			 */
175    struct ConnRec	* start_conn; /* connection at vlist[0] */
176    struct ConnRec	* end_conn; /* connection at vlist[n-1] */
177    			/*
178    			 * To be obsoleted!
179    			 */
180    int			aw, ah;
181    char			aw_spec[40], ah_spec[40];
182 } * PolyRecPtr;
183 
184 typedef struct PolygonRec {
185    int			n;	/* number of points in the polygon */
186    IntPoint		* vlist; /* absolute */
187    char			* smooth;
188    int			ssn;	/* number of points in a structured spline */
189    IntPoint		* ssvlist; /* absolute */
190    char			* ssmooth;
191    int			sn;	/* number of points in the spline polygon */
192    XPoint		* svlist; /* offsets */
193    int			intn;	/* interpolated spline original spec */
194    IntPoint		* intvlist; /* absolute */
195    int			fill, width, pen, curved, dash, tension;
196    char			width_spec[40];
197    int			rotated_n;
198    XPoint		* rotated_vlist; /* offsets */
199 } * PolygonRecPtr;
200 
201 typedef struct BoxRec {
202    int		fill, width, pen, dash;
203    char		width_spec[40];
204 } * BoxRecPtr;
205 
206 typedef struct OvalRec {
207    int		fill, width, pen, dash;
208    char		width_spec[40];
209    int		rotated_n;
210    XPoint	* rotated_vlist; /* offsets */
211 } * OvalRecPtr;
212 
213 typedef struct KeyValRec {
214    char *key;
215    char *value;
216    struct KeyValRec *next, *prev;
217 } KeyValInfo;
218 
219 typedef struct StrRec {
220    struct DynStrRec	dyn_str;
221    struct StrRec	* next, * prev;
222 } * StrRecPtr;
223 
224 typedef struct TextExtentsRec {
225    char	*buf;
226    int	len; /* strlen(buf) */
227    int	w, lbearing, rextra; /* lbearing is always <= 0, rextra >= 0 */
228    int	bbox_w, bbox_h, asc, des;
229 } TextExtentsInfo;
230 
231 typedef struct RecalcMetricsRec {
232    int	orig_x, orig_baseline_y;
233    int	x, baseline_y;
234    int	depth, pre_order;
235 } RecalcMetricsInfo;
236 
237 typedef struct StrSegRec {
238    int	color;
239    char	color_str[40]; /* copy of the color name in file */
240    int	font, style, sz_unit;
241    int	real_sz_unit; /* only used if Tgif.EditTextSize is used */
242    int	double_byte, double_byte_mod_bytes, double_byte_vertical, direction;
243    int	underline_on, overline_on;
244    int	w, asc, des, min_lbearing, max_rextra;
245    int	read_only, orig_w, orig_h, orig_asc, orig_des; /* only if read_only */
246    char	* font_name; /* only used in PRTGIF */
247    struct DynStrRec	dyn_str;
248    struct StrBlockRec	* owner;
249    /*
250     * for file version 38!
251     */
252    int	dontreencode;
253 } StrSegInfo;
254 
255 #define SB_SIMPLE        0
256 #define SB_SUPSUB_LEFT   1
257 #define SB_SUPSUB_CENTER 2
258 #define SB_SUPSUB_RIGHT  3
259 #define SB_CHAR_SPACE    4 /* special_char_w is pixel offsets */
260 
261 typedef struct StrBlockRec {
262    int	w, asc, des, min_lbearing, max_rextra;
263    int	read_only, orig_w, orig_h, orig_asc, orig_des; /* only if read_only */
264    int	special_char_w;
265    int	depth, pre_order; /* set in RecalcTextMetrics() */
266    int	type; /* one of SB_* */
267    StrSegInfo	*seg;
268    struct MiniLinesRec	*sup, *sub;
269    struct MiniLineRec	*owner_mini_line;
270    struct StrBlockRec	*next, *prev;
271    /*
272     * used to determine what to repaint
273     */
274    int clean;
275    struct BBRec clean_bbox, bbox;
276 } StrBlockInfo;
277 
278 typedef struct MiniLineRec {
279    int	w, asc, des, min_lbearing, max_rextra;
280    int	read_only, orig_w, orig_h, orig_asc, orig_des; /* only if read_only */
281    /*
282     * For the first mini_line, v_gap is always 0.
283     * For other mini_line, v_gap is relative to the mini_line
284     *       immediately above it (after asc and des of the mini_line,
285     *       and v_space of the minilines).
286     */
287    int	v_gap;
288    struct StrBlockRec	*first_block, *last_block;
289    struct MiniLineRec	*next, *prev;
290    struct MiniLinesRec	*owner_minilines;
291    /*
292     * used to determine what to repaint
293     */
294    int clean;
295    struct BBRec clean_bbox, bbox;
296 } MiniLineInfo;
297 
298 typedef struct MiniLinesRec {
299    int	w, h, min_lbearing, max_rextra;
300    int	read_only, orig_w, orig_h, orig_asc, orig_des; /* only if read_only */
301    int	just, v_space;
302    /*
303     * For the minilines of a text_ptr, baseline_offset always 0.
304     * For the sup and sub of a str_block, baseline_offset is relative to
305     *       the baseline of the str_block, which is the baseline of the
306     *       mini_line which owns the str_block.  This offsets the mini_lines
307     *       in it all together.
308     */
309    int	baseline_offset;
310    /*
311     * owner_block is NULL for the top minilines;
312     */
313    struct StrBlockRec	*owner_block;
314    struct MiniLineRec	*first, *last;
315    /*
316     * used to determine what to repaint
317     */
318    int clean;
319    struct BBRec clean_bbox, bbox;
320 } MiniLinesInfo;
321 
322 typedef struct TextRec {
323    /*
324     * The height of a line is determined by the font height of the first
325     * substr.  V_space is also the v_space of the first substr.
326     */
327    int			lines, pen, fill;
328    int			w, h, min_lbearing, max_rextra;
329    struct AttrRec       *attr; /* ptr to attr record if text obj is an attr */
330    Pixmap		cached_bitmap, cached_pixmap, cached_bg_bitmap;
331    int			cached_zoom, cached_zoomed;
332    struct XfrmMtrxRec	cached_ctm;
333    struct BBRec		orig_bbox;
334    int			underline_y_offset, overline_y_offset;
335    /* these are new */
336    /*
337     * baseline_y is the real thing!  y of struct ObjRec is derived from it
338     *       by subtracting minilines->asc
339     */
340    int	baseline_y;
341    int	read_only, orig_w, orig_h, orig_asc, orig_des; /* only if read_only */
342    struct MiniLinesRec	minilines;
343 } * TextRecPtr;
344 
345 typedef struct tagStretchStructuredSplineInfo {
346    int hinge; /* TRUE if a hinge point is selected, FALSE otherwise */
347    int orig_hinge_index; /* this index into vlist */
348    int earlier_smooth_selected;
349    int prev_valid; /* FALSE if the first point of a poly is selected */
350    int next_valid; /* FALSE if the last point of a poly is selected */
351    IntPointTriplet ipt_prev, ipt, ipt_next;
352    /* for drawing */
353    int num_vs, num_vs2;
354    IntPoint vs[5], vs2[5];
355    char smooth[5], smooth2[5];
356    XPoint *sv, *sv2, *saved_sv, *saved_sv2;
357    int sn, sn2, saved_sn, saved_sn2;
358    /* for moving a vertex -- only one vertex can be selected */
359    int orig_abs_x, orig_abs_y, new_abs_x, new_abs_y, abs_dx, abs_dy;
360    int rotated_orig_abs_x, rotated_orig_abs_y;
361    int rotated_new_abs_x, rotated_new_abs_y;
362    int rotated_abs_dx, rotated_abs_dy;
363 } StretchStructuredSplineInfo;
364 
365 typedef struct SelRec {
366    struct ObjRec	* obj;
367    struct SelRec	* next, * prev;
368 } * SelRecPtr;
369 
370 typedef struct tagMoveVertexInfo {
371    int orig_abs_x, orig_abs_y, new_abs_x, new_abs_y, abs_dx, abs_dy;
372    int rotated_orig_abs_x, rotated_orig_abs_y;
373    int rotated_new_abs_x, rotated_new_abs_y;
374    int rotated_abs_dx, rotated_abs_dy;
375 } MoveVertexInfo;
376 
377 typedef struct VSelRec {
378    struct ObjRec		* obj;
379    int				n, max_v, * v_index, * x, * y;
380    struct VSelRec		* next, * prev;
381    /* for moving a vertex -- normally pmvi is NULL */
382    MoveVertexInfo		* pmvi;
383 } * VSelRecPtr;
384 
385 typedef struct MoveSubCmdRec {
386    int	dx, dy;
387 } * MoveSubCmdRecPtr;
388 
389 typedef struct tagTextFormatInfo {
390    int color_index, font_style;
391    char color_str[40];
392 } TextFormatInfo;
393 
394 #define CHAT_STATE_NORMAL     0
395 #define CHAT_STATE_HELLO      1
396 #define CHAT_STATE_DISCONNECT 2
397 
398 typedef struct ChatSubCmdRec {
399    int type;
400    TextFormatInfo tfi;
401    char nick_name[MAXSTRING];
402    char encoding[MAXSTRING];
403    char *buf;
404 } * ChatSubCmdRecPtr;
405 
406 typedef struct SlideShowSubCmdRec {
407    int into_slideshow; /* TRUE if going into slideshow mode */
408 } * SlideShowSubCmdRecPtr;
409 
410 typedef struct ClearAllSubCmdRec {
411    int page_style;
412    float print_mag;
413 } * ClearAllSubCmdRecPtr;
414 
415 typedef struct SubCmdRec {
416    union {
417       struct MoveSubCmdRec	move;
418       struct ChatSubCmdRec	chat;
419       struct SlideShowSubCmdRec	slideshow;
420       struct ClearAllSubCmdRec	clearall;
421    } detail;
422 } * SubCmdRecPtr;
423 
424 typedef struct CmdRec {
425    int			type, undone;
426    int			include_tgif_obj, new_colormap, logical_clock;
427    char			* sender_process_id;
428    int			* pos_before, count_before, pos_before_has_ids;
429    int			* pos_after, count_after;
430    struct SelRec	* top_before, * bot_before;
431    struct SelRec	* top_after, * bot_after;
432    struct CmdRec	* next, * prev;
433    struct CmdRec	* first, * last;
434    /*
435     * if serialized is TRUE, pos_before should be typecasted to (char**)
436     *       and each entry is <creator_full_id> which is "id", "/",
437     *       "creator_pid", ":", and "creator_ip" concatenated together.
438     */
439    int			serialized;
440    char			* serialization_buf;
441    int			first_redo_after_deserialize;
442    int			skipped;
443    struct SubCmdRec	* subcmd;
444 } * CmdRecPtr;
445 
446 typedef struct PageRec {
447    struct ObjRec	* top, * bot;
448    struct PageRec	* next, * prev;
449    char			* name;
450    char			* page_file_name;
451    int			draw_orig_x, draw_orig_y, zoom_scale, zoomed_in;
452    int			layer_on;
453 } * PageRecPtr;
454 
455 typedef struct StkRec {
456    struct ObjRec	* first, * last, * sel;
457    struct StkRec	* next;
458    struct CmdRec	* first_cmd, * last_cmd, * cur_cmd;
459    int			history_count;
460    int			name_valid, file_mod, id, page_style;
461    int			orig_x, orig_y, zoom, zoomed;
462    int			grid_system, english_grid, metric_grid, snap_on;
463    int			color, h_align, v_align, line_w, line_s;
464    int			fill, pen, dash, just, font, f_style, f_sz_unit;
465    int			trans_pat;
466    float		print_mag;
467    int			v_space, grid_shown, move_mode;
468    int			rcb_radius, underline_on, underline_y_offset;
469    int			overline_on, overline_y_offset;
470    char			name[MAXPATHLENGTH+1], domain[MAXPATHLENGTH+1];
471    char			dir[MAXPATHLENGTH+1], sym_dir[MAXPATHLENGTH+1];
472    char			* saved_comments;
473    int			saved_comments_len;
474    struct AttrRec	* first_file_attr, * last_file_attr;
475    struct PageRec	* first_page, * last_page, * cur_page;
476    int			cur_page_num, last_page_num, cols, rows;
477    int			page_layout_mode, color_dump;
478    int			one_page_width, one_page_height;
479    int			file_bg_pixel, file_fg_pixel;
480    int			file_bg_pixmap_w, file_bg_pixmap_h;
481    char			*file_bg_color_str, *file_fg_color_str;
482    char			*file_bg_gif_url;
483    Pixmap		file_bg_pixmap;
484 } * StkRecPtr;
485 
486 typedef struct ArcRec {
487    int		fill, width, pen, dash, style, aw, ah;
488    char		width_spec[40], aw_spec[40], ah_spec[40];
489    int		xc, yc, x1, y1, x2, y2, dir;
490    int		ltx, lty, w, h, angle1, angle2;
491    int		a_angle1, a_angle2;
492    int		rotated_n, rotated_asn;
493    XPoint	* rotated_vlist, * rotated_asvlist; /* offsets */
494 } * ArcRecPtr;
495 
496 typedef struct RCBoxRec {
497    int		fill, width, pen, dash, radius;
498    char		width_spec[40];
499    int		rotated_n;
500    XPoint	* rotated_vlist; /* offsets */
501 } * RCBoxRecPtr;
502 
503 typedef struct XBmRec {
504    int			fill, real_type, flip, image_w, image_h;
505    int			eps_w, eps_h;
506    char			* data;
507    char			* filename;
508    char			* * epsflines;
509    char			write_date[32];
510    int			num_epsf_lines, epsf_level, save_epsf;
511    int			llx, lly, urx, ury; /* these values are x1000 */
512    XImage		* image;
513    Pixmap		bitmap;
514    Pixmap		cached_bitmap;
515    int			cached_zoom, cached_zoomed, cached_flip;
516    int			cached_w, cached_h;
517    struct XfrmMtrxRec	cached_ctm;
518 } * XBmRecPtr;
519 
520 typedef struct XPmRec {
521    int			fill, real_type, flip, image_w, image_h;
522    int			linked_jpeg; /* TRUE if JPEG is linked */
523    char			* filename; /* only valid if JPEG is linked */
524    char			tmp_ppm6_fname[MAXPATHLENGTH+1]; /* used temporarily */
525    int			ncolors;
526    int			chars_per_pixel;
527    int			first_pixel_is_bg;
528    int			* pixels, * red, * green, * blue;
529    char			* color_char;
530    char			* * color_str;
531    char			* data;
532    XImage		* image, * bitmap_image;
533    Pixmap		pixmap, bitmap;
534    Pixmap		cached_pixmap, cached_bitmap;
535    int			cached_zoom, cached_zoomed, cached_flip;
536    int			cached_w, cached_h, cached_color;
537    Pixmap		clip_mask;
538    struct XfrmMtrxRec	cached_ctm;
539    /*
540     * If real_type is PPM_TRUE, color_char, color_str, pixels, and data are
541     *         all NULL and ncolors is 0.
542     * The following are only valid if real_type is PPM_TRUE.
543     */
544    int			ppm_data_compress; /* 0x1: jpeg, 0x2: ppm.z */
545    char			* ppm_data; /* can be raw (jpeg) or deflated (ppm.z) */
546    unsigned int		ppm_data_size;
547    char			* ppm_mask_data; /* not used, for future transparency */
548    unsigned int		ppm_mask_size; /* not used, for future transparency */
549    int			has_transparent_color;
550    unsigned char	transparent_color[3]; /* r, g, b */
551    void			* userdata;
552 } * XPmRecPtr;
553 
554 typedef struct WinInfoRec {
555    Window	window;
556    int		mapped;
557    int		raise;
558    int		(*ev_handler)ARGS_DECL((XEvent*, struct WinInfoRec *));
559    void		(*expose_handler)ARGS_DECL((XEvent*, struct WinInfoRec *));
560    void		(*cleanup)ARGS_DECL((struct WinInfoRec *));
561    void		*userdata;
562 } * WinInfoPtr;
563 
564 typedef struct tagKeyOrBtnEvInfo {
565    int		type;
566    Bool		send_event;
567    Display	*display;
568    Window	window;
569    Time		time;
570    int		x, y;
571    unsigned int	keycode_or_button;
572    unsigned int	state;
573 } KeyOrBtnEvInfo;
574 
575 typedef struct MtrxRec {
576    float	m[2][2], rev_m[2][2], h_scale, v_scale;
577    float	image_w, image_h, w, h, transformed_w, transformed_h;
578    float	dump_h_scale, dump_v_scale;
579    int		rotate, flip, degree;
580 } * MtrxPtr;
581 
582 typedef struct _DspList {
583    char			itemstr[MAXPATHLENGTH+1];
584    char			pathstr[MAXPATHLENGTH+1];
585    int			directory;
586    struct _DspList	* next;
587 } DspList;
588 
589 typedef struct MouseStatusStrRec {
590    char	* l, * m, * r;
591 } MouseStatusStrPtr;
592 
593 typedef struct tagMouseOverStatusInfo {
594    char btn_str[MAX_STATUS_BTNS][MAXSTRING+1];
595    char one_line_str[MAXSTRING+1];
596    int one_line_status;
597    struct tagMouseOverStatusInfo *next;
598 } MouseOverStatusInfo;
599 
600 typedef struct VRec {
601    int vtype;
602    union {
603       int i;
604       double d;
605       char *s;
606    } val;
607 } VRecPtr;
608 
609 struct URLCacheRec {
610    int remote_buf_sz, is_html;
611    char *remote_buf, *content_type, *simple_url_name;
612    struct URLCacheRec *next, *prev;
613 };
614 
615 typedef struct PushedFontRec {
616    int font;
617    int sz_unit;
618    int style;
619    int just;
620    int pen;
621    int fill;
622    int trans_pat;
623    int v_space;
624    int color;
625    int underline_on;
626    int underline_y_offset;
627    int overline_on;
628    int overline_y_offset;
629    int double_byte, double_byte_mod_bytes, double_byte_vertical;
630    struct PushedFontRec *next;
631 } * PushedFontRecPtr;
632 
633 typedef struct ObjListRec {
634    struct ObjRec *top_obj, *bot_obj;
635    struct SelRec *top_sel, *bot_sel;
636    int count;
637 } ObjListInfo;
638 
639 typedef struct tagSimpleWinInfo {
640    int x, y, w, h;
641 } SimpleWinInfo;
642 
643 typedef struct tagDirtyBBoxInfo {
644    int valid;
645    int force_redraw_all;
646    struct BBRec bbox;
647 } DirtyBBoxInfo;
648 
649 typedef struct tagTextHighlightInfo {
650    /* all these values are screen offsets */
651    int start_x, start_min_y, start_max_y, start_baseline_y;
652    int end_x, end_min_y, end_max_y, end_baseline_y;
653    StrBlockInfo *start_str_block_ptr, *end_str_block_ptr;
654    int start_index, end_index;
655    int highlighting; /* used in PaintMiniLines() */
656    int mode; /* one of PAINT_* above */
657 } TextHighlightInfo;
658 
659 typedef struct tagCopyUTF8Info {
660    int single_byte_valid, double_byte_valid;
661    StrSegInfo single_byte_seg;
662    StrSegInfo double_byte_seg;
663 } CopyUTF8Info;
664 
665 typedef struct tagDrawTextInfo {
666    /* the following is from miniline.e */
667 
668    TextHighlightInfo text_highlight_info;
669 
670    int text_orig_x, text_orig_y, text_orig_baseline_y;
671    int text_abs_x, text_abs_y, text_abs_baseline_y;
672 
673    int text_cur_x, text_cur_y, text_cur_baseline_y;
674    int text_cur_index;
675    int text_end_x, text_end_y, text_end_baseline_y;
676    int text_end_index;
677 
678    int text_abs_min_lbearing, text_abs_max_rextra;
679    int text_w, text_h;
680 
681    int text_highlight;
682 
683    struct ObjRec *cur_text_obj;
684 
685    struct BBRec cur_text_obbox, cur_text_bbox;
686 
687    StrBlockInfo *cur_str_block;
688    StrBlockInfo *end_str_block;
689    MiniLineInfo *first_miniLine, *last_miniLine;
690 
691    int esc_pressed;
692 
693    int cur_text_outline_w, cur_text_outline_half_w;
694 
695    /* the following is from text.e */
696 
697    int text_drawn;
698    int cur_text_modified;
699    int text_vspace;
700 
701    int text_just;
702    int text_cursor_shown;
703    int text_cursor_h;
704    int editing_text;
705    int cur_text_is_new;
706 
707    int edit_text_size;
708 
709    /* the following is from struct PushedFontRec */
710 
711    struct PushedFontRec font_info;
712 } DrawTextInfo;
713 
714 typedef struct tagColorBytes {
715    int valid;
716    unsigned char r, g, b;
717 } ColorBytes;
718 
719 typedef struct tagTrueColorInfo {
720    unsigned long r_mask, g_mask, b_mask;
721    unsigned int r_shift, g_shift, b_shift;
722    double dr_maxval, dg_maxval, db_maxval;
723    /* dr_maxval_div255 = dr_maxval/255, etc. */
724    double dr_maxval_div255, dg_maxval_div255, db_maxval_div255;
725    unsigned int num_r_bits, num_g_bits, num_b_bits;
726 } TrueColorInfo;
727 
728 /* ------------------ imageproc stuff ------------------ */
729 
730 typedef void (ImageMapColorFunc)ARGS_DECL((int nColorIndex, XColor*));
731 typedef int (ConvolveFunc)ARGS_DECL((int x, int y));
732 
733 #define TRAP_NODE_LEAF 0
734 #define TRAP_NODE_PT   1
735 #define TRAP_NODE_SEG  2
736 
737 #define TRAP_PT_L 0
738 #define TRAP_PT_T 1
739 #define TRAP_PT_R 2
740 #define TRAP_PT_B 3
741 #define TRAP_PT_C 4
742 
743 #define TRAP_SEG_L 0
744 #define TRAP_SEG_T 1
745 #define TRAP_SEG_R 2
746 #define TRAP_SEG_B 3
747 
748 #define TRAP_LEAF_LT 0
749 #define TRAP_LEAF_RT 1
750 #define TRAP_LEAF_LB 2
751 #define TRAP_LEAF_RB 3
752 
753 typedef struct TrapMapSegRec {
754    double m, b; /* y = mx + b */
755 } TrapMapSeg;
756 
757 typedef struct TrapMapRec {
758    int type; /* TRAP_NODE_* */
759    union {
760       struct {
761          int which; /* TRAP_LEAF_* */
762          int *data; /* points to one of gaTrapMapLeaf */
763       } leaf;
764       struct {
765          int which; /* TRAP_PT_* */
766          IntPoint *data; /* points to one of gaTrapMapPt */
767          struct TrapMapRec *left, *right;
768       } pt;
769       struct {
770          int which; /* TRAP_SEG_* */
771          TrapMapSeg *data; /* points to one of gaTrapMapSeg */
772          struct TrapMapRec *above, *below;
773       } seg;
774    } detail;
775 } TrapMap;
776 
777 typedef struct TrapMapSpecRec {
778    int type;
779    int which;
780 } TrapMapSpec;
781 
782 /* ------------------ copy and paste properties stuff ------------------ */
783 
784 typedef struct CheckArrayRec {
785    int num_cols;
786    int num_rows;
787    int **value; /* value[0..(col_index-1)][0..(row_index-1)] */
788    char **col_name; /* col_name[0..col_index] */
789 } * CheckArrayRecPtr;
790 
791 typedef int (GetEntriesFunc)ARGS_DECL((DspList**, char***, int *pn_num_entries,
792       int *pn_marked_index, struct CheckArrayRec **, char *inbuf, void*));
793 typedef int (AfterLoopFunc)ARGS_DECL((DspList**, char***, int *pn_num_entries,
794       int *pn_marked_index, struct CheckArrayRec **, char *cur_buf,
795       int btn_id, int selected_index, void*));
796 typedef int (CheckUpdateFunc)ARGS_DECL((DspList**, char***,
797       int *pn_num_entries, int *pn_marked_index, struct CheckArrayRec **,
798       char *cur_buf, int col, int row, void*));
799 
800 typedef struct PropertiesRec {
801    int			color, width, aw, ah, width_index;
802    char			color_str[40], width_spec[40], aw_spec[40], ah_spec[40];
803    int			fill, pen, dash, arrow_style, curved, rcb_radius;
804    int			trans_pat, text_just, text_sz_unit, v_space;
805    int			underline_on, overline_on;
806    int			double_byte, text_font, text_style;
807    int			transformed;
808    struct XfrmMtrxRec	ctm;
809    void			* userdata;
810 } * PropertiesRecPtr;
811 
812 /* ------------------ pixmap button stuff ------------------ */
813 
814 #define TGBS_NORMAL 0 /* button state is enabled */
815 #define TGBS_GRAYED 1 /* button state is disabled */
816 #define TGBS_RAISED 2 /* button state is mouse-overed */
817 #define TGBS_LOWRED 3 /* button state is pressed */
818 
819 typedef struct TgPxMpBtnRec {
820    int		flags; /* if (1<<TGBS_* != 0) then pixmap[TGBS_*] is valid */
821    int		state;
822    Pixmap	pixmap[4];
823 } TgPxMpBtn;
824 
825 /* ------------------ menu stuff ------------------ */
826 
827 #define TGMUITEM_SEPARATOR         ((char*)(-1))
828 #define TGMUITEM_BREAK             ((char*)(-2))
829 #define TGMUITEM_SUBMENU           ((char*)(-3))
830 #define TGMUITEM_PINNABLESUBMENU   ((char*)(-4))
831 
832                                   /* flasg */
833 #define TGMU_SEPARATOR            0x00000001
834 #define TGMU_BREAK                0x00000002 /* does not handle this, yet */
835 #define TGMU_HAS_CHECK            0x00000004 /* put a check mark if checked */
836 #define TGMU_HAS_RADIO            0x00000008 /* put a dot mark if checked */
837 #define TGMU_HAS_SUBMENU          0x00000010
838 #define TGMU_SUBMENU_PINNABLE     0x00000020
839 #define TGMU_HAS_SHORTCUT         0x00000040
840 #define TGMU_MULTICOLOR           0x00000080
841 #define TGMU_DISABLED             0x00000100
842                                   /* masks */
843 #define TGMU_MASK_STATE           0x00010000 /* set/get state */
844 #define TGMU_MASK_CMDID           0x00020000 /* set/get cmdid */
845 #define TGMU_MASK_MULTICOLOR      0x00040000 /* set/get multicolor_pixel */
846 #define TGMU_MASK_PXMPBTN1        0x00100000 /* set/get checked_pxmpbtn */
847 #define TGMU_MASK_PXMPBTN2        0x00200000 /* set/get unchecked_pxmpbtn */
848 #define TGMU_MASK_CHECK           0x00400000 /* set/get check for check mark */
849 #define TGMU_MASK_RADIO           0x00800000 /* set/get check for radio mark */
850 #define TGMU_MASK_MENUSTR         0x01000000 /* set/get menu_str */
851 #define TGMU_MASK_STATUSSTR       0x02000000 /* set/get status_str */
852 #define TGMU_MASK_SUBMENU         0x04000000 /* set/get status_str */
853 #define TGMU_MASK_PINNABLESUBMENU 0x08000000 /* set/get status_str */
854 #define TGMU_MASK_SHORTCUTSTR     0x10000000 /* set/get status_str */
855 #define TGMU_MASK_LTXY            0x20000000 /* set/get status_str */
856 #define TGMU_MASK_USERDATA        0x40000000 /* set/get bbox.ltx and bbox.lty */
857 #define TGMU_MASK_RAWSTATUSSTR    0x80000000 /* need to gettext() before copy */
858 
859 typedef struct TgMenuItemRec {
860    int		flags; /* TGMU_* */
861    int		state; /* one of TGBS_* */
862    int		checked; /* valid if TGMU_HAS_CHECK or TGMU_HAS_RADIO */
863    int		cmdid; /* command identifier */
864    int		multicolor_pixel; /* valid only if TGMU_MULTICOLOR */
865    struct BBRec	bbox;
866    TgPxMpBtn	*checked_pxmpbtn; /* valid only if TGMU_HAS_PIXMAP */
867    TgPxMpBtn	*unchecked_pxmpbtn; /* valid only if TGMU_HAS_PIXMAP */
868    int		menu_str_allocated; /* need to free(menu_str) on destroy */
869    char		*menu_str;
870    char		*status_str;
871    void		*userdata;
872    union {
873       struct TgMenuRec	*submenu;
874       char		*shortcut_str;
875    } detail;
876    struct TgMenuItemInfoRec	*submenu_create_info;
877 } TgMenuItem;
878 
879 #define TGMUTYPE_TEXT   0
880 #define TGMUTYPE_COLOR  1
881 #define TGMUTYPE_BITMAP 2
882 
883 #define TGMUTYPE_MASK      0x0f
884 #define TGMUTYPE_CANSCROLL 0x10
885 
886 typedef int (RefreshMenuFunc)ARGS_DECL((void *menu));
887 
888 typedef struct TgMenuRec {
889    int			type; /* one of TGMUTYPE_* */
890    int			num_items;
891    int			selected_index;
892    struct BBRec		bbox;
893    Window		window;
894    int			padding; /* 0 if not 3D */
895    int			brdr_w; /* 0 if 3D */
896    int			is_main_menu;
897    int			track_menubar;
898    int			track_parent_menu;
899    int			disallow_pinning;
900    int			check_start, str_start; /* for TGMUTYPE_TEXT */
901    int			shortcut_start, arrow_start; /* for TGMUTYPE_TEXT */
902    /* can_scroll -- can have a scroll bar */
903    int			can_scroll;
904    int			scroll_start; /* 0: no scrollbar */
905    int			first_index; /* 0: scroll all the way to top or left */
906    /* multicolumn -- for TGMUTYPE_COLOR or TGMUTYPE_BITMAP */
907    int			image_w, image_h, num_rows, num_cols;
908    TgMenuItem		*menuitems; /* for TGMUTYPE_TEXT */
909    void			*userdata;
910    struct TgMenuRec	*parent_menu;
911    RefreshMenuFunc	*refresh_proc; /* must set this for a submenu */
912 } TgMenu;
913 
914 typedef struct TgMenuItemInfoRec {
915    /*
916     * for TGMUTYPE_TEXT, menu_str is (char*)
917     * for TGMUTYPE_COLOR, menu_str is (int*)
918     * for TGMUTYPE_BITMAP, menu_str is (Pixmap*)
919     * menu_str can also be just TGMUITEM_SEPARATOR
920     */
921    char *menu_str;
922    /*
923     * for TGMUTYPE_TEXT, shortcut_str is (char*) or TGMUITEM_SUBMENU
924     * for TGMUTYPE_BITMAP, shortcut_str NULL
925     */
926    char *shortcut_str;
927    char *status_str;
928    struct TgMenuInfoRec	*submenu_info;
929    int cmdid; /* INVALID means no cmdid */
930 } TgMenuItemInfo;
931 
932 typedef TgMenu *(CreateMenuFunc)ARGS_DECL((TgMenu *parent_menu, int x, int y,
933       struct TgMenuInfoRec *menuinfo, int status_str_xlated));
934 
935 typedef struct TgMenuInfoRec {
936    int			type; /* one of TGMUTYPE_* */
937    TgMenuItemInfo	*items;
938    CreateMenuFunc	*create_proc;
939 } TgMenuInfo;
940 
941 /* ------------------ shortcut stuff ------------------ */
942 
943 #ifdef __DARWIN__
944 #ifdef _DARWIN_MOD1_AS_META
945 #define METAMASK (Mod1Mask)
946 #else /* ~_DARWIN_MOD1_AS_META */
947 #define METAMASK (Mod2Mask)
948 #endif /* _DARWIN_MOD1_AS_META */
949 #else /* ~__DARWIN__ */
950 #define METAMASK (Mod1Mask)
951 #endif /* __DARWIN__ */
952 
953 #define CNTRL_ONLY (ControlMask)
954 #define META_ONLY (METAMASK)
955 #define CNTRL_META (ControlMask|METAMASK)
956 
957 typedef struct ShortCutRec {
958    char         code;
959    unsigned int state;
960    char         name[80];
961    short        num_args;
962    short        cmdid;
963 } ShortCutInfo;
964 
965 /* ------------------ edit attr stuff ------------------ */
966 
967 typedef struct tagEditAttrRec {
968    int	num_attrs;
969    char	**attr_names;
970    char	**attr_values;
971    char	**attr_strings;
972    char	**status_strings;
973    int	*fore_colors;
974    int	*attr_indices;
975 } EditAttrInfo;
976 
977 /* ------------------ scroll stuff ------------------ */
978 
979 typedef int (ScrollBtnCallbackFunc)ARGS_DECL((void*));
980 typedef int (ScrollingCallbackFunc)ARGS_DECL((XMotionEvent*, void*));
981 
982 typedef struct tagScrollBtnCallbackInfo {
983    int ms;
984    void *pv_userdata;
985    ScrollBtnCallbackFunc *pf_scroll_btn_callback;
986 } ScrollBtnCallbackInfo;
987 
988 /* ------------------ exec stuff ------------------ */
989 
990 typedef int (ExecFunc)ARGS_DECL((char **argv, struct ObjRec *obj_ptr,
991                                  char *orig_cmd));
992 typedef int (RawExecFunc)ARGS_DECL((char **argv, char **raw_argv,
993                                     struct ObjRec *obj_ptr, char *orig_cmd));
994 typedef void (SimpleExecFunc)ARGS_DECL((struct ObjRec *obj_ptr,
995                                         char *orig_cmd));
996 
997 typedef struct tagExecInfoRec {
998    NLFN *pfunc;
999    char *func_name;
1000    int func_argc;
1001          /*
1002           * if (func_argc == 0) {
1003           *    pfunc is (SimpleExecFunc)();
1004           * } else if (func_argc < 0) {
1005           *    pfunc is (RawExecFunc)();
1006           * } else {
1007           *    pfunc is (ExecFunc)();
1008           * }
1009           */
1010    int double_quotes_for_null;
1011          /*
1012           * If TRUE, then if $(foo) evaluates to the empty string, "" is
1013           *       passed.  This is mainly used by commands with expression
1014           *       evaluations.
1015           */
1016 } ExecInfo;
1017 
1018 /* ------------------ page stuff ------------------ */
1019 
1020 typedef struct tagSpecifyPagesInfoRec {
1021    int num_pages_specified;
1022    int *page_specified;
1023 } SpecifyPagesInfo;
1024 
1025 typedef struct tagPageInfoRec {
1026    int page_layout_mode, paper_col, paper_row;
1027    int cur_page_num, last_page_num;
1028    struct PageRec *first_page, *last_page, *cur_page;
1029 } PageInfo;
1030 
1031 /* ------------------ progress stuff ------------------ */
1032 
1033 typedef struct tagProgressInfoRec {
1034    int total_size;
1035    int target_percent;
1036 
1037    char status_buf[MAX_STATUS_BTNS+1][MAXSTRING+1];
1038    int one_line_status;
1039 } ProgressInfo;
1040 
1041 /* ------------------ generated_by stuff ------------------ */
1042 
1043 typedef struct tagGeneratedByInfoRec {
1044    char name[40];
1045    int version; /* version for tgif */
1046    char version_str[40]; /* version of the tool */
1047 } GenerateByInfo;
1048 
1049 /* ------------------ pngtrans stuff ------------------ */
1050 
1051 typedef struct tagPngHeaderInfo {
1052     int valid;
1053     char fname[MAXPATHLENGTH];
1054     FILE *fp;
1055     uint32_t image_w;
1056     uint32_t image_h;
1057     unsigned char bit_depth;
1058     unsigned char color_type;
1059     unsigned char compression_method;
1060     unsigned char filter_method;
1061     unsigned char interlace_method;
1062     uint32_t palette_sz;
1063     unsigned char *palette;
1064     int trans_color_pixel_found;
1065     unsigned char trans_color_pixel_red;
1066     unsigned char trans_color_pixel_green;
1067     unsigned char trans_color_pixel_blue;
1068 } PngHeaderInfo;
1069 
1070 #endif /*_TGIF_TYPES_H_*/
1071