Remove libXXXX.so.1.0 lines from .cvsignore files.
[wine] / dlls / ttydrv / objects.c
1 /*
2  * TTY DC objects
3  *
4  * Copyright 1999 Patrik Stridvall
5  */
6
7 #include "bitmap.h"
8 #include "brush.h"
9 #include "font.h"
10 #include "gdi.h"
11 #include "pen.h"
12 #include "ttydrv.h"
13 #include "debugtools.h"
14
15 DEFAULT_DEBUG_CHANNEL(ttydrv);
16
17 /**********************************************************************/
18
19 extern HBITMAP TTYDRV_DC_BITMAP_SelectObject(DC *dc, HBITMAP hbitmap, BITMAPOBJ *bitmap);
20 extern BOOL TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap, BITMAPOBJ *bitmap);
21
22
23 /***********************************************************************
24  *              TTYDRV_DC_BRUSH_SelectObject
25  */
26 static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush, BRUSHOBJ *brush)
27 {
28   HBRUSH hPreviousBrush;
29
30   TRACE("(%p, 0x%04x, %p)\n", dc, hbrush, brush);
31
32   hPreviousBrush = dc->hBrush;
33   dc->hBrush = hbrush;
34
35   return hPreviousBrush;
36 }
37
38 /***********************************************************************
39  *              TTYDRV_DC_FONT_SelectObject
40  */
41 static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont, FONTOBJ *font)
42 {
43   HFONT hPreviousFont;
44
45   TRACE("(%p, 0x%04x, %p)\n", dc, hfont, font);
46
47   hPreviousFont = dc->hFont;
48   dc->hFont = hfont;
49
50   return hPreviousFont;
51 }
52
53 /***********************************************************************
54  *              TTYDRV_DC_PEN_SelectObject
55  */
56 static HPEN TTYDRV_DC_PEN_SelectObject(DC *dc, HBRUSH hpen, PENOBJ *pen)
57 {
58   HPEN hPreviousPen;
59
60   TRACE("(%p, 0x%04x, %p)\n", dc, hpen, pen);
61
62   hPreviousPen = dc->hPen;
63   dc->hPen = hpen;
64
65   return hPreviousPen;
66 }
67
68 /***********************************************************************
69  *              TTYDRV_DC_SelectObject
70  */
71 HGDIOBJ TTYDRV_DC_SelectObject(DC *dc, HGDIOBJ handle)
72 {
73   GDIOBJHDR *ptr = GDI_GetObjPtr(handle, MAGIC_DONTCARE);
74   HGDIOBJ result = 0;
75
76   if(!ptr) return 0;
77
78   switch(GDIMAGIC(ptr->wMagic))
79   {
80     case BITMAP_MAGIC:
81       result = TTYDRV_DC_BITMAP_SelectObject(dc, handle, (BITMAPOBJ *) ptr);
82       break;
83     case BRUSH_MAGIC:
84       result = TTYDRV_DC_BRUSH_SelectObject(dc, handle, (BRUSHOBJ *) ptr);
85       break;
86     case FONT_MAGIC:
87       result = TTYDRV_DC_FONT_SelectObject(dc, handle, (FONTOBJ *) ptr);          
88       break;
89     case PEN_MAGIC:
90       result = TTYDRV_DC_PEN_SelectObject(dc, handle, (PENOBJ *) ptr);
91       break;
92     case REGION_MAGIC:
93       /* FIXME: Shouldn't be handled here */
94       result = (HGDIOBJ) SelectClipRgn(dc->hSelf, handle);
95       break;
96     default:
97       ERR("handle (0x%04x) has unknown magic (0x%04x)\n",
98                                                 handle, GDIMAGIC(ptr->wMagic));
99   }
100
101   GDI_ReleaseObj(handle);
102     
103   return result;
104 }
105
106 /***********************************************************************
107  *           TTYDRV_DC_DeleteObject
108  */
109 BOOL TTYDRV_DC_DeleteObject(HGDIOBJ handle)
110 {
111   GDIOBJHDR *ptr = GDI_GetObjPtr(handle, MAGIC_DONTCARE);
112   BOOL result;
113   
114   if(!ptr) return FALSE;
115      
116   switch(GDIMAGIC(ptr->wMagic))
117   {
118     case BITMAP_MAGIC:
119       result = TTYDRV_DC_BITMAP_DeleteObject(handle, (BITMAPOBJ *) ptr);
120       break;
121     case BRUSH_MAGIC:
122     case FONT_MAGIC:
123     case PEN_MAGIC:
124     case REGION_MAGIC:
125       result = TRUE;
126       break;
127     default:
128       ERR("handle (0x%04x) has unknown magic (0x%04x)\n",
129                                                 handle, GDIMAGIC(ptr->wMagic));   
130       result = FALSE;
131   }
132
133   GDI_ReleaseObj(handle);
134
135   return result;
136 }