1 /*****
2 * toolkit.h : XmHTML Motif function & data type wrappers
3 *
4 * This file Version	$Revision$
5 *
6 * Creation date:		Thu Jan  8 04:32:19 GMT+0100 1998
7 * Last modification: 	$Date$
8 * By:					$Author$
9 * Current State:		$State$
10 *
11 * Author:				newt
12 *
13 * Copyright (C) 1994-1997 by Ripley Software Development
14 * All Rights Reserved
15 *
16 * This file is part of the XmHTML Widget Library
17 *
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Library 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 library 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 * Library General Public License for more details.
27 *
28 * You should have received a copy of the GNU Library General Public
29 * License along with this library; if not, write to the Free
30 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 *
32 * About this file:
33 *
34 *	XmHTML is originally an Xt/Motif based Widget. To make porting to
35 *	other toolkits a bit easier, XmHTML uses a toolkit abstraction and a
36 *	set of defines that allow you to replace all X/Xt/Xm functions used by
37 *	XmHTML.
38 *
39 *	All Xt/Xm functions are wrapped together in what I call a
40 *	ToolkitAbstraction (see XmHTMLP.h for the definition and motif.c for
41 *	the Motif ToolkitAbstraction).
42 *
43 *	There is one assumption though: that you never include a header containing
44 *	Xt or Xm specifics. If you do this however, you will need to override
45 *	a whole bunch of routines, typedefs and constants (don't worry, they
46 *	are all listed).
47 *
48 *****/
49 /*****
50 * $Source$
51 *****/
52 /*****
53 * ChangeLog
54 * $Log$
55 * Revision 1.1  2011/06/30 16:08:41  rwcox
56 * Cadd
57 *
58 * Revision 1.2  1998/04/27 07:03:52  newt
59 * more tka stuff
60 *
61 * Revision 1.1  1998/04/04 06:27:29  newt
62 * Initial Revision
63 *
64 *****/
65 
66 #ifndef _toolkit_h_
67 #define _toolkit_h_
68 
69 #define XmHTMLPrivateHeader "XmHTML/XmHTMLP.h"
70 #define HAVE_XCCP_H
71 
72 /* Every XmHTML source file requires these two X11 includes */
73 #include <X11/Xlib.h>
74 #include <X11/Intrinsic.h>
75 #include <X11/IntrinsicP.h>
76 
77 /*****
78 * X types & constants
79 * We need defines for these as typedefs would lead to a tremendous amount
80 * of warnings (with most compilers that is). Lint would go absolutely crazy...
81 *****/
82 
83 /* common types */
84 #define XCOLOR					XColor
85 #define COLORMAP				Colormap
86 #define PIXMAP					Pixmap
87 #define WINDOW					Window
88 #define DRAWABLE				Drawable
89 #define XIMAGE					XImage
90 #define XFONTSTRUCT				XFontStruct
91 #define XFONTSET				XFontSet
92 #define VISUAL					Visual
93 #define XGC						GC
94 #define XCHARSTRUCT				XCharStruct
95 
96 #define XEVENT					XEvent
97 #define XBUTTONPRESSEDEVENT		XButtonPressedEvent
98 #define XBUTTONRELEASEDEVENT	XButtonReleasedEvent
99 
100 /* byte ordering for this host */
101 #define LSBFIRST					LSBFirst
102 #define MSBFIRST					MSBFirst
103 
104 /* Color access macros */
105 #define GETP(c)	(c).pixel
106 #define GETR(c)	(c).red
107 #define GETG(c)	(c).green
108 #define GETB(c)	(c).blue
109 #define GETF(c)	(c).flags
110 
111 #define GETPP(c)	(c)->pixel
112 #define GETPR(c)	(c)->red
113 #define GETPG(c)	(c)->green
114 #define GETPB(c)	(c)->blue
115 #define GETPF(c)	(c)->flags
116 
117 /*****
118 * This macro should return a XFontStruct
119 *****/
120 #define FontIsXFont(font)			font
121 
122 #define XTEVENTPROC(f,a,b,c,d) \
123 	f(a,b,c,d)
124 
125 /*****
126 * Xlib Function Wrappers
127 *****/
128 
129 #define TkaCurrentTime CurrentTime
130 
131 /*****
132 * XFontStruct access macro's
133 *****/
134 #define TkaFont(XF)				((XF)->xfont)
135 #define TkaFontLeftBearing(XF)	((XF)->max_bounds.lbearing)
136 #define TkaFontRightBearing(XF)	((XF)->max_bounds.rbearing)
137 #define TkaFontWidth(XF)		((XF)->max_bounds.width)
138 #define TkaFontAscent(XF)		((XF)->ascent)
139 #define TkaFontDescent(XF)		((XF)->descent)
140 #define TkaFontMaxAscent(XF)	((XF)->max_bounds.ascent)
141 #define TkaFontMaxDescent(XF)	((XF)->max_bounds.descent)
142 #define TkaFontLineheight(XF)	((XF)->ascent + (XF)->descent)
143 
144 /*****
145 * XImage wrappers & access macros.
146 *****/
147 
148 #define TkaImageData(image) \
149 	(image->data)
150 
151 #define TkaImageBitsPerPixel(image) \
152 	(image->bits_per_pixel)
153 
154 #define TkaImageBytesPerLine(image) \
155 	(image->bytes_per_line)
156 
157 #define TkaImageByteOrder(image) \
158 	(image->byte_order)
159 
160 #define TkaImageBitmapBitOrder(image) \
161 	(image->bitmap_bit_order)
162 
163 /* check support for various combinations of bits per pixel */
164 #define TkaImageCheck2bpp(image) \
165 	(image->bits_per_pixel == 2)
166 
167 #define TkaImageCheck4bpp(image) \
168 	(image->bits_per_pixel == 4)
169 
170 #define TkaImageCheck24bpp(image) \
171 	(image->bits_per_pixel == 24)
172 
173 #define TkaImageCheck32bpp(image) \
174 	(image->bits_per_pixel == 32)
175 
176 /*****
177 * Xt Function wrappers
178 *****/
179 
180 #define TkaWidgetName(w)		XtName((Widget)w)
181 #define TkaWidgetClassName(w)	(XtClass((Widget)w)->core_class.class_name)
182 
183 /* Check for the presence of a callback function */
184 #define TkaHasCallback(W,D) ATTR_HTML(W, D)
185 
186 /* Activate a callback function */
187 #define TkaCallCallbackList(W,C,D) \
188 	XtCallCallbackList((Widget)W, ATTR_HTML(W,C##_callback), D)
189 
190 /* Set the position of a scrollbar slider */
191 #define TkaScrollbarSliderSetPosition(W,V) \
192 	XtVaSetValues(W, XmNvalue, V, NULL)
193 
194 /*****
195 * Motif wrappers
196 *****/
197 
198 /* none */
199 
200 /*****
201 * Widget internal access wrappers
202 *****/
203 
204 /* Main access method. *REQUIRES* a variable of html to be known */
205 #define HTML_ATTR(field)	((XmHTMLWidget)html)->html.field
206 #define CORE_ATTR(field)	((Widget)html)->core.field
207 #define MGR_ATTR(field)		((XmHTMLWidget)html)->manager.field
208 
209 /* subclass access methods */
210 #define ATTR_CORE(widget,field) \
211 	(widget)->core.field
212 
213 #define ATTR_MGR(widget,field) \
214 	(widget)->manager.field
215 
216 #define ATTR_HTML(widget,field) \
217 	((XmHTMLWidget)widget)->html.field
218 
219 /* widely used subclass properties */
220 
221 /* get XFont used by the default XmHTMLFont */
222 #define GetDefaultXFont(widget) \
223 	ATTR_HTML(widget,default_font->xfont)
224 
225 #define TkaGetBackground(widget) \
226 	ATTR_CORE(widget,background_pixel)
227 
228 #define TkaGetColormap(widget) ATTR_CORE(widget,colormap)
229 
230 #define TkaVisualGetDepth(widget) \
231 	ATTR_HTML(widget,xcc->visualInfo->depth)
232 
233 #define TkaVisualGetMapEntries(visual) \
234 	visual->map_entries
235 
236 /* Don't add anything after this endif! */
237 #endif /* _toolkit_h_ */
238