Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / gtx / gtxwindows.h
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10 #ifndef __gator_windows_h
11 #define __gator_windows_h 1
12
13 /*--------------------------------------------------------------------------------
14 * gator_windows.h
15 *
16 * Constants and data structures defining the basis for gator windows,
17 * independent of the lower-level graphical environment.
18 *--------------------------------------------------------------------------------*/
19
20 /*
21 * Gator window definition.
22 */
23 struct gwin {
24 int w_type; /*Type of window */
25 int w_x, w_y; /*X and Y coordinates */
26 int w_width, w_height; /*Width & height in pixels */
27 int w_changed; /*Does the window need to be refreshed? */
28 struct gwinops *w_op; /*Ptr to the operations defined on the window */
29 struct gwin *w_parent; /*Parent window, if any */
30 struct gtx_frame *w_frame; /*Frame information */
31 int *w_data; /*Ptr to info describing the window */
32 };
33
34 /*
35 * window display list item.
36 */
37 struct gwin_dlist {
38 struct gwin_dlist *next; /* "car" */
39 struct onode *data; /* "cdr" */
40 };
41
42 /*
43 * Initialization parameters for the gator window package.
44 */
45 struct gwin_initparams {
46 int i_type; /*Type of lower-level graphics package used */
47 int i_x, i_y; /*X, Y coordinates of the screen area */
48 int i_width, i_height; /*Width, height of the screen area */
49 int i_debug; /*Should debugging be turned on? */
50 };
51
52 /*
53 * Creation parameters for gator windows.
54 */
55 struct gwin_createparams {
56 int cr_type; /*Type of window */
57 int cr_x, cr_y; /*X and Y coordinates */
58 int cr_width, cr_height; /*Width & height in pixels */
59 struct gwin *cr_parentwin; /*Ptr to parent window structure */
60 };
61
62 /*
63 * Line-drawing parameters.
64 */
65 struct gwin_lineparams {
66 int x1, y1; /*X, Y coordinates of first point */
67 int x2, y2; /*X, Y coordinates of second point */
68 };
69
70 /*
71 * Rectangle-drawing parameters.
72 */
73 struct gwin_rectparams {
74 int x, y; /*X, Y coordinates of rectangle's origin */
75 int width, height; /*Rectangle width & height */
76 };
77
78 /*
79 * Size params.
80 */
81 struct gwin_sizeparams {
82 int maxx, maxy; /* x,y size */
83 };
84
85 /*
86 * Char-drawing parameters.
87 */
88 struct gwin_charparams {
89 int x, y; /*X, Y coordinates of char origin */
90 char c; /*Char to draw */
91 int highlight; /*Print in highlight/standout mode? */
92 };
93
94 /*
95 * String-drawing parameters.
96 */
97 struct gwin_strparams {
98 int x, y; /*X, Y coordinates of string */
99 int highlight; /*Print in highlight/standout mode? */
100 char *s; /*String to draw */
101 };
102
103 /*
104 * Inversion parameters.
105 */
106 struct gwin_invparams {
107 int x, y; /*X, Y coordinates of origin */
108 int width, height; /*Width & height of rectangle to invert */
109 };
110
111 /*
112 * Operations on gator windows.
113 */
114 struct gwinops {
115 int (*gw_box) (struct gwin *); /* Draw a box around the given window */
116 int (*gw_clear) (struct gwin *); /* Clear out a window */
117 int (*gw_destroy) (struct gwin *); /* Destroy a window */
118 int (*gw_display) (struct gwin *); /* [Re]display a window */
119 int (*gw_drawline) (struct gwin *, struct gwin_lineparams *);
120 /* Draw a line between two points */
121 int (*gw_drawrectangle) (struct gwin *, struct gwin_rectparams *);
122 /* Draw a rectangle at the given loc & dimensions */
123 int (*gw_drawchar) (struct gwin *, struct gwin_charparams *);
124 /* Draw a char at the given location */
125 int (*gw_drawstring) (struct gwin *, struct gwin_strparams *);
126 /* Draw a char string at the given location */
127 int (*gw_invert) (struct gwin *, struct gwin_invparams *);
128 /* Invert region */
129 int (*gw_getchar) (struct gwin *); /* Get a character from a window */
130 int (*gw_getdimensions) (struct gwin *, struct gwin_sizeparams *);
131 /* Get dimensions of a window */
132 int (*gw_wait) (struct gwin *); /* Wait for input */
133 };
134
135 /*
136 * Macros facilitating the use of the window functions.
137 */
138 #define WOP_BOX(WNP) (WNP)->w_op->gw_box(WNP)
139 #define WOP_CLEAR(WNP) (WNP)->w_op->gw_clear(WNP)
140 #define WOP_DESTROY(WNP) (WNP)->w_op->gw_destroy(WNP)
141 #define WOP_DISPLAY(WNP) (WNP)->w_op->gw_display(WNP)
142 #define WOP_DRAWLINE(WNP, params) (WNP)->w_op->gw_drawline(WNP, params)
143 #define WOP_DRAWRECTANGLE(WNP, params) (WNP)->w_op->gw_drawrectangle(WNP, params)
144 #define WOP_DRAWCHAR(WNP, params) (WNP)->w_op->gw_drawchar(WNP, params)
145 #define WOP_DRAWSTRING(WNP, params) (WNP)->w_op->gw_drawstring(WNP, params)
146 #define WOP_INVERT(WNP, params) (WNP)->w_op->gw_invert(WNP, params)
147 #define WOP_GETCHAR(WNP) (WNP)->w_op->gw_getchar(WNP)
148 #define WOP_GETDIMENSIONS(WNP,params) (WNP)->w_op->gw_getdimensions(WNP, params)
149 #define WOP_WAIT(WNP) (WNP)->w_op->gw_wait(WNP)
150
151 /*
152 * Base operations on the lower-level window system.
153 */
154 struct gwinbaseops {
155 struct gwin *(*gw_createwin) (void *);
156 /*Create a window */
157 int (*gw_cleanup) (struct gwin *); /*Clean up before program exit */
158 };
159
160 /*
161 * Ptr to the base operation array.
162 */
163 extern struct gwinbaseops gwinbops;
164
165 /*
166 * Macros facilitating the use of the base window operations.
167 */
168 #define WOP_CREATE(p) ((*(gwinbops.gw_createwin))(p))
169 #define WOP_CLEANUP(w) ((*(gwinbops.gw_cleanup))(w))
170
171 /*
172 * Pointer to the base window, which is created by the initialization routine.
173 */
174 extern struct gwin gator_basegwin;
175
176 extern int gw_init(struct gwin_initparams *);
177 /*
178 * Summary:
179 * Initialize the gator window package.
180 *
181 * Args:
182 * struct gwin_initparams *params: Ptr to initialization params.
183 *
184 * Returns:
185 * 0 on success,
186 * Error value otherwise.
187 */
188
189 /* initialize the whole gator toolkit package */
190 extern struct gwin *gtx_Init(int, int);
191
192 #endif /* __gator_windows_h */