1/*
2 * Copyright (c) 1998 by The XFree86 Project, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17 * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 *
22 * Except as contained in this notice, the name of the XFree86 Project shall
23 * not be used in advertising or otherwise to promote the sale, use or other
24 * dealings in this Software without prior written authorization from the
25 * XFree86 Project.
26 */
27
28#ifndef _XawPrivate_h
29#define _XawPrivate_h
30
31#define XawMax(a, b) ((a) > (b) ? (a) : (b))
32#define XawMin(a, b) ((a) < (b) ? (a) : (b))
33#define XawAbs(a)    ((a) < 0 ? -(a) : (a))
34
35#define XawStackAlloc(size, stk_buffer)		\
36((size) <= sizeof(stk_buffer)			\
37 ? (XtPointer)(stk_buffer)			\
38 : XtMalloc((Cardinal)(size)))
39
40#define XawStackFree(pointer, stk_buffer)	\
41do {						\
42  if ((pointer) != (XtPointer)(stk_buffer))	\
43    XtFree((char *)pointer);			\
44} while (0)
45
46#ifndef XtX
47#define XtX(w)            (((RectObj)w)->rectangle.x)
48#endif
49#ifndef XtY
50#define XtY(w)            (((RectObj)w)->rectangle.y)
51#endif
52#ifndef XtWidth
53#define XtWidth(w)        (((RectObj)w)->rectangle.width)
54#endif
55#ifndef XtHeight
56#define XtHeight(w)       (((RectObj)w)->rectangle.height)
57#endif
58#ifndef XtBorderWidth
59#define XtBorderWidth(w)  (((RectObj)w)->rectangle.border_width)
60#endif
61
62#ifndef OLDXAW
63#define XAW_PRIV_VAR_PREFIX '$'
64
65typedef Bool (*XawParseBooleanProc)(Widget, String, XEvent*, Bool*);
66
67typedef struct _XawActionVarList XawActionVarList;
68typedef struct _XawActionResList XawActionResList;
69
70/* Boolean expressions */
71Bool XawParseBoolean(Widget, String, XEvent*, Bool*);
72Bool XawBooleanExpression(Widget, String, XEvent*);
73
74/* actions */
75void XawPrintActionErrorMsg(String, Widget, String*, Cardinal*);
76XawActionResList *XawGetActionResList(WidgetClass);
77XawActionVarList *XawGetActionVarList(Widget);
78
79void XawSetValuesAction(Widget, XEvent*, String*, Cardinal*);
80void XawGetValuesAction(Widget, XEvent*, String*, Cardinal*);
81void XawDeclareAction(Widget, XEvent*, String*, Cardinal*);
82void XawCallProcAction(Widget, XEvent*, String*, Cardinal*);
83
84/* display lists */
85#define	XAWDL_CONVERT_ERROR	(XtPointer)-1
86typedef struct _XawDL _XawDisplayList;
87typedef struct _XawDLClass XawDLClass, XawDisplayListClass;
88
89typedef void (*XawDisplayListProc)(Widget, XtPointer, XtPointer,
90				   XEvent*, Region);
91typedef void *(*XawDLArgsInitProc)(String, String*, Cardinal*,
92				   Screen*, Colormap, int);
93typedef void *(*XawDLDataInitProc)(String,
94				   Screen*, Colormap, int);
95typedef void (*XawDLArgsDestructor)(Display*, String, XtPointer,
96				    String*, Cardinal*);
97typedef void (*XawDLDataDestructor)(Display*, String, XtPointer);
98
99void XawRunDisplayList(Widget, _XawDisplayList*, XEvent*, Region);
100void XawDisplayListInitialize(void);
101
102_XawDisplayList *XawCreateDisplayList(String, Screen*, Colormap, int);
103void XawDestroyDisplayList(_XawDisplayList*);
104String XawDisplayListString(_XawDisplayList*);
105XawDLClass *XawGetDisplayListClass(String);
106XawDLClass *XawCreateDisplayListClass(String,
107				      XawDLArgsInitProc, XawDLArgsDestructor,
108				      XawDLDataInitProc, XawDLDataDestructor);
109Bool XawDeclareDisplayListProc(XawDLClass*, String, XawDisplayListProc);
110
111/* pixmaps */
112typedef struct _XawArgVal {
113  String name;
114  String value;
115} XawArgVal;
116
117typedef struct _XawParams {
118  String name;
119  String type;
120  String ext;
121  XawArgVal **args;
122  Cardinal num_args;
123} XawParams;
124
125typedef struct _XawPixmap {
126  String name;
127  Pixmap pixmap;
128  Pixmap mask;
129  Dimension width;
130  Dimension height;
131} XawPixmap;
132
133typedef Bool (*XawPixmapLoader)(XawParams*, Screen*, Colormap, int,
134				   Pixmap*, Pixmap*,
135				   Dimension*, Dimension*);
136Bool XawPixmapsInitialize(void);
137Bool XawAddPixmapLoader(String, String, XawPixmapLoader);
138XawPixmap *XawLoadPixmap(String, Screen*, Colormap, int);
139XawPixmap *XawPixmapFromXPixmap(Pixmap, Screen*, Colormap, int);
140XawParams *XawParseParamsString(String name);
141void XawFreeParamsStruct(XawParams *params);
142XawArgVal *XawFindArgVal(XawParams *params, String name);
143void XawReshapeWidget(Widget, XawPixmap*);
144#endif /* OLDXAW */
145
146/* misc */
147void XawTypeToStringWarning(Display*, String);
148
149/* OS.c */
150int _XawGetPageSize(void);
151
152#endif /* _XawPrivate_h */
153