Better implementation of GetCalendarInfo{A,W}, not perfect.
[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 "ttydrv.h"
25 #include "winbase.h"
26 #include "wine/debug.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
29
30 /**********************************************************************/
31
32 const DC_FUNCTIONS *TTYDRV_DC_Funcs = NULL;  /* hack */
33
34 /**********************************************************************
35  *           TTYDRV_GDI_Initialize
36  */
37 BOOL TTYDRV_GDI_Initialize(void)
38 {
39   return TTYDRV_PALETTE_Initialize();
40 }
41
42 /***********************************************************************
43  *           TTYDRV_DC_CreateDC
44  */
45 BOOL TTYDRV_DC_CreateDC(DC *dc, LPCSTR driver, LPCSTR device,
46                         LPCSTR output, const DEVMODEA *initData)
47 {
48   TTYDRV_PDEVICE *physDev;
49
50   TRACE("(%p, %s, %s, %s, %p)\n",
51     dc, debugstr_a(driver), debugstr_a(device), 
52     debugstr_a(output), initData);
53
54   if (!TTYDRV_DC_Funcs) TTYDRV_DC_Funcs = dc->funcs;  /* hack */
55
56   dc->physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
57                           sizeof(TTYDRV_PDEVICE));  
58   if(!dc->physDev) {
59     ERR("Can't allocate physDev\n");
60     return FALSE;
61   }
62   physDev = (TTYDRV_PDEVICE *) dc->physDev;
63   physDev->hdc = dc->hSelf;
64   physDev->dc = dc;
65
66   if(dc->flags & DC_MEMORY){
67     physDev->window = NULL;
68     physDev->cellWidth = 1;
69     physDev->cellHeight = 1;
70
71     TTYDRV_DC_CreateBitmap(dc->hBitmap);
72   } else {
73     physDev->window = root_window;
74     physDev->cellWidth = cell_width;
75     physDev->cellHeight = cell_height;
76
77     dc->bitsPerPixel = 1;
78   }
79
80   return TRUE;
81 }
82
83 /***********************************************************************
84  *           TTYDRV_DC_DeleteDC
85  */
86 BOOL TTYDRV_DC_DeleteDC(TTYDRV_PDEVICE *physDev)
87 {
88     TRACE("(%x)\n", physDev->hdc);
89
90     physDev->dc->physDev = NULL;
91     HeapFree( GetProcessHeap(), 0, physDev );
92     return TRUE;
93 }
94
95
96 /***********************************************************************
97  *           GetDeviceCaps    (TTYDRV.@)
98  */
99 INT TTYDRV_GetDeviceCaps( TTYDRV_PDEVICE *physDev, INT cap )
100 {
101     switch(cap)
102     {
103     case DRIVERVERSION:
104         return 0x300;
105     case TECHNOLOGY:
106         return DT_RASDISPLAY;
107     case HORZSIZE:
108         return 0;    /* FIXME: Screen width in mm */
109     case VERTSIZE:
110         return 0;    /* FIXME: Screen height in mm */
111     case HORZRES:
112         return cell_width * screen_cols;
113     case VERTRES:
114         return cell_height * screen_rows;
115     case BITSPIXEL:
116         return 1;    /* FIXME */
117     case PLANES:
118         return 1;
119     case NUMBRUSHES:
120         return 16 + 6;
121     case NUMPENS:
122         return 16;
123     case NUMMARKERS:
124         return 0;
125     case NUMFONTS:
126         return 0;
127     case NUMCOLORS:
128         return 100;
129     case PDEVICESIZE:
130         return sizeof(TTYDRV_PDEVICE);
131     case CURVECAPS:
132         return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
133                 CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
134     case LINECAPS:
135         return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
136                 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
137     case POLYGONALCAPS:
138         return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
139                 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
140     case TEXTCAPS:
141         return 0;
142     case CLIPCAPS:
143         return CP_REGION;
144     case RASTERCAPS:
145         return (RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 | RC_DI_BITMAP |
146                 RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS);
147     case ASPECTX:
148     case ASPECTY:
149         return 36;
150     case ASPECTXY:
151         return 51;
152     case LOGPIXELSX:
153     case LOGPIXELSY:
154         return 72;  /* FIXME */
155     case SIZEPALETTE:
156         return 256;  /* FIXME */
157     case NUMRESERVED:
158         return 0;
159     case COLORRES:
160         return 0;
161     case PHYSICALWIDTH:
162     case PHYSICALHEIGHT:
163     case PHYSICALOFFSETX:
164     case PHYSICALOFFSETY:
165     case SCALINGFACTORX:
166     case SCALINGFACTORY:
167     case VREFRESH:
168     case DESKTOPVERTRES:
169     case DESKTOPHORZRES:
170     case BTLALIGNMENT:
171         return 0;
172     default:
173         FIXME("(%04x): unsupported capability %d, will return 0\n", physDev->hdc, cap );
174         return 0;
175     }
176 }