Update shell xxxAW wrapper prototypes for fixed SHLWAPI functions.
[wine] / dlls / ttydrv / objects.c
1 /*
2  * TTY DC objects
3  *
4  * Copyright 1999 Patrik Stridvall
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include "bitmap.h"
24 #include "gdi.h"
25 #include "ttydrv.h"
26 #include "wine/debug.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
29
30 /**********************************************************************/
31
32 extern HBITMAP TTYDRV_DC_BITMAP_SelectObject(DC *dc, HBITMAP hbitmap, BITMAPOBJ *bitmap);
33 extern BOOL TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap, BITMAPOBJ *bitmap);
34
35
36 /***********************************************************************
37  *              TTYDRV_DC_BRUSH_SelectObject
38  */
39 static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush)
40 {
41   HBRUSH hPreviousBrush;
42
43   TRACE("(%p, 0x%04x)\n", dc, hbrush);
44
45   hPreviousBrush = dc->hBrush;
46   dc->hBrush = hbrush;
47
48   return hPreviousBrush;
49 }
50
51 /***********************************************************************
52  *              TTYDRV_DC_FONT_SelectObject
53  */
54 static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont)
55 {
56   TRACE("(%p, 0x%04x)\n", dc, hfont);
57
58   return TRUE; /* Use device font */
59 }
60
61 /***********************************************************************
62  *              TTYDRV_DC_PEN_SelectObject
63  */
64 static HPEN TTYDRV_DC_PEN_SelectObject(DC *dc, HBRUSH hpen)
65 {
66   HPEN hPreviousPen;
67
68   TRACE("(%p, 0x%04x)\n", dc, hpen);
69
70   hPreviousPen = dc->hPen;
71   dc->hPen = hpen;
72
73   return hPreviousPen;
74 }
75
76 /***********************************************************************
77  *              TTYDRV_DC_SelectObject
78  */
79 HGDIOBJ TTYDRV_DC_SelectObject(DC *dc, HGDIOBJ handle)
80 {
81   GDIOBJHDR *ptr = GDI_GetObjPtr(handle, MAGIC_DONTCARE);
82   HGDIOBJ result = 0;
83
84   if(!ptr) return 0;
85
86   switch(GDIMAGIC(ptr->wMagic))
87   {
88     case BITMAP_MAGIC:
89       result = TTYDRV_DC_BITMAP_SelectObject(dc, handle, (BITMAPOBJ *) ptr);
90       break;
91     case BRUSH_MAGIC:
92       result = TTYDRV_DC_BRUSH_SelectObject(dc, handle);
93       break;
94     case FONT_MAGIC:
95       result = TTYDRV_DC_FONT_SelectObject(dc, handle);
96       break;
97     case PEN_MAGIC:
98       result = TTYDRV_DC_PEN_SelectObject(dc, handle);
99       break;
100     case REGION_MAGIC:
101       /* FIXME: Shouldn't be handled here */
102       result = (HGDIOBJ) SelectClipRgn(dc->hSelf, handle);
103       break;
104     default:
105       ERR("handle (0x%04x) has unknown magic (0x%04x)\n",
106                                                 handle, GDIMAGIC(ptr->wMagic));
107   }
108
109   GDI_ReleaseObj(handle);
110     
111   return result;
112 }
113
114 /***********************************************************************
115  *           TTYDRV_DC_DeleteObject
116  */
117 BOOL TTYDRV_DC_DeleteObject(HGDIOBJ handle)
118 {
119   GDIOBJHDR *ptr = GDI_GetObjPtr(handle, MAGIC_DONTCARE);
120   BOOL result;
121   
122   if(!ptr) return FALSE;
123      
124   switch(GDIMAGIC(ptr->wMagic))
125   {
126     case BITMAP_MAGIC:
127       result = TTYDRV_DC_BITMAP_DeleteObject(handle, (BITMAPOBJ *) ptr);
128       break;
129     case BRUSH_MAGIC:
130     case FONT_MAGIC:
131     case PEN_MAGIC:
132     case REGION_MAGIC:
133       result = TRUE;
134       break;
135     default:
136       ERR("handle (0x%04x) has unknown magic (0x%04x)\n",
137                                                 handle, GDIMAGIC(ptr->wMagic));   
138       result = FALSE;
139   }
140
141   GDI_ReleaseObj(handle);
142
143   return result;
144 }