Private.h revision 7a84e134
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/* $XFree86: xc/lib/Xaw/Private.h,v 3.9 1999/05/16 10:12:48 dawes Exp $ */
29
30#ifndef _XawPrivate_h
31#define _XawPrivate_h
32
33#define XawMax(a, b) ((a) > (b) ? (a) : (b))
34#define XawMin(a, b) ((a) < (b) ? (a) : (b))
35#define XawAbs(a)    ((a) < 0 ? -(a) : (a))
36
37#define XawStackAlloc(size, stk_buffer)		\
38((size) <= sizeof(stk_buffer)			\
39 ? (XtPointer)(stk_buffer)			\
40 : XtMalloc((unsigned)(size)))
41
42#define XawStackFree(pointer, stk_buffer)	\
43do {						\
44  if ((pointer) != (XtPointer)(stk_buffer))	\
45    XtFree((char *)pointer);			\
46} while (0)
47
48#ifndef XtX
49#define XtX(w)            (((RectObj)w)->rectangle.x)
50#endif
51#ifndef XtY
52#define XtY(w)            (((RectObj)w)->rectangle.y)
53#endif
54#ifndef XtWidth
55#define XtWidth(w)        (((RectObj)w)->rectangle.width)
56#endif
57#ifndef XtHeight
58#define XtHeight(w)       (((RectObj)w)->rectangle.height)
59#endif
60#ifndef XtBorderWidth
61#define XtBorderWidth(w)  (((RectObj)w)->rectangle.border_width)
62#endif
63
64#ifndef OLDXAW
65#define XAW_PRIV_VAR_PREFIX '$'
66
67typedef Bool (*XawParseBooleanProc)(Widget, String, XEvent*, Bool*);
68
69typedef struct _XawActionVarList XawActionVarList;
70typedef struct _XawActionResList XawActionResList;
71
72/* Boolean expressions */
73Bool XawParseBoolean(Widget, String, XEvent*, Bool*);
74Bool XawBooleanExpression(Widget, String, XEvent*);
75
76/* actions */
77void XawPrintActionErrorMsg(String, Widget, String*, Cardinal*);
78XawActionResList *XawGetActionResList(WidgetClass);
79XawActionVarList *XawGetActionVarList(Widget);
80
81void XawSetValuesAction(Widget, XEvent*, String*, Cardinal*);
82void XawGetValuesAction(Widget, XEvent*, String*, Cardinal*);
83void XawDeclareAction(Widget, XEvent*, String*, Cardinal*);
84void XawCallProcAction(Widget, XEvent*, String*, Cardinal*);
85
86/* display lists */
87#define	XAWDL_CONVERT_ERROR	(XtPointer)-1
88typedef struct _XawDL _XawDisplayList;
89typedef struct _XawDLClass XawDLClass, XawDisplayListClass;
90
91typedef void (*XawDisplayListProc)(Widget, XtPointer, XtPointer,
92				   XEvent*, Region);
93typedef void *(*XawDLArgsInitProc)(String, String*, Cardinal*,
94				   Screen*, Colormap, int);
95typedef void *(*XawDLDataInitProc)(String,
96				   Screen*, Colormap, int);
97typedef void (*XawDLArgsDestructor)(Display*, String, XtPointer,
98				    String*, Cardinal*);
99typedef void (*XawDLDataDestructor)(Display*, String, XtPointer);
100
101void XawRunDisplayList(Widget, _XawDisplayList*, XEvent*, Region);
102void XawDisplayListInitialize(void);
103
104_XawDisplayList *XawCreateDisplayList(String, Screen*, Colormap, int);
105void XawDestroyDisplayList(_XawDisplayList*);
106String XawDisplayListString(_XawDisplayList*);
107XawDLClass *XawGetDisplayListClass(String);
108XawDLClass *XawCreateDisplayListClass(String,
109				      XawDLArgsInitProc, XawDLArgsDestructor,
110				      XawDLDataInitProc, XawDLDataDestructor);
111Bool XawDeclareDisplayListProc(XawDLClass*, String, XawDisplayListProc);
112
113/* pixmaps */
114typedef struct _XawArgVal {
115  String name;
116  String value;
117} XawArgVal;
118
119typedef struct _XawParams {
120  String name;
121  String type;
122  String ext;
123  XawArgVal **args;
124  Cardinal num_args;
125} XawParams;
126
127typedef struct _XawPixmap {
128  String name;
129  Pixmap pixmap;
130  Pixmap mask;
131  Dimension width;
132  Dimension height;
133} XawPixmap;
134
135typedef Bool (*XawPixmapLoader)(XawParams*, Screen*, Colormap, int,
136				   Pixmap*, Pixmap*,
137				   Dimension*, Dimension*);
138Bool XawPixmapsInitialize(void);
139Bool XawAddPixmapLoader(String, String, XawPixmapLoader);
140XawPixmap *XawLoadPixmap(String, Screen*, Colormap, int);
141XawPixmap *XawPixmapFromXPixmap(Pixmap, Screen*, Colormap, int);
142XawParams *XawParseParamsString(String name);
143void XawFreeParamsStruct(XawParams *params);
144XawArgVal *XawFindArgVal(XawParams *params, String name);
145void XawReshapeWidget(Widget, XawPixmap*);
146#endif /* OLDXAW */
147
148/* misc */
149void XawTypeToStringWarning(Display*, String);
150
151/* OS.c */
152int _XawGetPageSize(void);
153
154#endif /* _XawPrivate_h */
155