OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tk/] [mac/] [tkMacXStubs.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tkMacXStubs.c --
3
 *
4
 *      This file contains most of the X calls called by Tk.  Many of
5
 * these calls are just stubs and either don't make sense on the
6
 * Macintosh or thier implamentation just doesn't do anything.  Other
7
 * calls will eventually be moved into other files.
8
 *
9
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
10
 *
11
 * See the file "license.terms" for information on usage and redistribution
12
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
 *
14
 * RCS: @(#) $Id: tkMacXStubs.c,v 1.1.1.1 2002-01-16 10:25:58 markom Exp $
15
 */
16
 
17
#include "tkInt.h"
18
#include <X.h>
19
#include <Xlib.h>
20
#include <stdio.h>
21
#include <tcl.h>
22
 
23
#include <Xatom.h>
24
 
25
#include <Windows.h>
26
#include <Fonts.h>
27
#include <QDOffscreen.h>
28
#include <ToolUtils.h>
29
#include <Sound.h>
30
#include "tkMacInt.h"
31
 
32
/*
33
 * Because this file is still under major development Debugger statements are
34
 * used through out this file.  The define TCL_DEBUG will decide whether
35
 * the debugger statements actually call the debugger or not.
36
 */
37
 
38
#ifndef TCL_DEBUG
39
#   define Debugger()
40
#endif
41
 
42
#define ROOT_ID 10
43
 
44
/*
45
 * Declarations of static variables used in this file.
46
 */
47
 
48
static TkDisplay *gMacDisplay = NULL; /* Macintosh display. */
49
static char *macScreenName = ":0";
50
                                /* Default name of macintosh display. */
51
 
52
/*
53
 * Forward declarations of procedures used in this file.
54
 */
55
 
56
static XID MacXIdAlloc _ANSI_ARGS_((Display *display));
57
static int DefaultErrorHandler _ANSI_ARGS_((Display* display,
58
        XErrorEvent* err_evt));
59
 
60
/*
61
 * Other declrations
62
 */
63
 
64
int TkMacXDestroyImage _ANSI_ARGS_((XImage *image));
65
unsigned long TkMacXGetPixel _ANSI_ARGS_((XImage *image, int x, int y));
66
int TkMacXPutPixel _ANSI_ARGS_((XImage *image, int x, int y,
67
        unsigned long pixel));
68
XImage *TkMacXSubImage _ANSI_ARGS_((XImage *image, int x, int y,
69
        unsigned int width, unsigned int height));
70
int TkMacXAddPixel _ANSI_ARGS_((XImage *image, long value));
71
int _XInitImageFuncPtrs _ANSI_ARGS_((XImage *image));
72
 
73
/*
74
 *----------------------------------------------------------------------
75
 *
76
 * TkpOpenDisplay --
77
 *
78
 *      Create the Display structure and fill it with device
79
 *      specific information.
80
 *
81
 * Results:
82
 *      Returns a Display structure on success or NULL on failure.
83
 *
84
 * Side effects:
85
 *      Allocates a new Display structure.
86
 *
87
 *----------------------------------------------------------------------
88
 */
89
 
90
TkDisplay *
91
TkpOpenDisplay(
92
    char *display_name)
93
{
94
    Display *display;
95
    Screen *screen;
96
    GDHandle graphicsDevice;
97
 
98
    if (gMacDisplay != NULL) {
99
        if (strcmp(gMacDisplay->display->display_name, display_name) == 0) {
100
            return gMacDisplay;
101
        } else {
102
            return NULL;
103
        }
104
    }
105
 
106
    graphicsDevice = GetMainDevice();
107
    display = (Display *) ckalloc(sizeof(Display));
108
    display->resource_alloc = MacXIdAlloc;
109
    screen = (Screen *) ckalloc(sizeof(Screen) * 2);
110
    display->default_screen = 0;
111
    display->request = 0;
112
    display->nscreens = 1;
113
    display->screens = screen;
114
    display->display_name = macScreenName;
115
    display->qlen = 0;
116
 
117
    screen->root = ROOT_ID;
118
    screen->display = display;
119
    screen->root_depth = (*(*graphicsDevice)->gdPMap)->cmpSize *
120
                               (*(*graphicsDevice)->gdPMap)->cmpCount;
121
    screen->height = (*graphicsDevice)->gdRect.bottom -
122
        (*graphicsDevice)->gdRect.top;
123
    screen->width = (*graphicsDevice)->gdRect.right -
124
        (*graphicsDevice)->gdRect.left;
125
 
126
    screen->mwidth = (screen->width * 254 + 360) / 720;
127
    screen->mheight = (screen->height * 254 + 360) / 720;
128
    screen->black_pixel = 0x00000000;
129
    screen->white_pixel = 0x00FFFFFF;
130
    screen->root_visual = (Visual *) ckalloc(sizeof(Visual));
131
    screen->root_visual->visualid = 0;
132
    screen->root_visual->class = TrueColor;
133
    screen->root_visual->red_mask = 0x00FF0000;
134
    screen->root_visual->green_mask = 0x0000FF00;
135
    screen->root_visual->blue_mask = 0x000000FF;
136
    screen->root_visual->bits_per_rgb = 24;
137
    screen->root_visual->map_entries = 2 ^ 8;
138
 
139
    gMacDisplay = (TkDisplay *) ckalloc(sizeof(TkDisplay));
140
    gMacDisplay->display = display;
141
    return gMacDisplay;
142
}
143
 
144
/*
145
 *----------------------------------------------------------------------
146
 *
147
 * TkpCloseDisplay --
148
 *
149
 *      Deallocates a display structure created by TkpOpenDisplay.
150
 *
151
 * Results:
152
 *      None.
153
 *
154
 * Side effects:
155
 *      Frees memory.
156
 *
157
 *----------------------------------------------------------------------
158
 */
159
 
160
void
161
TkpCloseDisplay(
162
    TkDisplay *displayPtr)
163
{
164
    Display *display = displayPtr->display;
165
    if (gMacDisplay != displayPtr) {
166
        panic("TkpCloseDisplay: tried to call TkpCloseDisplay on bad display");
167
    }
168
 
169
    /*
170
     * Make sure that the local scrap is transfered to the global
171
     * scrap if needed.
172
     */
173
 
174
    TkSuspendClipboard();
175
 
176
    gMacDisplay = NULL;
177
    if (display->screens != (Screen *) NULL) {
178
        if (display->screens->root_visual != (Visual *) NULL) {
179
            ckfree((char *) display->screens->root_visual);
180
        }
181
        ckfree((char *) display->screens);
182
    }
183
    ckfree((char *) display);
184
    ckfree((char *) displayPtr);
185
}
186
 
187
/*
188
 *----------------------------------------------------------------------
189
 *
190
 * MacXIdAlloc --
191
 *
192
 *      This procedure is invoked by Xlib as the resource allocator
193
 *      for a display.
194
 *
195
 * Results:
196
 *      The return value is an X resource identifier that isn't currently
197
 *      in use.
198
 *
199
 * Side effects:
200
 *      The identifier is removed from the stack of free identifiers,
201
 *      if it was previously on the stack.
202
 *
203
 *----------------------------------------------------------------------
204
 */
205
 
206
static XID
207
MacXIdAlloc(
208
    Display *display)                   /* Display for which to allocate. */
209
{
210
        static long int cur_id = 100;
211
        /*
212
         * Some special XIds are reserved
213
         *   - this is why we start at 100
214
         */
215
 
216
        return ++cur_id;
217
}
218
 
219
/*
220
 *----------------------------------------------------------------------
221
 *
222
 * TkpWindowWasRecentlyDeleted --
223
 *
224
 *      Tries to determine whether the given window was recently deleted.
225
 *      Called from the generic code error handler to attempt to deal with
226
 *      async BadWindow errors under some circumstances.
227
 *
228
 * Results:
229
 *      Always 0, we do not keep this information on the Mac, so we do not
230
 *      know whether the window was destroyed.
231
 *
232
 * Side effects:
233
 *      None.
234
 *
235
 *----------------------------------------------------------------------
236
 */
237
 
238
int
239
TkpWindowWasRecentlyDeleted(
240
    Window win,
241
    TkDisplay *dispPtr)
242
{
243
    return 0;
244
}
245
 
246
/*
247
 *----------------------------------------------------------------------
248
 *
249
 * DefaultErrorHandler --
250
 *
251
 *      This procedure is the default X error handler.  Tk uses it's
252
 *      own error handler so this call should never be called.
253
 *
254
 * Results:
255
 *      None.
256
 *
257
 * Side effects:
258
 *      This function will call panic and exit.
259
 *
260
 *----------------------------------------------------------------------
261
 */
262
 
263
static int
264
DefaultErrorHandler(
265
    Display* display,
266
    XErrorEvent* err_evt)
267
{
268
    /*
269
     * This call should never be called.  Tk replaces
270
     * it with its own error handler.
271
     */
272
    panic("Warning hit bogus error handler!");
273
    return 0;
274
}
275
 
276
 
277
char *
278
XGetAtomName(
279
    Display * display,
280
    Atom atom)
281
{
282
    display->request++;
283
    return NULL;
284
}
285
 
286
int
287
_XInitImageFuncPtrs(XImage *image)
288
{
289
    return 0;
290
}
291
 
292
XErrorHandler
293
XSetErrorHandler(
294
    XErrorHandler handler)
295
{
296
    return DefaultErrorHandler;
297
}
298
 
299
Window
300
XRootWindow(Display *display, int screen_number)
301
{
302
    display->request++;
303
    return ROOT_ID;
304
}
305
 
306
XImage *
307
XGetImage(display, d, x, y, width, height, plane_mask, format)
308
    Display *display;
309
    Drawable d;
310
    int x;
311
    int y;
312
    unsigned int width;
313
    unsigned int height;
314
    unsigned long plane_mask;
315
    int format;
316
{
317
    Debugger();
318
    return NULL;
319
}
320
 
321
int
322
XGetGeometry(display, d, root_return, x_return, y_return, width_return,
323
        height_return, border_width_return, depth_return)
324
    Display* display;
325
    Drawable d;
326
    Window* root_return;
327
    int* x_return;
328
    int* y_return;
329
    unsigned int* width_return;
330
    unsigned int* height_return;
331
    unsigned int* border_width_return;
332
    unsigned int* depth_return;
333
{
334
    /* Used in tkCanvPs.c & wm code */
335
    Debugger();
336
    return 0;
337
}
338
 
339
void
340
XChangeProperty(
341
    Display* display,
342
    Window w,
343
    Atom property,
344
    Atom type,
345
    int format,
346
    int mode,
347
    _Xconst unsigned char* data,
348
    int nelements)
349
{
350
    Debugger();
351
}
352
 
353
void
354
XSelectInput(
355
    Display* display,
356
    Window w,
357
    long event_mask)
358
{
359
    Debugger();
360
}
361
 
362
void
363
XBell(
364
    Display* display,
365
    int percent)
366
{
367
    SysBeep(percent);
368
}
369
 
370
void
371
XSetWMNormalHints(
372
    Display* display,
373
    Window w,
374
    XSizeHints* hints)
375
{
376
    /*
377
     * Do nothing.  Shouldn't even be called.
378
     */
379
}
380
 
381
XSizeHints *
382
XAllocSizeHints()
383
{
384
    /*
385
     * Always return NULL.  Tk code checks to see if NULL
386
     * is returned & does nothing if it is.
387
     */
388
 
389
    return NULL;
390
}
391
 
392
XImage *
393
XCreateImage(
394
    Display* display,
395
    Visual* visual,
396
    unsigned int depth,
397
    int format,
398
    int offset,
399
    char* data,
400
    unsigned int width,
401
    unsigned int height,
402
    int bitmap_pad,
403
    int bytes_per_line)
404
{
405
    XImage *ximage;
406
 
407
    display->request++;
408
    ximage = (XImage *) ckalloc(sizeof(XImage));
409
 
410
    ximage->height = height;
411
    ximage->width = width;
412
    ximage->depth = depth;
413
    ximage->xoffset = offset;
414
    ximage->format = format;
415
    ximage->data = data;
416
    ximage->bitmap_pad = bitmap_pad;
417
    if (bytes_per_line == 0) {
418
        ximage->bytes_per_line = width * 4;  /* assuming 32 bits per pixel */
419
    } else {
420
        ximage->bytes_per_line = bytes_per_line;
421
    }
422
 
423
    if (format == ZPixmap) {
424
        ximage->bits_per_pixel = 32;
425
        ximage->bitmap_unit = 32;
426
    } else {
427
        ximage->bits_per_pixel = 1;
428
        ximage->bitmap_unit = 8;
429
    }
430
    ximage->byte_order = LSBFirst;
431
    ximage->bitmap_bit_order = LSBFirst;
432
    ximage->red_mask = 0x00FF0000;
433
    ximage->green_mask = 0x0000FF00;
434
    ximage->blue_mask = 0x000000FF;
435
 
436
    ximage->f.destroy_image = TkMacXDestroyImage;
437
    ximage->f.get_pixel = TkMacXGetPixel;
438
    ximage->f.put_pixel = TkMacXPutPixel;
439
    ximage->f.sub_image = TkMacXSubImage;
440
    ximage->f.add_pixel = TkMacXAddPixel;
441
 
442
    return ximage;
443
}
444
 
445
GContext
446
XGContextFromGC(
447
    GC gc)
448
{
449
    /* TODO - currently a no-op */
450
    return 0;
451
}
452
 
453
Status
454
XSendEvent(
455
    Display* display,
456
    Window w,
457
    Bool propagate,
458
    long event_mask,
459
    XEvent* event_send)
460
{
461
    Debugger();
462
    return 0;
463
}
464
 
465
int
466
XGetWindowProperty(
467
    Display *display,
468
    Window w,
469
    Atom property,
470
    long long_offset,
471
    long long_length,
472
    Bool delete,
473
    Atom req_type,
474
    Atom *actual_type_return,
475
    int *actual_format_return,
476
    unsigned long *nitems_return,
477
    unsigned long *bytes_after_return,
478
    unsigned char ** prop_return)
479
{
480
    display->request++;
481
    *actual_type_return = None;
482
    *actual_format_return = *bytes_after_return = 0;
483
    *nitems_return = 0;
484
    return 0;
485
}
486
 
487
void
488
XRefreshKeyboardMapping()
489
{
490
    /* used by tkXEvent.c */
491
    Debugger();
492
}
493
 
494
void
495
XSetIconName(
496
    Display* display,
497
    Window w,
498
    const char *icon_name)
499
{
500
    /*
501
     * This is a no-op, no icon name for Macs.
502
     */
503
    display->request++;
504
}
505
 
506
void
507
XForceScreenSaver(
508
    Display* display,
509
    int mode)
510
{
511
    /*
512
     * This function is just a no-op.  It is defined to
513
     * reset the screen saver.  However, there is no real
514
     * way to do this on a Mac.  Let me know if there is!
515
     */
516
    display->request++;
517
}
518
 
519
/*
520
 *----------------------------------------------------------------------
521
 *
522
 * TkGetServerInfo --
523
 *
524
 *      Given a window, this procedure returns information about
525
 *      the window server for that window.  This procedure provides
526
 *      the guts of the "winfo server" command.
527
 *
528
 * Results:
529
 *      None.
530
 *
531
 * Side effects:
532
 *      None.
533
 *
534
 *----------------------------------------------------------------------
535
 */
536
 
537
void
538
TkGetServerInfo(
539
    Tcl_Interp *interp,         /* The server information is returned in
540
                                 * this interpreter's result. */
541
    Tk_Window tkwin)            /* Token for window;  this selects a
542
                                 * particular display and server. */
543
{
544
    char buffer[50], buffer2[50];
545
 
546
    sprintf(buffer, "X%dR%d ", ProtocolVersion(Tk_Display(tkwin)),
547
            ProtocolRevision(Tk_Display(tkwin)));
548
    sprintf(buffer2, " %d", VendorRelease(Tk_Display(tkwin)));
549
    Tcl_AppendResult(interp, buffer, ServerVendor(Tk_Display(tkwin)),
550
            buffer2, (char *) NULL);
551
}
552
/*
553
 * Image stuff
554
 */
555
 
556
int
557
TkMacXDestroyImage(
558
    XImage *image)
559
{
560
    Debugger();
561
    return 0;
562
}
563
 
564
unsigned long
565
TkMacXGetPixel(
566
    XImage *image,
567
    int x,
568
    int y)
569
{
570
    Debugger();
571
    return 0;
572
}
573
 
574
int
575
TkMacXPutPixel(
576
    XImage *image,
577
    int x,
578
    int y,
579
    unsigned long pixel)
580
{
581
    /* Debugger(); */
582
    return 0;
583
}
584
 
585
XImage *
586
TkMacXSubImage(
587
    XImage *image,
588
    int x,
589
    int y,
590
    unsigned int width,
591
    unsigned int height)
592
{
593
    Debugger();
594
    return NULL;
595
}
596
 
597
int
598
TkMacXAddPixel(
599
    XImage *image,
600
    long value)
601
{
602
    Debugger();
603
    return 0;
604
}
605
 
606
/*
607
 *----------------------------------------------------------------------
608
 *
609
 * XChangeWindowAttributes, XSetWindowBackground,
610
 * XSetWindowBackgroundPixmap, XSetWindowBorder, XSetWindowBorderPixmap,
611
 * XSetWindowBorderWidth, XSetWindowColormap
612
 *
613
 *      These functions are all no-ops.  They all have equivilent
614
 *      Tk calls that should always be used instead.
615
 *
616
 * Results:
617
 *      None.
618
 *
619
 * Side effects:
620
 *      None.
621
 *
622
 *----------------------------------------------------------------------
623
 */
624
 
625
void
626
XChangeWindowAttributes(
627
    Display* display,
628
    Window w,
629
    unsigned long value_mask,
630
    XSetWindowAttributes* attributes)
631
{
632
}
633
 
634
void
635
XSetWindowBackground(
636
        Display *display,
637
        Window window,
638
        unsigned long value)
639
{
640
}
641
 
642
void
643
XSetWindowBackgroundPixmap(
644
    Display* display,
645
    Window w,
646
    Pixmap background_pixmap)
647
{
648
}
649
 
650
void
651
XSetWindowBorder(
652
    Display* display,
653
    Window w,
654
    unsigned long border_pixel)
655
{
656
}
657
 
658
void
659
XSetWindowBorderPixmap(
660
    Display* display,
661
    Window w,
662
    Pixmap border_pixmap)
663
{
664
}
665
 
666
void
667
XSetWindowBorderWidth(
668
    Display* display,
669
    Window w,
670
    unsigned int width)
671
{
672
}
673
 
674
void
675
XSetWindowColormap(
676
    Display* display,
677
    Window w,
678
    Colormap colormap)
679
{
680
    Debugger();
681
}
682
 
683
/*
684
 *----------------------------------------------------------------------
685
 *
686
 * TkGetDefaultScreenName --
687
 *
688
 *      Returns the name of the screen that Tk should use during
689
 *      initialization.
690
 *
691
 * Results:
692
 *      Returns a statically allocated string.
693
 *
694
 * Side effects:
695
 *      None.
696
 *
697
 *----------------------------------------------------------------------
698
 */
699
 
700
char *
701
TkGetDefaultScreenName(
702
    Tcl_Interp *interp,         /* Not used. */
703
    char *screenName)           /* If NULL, use default string. */
704
{
705
    if ((screenName == NULL) || (screenName[0] == '\0')) {
706
        screenName = macScreenName;
707
    }
708
    return screenName;
709
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.