1 | /* |
---|
2 | * Various stuff stolen from the X Toolkit... |
---|
3 | * |
---|
4 | * $Id: Jets.h,v 1.4 2004-02-25 21:21:37 rbasch Exp $ |
---|
5 | * |
---|
6 | * Copyright 1990, 1991 by the Massachusetts Institute of Technology. |
---|
7 | * |
---|
8 | * For copying and distribution information, please see the file |
---|
9 | * <mit-copyright.h>. |
---|
10 | * |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef _Xj_Jets_h |
---|
14 | #define _Xj_Jets_h |
---|
15 | |
---|
16 | #include <string.h> |
---|
17 | #include <X11/X.h> |
---|
18 | #include <X11/Xlib.h> |
---|
19 | #include <X11/Xutil.h> |
---|
20 | #include <X11/Xresource.h> |
---|
21 | |
---|
22 | #define Boolean int |
---|
23 | |
---|
24 | typedef void (*XjInitializeProc)(); |
---|
25 | typedef void (*XjPreRealizeProc)(); |
---|
26 | typedef void (*XjRealizeProc)(); |
---|
27 | typedef Boolean (*XjEventProc)(); |
---|
28 | typedef void (*XjExposeProc)(); |
---|
29 | typedef void (*XjQuerySizeProc)(); |
---|
30 | typedef void (*XjMoveProc)(); |
---|
31 | typedef void (*XjResizeProc)(); |
---|
32 | typedef void (*XjDestroyProc)(); |
---|
33 | typedef int (*XjCallbackProc)(); |
---|
34 | typedef void (*XjProc)(); |
---|
35 | |
---|
36 | #ifdef __STDC__ |
---|
37 | typedef void* XjPointer; |
---|
38 | #else |
---|
39 | typedef char* XjPointer; |
---|
40 | #endif |
---|
41 | |
---|
42 | typedef struct _XjCallbackRec |
---|
43 | { |
---|
44 | char *name; |
---|
45 | XjCallbackProc proc; |
---|
46 | } XjCallbackRec; |
---|
47 | |
---|
48 | #define argInt 0 |
---|
49 | #define argString 1 |
---|
50 | #define argPtr 2 |
---|
51 | |
---|
52 | typedef struct _XjCallback |
---|
53 | { |
---|
54 | struct _XjCallback *next; |
---|
55 | int argType; |
---|
56 | void *passPtr; |
---|
57 | char *passString; |
---|
58 | int passInt; |
---|
59 | XjCallbackProc proc; |
---|
60 | } XjCallback; |
---|
61 | |
---|
62 | typedef struct _XjPixmap |
---|
63 | { |
---|
64 | unsigned int width, height; |
---|
65 | int hot_x, hot_y; |
---|
66 | Pixmap pixmap; |
---|
67 | } XjPixmap; |
---|
68 | |
---|
69 | typedef struct _XjSize |
---|
70 | { |
---|
71 | int width, height; |
---|
72 | } XjSize; |
---|
73 | |
---|
74 | typedef struct _XjResource { |
---|
75 | char * resource_name; /* Resource name */ |
---|
76 | char * resource_class; /* Resource class */ |
---|
77 | char * resource_type; /* Representation type desired */ |
---|
78 | int resource_size; /* Size in bytes of representation */ |
---|
79 | int resource_offset;/* Offset from base to put resource value */ |
---|
80 | char * default_type; /* representation type of specified default */ |
---|
81 | caddr_t default_addr; /* Address of default resource */ |
---|
82 | } XjResource; |
---|
83 | |
---|
84 | typedef struct _CoreClassPart { |
---|
85 | char *className; /* name of this jet class */ |
---|
86 | int jetSize; |
---|
87 | XjInitializeProc classInitialize; |
---|
88 | int classInitialized; |
---|
89 | XjInitializeProc initialize; |
---|
90 | XjPreRealizeProc preRealize; |
---|
91 | XjRealizeProc realize; |
---|
92 | XjEventProc event; /* proc to pass jet's events to */ |
---|
93 | XjExposeProc expose; /* proc to pass exposes to; this |
---|
94 | is for jets without windows */ |
---|
95 | XjQuerySizeProc querySize; |
---|
96 | XjMoveProc move; |
---|
97 | XjResizeProc resize; |
---|
98 | XjDestroyProc destroy; |
---|
99 | XjResource *resources; /* location of resource table */ |
---|
100 | int num_resources; |
---|
101 | } CoreClassPart; |
---|
102 | |
---|
103 | typedef struct _JetClassRec { |
---|
104 | CoreClassPart core_class; |
---|
105 | } JetClassRec, CoreClassRec; |
---|
106 | |
---|
107 | typedef struct _JetClassRec *JetClass; |
---|
108 | |
---|
109 | #define XjNumber(n) ((sizeof(n) / sizeof(n[0]))) |
---|
110 | |
---|
111 | typedef struct _CorePart { |
---|
112 | JetClass classRec; /* class record for this jet inst */ |
---|
113 | char *name; /* instance name */ |
---|
114 | Display *display; /* display */ |
---|
115 | Window window; /* this instance's window (if any) */ |
---|
116 | int x, y; |
---|
117 | int width, height; |
---|
118 | int borderWidth; |
---|
119 | struct _JetRec *parent; /* parent of this jet */ |
---|
120 | struct _JetRec *sibling; /* next sibling */ |
---|
121 | struct _JetRec *child; /* first child */ |
---|
122 | Boolean need_expose; /* need an expose? (set by parent) */ |
---|
123 | } CorePart; |
---|
124 | |
---|
125 | typedef struct _JetRec { |
---|
126 | CorePart core; |
---|
127 | } JetRec, CoreRec; |
---|
128 | |
---|
129 | typedef struct _JetRec *Jet; |
---|
130 | |
---|
131 | #define XjParent(jet) ((jet)->core.parent) |
---|
132 | #define XjChild(jet) ((jet)->core.child) |
---|
133 | #define XjSibling(jet) ((jet)->core.sibling) |
---|
134 | #define XjWindow(jet) ((jet)->core.window) |
---|
135 | #define XjDisplay(jet) ((jet)->core.display) |
---|
136 | #define XjName(jet) ((jet)->core.name) |
---|
137 | |
---|
138 | typedef long XjArgVal; |
---|
139 | |
---|
140 | extern int global_argc; |
---|
141 | extern int malloced; |
---|
142 | extern char **global_argv; |
---|
143 | extern char *programName; |
---|
144 | extern char *programClass; |
---|
145 | extern char *displayName; |
---|
146 | extern XrmDatabase rdb; |
---|
147 | extern unsigned long writecolors[]; |
---|
148 | extern Colormap xjcolormap; |
---|
149 | |
---|
150 | #define XjColormap(j) xjcolormap |
---|
151 | #define XjGetColor(c) (writecolors[c]) |
---|
152 | #define XjNoColor -1 |
---|
153 | |
---|
154 | extern char *XjMalloc(), *XjRealloc(); |
---|
155 | extern Jet XjCreateRoot(); |
---|
156 | extern void XjVaGetValues(Jet jet, char *valName, ...); |
---|
157 | extern Jet XjVaCreateJet(char *name, JetClass class, Jet parent, |
---|
158 | char *valName, ...); |
---|
159 | extern Jet XjFindJet(); |
---|
160 | extern void XjReadCallback(); |
---|
161 | extern void XjLoadFromResources(); |
---|
162 | extern void XjSetSignalChecker(); |
---|
163 | extern void XjRealizeJet(); |
---|
164 | extern void XjDestroyJet(); |
---|
165 | extern void XjRegisterWindow(); |
---|
166 | extern void XjUnregisterWindow(); |
---|
167 | extern void XjSelectInput(); |
---|
168 | extern void XjEventLoop(); |
---|
169 | extern void XjFatalError(); |
---|
170 | extern void XjWarning(); |
---|
171 | extern void XjUsage(); |
---|
172 | extern int XjAddWakeup(); |
---|
173 | extern unsigned long XjRemoveWakeup(); |
---|
174 | extern void XjRegisterCallback(); |
---|
175 | extern void XjRegisterCallbacks(); |
---|
176 | extern void XjCallCallbacks(); |
---|
177 | extern void XjQuerySize(); |
---|
178 | extern void XjMove(); |
---|
179 | extern void XjResize(); |
---|
180 | extern XjCallbackProc XjGetCallback(); |
---|
181 | extern XjCallback *XjConvertStringToCallback(); |
---|
182 | extern void XjStdinCallback(); |
---|
183 | extern void XjExit(); |
---|
184 | |
---|
185 | #define XjNwidth "width" |
---|
186 | #define XjCWidth "Width" |
---|
187 | #define XjNheight "height" |
---|
188 | #define XjCHeight "Height" |
---|
189 | #define XjNx "x" |
---|
190 | #define XjCX "X" |
---|
191 | #define XjNy "y" |
---|
192 | #define XjCY "Y" |
---|
193 | #define XjNfont "font" |
---|
194 | #define XjCFont "Font" |
---|
195 | #define XjNforeground "foreground" |
---|
196 | #define XjCForeground "Foreground" |
---|
197 | #define XjNbackground "background" |
---|
198 | #define XjCBackground "Background" |
---|
199 | #define XjCCenter "Center" |
---|
200 | #define XjNcenterX "centerX" |
---|
201 | #define XjNcenterY "centerY" |
---|
202 | #define XjCJustify "Justify" |
---|
203 | #define XjNjustify "justify" |
---|
204 | #define XjNjustifyX "justifyX" |
---|
205 | #define XjNjustifyY "justifyY" |
---|
206 | #define XjCPixmap "Pixmap" |
---|
207 | #define XjNpixmap "pixmap" |
---|
208 | #define XjCPadding "Padding" |
---|
209 | #define XjNpadding "padding" |
---|
210 | #define XjCReverseVideo "ReverseVideo" |
---|
211 | #define XjNreverseVideo "reverseVideo" |
---|
212 | #define XjCHighlightProc "HighlightProc" |
---|
213 | #define XjNhighlightProc "highlightProc" |
---|
214 | #define XjNunHighlightProc "unHighlightProc" |
---|
215 | |
---|
216 | #define XjRInt "Int" |
---|
217 | #define XjRJustify "Justify" |
---|
218 | #define XjROrientation "Orientation" |
---|
219 | #define XjRDirection "Direction" |
---|
220 | #define XjRBoolean "Boolean" |
---|
221 | #define XjRString "String" |
---|
222 | #define XjRFontStruct "FontStruct" |
---|
223 | #define XjRFont "Font" |
---|
224 | #define XjRColor "Color" |
---|
225 | #define XjRCallback "Callback" |
---|
226 | #define XjRPixmap "Pixmap" |
---|
227 | #define XjRJet "Jet" |
---|
228 | |
---|
229 | #define XjDefaultFont "XjDefaultFont" |
---|
230 | #define XjNone "none" |
---|
231 | #define XjDefaultValue "-1" |
---|
232 | #define XjDefaultForeground "XjDefaultForeground" |
---|
233 | #define XjDefaultBackground "XjDefaultBackground" |
---|
234 | #define XjColor "color" |
---|
235 | #define XjLeftJustify "left" |
---|
236 | #define XjRightJustify "right" |
---|
237 | #define XjTopJustify "top" |
---|
238 | #define XjBottomJustify "bottom" |
---|
239 | #define XjCenterJustify "center" |
---|
240 | #define XjVertical "vertical" |
---|
241 | #define XjHorizontal "horizontal" |
---|
242 | #define XjNorth "north" |
---|
243 | #define XjNorthEast "northeast" |
---|
244 | #define XjEast "east" |
---|
245 | #define XjSouthEast "southeast" |
---|
246 | #define XjSouth "south" |
---|
247 | #define XjSouthWest "southwest" |
---|
248 | #define XjWest "west" |
---|
249 | #define XjNorthWest "northwest" |
---|
250 | |
---|
251 | #define Top -1 |
---|
252 | #define Bottom 1 |
---|
253 | #define Left -1 |
---|
254 | #define Right 1 |
---|
255 | #define Center 0 |
---|
256 | #define Vertical 0 |
---|
257 | #define Horizontal 1 |
---|
258 | |
---|
259 | #define North 0 |
---|
260 | #define NorthEast 1 |
---|
261 | #define East 2 |
---|
262 | #define SouthEast 3 |
---|
263 | #define South 4 |
---|
264 | #define SouthWest 5 |
---|
265 | #define West 6 |
---|
266 | #define NorthWest 7 |
---|
267 | |
---|
268 | #define XjCActivateProc "ActivateProc" |
---|
269 | #define XjNactivateProc "activateProc" |
---|
270 | |
---|
271 | #define XjInheritValue "-1" |
---|
272 | |
---|
273 | #define XjOffset(type,field) \ |
---|
274 | ((int) (((char *) (&(((type)NULL)->field))) - ((char *) NULL))) |
---|
275 | |
---|
276 | /* #define XjFree(ptr) free(ptr) */ |
---|
277 | #define XjCreatePixmap(d, r, w, h, p) XCreatePixmap((d), (r), (w), (h), (p)) |
---|
278 | #define XjFreePixmap(d, p) XFreePixmap((d), (p)) |
---|
279 | #define XjCreateGC(d, r, m, v) XCreateGC((d), (r), (m), (v)) |
---|
280 | #define XjFreeGC(d, gc) XFreeGC((d), (gc)) |
---|
281 | #define XjCreateFontCursor(d, s) XCreateFontCursor((d), (s)) |
---|
282 | #define XjFreeCursor(d, c) XFreeCursor((d), (c)) |
---|
283 | #define XjFreeStringList(p) XFreeStringList((p)) |
---|
284 | |
---|
285 | #define XjNewString(str) \ |
---|
286 | ((str) != NULL ? (strcpy(XjMalloc((unsigned)strlen(str) + 1), str)) : NULL) |
---|
287 | |
---|
288 | #ifndef MIN |
---|
289 | #define MIN(x, y) (((x) < (y)) ? (x) : (y)) |
---|
290 | #endif |
---|
291 | #ifndef MAX |
---|
292 | #define MAX(x, y) (((x) > (y)) ? (x) : (y)) |
---|
293 | #endif |
---|
294 | |
---|
295 | /* |
---|
296 | * Root specific records... |
---|
297 | */ |
---|
298 | extern JetClass rootJetClass; |
---|
299 | |
---|
300 | typedef struct {int littlefoo;} RootClassPart; |
---|
301 | |
---|
302 | typedef struct _RootClassRec { |
---|
303 | CoreClassPart core_class; |
---|
304 | RootClassPart root_class; |
---|
305 | } RootClassRec; |
---|
306 | |
---|
307 | extern RootClassRec rootClassRec; |
---|
308 | |
---|
309 | typedef struct _RootRec { |
---|
310 | CorePart core; |
---|
311 | } RootRec; |
---|
312 | |
---|
313 | typedef struct _RootRec *RootJet; |
---|
314 | typedef struct _RootClassRec *RootJetClass; |
---|
315 | |
---|
316 | #define XjCRoot "Root" |
---|
317 | |
---|
318 | #endif /* _Xj_Jets_h */ |
---|