Update shell xxxAW wrapper prototypes for fixed SHLWAPI functions.
[wine] / dlls / ttydrv / dc.c
1 /*
2  * TTY DC driver
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 "gdi.h"
24 #include "bitmap.h"
25 #include "palette.h"
26 #include "ttydrv.h"
27 #include "winbase.h"
28 #include "wine/debug.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
31
32 /**********************************************************************/
33
34 BITMAP_DRIVER TTYDRV_BITMAP_Driver =
35 {
36   TTYDRV_BITMAP_SetDIBits,
37   TTYDRV_BITMAP_GetDIBits,
38   TTYDRV_BITMAP_DeleteDIBSection,
39   TTYDRV_BITMAP_SetDIBColorTable,
40   TTYDRV_BITMAP_GetDIBColorTable,
41   TTYDRV_BITMAP_Lock,
42   TTYDRV_BITMAP_Unlock
43 };
44
45 PALETTE_DRIVER TTYDRV_PALETTE_Driver = 
46 {
47   TTYDRV_PALETTE_SetMapping,
48   TTYDRV_PALETTE_UpdateMapping,
49   TTYDRV_PALETTE_IsDark
50 };
51
52 const DC_FUNCTIONS *TTYDRV_DC_Funcs = NULL;  /* hack */
53
54 /**********************************************************************
55  *           TTYDRV_GDI_Initialize
56  */
57 BOOL TTYDRV_GDI_Initialize(void)
58 {
59   BITMAP_Driver = &TTYDRV_BITMAP_Driver;
60   PALETTE_Driver = &TTYDRV_PALETTE_Driver;
61
62   return TTYDRV_PALETTE_Initialize();
63 }
64
65 /***********************************************************************
66  *           TTYDRV_DC_CreateDC
67  */
68 BOOL TTYDRV_DC_CreateDC(DC *dc, LPCSTR driver, LPCSTR device,
69                         LPCSTR output, const DEVMODEA *initData)
70 {
71   TTYDRV_PDEVICE *physDev;
72   BITMAPOBJ *bmp;
73
74   TRACE("(%p, %s, %s, %s, %p)\n",
75     dc, debugstr_a(driver), debugstr_a(device), 
76     debugstr_a(output), initData);
77
78   if (!TTYDRV_DC_Funcs) TTYDRV_DC_Funcs = dc->funcs;  /* hack */
79
80   dc->physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
81                           sizeof(TTYDRV_PDEVICE));  
82   if(!dc->physDev) {
83     ERR("Can't allocate physDev\n");
84     return FALSE;
85   }
86   physDev = (TTYDRV_PDEVICE *) dc->physDev;
87   
88   if(dc->flags & DC_MEMORY){
89     physDev->window = NULL;
90     physDev->cellWidth = 1;
91     physDev->cellHeight = 1;
92
93     TTYDRV_DC_CreateBitmap(dc->hBitmap);
94     bmp = (BITMAPOBJ *) GDI_GetObjPtr(dc->hBitmap, BITMAP_MAGIC);
95                                    
96     dc->bitsPerPixel = bmp->bitmap.bmBitsPixel;
97     
98     dc->totalExtent.left   = 0;
99     dc->totalExtent.top    = 0;
100     dc->totalExtent.right  = bmp->bitmap.bmWidth;
101     dc->totalExtent.bottom = bmp->bitmap.bmHeight;
102     dc->hVisRgn            = CreateRectRgnIndirect( &dc->totalExtent );
103     
104     GDI_ReleaseObj( dc->hBitmap );
105   } else {
106     physDev->window = root_window;
107     physDev->cellWidth = cell_width;
108     physDev->cellHeight = cell_height;
109     
110     dc->bitsPerPixel       = 1;
111     dc->totalExtent.left   = 0;
112     dc->totalExtent.top    = 0;
113     dc->totalExtent.right  = cell_width * screen_cols;
114     dc->totalExtent.bottom = cell_height * screen_rows;
115     dc->hVisRgn            = CreateRectRgnIndirect( &dc->totalExtent );    
116   }
117
118   return TRUE;
119 }
120
121 /***********************************************************************
122  *           TTYDRV_DC_DeleteDC
123  */
124 BOOL TTYDRV_DC_DeleteDC(DC *dc)
125 {
126   TRACE("(%p)\n", dc);
127
128   HeapFree( GetProcessHeap(), 0, dc->physDev );
129   dc->physDev = NULL;
130   
131   return TRUE;
132 }
133
134
135 /***********************************************************************
136  *           GetDeviceCaps    (TTYDRV.@)
137  */
138 INT TTYDRV_GetDeviceCaps( DC *dc, INT cap )
139 {
140     switch(cap)
141     {
142     case DRIVERVERSION:
143         return 0x300;
144     case TECHNOLOGY:
145         return DT_RASDISPLAY;
146     case HORZSIZE:
147         return 0;    /* FIXME: Screen width in mm */
148     case VERTSIZE:
149         return 0;    /* FIXME: Screen height in mm */
150     case HORZRES:
151         return 640;  /* FIXME: Screen width in pixel */
152     case VERTRES:
153         return 480;  /* FIXME: Screen height in pixel */
154     case BITSPIXEL:
155         return 1;    /* FIXME */
156     case PLANES:
157         return 1;
158     case NUMBRUSHES:
159         return 16 + 6;
160     case NUMPENS:
161         return 16;
162     case NUMMARKERS:
163         return 0;
164     case NUMFONTS:
165         return 0;
166     case NUMCOLORS:
167         return 100;
168     case PDEVICESIZE:
169         return sizeof(TTYDRV_PDEVICE);
170     case CURVECAPS:
171         return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
172                 CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
173     case LINECAPS:
174         return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
175                 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
176     case POLYGONALCAPS:
177         return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
178                 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
179     case TEXTCAPS:
180         return 0;
181     case CLIPCAPS:
182         return CP_REGION;
183     case RASTERCAPS:
184         return (RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 | RC_DI_BITMAP |
185                 RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS);
186     case ASPECTX:
187     case ASPECTY:
188         return 36;
189     case ASPECTXY:
190         return 51;
191     case LOGPIXELSX:
192     case LOGPIXELSY:
193         return 72;  /* FIXME */
194     case SIZEPALETTE:
195         return 256;  /* FIXME */
196     case NUMRESERVED:
197         return 0;
198     case COLORRES:
199         return 0;
200     case PHYSICALWIDTH:
201     case PHYSICALHEIGHT:
202     case PHYSICALOFFSETX:
203     case PHYSICALOFFSETY:
204     case SCALINGFACTORX:
205     case SCALINGFACTORY:
206     case VREFRESH:
207     case DESKTOPVERTRES:
208     case DESKTOPHORZRES:
209     case BTLALIGNMENT:
210         return 0;
211     default:
212         FIXME("(%04x): unsupported capability %d, will return 0\n", dc->hSelf, cap );
213         return 0;
214     }
215 }
216
217
218 /***********************************************************************
219  *              TTYDRV_DC_SetDeviceClipping
220  */
221 void TTYDRV_DC_SetDeviceClipping(DC *dc)
222 {
223   TRACE("(%p)\n", dc);
224 }