Create an X window for every window, including children.
[wine] / graphics / x11drv / objects.c
1 /*
2  * GDI objects
3  *
4  * Copyright 1993 Alexandre Julliard
5  */
6
7 #include "config.h"
8
9 #include <stdlib.h>
10 #include <stdio.h>
11
12 #include "bitmap.h"
13 #include "brush.h"
14 #include "font.h"
15 #include "pen.h"
16 #include "debugtools.h"
17
18 DEFAULT_DEBUG_CHANNEL(gdi);
19
20
21 extern HBITMAP X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
22                                              BITMAPOBJ * bmp );
23 extern HBRUSH X11DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush,
24                                            BRUSHOBJ * brush );
25 extern HFONT X11DRV_FONT_SelectObject( DC * dc, HFONT hfont,
26                                          FONTOBJ * font );
27 extern HPEN X11DRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen );
28
29 extern BOOL X11DRV_BITMAP_DeleteObject( HBITMAP hbitmap, BITMAPOBJ *bmp );
30
31 /***********************************************************************
32  *           X11DRV_SelectObject
33  */
34 HGDIOBJ X11DRV_SelectObject( DC *dc, HGDIOBJ handle )
35 {
36     GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
37     HGDIOBJ ret = 0;
38
39     if (!ptr) return 0;
40     TRACE("hdc=%04x %04x\n", dc->hSelf, handle );
41     
42     switch(GDIMAGIC(ptr->wMagic))
43     {
44       case PEN_MAGIC:
45           ret = X11DRV_PEN_SelectObject( dc, handle, (PENOBJ *)ptr );
46           break;
47       case BRUSH_MAGIC:
48           ret = X11DRV_BRUSH_SelectObject( dc, handle, (BRUSHOBJ *)ptr );
49           break;
50       case BITMAP_MAGIC:
51           ret = X11DRV_BITMAP_SelectObject( dc, handle, (BITMAPOBJ *)ptr );
52           break;
53       case FONT_MAGIC:
54           ret = X11DRV_FONT_SelectObject( dc, handle, (FONTOBJ *)ptr );   
55           break;
56       case REGION_MAGIC:
57           ret = (HGDIOBJ16)SelectClipRgn16( dc->hSelf, handle );
58           break;
59     }
60     GDI_ReleaseObj( handle );
61     return ret;
62 }
63
64
65 /***********************************************************************
66  *           X11DRV_DeleteObject
67  */
68 BOOL X11DRV_DeleteObject( HGDIOBJ handle )
69 {
70     GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
71     BOOL ret = 0;
72
73     if (!ptr) return FALSE;
74      
75     switch(GDIMAGIC(ptr->wMagic)) {
76     case BITMAP_MAGIC:
77         ret = X11DRV_BITMAP_DeleteObject( handle, (BITMAPOBJ *)ptr );
78         break;
79
80     default:
81         ERR("Shouldn't be here!\n");
82         ret = FALSE;
83         break;
84     }
85     GDI_ReleaseObj( handle );
86     return ret;
87 }
88