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