gtx-prototypes-20090316
[openafs.git] / src / gtx / X11windows.c
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 /*
11  * gator_X11windows.c
12  *
13  * Description:
14  *      Implementation of the gator X11 window facility.
15  *
16  *------------------------------------------------------------------------*/
17
18 #include <afsconfig.h>
19 #include <afs/param.h>
20
21 RCSID
22     ("$Header$");
23
24 #include "gtxX11win.h"          /*Interface definition */
25 #include <stdio.h>              /*Standard I/O package */
26
27 #if     !defined(NeXT)
28 extern int errno;               /*System error number */
29 #endif /* NeXT */
30 int X11_debug;                  /*Is debugging turned on? */
31 static char mn[] = "gator_X11windows";  /*Module name */
32
33 /*
34  * Version of standard operations for a X11 window.
35  */
36 struct gwinops X11_gwinops = {
37     gator_X11gwin_box,
38     gator_X11gwin_clear,
39     gator_X11gwin_destroy,
40     gator_X11gwin_display,
41     gator_X11gwin_drawline,
42     gator_X11gwin_drawrectangle,
43     gator_X11gwin_drawchar,
44     gator_X11gwin_drawstring,
45     gator_X11gwin_invert,
46     gator_X11gwin_getchar,
47     gator_X11gwin_getdimensions,
48     gator_X11gwin_wait,
49 };
50
51 struct gwinbaseops gator_X11_gwinbops = {
52     gator_X11gwin_create,
53     gator_X11gwin_cleanup
54 };
55
56 /*
57  * Macros to map pixel positions to row & column positions.
58  * (Note: for now, they are the identity function!!)
59  */
60 #define GATOR_MAP_X_TO_COL(w, x)    (x)
61 #define GATOR_MAP_Y_TO_LINE(w, y)   (y)
62
63 /*------------------------------------------------------------------------
64  * gator_X11gwin_init
65  *
66  * Description:
67  *      Initialize the X11 window package.
68  *
69  * Arguments:
70  *      int adebug: Is debugging turned on?
71  *
72  * Returns:
73  *      0 on success,
74  *      Error value otherwise.
75  *
76  * Environment:
77  *      Nothing interesting.
78  *
79  * Side Effects:
80  *      As advertised.
81  *------------------------------------------------------------------------*/
82
83 int
84 gator_X11gwin_init(int adebug)
85 {                               /*gator_X11gwin_init */
86
87     static char rn[] = "gator_X11gwin_init";    /*Routine name */
88
89     /*
90      * Remember if we'll be doing debugging, init X11 and clear the
91      * standard screen.
92      */
93     X11_debug = adebug;
94
95     if (X11_debug)
96         fprintf(stderr, "[%s:%s] Called\n", mn, rn);
97
98     /*
99      * We return success, fill this routine it at some point.
100      */
101     return (0);
102
103 }                               /*gator_X11gwin_init */
104
105 /*------------------------------------------------------------------------
106  * gator_X11gwin_create
107  *
108  * Description:
109  *      Create a X11 window.
110  *
111  * Arguments:
112  *      struct gator_X11gwin_params *params : Ptr to creation parameters.
113  *
114  * Returns:
115  *      Ptr to the created X11 window if successful,
116  *      Null ptr otherwise.
117  *
118  * Environment:
119  *      Nothing interesting.
120  *
121  * Side Effects:
122  *      As advertised.
123  *------------------------------------------------------------------------*/
124
125 struct gwin *
126 gator_X11gwin_create(struct gator_X11gwin_params *params)
127 {                               /*gator_X11gwin_create */
128
129     static char rn[] = "gator_X11gwin_create";  /*Routine name */
130
131     if (X11_debug)
132         fprintf(stderr, "[%s:%s] Called\n", mn, rn);
133
134     return (NULL);
135
136 }                               /*gator_X11gwin_create */
137
138 /*------------------------------------------------------------------------
139  * gator_X11gwin_cleanup
140  *
141  * Description:
142  *      Create a X11 window.
143  *
144  * Arguments:
145  *      struct gwin *gwp : Ptr to base window.
146  *
147  * Returns:
148  *      0 on success,
149  *      Error value otherwise.
150  *
151  * Environment:
152  *      Nothing interesting.
153  *
154  * Side Effects:
155  *      As advertised.
156  *------------------------------------------------------------------------*/
157
158 int
159 gator_X11gwin_cleanup(struct gwin *gwp)
160 {                               /*gator_X11gwin_cleanup */
161
162     static char rn[] = "gator_X11gwin_cleanup"; /*Routine name */
163
164     if (X11_debug)
165         fprintf(stderr, "[%s:%s] Called\n", mn, rn);
166
167     return (0);
168
169 }                               /*gator_X11gwin_cleanup */
170
171 /*------------------------------------------------------------------------
172  * gator_X11gwin_box
173  *
174  * Description:
175  *      Draw a box around the given X11 window.
176  *
177  * Arguments:
178  *      struct gwin *gwp : Ptr to the X11 window to draw
179  *                         a box around.
180  *
181  * Returns:
182  *      0 on success,
183  *      Error value otherwise.
184  *
185  * Environment:
186  *      Nothing interesting.
187  *
188  * Side Effects:
189  *      As advertised.
190  *------------------------------------------------------------------------*/
191
192 int
193 gator_X11gwin_box(struct gwin *gwp)
194 {                               /*gator_X11gwin_box */
195
196     static char rn[] = "gator_X11gwin_box";     /*Routine name */
197
198     if (X11_debug)
199         fprintf(stderr, "[%s:%s] Called\n", mn, rn);
200
201     return (0);
202
203 }                               /*gator_X11gwin_box */
204
205 /*------------------------------------------------------------------------
206  * gator_X11gwin_clear
207  *
208  * Description:
209  *      Clear out the given X11 window.
210  *
211  * Arguments:
212  *      struct gwin *gwp : Ptr to the X11 window to clear out.
213  *
214  * Returns:
215  *      0 on success,
216  *      Error value otherwise.
217  *
218  * Environment:
219  *      Nothing interesting.
220  *
221  * Side Effects:
222  *      As advertised.
223  *------------------------------------------------------------------------*/
224
225 int
226 gator_X11gwin_clear(struct gwin *gwp)
227 {                               /*gator_X11gwin_clear */
228
229     static char rn[] = "gator_X11gwin_clear";   /*Routine name */
230
231     if (X11_debug)
232         fprintf(stderr, "[%s:%s] Called\n", mn, rn);
233
234     return (0);
235
236 }                               /*gator_X11gwin_clear */
237
238 /*------------------------------------------------------------------------
239  * gator_X11gwin_destroy
240  *
241  * Description:
242  *      Destroy the given X11 window.
243  *
244  * Arguments:
245  *      struct gwin *gwp : Ptr to the X11 window to destroy.
246  *
247  * Returns:
248  *      0 on success,
249  *      Error value otherwise.
250  *
251  * Environment:
252  *      Nothing interesting.
253  *
254  * Side Effects:
255  *      As advertised.
256  *------------------------------------------------------------------------*/
257
258 int
259 gator_X11gwin_destroy(struct gwin *gwp)
260 {                               /*gator_X11gwin_destroy */
261
262     static char rn[] = "gator_X11gwin_destroy"; /*Routine name */
263
264     if (X11_debug)
265         fprintf(stderr, "[%s:%s] Called\n", mn, rn);
266
267     return (0);
268
269 }                               /*gator_X11gwin_destroy */
270
271 /*------------------------------------------------------------------------
272  * gator_X11gwin_display
273  *
274  * Description:
275  *      Display/redraw the given X11 window.
276  *
277  * Arguments:
278  *      struct gwin *gwp : Ptr to the X11 window to draw.
279  *
280  * Returns:
281  *      0 on success,
282  *      Error value otherwise.
283  *
284  * Environment:
285  *      Nothing interesting.
286  *
287  * Side Effects:
288  *      As advertised.
289  *------------------------------------------------------------------------*/
290
291 int
292 gator_X11gwin_display(struct gwin *gwp)
293 {                               /*gator_X11gwin_display */
294
295     static char rn[] = "gator_X11gwin_display"; /*Routine name */
296
297     if (X11_debug)
298         fprintf(stderr, "[%s:%s] Called\n", mn, rn);
299
300     return (0);
301
302 }                               /*gator_X11gwin_display */
303
304 /*------------------------------------------------------------------------
305  * gator_X11gwin_drawline
306  *
307  * Description:
308  *      Draw a line between two points in the given X11
309  *      window.
310  *
311  * Arguments:
312  *      struct gwin *gwp : Ptr to the X11 window in which
313  *                                 the line is to be drawn.
314  *      struct gwin_lineparams *params : Ptr to other params.
315  *
316  * Returns:
317  *      0 on success,
318  *      Error value otherwise.
319  *
320  * Environment:
321  *      Nothing interesting.
322  *
323  * Side Effects:
324  *      As advertised.
325  *------------------------------------------------------------------------*/
326
327 int
328 gator_X11gwin_drawline(struct gwin *gwp, struct gwin_lineparams *params)
329 {                               /*gator_X11gwin_drawline */
330
331     static char rn[] = "gator_X11gwin_drawline";        /*Routine name */
332
333     if (X11_debug)
334         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
335                 rn);
336
337     return (0);
338
339 }                               /*gator_X11gwin_drawline */
340
341 /*------------------------------------------------------------------------
342  * gator_X11gwin_drawrectangle
343  *
344  * Description:
345  *      Draw a rectangle in the given X11 window.
346  *
347  * Arguments:
348  *      struct gwin *gwp : Ptr to the X11 window in which
349  *                                 the rectangle is to be drawn.
350  *      struct gwin_rectparams *params : Ptr to other params.
351  *
352  * Returns:
353  *      0 on success,
354  *      Error value otherwise.
355  *
356  * Environment:
357  *      Nothing interesting.
358  *
359  * Side Effects:
360  *      As advertised.
361  *------------------------------------------------------------------------*/
362
363 int
364 gator_X11gwin_drawrectangle(struct gwin *gwp, struct gwin_rectparams *params)
365 {                               /*gator_X11gwin_drawrectangle */
366
367     static char rn[] = "gator_X11gwin_drawrectangle";   /*Routine name */
368
369     if (X11_debug)
370         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
371                 rn);
372
373     return (0);
374
375 }                               /*gator_X11gwin_drawrectangle */
376
377 /*------------------------------------------------------------------------
378  * gator_X11gwin_drawchar
379  *
380  * Description:
381  *      Draw a character in the given X11 window.
382  *
383  * Arguments:
384  *      struct gwin *gwp : Ptr to the X11 window in which
385  *                                 the character is to be drawn.
386  *      struct gwin_charparams *params : Ptr to other params.
387  *
388  * Returns:
389  *      0 on success,
390  *      Error value otherwise.
391  *
392  * Environment:
393  *      Nothing interesting.
394  *
395  * Side Effects:
396  *      As advertised.
397  *------------------------------------------------------------------------*/
398
399 int
400 gator_X11gwin_drawchar(struct gwin *gwp, struct gwin_charparams *params)
401 {                               /*gator_X11gwin_drawchar */
402
403     static char rn[] = "gator_X11gwin_drawchar";        /*Routine name */
404
405     if (X11_debug)
406         fprintf(stderr, "[%s:%s] Called\n", mn, rn);
407
408     return (0);
409
410 }                               /*gator_X11gwin_drawchar */
411
412 /*------------------------------------------------------------------------
413  * gator_X11gwin_drawstring
414  *
415  * Description:
416  *      Draw a string in the given X11 window.
417  *
418  * Arguments:
419  *      struct gwin *gwp : Ptr to the X11 window in which
420  *                                 the string is to be drawn.
421  *      struct gwin_strparams *params : Ptr to other params.
422  *
423  * Returns:
424  *      0 on success,
425  *      Error value otherwise.
426  *
427  * Environment:
428  *      Nothing interesting.
429  *
430  * Side Effects:
431  *      As advertised.
432  *------------------------------------------------------------------------*/
433
434 int
435 gator_X11gwin_drawstring(struct gwin *gwp, struct gwin_strparams *params)
436 {                               /*gator_X11gwin_drawstring */
437
438     static char rn[] = "gator_X11gwin_drawstring";      /*Routine name */
439
440     if (X11_debug)
441         fprintf(stderr, "[%s:%s] Called\n", mn, rn);
442
443     return (0);
444
445 }                               /*gator_X11gwin_drawstring */
446
447 /*------------------------------------------------------------------------
448  * gator_X11gwin_invert
449  *
450  * Description:
451  *      Invert a region in the given X11 window.
452  *
453  * Arguments:
454  *      struct gwin *gwp : Ptr to the X11 window in which
455  *                                 the inverted region lies.
456  *      struct gwin_invparams *params : Ptr to other params.
457  *
458  * Returns:
459  *      0 on success,
460  *      Error value otherwise.
461  *
462  * Environment:
463  *      Nothing interesting.
464  *
465  * Side Effects:
466  *      As advertised.
467  *------------------------------------------------------------------------*/
468
469 int
470 gator_X11gwin_invert(struct gwin *gwp, struct gwin_invparams *params)
471 {                               /*gator_X11gwin_invert */
472
473     static char rn[] = "gator_X11gwin_invert";  /*Routine name */
474
475     if (X11_debug)
476         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
477                 rn);
478
479     return (0);
480
481 }                               /*gator_X11gwin_invert */
482
483 /*------------------------------------------------------------------------
484  * gator_X11gwin_getchar
485  *
486  * Description:
487  *      Pick up a character from the given window.
488  *
489  * Arguments:
490  *      struct gwin *gwp : Ptr to the X11 window to listen to.
491  *
492  * Returns:
493  *      Value of the character read,
494  *      -1 otherwise.
495  *
496  * Environment:
497  *      Nothing interesting.
498  *
499  * Side Effects:
500  *      As advertised.
501  *------------------------------------------------------------------------*/
502
503 int
504 gator_X11gwin_getchar(struct gwin *gwp)
505 {                               /*gator_X11gwin_getchar */
506
507     static char rn[] = "gator_X11gwin_getchar"; /*Routine name */
508
509     if (X11_debug)
510         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
511                 rn);
512
513     return (-1);
514
515 }                               /*gator_X11gwin_getchar */
516
517 /*------------------------------------------------------------------------
518  * gator_X11gwin_getdimensions
519  *
520  * Description:
521  *      Get the window's X,Y dimensions.
522  *
523  * Arguments:
524  *      struct gwin *gwp               : Ptr to the X11 window to examine.
525  *      struct gwin_sizeparams *aparms : Ptr to size params to set.
526  *
527  * Returns:
528  *      0 if successful,
529  *      -1 otherwise.
530  *
531  * Environment:
532  *      Nothing interesting.
533  *
534  * Side Effects:
535  *      As advertised.
536  *------------------------------------------------------------------------*/
537
538 int
539 gator_X11gwin_getdimensions(struct gwin *gwp, struct gwin_sizeparams *aparms)
540 {                               /*gator_X11gwin_getdimensions */
541
542     static char rn[] = "gator_X11gwin_getdimensions";   /*Routine name */
543
544     if (X11_debug)
545         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
546                 rn);
547
548     return (-1);
549
550 }                               /*gator_X11gwin_getdimensions */
551
552 /*------------------------------------------------------------------------
553  * gator_X11gwin_wait
554  *
555  * Description:
556  *      Wait until input is available.
557  *
558  * Arguments:
559  *      struct gwin *gwp : Ptr to the X11 window to wait on.
560  *
561  * Returns:
562  *      0 if successful,
563  *      -1 otherwise.
564  *
565  * Environment:
566  *      Nothing interesting.
567  *
568  * Side Effects:
569  *      As advertised.
570  *------------------------------------------------------------------------*/
571
572 int
573 gator_X11gwin_wait(struct gwin *gwp)
574 {                               /*gator_X11gwin_wait */
575
576     static char rn[] = "gator_X11gwin_wait";    /*Routine name */
577
578     if (X11_debug)
579         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
580                 rn);
581
582     return (-1);
583
584 }                               /*gator_X11gwin_wait */