Removed some direct accesses to the DC structure.
[wine/multimedia.git] / dlls / ttydrv / dc.c
blob9a1c6f97c0beb6af38011ceb1fa29bc5f38bcb5c
1 /*
2 * TTY DC driver
4 * Copyright 1999 Patrik Stridvall
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.
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.
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
21 #include "config.h"
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"
30 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
32 /**********************************************************************/
34 PALETTE_DRIVER TTYDRV_PALETTE_Driver =
36 TTYDRV_PALETTE_SetMapping,
37 TTYDRV_PALETTE_UpdateMapping,
38 TTYDRV_PALETTE_IsDark
41 const DC_FUNCTIONS *TTYDRV_DC_Funcs = NULL; /* hack */
43 /**********************************************************************
44 * TTYDRV_GDI_Initialize
46 BOOL TTYDRV_GDI_Initialize(void)
48 PALETTE_Driver = &TTYDRV_PALETTE_Driver;
50 return TTYDRV_PALETTE_Initialize();
53 /***********************************************************************
54 * TTYDRV_DC_CreateDC
56 BOOL TTYDRV_DC_CreateDC(DC *dc, LPCSTR driver, LPCSTR device,
57 LPCSTR output, const DEVMODEA *initData)
59 TTYDRV_PDEVICE *physDev;
60 BITMAPOBJ *bmp;
62 TRACE("(%p, %s, %s, %s, %p)\n",
63 dc, debugstr_a(driver), debugstr_a(device),
64 debugstr_a(output), initData);
66 if (!TTYDRV_DC_Funcs) TTYDRV_DC_Funcs = dc->funcs; /* hack */
68 dc->physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
69 sizeof(TTYDRV_PDEVICE));
70 if(!dc->physDev) {
71 ERR("Can't allocate physDev\n");
72 return FALSE;
74 physDev = (TTYDRV_PDEVICE *) dc->physDev;
75 physDev->hdc = dc->hSelf;
76 physDev->dc = dc;
78 if(dc->flags & DC_MEMORY){
79 physDev->window = NULL;
80 physDev->cellWidth = 1;
81 physDev->cellHeight = 1;
83 TTYDRV_DC_CreateBitmap(dc->hBitmap);
84 bmp = (BITMAPOBJ *) GDI_GetObjPtr(dc->hBitmap, BITMAP_MAGIC);
86 dc->bitsPerPixel = bmp->bitmap.bmBitsPixel;
88 dc->totalExtent.left = 0;
89 dc->totalExtent.top = 0;
90 dc->totalExtent.right = bmp->bitmap.bmWidth;
91 dc->totalExtent.bottom = bmp->bitmap.bmHeight;
92 dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
94 GDI_ReleaseObj( dc->hBitmap );
95 } else {
96 physDev->window = root_window;
97 physDev->cellWidth = cell_width;
98 physDev->cellHeight = cell_height;
100 dc->bitsPerPixel = 1;
101 dc->totalExtent.left = 0;
102 dc->totalExtent.top = 0;
103 dc->totalExtent.right = cell_width * screen_cols;
104 dc->totalExtent.bottom = cell_height * screen_rows;
105 dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
108 return TRUE;
111 /***********************************************************************
112 * TTYDRV_DC_DeleteDC
114 BOOL TTYDRV_DC_DeleteDC(TTYDRV_PDEVICE *physDev)
116 TRACE("(%x)\n", physDev->hdc);
118 physDev->dc->physDev = NULL;
119 HeapFree( GetProcessHeap(), 0, physDev );
120 return TRUE;
124 /***********************************************************************
125 * GetDeviceCaps (TTYDRV.@)
127 INT TTYDRV_GetDeviceCaps( TTYDRV_PDEVICE *physDev, INT cap )
129 switch(cap)
131 case DRIVERVERSION:
132 return 0x300;
133 case TECHNOLOGY:
134 return DT_RASDISPLAY;
135 case HORZSIZE:
136 return 0; /* FIXME: Screen width in mm */
137 case VERTSIZE:
138 return 0; /* FIXME: Screen height in mm */
139 case HORZRES:
140 return 640; /* FIXME: Screen width in pixel */
141 case VERTRES:
142 return 480; /* FIXME: Screen height in pixel */
143 case BITSPIXEL:
144 return 1; /* FIXME */
145 case PLANES:
146 return 1;
147 case NUMBRUSHES:
148 return 16 + 6;
149 case NUMPENS:
150 return 16;
151 case NUMMARKERS:
152 return 0;
153 case NUMFONTS:
154 return 0;
155 case NUMCOLORS:
156 return 100;
157 case PDEVICESIZE:
158 return sizeof(TTYDRV_PDEVICE);
159 case CURVECAPS:
160 return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
161 CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
162 case LINECAPS:
163 return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
164 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
165 case POLYGONALCAPS:
166 return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
167 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
168 case TEXTCAPS:
169 return 0;
170 case CLIPCAPS:
171 return CP_REGION;
172 case RASTERCAPS:
173 return (RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 | RC_DI_BITMAP |
174 RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS);
175 case ASPECTX:
176 case ASPECTY:
177 return 36;
178 case ASPECTXY:
179 return 51;
180 case LOGPIXELSX:
181 case LOGPIXELSY:
182 return 72; /* FIXME */
183 case SIZEPALETTE:
184 return 256; /* FIXME */
185 case NUMRESERVED:
186 return 0;
187 case COLORRES:
188 return 0;
189 case PHYSICALWIDTH:
190 case PHYSICALHEIGHT:
191 case PHYSICALOFFSETX:
192 case PHYSICALOFFSETY:
193 case SCALINGFACTORX:
194 case SCALINGFACTORY:
195 case VREFRESH:
196 case DESKTOPVERTRES:
197 case DESKTOPHORZRES:
198 case BTLALIGNMENT:
199 return 0;
200 default:
201 FIXME("(%04x): unsupported capability %d, will return 0\n", physDev->hdc, cap );
202 return 0;