1 /*****
2 * tka.h : XmHTML Toolkit Abstraction Public Interface
3 *
4 * This file Version	$Revision$
5 *
6 * Creation date:		Mon Sep 28 08:49:25 CEST 1998
7 * Last modification: 	$Date$
8 * By:					$Author$
9 * Current State:		$State$
10 *
11 * Author:				XmHTML Developers Account
12 *
13 * Copyright (C) 1994-1998 by Ripley Software Development
14 * All Rights Reserved
15 *
16 * This file is part of no particular project.
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public
20 * License as published by the Free Software Foundation; either
21 * version 2 of the License, or (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public
29 * License along with this program; if not, write to the Free
30 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 *
32 *****/
33 /*****
34 * $Source$
35 *****/
36 /*****
37 * ChangeLog
38 * $Log$
39 * Revision 1.1  2011/06/30 16:08:41  rwcox
40 * Cadd
41 *
42 *
43 *****/
44 
45 #ifndef _tka_h_
46 #define _tka_h_
47 
48 /*****
49 * Toolkit independent rendering functions. This enables us to use the
50 * same engine for rendering to a display, text or postscript.
51 *
52 * This abstraction makes it a *lot* easier when porting XmHTML to other
53 * toolkits, provided the display functions know how to deal/convert the
54 * X-specific types. See also toolkit.h for other toolkit-dependent
55 * definitions.
56 *****/
57 #define GC_FILL_SOLID				0
58 #define GC_FILL_TILED				1
59 #define GC_FILL_STIPPLED			2
60 #define GC_FILL_OPAQUE_STIPPLED		3
61 
62 #define GC_CAP_NOT_LAST				0
63 #define GC_CAP_BUTT					1
64 #define GC_CAP_ROUND				2
65 #define GC_CAP_PROJECTING			3
66 
67 #define GC_LINE_SOLID				0
68 #define GC_LINE_ON_OFF_DASH			1
69 #define GC_LINE_DOUBLE_DASH			2
70 
71 #define GC_JOIN_MITER				0
72 #define GC_JOIN_ROUND				1
73 #define GC_JOIN_BEVEL				2
74 
75 #define GC_GXcopy					0
76 
77 #define GC_COORDMODE_ORIGIN			0
78 #define GC_COORDMODE_PREVIOUS		1
79 
80 typedef struct _ToolkitAbstraction{
81 	Display *dpy;			/* display being used		*/
82 	Drawable win;			/* render area				*/
83 	Drawable defaultRoot;	/* fallback window			*/
84 
85 	/*****
86 	* Screen definitions
87 	*****/
88 	int width;				/* width in pixels			*/
89 	int height;				/* height in pixels			*/
90 	int widthMM;			/* width in millimeters		*/
91 	int heightMM;			/* height in millimeters	*/
92 
93 	/**********
94 	* Xlib function wrappers
95 	**********/
96 
97 	/*****
98 	* GC properties
99 	*****/
100 
101 	int fill_style[4];
102 	int cap_style[4];
103 	int line_style[3];
104 	int join_style[3];
105 	int gc_func[2];
106 	int coord_mode[2];
107 
108 	/*****
109 	* GC functions
110 	*****/
111 	GC	(*CreateGC)(
112 #ifdef NeedFunctionPrototypes
113 		Display*			/* display */,
114 		Drawable			/* d */,
115 		unsigned long		/* valuemask */,
116 		XGCValues*			/* values */
117 #endif
118 	);
119 
120 	int (*FreeGC)(
121 #ifdef NeedFunctionPrototypes
122 		Display*			/* display */,
123 		GC					/* gc */
124 #endif
125 	);
126 
127 	int (*CopyGC)(
128 #ifdef NeedFunctionPrototypes
129 		Display*			/* display */,
130 		GC					/* src */,
131 		unsigned long		/* valuemask */,
132 		GC					/* dest */
133 #endif
134 	);
135 
136 	int (*SetFunction)(
137 #ifdef NeedFunctionPrototypes
138 		Display*			/* display */,
139 		GC					/* gc */,
140 		int					/* function */
141 #endif
142 	);
143 
144 	int (*SetClipMask)(
145 #ifdef NeedFunctionPrototypes
146 		Display*			/* display */,
147 		GC					/* gc */,
148 		Pixmap				/* pixmap */
149 #endif
150 	);
151 
152 	int (*SetClipOrigin)(
153 #ifdef NeedFunctionPrototypes
154 		Display*			/* display */,
155 		GC					/* gc */,
156 		int					/* clip_x_origin */,
157 		int					/* clip_y_origin */
158 #endif
159 	);
160 
161 	int (*SetTile)(
162 #ifdef NeedFunctionPrototypes
163 		Display*			/* display */,
164 		GC					/* gc */,
165 		Pixmap				/* tile */
166 #endif
167 	);
168 
169 	int (*SetTSOrigin)(
170 #ifdef NeedFunctionPrototypes
171 		Display*			/* display */,
172 		GC					/* gc */,
173 		int					/* ts_x_origin */,
174 		int					/* ts_y_origin */
175 #endif
176 	);
177 
178 	int (*SetFillStyle)(
179 #ifdef NeedFunctionPrototypes
180 		Display*			/* display */,
181 		GC					/* gc */,
182 		int					/* fill_style */
183 #endif
184 	);
185 
186 	int (*SetFont)(
187 #ifdef NeedFunctionPrototypes
188 		Display*			/* display */,
189 		GC					/* gc */,
190 		XmHTMLfont*			/* font */
191 #endif
192 	);
193 
194 	int (*SetForeground)(
195 #ifdef NeedFunctionPrototypes
196 		Display*			/* display */,
197 		GC					/* gc */,
198 		unsigned long		/* foreground */
199 #endif
200 	);
201 
202 	int (*SetBackground)(
203 #ifdef NeedFunctionPrototypes
204 		Display*			/* display */,
205 		GC					/* gc */,
206 		unsigned long		/* background */
207 #endif
208 	);
209 
210 	int (*SetLineAttributes)(
211 #ifdef NeedFunctionPrototypes
212 		Display*			/* display */,
213 		GC					/* gc */,
214 		unsigned int		/* line_width */,
215 		int					/* line_style */,
216 		int					/* cap_style */,
217 		int					/* join_style */
218 #endif
219 	);
220 
221 	/*****
222 	* Font functions
223 	*****/
224 
225 	XFontStruct* (*LoadQueryFont)(
226 #ifdef NeedFunctionPrototypes
227 		Display*			/* display */,
228 		_Xconst char*		/* name */
229 #endif
230 	);
231 
232 	int (*FreeFont)(
233 #ifdef NeedFunctionPrototypes
234 		Display*			/* display */,
235 		XFontStruct*		/* font_struct */
236 #endif
237 	);
238 
239 	int (*GetFontProperty)(
240 #ifdef NeedFunctionPrototypes
241 		XFontStruct*		/* font_struct */,
242 		Atom				/* atom */,
243 		unsigned long*		/* value_return */
244 #endif
245 	);
246 
247 	/*****
248 	* Cursor & pointer functions
249 	*****/
250 	int (*UngrabPointer)(
251 #ifdef NeedFunctionPrototypes
252 		Display*			/* display */,
253 		Time				/* time */
254 #endif
255 	);
256 
257 	int (*DefineCursor)(
258 #ifdef NeedFunctionPrototypes
259 		Display*			/* display */,
260 		Window				/* w */,
261 		Cursor				/* cursor */
262 #endif
263 	);
264 
265 	int (*UndefineCursor)(
266 #ifdef NeedFunctionPrototypes
267 		Display*			/* display */,
268 		Window				/* w */
269 #endif
270 	);
271 
272 	int (*FreeCursor)(
273 #ifdef NeedFunctionPrototypes
274 		Display*			/* display */,
275 		Cursor				/* cursor */
276 #endif
277 	);
278 
279 	/*****
280 	* Color functions
281 	*****/
282 
283 	int (*ParseColor)(
284 #ifdef NeedFunctionPrototypes
285 		Display*			/* display */,
286 		Colormap			/* colormap */,
287 		_Xconst char*		/* spec */,
288 		XColor*				/* exact_def_return */
289 #endif
290 	);
291 
292 	int (*AllocColor)(
293 #ifdef NeedFunctionPrototypes
294 		Display*			/* display */,
295 		Colormap			/* colormap */,
296 		XColor*				/* screen_in_out */
297 #endif
298 	);
299 
300 	int (*QueryColor)(
301 #ifdef NeedFunctionPrototypes
302 		Display*			/* display */,
303 		Colormap			/* colormap */,
304 		XColor*				/* def_in_out */
305 #endif
306 	);
307 
308 	int (*QueryColors)(
309 #ifdef NeedFunctionPrototypes
310 		Display*			/* display */,
311 		Colormap			/* colormap */,
312 		XColor*				/* defs_in_out */,
313 		int					/* ncolors */
314 #endif
315 	);
316 
317 	int (*FreeColors)(
318 #ifdef NeedFunctionPrototypes
319 		Display*			/* display */,
320 		Colormap			/* colormap */,
321 		unsigned long*		/* pixels */,
322 		int					/* npixels */,
323 		unsigned long		/* planes */
324 #endif
325 	);
326 
327 	/*****
328 	* Pixmap functions
329 	*****/
330 
331 	Pixmap (*CreatePixmap)(
332 #ifdef NeedFunctionPrototypes
333 		Display*			/* display */,
334 		Drawable			/* d */,
335 		unsigned int		/* width */,
336 		unsigned int		/* height */,
337 		unsigned int		/* depth */
338 #endif
339 	);
340 
341 	Pixmap (*CreatePixmapFromBitmapData)(
342 #ifdef NeedFunctionPrototypes
343 		Display*			/* display */,
344 		Drawable			/* d */,
345 		char*				/* data */,
346 		unsigned int		/* width */,
347 		unsigned int		/* height */,
348 		unsigned long		/* fg */,
349 		unsigned long		/* bg */,
350 		unsigned int		/* depth */
351 #endif
352 	);
353 
354 	int	(*FreePixmap)(
355 #ifdef NeedFunctionPrototypes
356 		Display*			/* display */,
357 		Pixmap				/* pixmap */
358 #endif
359 	);
360 
361 	/*****
362 	* XImage functions
363 	*****/
364 
365 	XImage *(*CreateImage)(
366 #ifdef NeedFunctionPrototypes
367 		Display*			/* display */,
368 		Visual*				/* visual */,
369 		unsigned int		/* depth */,
370 		int					/* format */,
371 		int					/* offset */,
372 		char*				/* data */,
373 		unsigned int		/* width */,
374 		unsigned int		/* height */,
375 		int					/* bitmap_pad */,
376 		int					/* bytes_per_line */
377 #endif
378 	);
379 
380 	void (*DestroyImage)(
381 #ifdef NeedFunctionPrototypes
382 		XImage *image
383 #endif
384 	);
385 
386 	int  (*PutImage)(
387 #ifdef NeedFunctionPrototypes
388 		Display*			/* display */,
389 		Drawable			/* d */,
390 		GC					/* gc */,
391 		XImage*				/* image */,
392 		int					/* src_x */,
393 		int					/* src_y */,
394 		int					/* dest_x */,
395 		int					/* dest_y */,
396 		unsigned int		/* width */,
397 		unsigned int		/* height */
398 #endif
399 	);
400 
401 	void (*DrawImage)(
402 #ifdef NeedFunctionPrototypes
403 		XmHTMLWidget					/* Widget */,
404 		XmHTMLImage*					/* image */,
405 		GC								/* gc */,
406 		int								/* src_x */,
407 		int								/* src_y */,
408 		unsigned int					/* width */,
409 		unsigned int					/* height */,
410 		int								/* dest_x */,
411 		int								/* dest_y */
412 #endif
413 	);
414 
415 	void (*DrawAnchorData)(
416 #ifdef NeedFunctionPrototypes
417 		Display*						/* display */,
418 		Window							/* win */,
419 		GC								/* gc */,
420 		int								/* x */,
421 		int								/* y */,
422 		XmHTMLObjectTableElement		/* anchor */
423 #endif
424 	);
425 
426 
427 	XImage* (*GetImage)(
428 #ifdef NeedFunctionPrototypes
429 		Display*			/* display */,
430 		Drawable			/* d */,
431 		int					/* x */,
432 		int					/* y */,
433 		unsigned int		/* width */,
434 		unsigned int		/* height */,
435 		unsigned long		/* plane_mask */,
436 		int					/* format */
437 #endif
438 	);
439 
440 	unsigned long (*GetPixel)(
441 #ifdef NeedFunctionPrototypes
442 		XImage *ximage		/* image */,
443 		_XtDimension x		/* x coordinate */,
444 		_XtDimension y		/* y coordinate */
445 #endif
446 	);
447 
448 	/*****
449 	* string/text functions
450 	*****/
451 
452 	int (*TextWidth)(
453 #ifdef NeedFunctionPrototypes
454 		XmHTMLfont*		/* font_struct */,
455 		_Xconst char*		/* string */,
456 		int					/* count */
457 #endif
458 	);
459 
460 	int (*TextExtents)(
461 #ifdef NeedFunctionPrototypes
462 		XFontStruct*		/* font_struct */,
463 		_Xconst char*		/* string */,
464 		int					/* nchars */,
465 		int*				/* direction_return */,
466 		int*				/* font_ascent_return */,
467 		int*				/* font_descent_return */,
468 		XCharStruct*		/* overall_return */
469 #endif
470 	);
471 
472 	/*****
473 	* Render functions
474 	*****/
475 
476 	int  (*DrawString)(
477 #ifdef NeedFunctionPrototypes
478 		Display*			/* display */,
479 		Drawable			/* d */,
480 		struct _XmHTMLFont*	/* font */,
481 		GC					/* gc */,
482 		int					/* x */,
483 		int					/* y */,
484 		_Xconst char*		/* string */,
485 		int					/* length */
486 #endif
487 	);
488 
489 	/*****
490 	* Render functions
491 	*****/
492 
493 	int (*DrawLine)(
494 #ifdef NeedFunctionPrototypes
495 		Display*			/* display */,
496 		Drawable			/* d */,
497 		GC					/* gc */,
498 		int					/* x1 */,
499 		int					/* x2 */,
500 		int					/* y1 */,
501 		int					/* y2 */
502 #endif
503 	);
504 
505 	int (*DrawLines)(
506 #ifdef NeedFunctionPrototypes
507 		Display*			/* display */,
508 		Drawable			/* d */,
509 		GC					/* gc */,
510 		XPoint*				/* points */,
511 		int					/* npoints */,
512 		int					/* mode */
513 #endif
514 	);
515 
516 	int (*DrawRectangle)(
517 #ifdef NeedFunctionPrototypes
518 		Display*			/* display */,
519 		Drawable			/* d */,
520 		GC					/* gc */,
521 		int					/* x */,
522 		int					/* y */,
523 		unsigned int		/* width */,
524 		unsigned int		/* height */
525 #endif
526 	);
527 
528 	int (*FillRectangle)(
529 #ifdef NeedFunctionPrototypes
530 		Display*			/* display */,
531 		Drawable			/* d */,
532 		GC					/* gc */,
533 		int					/* x */,
534 		int					/* y */,
535 		unsigned int		/* width */,
536 		unsigned int		/* height */
537 #endif
538 	);
539 
540 	int (*DrawArc)(
541 #ifdef NeedFunctionPrototypes
542 		Display*			/* display */,
543 		Drawable			/* d */,
544 		GC					/* gc */,
545 		int					/* x */,
546 		int					/* y */,
547 		unsigned int		/* width */,
548 		unsigned int		/* height */,
549 		int					/* angle1 */,
550 		int					/* angle2 */
551 #endif
552 	);
553 
554 	int (*FillArc)(
555 #ifdef NeedFunctionPrototypes
556 		Display*			/* display */,
557 		Drawable			/* d */,
558 		GC					/* gc */,
559 		int					/* x */,
560 		int					/* y */,
561 		unsigned int		/* width */,
562 		unsigned int		/* height */,
563 		int					/* angle1 */,
564 		int					/* angle2 */
565 #endif
566 	);
567 
568 	/*****
569 	* misc. functions
570 	*****/
571 
572 	int (*CopyArea)(
573 #ifdef NeedFunctionPrototypes
574 		Display*			/* display */,
575 		Drawable			/* src */,
576 		Drawable			/* dest */,
577 		GC					/* gc */,
578 		int					/* src_x */,
579 		int					/* src_y */,
580 		unsigned int		/* width */,
581 		unsigned int		/* height */,
582 		int					/* dest_x */,
583 		int					/* dest_y */
584 #endif
585 	);
586 
587 	int (*ClearArea)(
588 #ifdef NeedFunctionPrototypes
589 		Display*			/* display */,
590 		Window				/* w */,
591 		int					/* x */,
592 		int					/* y */,
593 		unsigned int		/* width */,
594 		unsigned int		/* height */,
595 		Bool				/* exposures */
596 #endif
597 	);
598 
599 	int (*Sync)(
600 #ifdef NeedFunctionPrototypes
601 		Display*			/* display */,
602 		Bool				/* discard */
603 #endif
604 	);
605 
606 	/**********
607 	* X Toolkit Intrinsics wrappers
608 	**********/
609 
610 	Boolean	(*IsRealized)(
611 #ifdef NeedFunctionPrototypes
612 		Widget				/* widget */
613 #endif
614 	);
615 
616 	Boolean (*IsManaged)(
617 #ifdef NeedFunctionPrototypes
618 		Widget				/* rectobj */
619 #endif
620 	);
621 
622 	void	(*ManageChild)(
623 #ifdef NeedFunctionPrototypes
624 		Widget				/* child */
625 #endif
626 	);
627 
628 	void (*UnmanageChild)(
629 #ifdef NeedFunctionPrototypes
630 		Widget				/* child */
631 #endif
632 	);
633 
634 	void	(*MoveWidget)(
635 #ifdef NeedFunctionPrototypes
636 		Widget				/* widget */,
637 		_XtPosition			/* x */,
638 		_XtPosition			/* y */
639 #endif
640 	);
641 
642 	void	(*ResizeWidget)(
643 #ifdef NeedFunctionPrototypes
644 		Widget				/* widget */,
645 		_XtDimension		/* width */,
646 		_XtDimension		/* height */,
647 		_XtDimension		/* border_width */
648 #endif
649 	);
650 
651 	void	(*ConfigureWidget)(
652 #ifdef NeedFunctionPrototypes
653 		Widget				/* widget */,
654 		_XtPosition			/* x */,
655 		_XtPosition			/* y */,
656 		_XtDimension		/* width */,
657 		_XtDimension		/* height */,
658 		_XtDimension		/* border_width */
659 #endif
660 	);
661 
662 	void	(*DestroyWidget)(
663 #ifdef NeedFunctionPrototypes
664 		 Widget				/* widget */
665 #endif
666 	);
667 
668 	void	(*SetMappedWhenManaged)(
669 #ifdef NeedFunctionPrototypes
670 		Widget				/* widget */,
671 		_XtBoolean			/* mapped_when_managed */
672 #endif
673 	);
674 
675 	void	(*RemoveTimeOut)(
676 #ifdef NeedFunctionPrototypes
677 		XtIntervalId		/* timer */
678 #endif
679 	);
680 
681 	XtIntervalId	(*AddTimeOut)(
682 #ifdef NeedFunctionPrototypes
683 		XtAppContext		/* app_context */,
684 		unsigned long		/* interval */,
685 		XtTimerCallbackProc	/* proc */,
686 		XtPointer			/* closure */
687 #endif
688 	);
689 
690 	/**********
691 	* Motif Wrappers
692 	**********/
693 
694 	void (*DrawShadows)(
695 #ifdef NeedFunctionPrototypes
696 		Display *display,
697 		Drawable d,
698 		GC top_gc,
699 		GC bottom_gc,
700 #if NeedWidePrototypes
701 		int x,
702 		int y,
703 		int width,
704 		int height,
705 		int shad_thick,
706 #else
707 		Position x,
708 		Position y,
709 		Dimension width,
710 		Dimension height,
711 		Dimension shad_thick,
712 #endif	/* NeedWidePrototypes */
713 		unsigned int shad_type
714 #endif
715 	);
716 
717 	/**********
718 	* Implementation Specific data
719 	**********/
720 	void *data;
721 
722 	void (*FreeData)(
723 #ifdef NeedFunctionPrototypes
724 		void*
725 #endif
726 	);
727 
728 }ToolkitAbstraction;
729 
730 /* Create a new toolkit abstraction */
731 extern ToolkitAbstraction *XmHTMLTkaCreate(void);
732 
733 /* destroy a toolkit abstraction */
734 extern void XmHTMLTkaDestroy(ToolkitAbstraction *tka);
735 
736 /* Copy a toolkit abstraction */
737 extern ToolkitAbstraction *XmHTMLTkaCopy(ToolkitAbstraction *tka);
738 
739 /* Supply a new toolkit abstraction to a XmHTML Widget */
740 #ifdef NOTYET
741 extern Boolean XmHTMLTkaSet(Widget w, ToolkitAbstraction *tka);
742 #endif
743 
744 /* Set the render area for a tka to use */
745 extern void XmHTMLTkaSetDrawable(ToolkitAbstraction *tka, Drawable drawable);
746 
747 /* Set the display area for a tka to use */
748 extern void XmHTMLTkaSetDisplay(ToolkitAbstraction *tka, Widget w);
749 
750 /* Recompute new top, bottom & highlight colors */
751 extern void XmHTMLTkaRecomputeColors(XmHTMLWidget html, Pixel bg_pixel);
752 
753 /* Recompute highlight color */
754 extern void XmHTMLTkaRecomputeHighlightColor(XmHTMLWidget html,
755 	Pixel bg_pixel);
756 
757 /* Recompute top & shadow colors */
758 extern void XmHTMLTkaRecomputeShadowColors(XmHTMLWidget html, Pixel base);
759 
760 /* Don't add anything after this endif! */
761 #endif /* _tka_h_ */
762 
763