|
|
1.1 root 1: /*
2: * $Header: Intrinsic.h,v 1.32 87/09/13 20:36:19 newman Exp $
3: */
4:
5: /*
6: * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
7: *
8: * All Rights Reserved
9: *
10: * Permission to use, copy, modify, and distribute this software and its
11: * documentation for any purpose and without fee is hereby granted,
12: * provided that the above copyright notice appear in all copies and that
13: * both that copyright notice and this permission notice appear in
14: * supporting documentation, and that the name of Digital Equipment
15: * Corporation not be used in advertising or publicity pertaining to
16: * distribution of the software without specific, written prior permission.
17: *
18: *
19: * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
20: * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
21: * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
22: * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23: * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24: * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
25: * SOFTWARE.
26: */
27: #ifndef _Xtintrinsic_h
28: #define _Xtintrinsic_h
29:
30:
31: /****************************************************************
32: ****************************************************************
33: *** ***
34: *** ***
35: *** X Toolkit Intrinsics ***
36: *** ***
37: *** ***
38: ****************************************************************
39: ****************************************************************/
40: /****************************************************************
41: *
42: * Miscellaneous definitions
43: *
44: ****************************************************************/
45:
46:
47: #include <X11/Xlib.h>
48: #include <X11/Xresource.h>
49: #include <sys/types.h>
50:
51: #ifndef NULL
52: #define NULL 0
53: #endif
54:
55:
56: #ifndef FALSE
57: #define FALSE 0
58: #define TRUE 1
59: #endif
60:
61: #define XtNumber(arr) ((Cardinal) (sizeof(arr) / sizeof(arr[0])))
62: #define XtOffset(type,field) ((unsigned int)&(((type)NULL)->field))
63: typedef char *String;
64: typedef struct _WidgetRec *Widget;
65: typedef struct _WidgetClassRec *WidgetClass;
66: typedef struct _CompositeRec *CompositeWidget;
67: typedef struct _XtEventRec *_XtEventTable;
68: typedef struct _XtActionsRec *XtActionList;
69: typedef struct _XtResource *XtResourceList;
70: typedef struct _GrabRec *GrabList;
71: typedef unsigned int Cardinal;
72: typedef char Boolean;
73: typedef unsigned long *Opaque;
74: typedef struct _TranslationData *_XtTranslations;
75: typedef struct _XtCallbackRec* XtCallbackList;
76: typedef unsigned long XtCallbackKind;
77: typedef unsigned long XtValueMask;
78: typedef unsigned long XtIntervalId;
79: typedef unsigned int XtGeometryMask;
80: typedef unsigned long XtGCMask; /* Mask of values that are used by widget*/
81: typedef unsigned long Pixel; /* Index into colormap */
82: typedef int Position; /* Offset from 0 coordinate */
83: typedef unsigned int Dimension; /* Size in pixels */
84: /* should be unsigned, but pcc */
85: /* generates bad code for unsigned? */
86:
87: typedef void (*XtProc)();
88: /* takes no arguments */
89:
90: typedef void (*XtWidgetProc)();
91: /* Widget widget */
92:
93: typedef void (*XtArgsProc)();
94: /* Widget widget */
95: /* ArgList args */
96: /* Cardinal num_args */
97:
98: typedef void (*XtInitProc)();
99: /* Widget requestWidget; */
100: /* Widget newWidget; */
101: /* ArgList args */
102: /* Cardinal num_args */
103:
104: typedef Boolean (*XtSetValuesProc)(); /* returns TRUE if redisplay needed */
105: /* Widget widget; */
106: /* Widget request; */
107: /* Widget new; */
108: /* Boolean last; */
109:
110: typedef void (*XtExposeProc)();
111: /* Widget widget; */
112: /* XEvent *event; */
113:
114: typedef void (*XtRealizeProc) ();
115: /* Widget widget; */
116: /* XtValueMask mask; */
117: /* XSetWindowAttributes *attributes; */
118:
119: typedef enum {
120: XtGeometryYes, /* Request accepted. */
121: XtGeometryNo, /* Request denied. */
122: XtGeometryAlmost, /* Request denied, but willing to take replyBox. */
123: } XtGeometryResult;
124:
125: typedef XtGeometryResult (*XtGeometryHandler)();
126: /* Widget widget */
127: /* XtWidgetGeometry *request */
128: /* XtWidgetGeometry *reply */
129:
130: /****************************************************************
131: *
132: * System Dependent Definitions
133: *
134: *
135: * XtArgVal ought to be a union of caddr_t, char *, long, int *, and proc *
136: * but casting to union types is not really supported.
137: *
138: * So the typedef for XtArgVal should be chosen such that
139: *
140: * sizeof (XtArgVal) >= sizeof(caddr_t)
141: * sizeof(char *)
142: * sizeof(long)
143: * sizeof(int *)
144: * sizeof(proc *)
145: *
146: * ArgLists rely heavily on the above typedef.
147: *
148: ****************************************************************/
149: typedef long XtArgVal;
150:
151: /***************************************************************
152: * Widget Core Data Structures
153: *
154: *
155: **************************************************************/
156:
157: typedef struct _CorePart {
158: WidgetClass widget_class; /* pointer to Widget's ClassRec */
159: Widget parent; /* parent widget */
160: String name; /* widget resource name */
161: XrmName xrm_name; /* widget resource name quarkified */
162: Screen *screen; /* window's screen */
163: Window window; /* window ID */
164: Position x, y; /* window position */
165: Dimension width, height; /* window dimensions */
166: Cardinal depth; /* number of planes in window */
167: Dimension border_width; /* window border width */
168: Pixel border_pixel; /* window border pixel */
169: Pixmap border_pixmap; /* window border pixmap or NULL */
170: Pixel background_pixel; /* window background pixel */
171: Pixmap background_pixmap; /* window background pixmap or NULL */
172: _XtEventTable event_table; /* private to event dispatcher */
173: _XtTranslations translations; /* private to Translation Manager */
174: Boolean visible; /* is window mapped and not occluded?*/
175: Boolean sensitive; /* is widget sensitive to user events*/
176: Boolean ancestor_sensitive; /* are all ancestors sensitive? */
177: Boolean managed; /* is widget geometry managed? */
178: Boolean mapped_when_managed;/* map window if it's managed? */
179: Boolean being_destroyed; /* marked for destroy */
180: XtCallbackList destroy_callbacks; /* who to call when widget destroyed */
181: } CorePart;
182:
183: typedef struct _WidgetRec {
184: CorePart core;
185: } WidgetRec;
186:
187: typedef Widget *WidgetList;
188:
189: /******************************************************************
190: *
191: * Core Class Structure. Widgets, regardless of their class, will have
192: * these fields. All widgets of a given class will have the same values
193: * for these fields. Widgets of a given class may also have additional
194: * common fields. These additional fields are included in incremental
195: * class structures, such as CommandClass.
196: *
197: * The fields that are specific to this subclass, as opposed to fields that
198: * are part of the superclass, are called "subclass fields" below. Many
199: * procedures are responsible only for the subclass fields, and not for
200: * any superclass fields.
201: *
202: ********************************************************************/
203:
204: typedef struct _CoreClassPart {
205: WidgetClass superclass; /* pointer to superclass ClassRec */
206: String class_name; /* widget resource class name */
207: Cardinal widget_size; /* size in bytes of widget record */
208: XtProc class_initialize; /* class initialization proc */
209: Boolean class_inited; /* has class been initialized? */
210: XtInitProc initialize; /* initialize subclass fields */
211: XtRealizeProc realize; /* XCreateWindow for widget */
212: XtActionList actions; /* widget semantics name to proc map */
213: Cardinal num_actions; /* number of entries in actions */
214: XtResourceList resources; /* resources for subclass fields */
215: Cardinal num_resources; /* number of entries in resources */
216: XrmClass xrm_class; /* resource class quarkified */
217: Boolean compress_motion; /* compress MotionNotify for widget */
218: Boolean compress_exposure; /* compress Expose events for widget */
219: Boolean visible_interest; /* select for VisibilityNotify */
220: XtWidgetProc destroy; /* free data for subclass pointers */
221: XtWidgetProc resize; /* geom manager changed widget size */
222: XtExposeProc expose; /* rediplay window */
223: XtSetValuesProc set_values; /* set subclass resource values */
224: XtWidgetProc accept_focus; /* assign input focus to widget */
225: } CoreClassPart;
226:
227: typedef struct _WidgetClassRec {
228: CoreClassPart core_class;
229: } WidgetClassRec;
230:
231: extern WidgetClassRec widgetClassRec;
232: extern WidgetClass widgetClass;
233:
234: /************************************************************************
235: *
236: * Additional instance fields for widgets of (sub)class 'Composite'
237: *
238: ************************************************************************/
239:
240: typedef Cardinal (*XtOrderProc)();
241: /* Widget child; */
242:
243:
244: typedef struct _CompositePart {
245: WidgetList children; /* array of ALL widget children */
246: Cardinal num_children; /* total number of widget children */
247: Cardinal num_slots; /* number of slots in children array */
248: Cardinal num_mapped_children; /* count of managed and mapped children */
249: XtOrderProc insert_position; /* compute position of new child */
250: } CompositePart;
251:
252: typedef struct _CompositeRec {
253: CorePart core;
254: CompositePart composite;
255: } CompositeRec;
256:
257: typedef struct _ConstraintPart {
258: caddr_t mumble; /* No new fields, keep C compiler happy */
259: } ConstraintPart;
260:
261: typedef struct _ConstraintRec {
262: CorePart core;
263: CompositePart composite;
264: ConstraintPart constraint;
265: } ConstraintRec, *ConstraintWidget;
266:
267: /*********************************************************************
268: *
269: * Additional class fields for widgets of (sub)class 'Composite'
270: *
271: ********************************************************************/
272:
273: typedef struct _CompositeClassPart {
274: XtGeometryHandler geometry_manager; /* geometry manager for children */
275: XtWidgetProc change_managed; /* change managed state of child */
276: XtArgsProc insert_child; /* physically add child to parent */
277: XtWidgetProc delete_child; /* physically remove child */
278: XtWidgetProc move_focus_to_next; /* move Focus to next child */
279: XtWidgetProc move_focus_to_prev; /* move Focus to previous child */
280: } CompositeClassPart;
281:
282: typedef struct _CompositeClassRec {
283: CoreClassPart core_class;
284: CompositeClassPart composite_class;
285: } CompositeClassRec, *CompositeWidgetClass;
286:
287: extern CompositeClassRec compositeClassRec;
288: extern CompositeWidgetClass compositeWidgetClass;
289:
290:
291: typedef struct _ConstraintClassPart {
292: XtResourceList constraints; /* constraint resource list */
293: Cardinal num_constraints; /* number of constraints in list */
294: } ConstraintClassPart;
295:
296: typedef struct _ConstraintClassRec {
297: CoreClassPart core_class;
298: CompositeClassPart composite_class;
299: ConstraintClassPart constraint_class;
300: } ConstraintClassRec, *ConstraintWidgetClass;
301:
302: extern ConstraintClassRec constraintClassRec;
303: extern ConstraintWidgetClass constraintWidgetClass;
304:
305: /*************************************************************************
306: *
307: * Generic Procedures
308: *
309: *************************************************************************/
310:
311:
312: extern Boolean XtIsSubclass ();
313: /* Widget widget; */
314: /* WidgetClass widgetClass; */
315:
316: /* Some macros to get frequently used components of a widget */
317:
318: #define XtDisplay(widget) ((widget)->core.screen->display)
319: #define XtScreen(widget) ((widget)->core.screen)
320: #define XtWindow(widget) ((widget)->core.window)
321: #define XtMapWidget(widget) XMapWindow(XtDisplay(widget), XtWindow(widget))
322: #define XtUnmapWidget(widget) \
323: XUnmapWindow(XtDisplay(widget), XtWindow(widget))
324: #define XtIsComposite(widget) \
325: XtIsSubclass(widget, (WidgetClass)compositeWidgetClass)
326: #define XtClass(widget) ((widget)->core.widget_class)
327: #define XtSuperclass(widget) (XtClass(widget)->core_class.superclass)
328:
329: extern Widget XtCreateWidget ();
330: /* String name; */
331: /* WidgetClass widgetClass; */
332: /* Widget parent; */
333: /* ArgList args; */
334: /* Cardinal num_args; */
335:
336: extern Widget TopLevelCreate (); /*hack for now*/
337: /* String name; */
338: /* WidgetClass widgetClass; */
339: /* Screen *screen;*/
340: /* ArgList args; */
341: /* Cardinal num_args; */
342:
343:
344:
345: extern void XtRealizeWidget ();
346: /* Widget widget */
347:
348: extern Boolean XtIsRealized ();
349: /* Widget widget; */
350:
351: extern void XtDestroyWidget ();
352: /* Widget widget */
353:
354: extern void XtSetSensitive ();
355: /* Widget widget; */
356: /* Boolean sensitive; */
357:
358: extern void XtSetMappedWhenManaged ();
359: /* Widget widget; */
360: /* Boolean mappedWhenManaged; */
361:
362: /**********************************************************
363: *
364: * Composite widget Procedures
365: *
366: **********************************************************\
367:
368:
369: extern void XtManageChildren ();
370: /* WidgetList children; */
371: /* Cardinal num_children; */
372:
373: extern void XtManageChild ();
374: /* Widget child; */
375:
376: extern void XtUnmanageChildren ();
377: /* WidgetList children; */
378: /* Cardinal num_children; */
379:
380: extern void XtUnmanageChild ();
381: /* Widget child; */
382:
383:
384: /*************************************************************
385: *
386: * Callbacks
387: *
388: **************************************************************/
389:
390: typedef void (*XtCallbackProc)();
391: /* Widget widget; */
392: /* caddr_t closure; data the application registered */
393: /* caddr_t callData; widget instance specific data passed to application*/
394:
395: typedef struct _XtCallbackRec {
396: XtCallbackList next;
397: Widget widget;
398: XtCallbackProc callback;
399: Opaque closure;
400: }XtCallbackRec;
401:
402: extern XtCallbackKind XtNewCallbackKind();
403: /* WidegtClass widgetClass; */
404: /* Cardinal offset; */
405:
406: extern void XtAddCallback ();
407: /* Widget widget; */
408: /* XtCallbackKind callbackKind; */
409: /* XtCallbackProc callback; */
410: /* caddr_t closure; */
411:
412: extern void XtRemoveCallback ();
413: /* Widget widget; */
414: /* XtCallbackKind callbackKind; */
415: /* XtCallbackProc callback; */
416: /* caddr_t closure; */
417:
418:
419: extern void XtRemoveAllCallbacks ();
420: /* Widget widget; */
421: /* XtCallbackKind callbackKind; */
422:
423: extern void XtCallCallbacks ();
424: /* Widget widget; */
425: /* XtCallbackKind callbackKind; */
426: /* caddr_t callData */
427:
428: /****************************************************************
429: *
430: * Toolkit initialization
431: *
432: ****************************************************************/
433:
434: extern Widget XtInitialize();
435: /* XtAtom name; */
436: /* XtAtom class; */
437: /* XrmOptionsDescRec options; */
438: /* Cardinal num_options; */
439: /* Cardinal *argc; */ /* returns count of args not processed */
440: /* char **argv; */
441:
442: /****************************************************************
443: *
444: * Memory Management
445: *
446: ****************************************************************/
447:
448: extern char *XtMalloc(); /* size */
449: /* Cardinal size; */
450:
451: extern char *XtCalloc(); /* num, size */
452: /* Cardinal num, size; */
453:
454: extern char *XtRealloc(); /* ptr, num */
455: /* char *ptr; */
456: /* Cardinal num; */
457:
458: extern void XtFree(); /* ptr */
459: /* char *ptr */
460:
461:
462: /****************************************************************
463: *
464: * Arg lists
465: *
466: ****************************************************************/
467:
468: typedef struct {
469: String name;
470: XtArgVal value;
471: } Arg, *ArgList;
472:
473: #define XtSetArg(arg, n, d) \
474: ( (arg).name = (n), (arg).value = (XtArgVal)(d) )
475:
476: extern ArgList XtMergeArgLists(); /* args1, num_args1, args2, num_args2 */
477: /* ArgList args1; */
478: /* int num_args1; */
479: /* ArgList args2; */
480: /* int num_args2; */
481:
482:
483:
484: /****************************************************************
485: *
486: * Event Management
487: *
488: ****************************************************************/
489:
490: /* ||| Much of this should be private */
491: XtCallbackList DestroyList;
492: Display *toplevelDisplay;
493: typedef unsigned long EventMask;
494:
495: typedef enum {pass,ignore,remap} GrabType;
496: typedef void (*XtEventHandler)(); /* widget, closure, event */
497: /* Widget widget */
498: /* caddr_t closure */
499: /* XEvent *event; */
500:
501: typedef struct _XtEventRec {
502: _XtEventTable next;
503: EventMask mask;
504: Boolean non_filter;
505: XtEventHandler proc;
506: Opaque closure;
507: }XtEventRec;
508:
509: typedef struct _GrabRec {
510: GrabList next;
511: Widget widget;
512: Boolean exclusive;
513: }GrabRec;
514:
515: typedef struct _MaskRec {
516: EventMask mask;
517: GrabType grabType;
518: Boolean sensitive;
519: }MaskRec;
520: #define is_sensitive TRUE
521: #define not_sensitive FALSE
522: GrabRec *grabList;
523:
524: extern EventMask _XtBuildEventMask(); /* widget */
525: /* Widget widget; */
526:
527: extern void XtAddEventHandler(); /* widget, eventMask, other, proc, closure */
528: /* Widget widget */
529: /* EventMask eventMask; */
530: /* Boolean other; */
531: /* XtEventHandler proc; */
532: /* caddr_t closure ; */
533:
534:
535: extern void XtRemoveEventHandler(); /* widget,eventMask,other,proc,closure */
536: /* Widget widget */
537: /* EventMask eventMask; */
538: /* Boolean other; */
539: /* XtEventHandler proc; */
540: /* caddr_t closure ; */
541:
542:
543: extern void XtDispatchEvent(); /* event */
544: /* XEvent *event; */
545:
546: extern void XtMainLoop();
547:
548: /****************************************************************
549: *
550: * Event Gathering Routines
551: *
552: ****************************************************************/
553:
554: typedef unsigned long XtInputMask;
555:
556: #define XtInputNoneMask 0L
557: #define XtInputReadMask (1L<<0)
558: #define XtInputWriteMask (1L<<1)
559: #define XtInputExceptMask (1L<<2)
560:
561: extern Atom XtHasInput;
562: extern Atom XtTimerExpired;
563:
564: extern XtIntervalId XtAddTimeOut();
565: /* Widget widget; */
566: /* unsigned long interval; */
567:
568: extern void XtRemoveTimeOut();
569: /* XtIntervalId timer; */
570:
571: extern unsigned long XtGetTimeOut();
572: /* XtIntervalId timer; */
573:
574: extern void XtAddInput(); /* widget, source, condition */
575: /* Widget widget */
576: /* int source; */
577: /* XtInputMask inputMask; */
578:
579: extern void XtRemoveInput(); /* widget, source, condition */
580: /* Widget widget */
581: /* int source; */
582: /* XtInputMask inputMask; */
583:
584: extern void XtNextEvent(); /* event */
585: /* XtEvent *event; */
586:
587: extern XtPeekEvent(); /* event */
588: /* XtEvent *event; */
589:
590: extern Boolean XtPending ();
591:
592:
593: /****************************************************************
594: *
595: * Geometry Management
596: *
597: ****************************************************************/
598:
599: #define XtDontChange 5 /* don't change the stacking order stack_mode */
600:
601: typedef struct {
602: XtGeometryMask request_mode;
603: Position x, y;
604: Dimension width, height, border_width;
605: Widget sibling;
606: int stack_mode; /* Above, Below, TopIf, BottomIf, Opposite */
607: } XtWidgetGeometry;
608:
609:
610: extern XtGeometryResult XtMakeGeometryRequest();
611: /* widget, request, reply */
612: /* Widget widget; */
613: /* XtWidgetGeometry *request; */
614: /* XtWidgetGeometry *reply; /* RETURN */
615:
616: extern XtGeometryResult XtMakeResizeRequest ();
617: /* Widget widget; */
618: /* Dimension width, height; */
619: /* Dimension *replyWidth, *replyHeight; */
620:
621: extern void XtResizeWindow(); /* widget */
622: /* Widget widget; */
623:
624: extern void XtResizeWidget(); /* widget, width, height, borderWidth */
625: /* Widget widget */
626: /* Dimension width, height, borderWidth; */
627:
628: extern void XtMoveWidget(); /* widget, x, y */
629: /* Widget widget */
630: /* Position x, y */
631:
632:
633: /****************************************************************
634: *
635: * Graphic Context Management
636: *****************************************************************/
637:
638: extern GC XtGetGC(); /* widget, valueMask, values */
639: /* Widget widget */
640: /* XtGCMask valueMask; */
641: /* XGCValues *values; */
642:
643: extern void XtDestroyGC ();
644: /* GC gc; */
645:
646: /****************************************************************
647: *
648: * Resources
649: *
650: ****************************************************************/
651:
652: #define StringToQuark(string) XrmAtomToQuark(string)
653: #define StringToName(string) XrmAtomToName(string)
654: #define StringToClass(string) XrmAtomToClass(string)
655:
656: typedef struct _XtResource {
657: String resource_name; /* Resource name */
658: String resource_class; /* Resource class */
659: String resource_type; /* Representation type desired */
660: Cardinal resource_size; /* Size in bytes of representation */
661: Cardinal resource_offset;/* Offset from base to put resource value */
662: String default_type; /* representation type of specified default */
663: caddr_t default_addr; /* Address of default resource */
664: } XtResource;
665:
666:
667: extern void XtGetResources();
668: /* Widget widget; */
669: /* ArgList args; */
670: /* int num_args; */
671:
672: extern void XtReadBinaryDatabase ();
673: /* FILE *f; */
674: /* ResourceDatabase *db; */
675:
676: extern void XtWriteBinaryDatabase ();
677: /* FILE *f; */
678: /* ResourceDatabase db; */
679:
680: extern void XtSetValues();
681: /* Widget widget; */
682: /* ArgList args; */
683: /* int num_args; */
684:
685: extern void XtGetValues();
686: /* Widget widget; */
687: /* ArgList args; */
688: /* Cardinal num_args; */
689:
690: extern Widget XtStringToWidget ();
691: /* String s; */
692:
693: extern WidgetClass XtStringToClass ();
694: /* String s; */
695:
696:
697:
698: /****************************************************************
699: *
700: * Translation Management
701: *
702: ****************************************************************/
703:
704: typedef struct _XtActionsRec{
705: char *string;
706: caddr_t value;
707: } XtActionsRec;
708:
709: /* ||| Should be private */
710: extern void XtDefineTranslation ();
711: /* Widget widget */
712:
713: /*************************************************************
714: *
715: * Error Handling
716: *
717: ************************************************************/
718:
719:
720: extern void XtSetErrorHandler(); /* errorProc */
721: /* (*errorProc)(String); */
722:
723: extern void XtError(); /* message */
724: /* String message */
725:
726: extern void XtSetWarningHandler(); /* errorProc */
727: /* (*errorProc)(String); */
728:
729: extern void XtWarning(); /* message */
730: /* String message */
731:
732:
733: #endif _Xtintrinsic_h
734: /* DON'T ADD STUFF AFTER THIS #endif */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.