Added a first-cut version of MapVirtualKeyExW() that has the same
[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 "local.h"
17 #include "debugtools.h"
18
19 DEFAULT_DEBUG_CHANNEL(gdi);
20
21
22 extern HBITMAP X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
23                                              BITMAPOBJ * bmp );
24 extern HBRUSH X11DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush,
25                                            BRUSHOBJ * brush );
26 extern HFONT X11DRV_FONT_SelectObject( DC * dc, HFONT hfont,
27                                          FONTOBJ * font );
28 extern HPEN X11DRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen );
29
30 extern BOOL X11DRV_BITMAP_DeleteObject( HBITMAP hbitmap, BITMAPOBJ *bmp );
31
32 /***********************************************************************
33  *           X11DRV_SelectObject
34  */
35 HGDIOBJ X11DRV_SelectObject( DC *dc, HGDIOBJ handle )
36 {
37     GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
38     HGDIOBJ ret = 0;
39
40     if (!ptr) return 0;
41     TRACE("hdc=%04x %04x\n", dc->hSelf, handle );
42     
43     switch(GDIMAGIC(ptr->wMagic))
44     {
45       case PEN_MAGIC:
46           ret = X11DRV_PEN_SelectObject( dc, handle, (PENOBJ *)ptr );
47           break;
48       case BRUSH_MAGIC:
49           ret = X11DRV_BRUSH_SelectObject( dc, handle, (BRUSHOBJ *)ptr );
50           break;
51       case BITMAP_MAGIC:
52           ret = X11DRV_BITMAP_SelectObject( dc, handle, (BITMAPOBJ *)ptr );
53           break;
54       case FONT_MAGIC:
55           ret = X11DRV_FONT_SelectObject( dc, handle, (FONTOBJ *)ptr );   
56           break;
57       case REGION_MAGIC:
58           ret = (HGDIOBJ16)SelectClipRgn16( dc->hSelf, handle );
59           break;
60     }
61     GDI_ReleaseObj( handle );
62     return ret;
63 }
64
65
66 /***********************************************************************
67  *           X11DRV_DeleteObject
68  */
69 BOOL X11DRV_DeleteObject( HGDIOBJ handle )
70 {
71     GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
72     BOOL ret = 0;
73
74     if (!ptr) return FALSE;
75      
76     switch(GDIMAGIC(ptr->wMagic)) {
77     case BITMAP_MAGIC:
78         ret = X11DRV_BITMAP_DeleteObject( handle, (BITMAPOBJ *)ptr );
79         break;
80
81     default:
82         ERR("Shouldn't be here!\n");
83         ret = FALSE;
84         break;
85     }
86     GDI_ReleaseObj( handle );
87     return ret;
88 }
89