Added YUV routines needed for v4l driver, and in the future possibly
[wine/gsoc-2012-control.git] / dlls / ttydrv / graphics.c
blob08185069238dc208c0fe901b42e21c36e0bc27f0
1 /*
2 * TTY DC graphics
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 <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winnls.h"
28 #include "wine/debug.h"
29 #include "ttydrv.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
33 /***********************************************************************
34 * TTYDRV_DC_Arc
36 BOOL TTYDRV_DC_Arc(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom,
37 INT xstart, INT ystart, INT xend, INT yend)
39 FIXME("(%p, %d, %d, %d, %d, %d, %d, %d, %d): stub\n",
40 physDev->hdc, left, top, right, bottom, xstart, ystart, xend, yend);
41 return TRUE;
44 /***********************************************************************
45 * TTYDRV_DC_Chord
47 BOOL TTYDRV_DC_Chord(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom,
48 INT xstart, INT ystart, INT xend, INT yend)
50 FIXME("(%p, %d, %d, %d, %d, %d, %d, %d, %d): stub\n",
51 physDev->hdc, left, top, right, bottom, xstart, ystart, xend, yend);
52 return TRUE;
55 /***********************************************************************
56 * TTYDRV_DC_Ellipse
58 BOOL TTYDRV_DC_Ellipse(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom)
60 FIXME("(%p, %d, %d, %d, %d): stub\n", physDev->hdc, left, top, right, bottom);
61 return TRUE;
64 /***********************************************************************
65 * TTYDRV_DC_ExtFloodFill
67 BOOL TTYDRV_DC_ExtFloodFill(TTYDRV_PDEVICE *physDev, INT x, INT y,
68 COLORREF color, UINT fillType)
70 FIXME("(%p, %d, %d, 0x%08lx, %u): stub\n", physDev->hdc, x, y, color, fillType);
71 return TRUE;
74 /***********************************************************************
75 * TTYDRV_DC_GetPixel
77 COLORREF TTYDRV_DC_GetPixel(TTYDRV_PDEVICE *physDev, INT x, INT y)
79 FIXME("(%p, %d, %d): stub\n", physDev->hdc, x, y);
80 return RGB(0,0,0); /* FIXME: Always returns black */
83 /***********************************************************************
84 * TTYDRV_DC_LineTo
86 BOOL TTYDRV_DC_LineTo(TTYDRV_PDEVICE *physDev, INT x, INT y)
88 #ifdef WINE_CURSES
89 INT row1, col1, row2, col2;
90 POINT pt[2];
92 TRACE("(%p, %d, %d)\n", physDev->hdc, x, y);
94 if(!physDev->window)
95 return FALSE;
97 GetCurrentPositionEx( physDev->hdc, &pt[0] );
98 pt[1].x = x;
99 pt[1].y = y;
100 LPtoDP( physDev->hdc, pt, 2 );
102 row1 = (physDev->org.y + pt[0].y) / physDev->cellHeight;
103 col1 = (physDev->org.x + pt[0].x) / physDev->cellWidth;
104 row2 = (physDev->org.y + pt[1].y) / physDev->cellHeight;
105 col2 = (physDev->org.x + pt[1].x) / physDev->cellWidth;
107 if(row1 > row2) {
108 INT tmp = row1;
109 row1 = row2;
110 row2 = tmp;
113 if(col1 > col2) {
114 INT tmp = col1;
115 col1 = col2;
116 col2 = tmp;
119 wmove(physDev->window, row1, col1);
120 if(col1 == col2) {
121 wvline(physDev->window, ACS_VLINE, row2-row1);
122 } else if(row1 == row2) {
123 whline(physDev->window, ACS_HLINE, col2-col1);
124 } else {
125 FIXME("Diagonal line drawing not yet supported\n");
127 wrefresh(physDev->window);
129 return TRUE;
130 #else /* defined(WINE_CURSES) */
131 FIXME("(%p, %d, %d): stub\n", physDev->hdc, x, y);
133 return TRUE;
134 #endif /* defined(WINE_CURSES) */
137 /***********************************************************************
138 * TTYDRV_DC_PaintRgn
140 BOOL TTYDRV_DC_PaintRgn(TTYDRV_PDEVICE *physDev, HRGN hrgn)
142 FIXME("(%p, %p): stub\n", physDev->hdc, hrgn);
143 return TRUE;
146 /***********************************************************************
147 * TTYDRV_DC_Pie
149 BOOL TTYDRV_DC_Pie(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom,
150 INT xstart, INT ystart, INT xend, INT yend)
152 FIXME("(%p, %d, %d, %d, %d, %d, %d, %d, %d): stub\n",
153 physDev->hdc, left, top, right, bottom, xstart, ystart, xend, yend);
154 return TRUE;
157 /***********************************************************************
158 * TTYDRV_DC_Polygon
160 BOOL TTYDRV_DC_Polygon(TTYDRV_PDEVICE *physDev, const POINT* pt, INT count)
162 FIXME("(%p, %p, %d): stub\n", physDev->hdc, pt, count);
163 return TRUE;
166 /***********************************************************************
167 * TTYDRV_DC_Polyline
169 BOOL TTYDRV_DC_Polyline(TTYDRV_PDEVICE *physDev, const POINT* pt, INT count)
171 FIXME("(%p, %p, %d): stub\n", physDev->hdc, pt, count);
172 return TRUE;
175 /***********************************************************************
176 * TTYDRV_DC_PolyPolygon
178 BOOL TTYDRV_DC_PolyPolygon(TTYDRV_PDEVICE *physDev, const POINT* pt, const INT* counts, UINT polygons)
180 FIXME("(%p, %p, %p, %u): stub\n", physDev->hdc, pt, counts, polygons);
181 return TRUE;
184 /***********************************************************************
185 * TTYDRV_DC_PolyPolyline
187 BOOL TTYDRV_DC_PolyPolyline(TTYDRV_PDEVICE *physDev, const POINT* pt, const DWORD* counts, DWORD polylines)
189 FIXME("(%p, %p, %p, %lu): stub\n", physDev->hdc, pt, counts, polylines);
191 return TRUE;
194 /***********************************************************************
195 * TTYDRV_DC_Rectangle
197 BOOL TTYDRV_DC_Rectangle(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom)
199 #ifdef WINE_CURSES
200 INT row1, col1, row2, col2;
201 RECT rect;
203 TRACE("(%p, %d, %d, %d, %d)\n", physDev->hdc, left, top, right, bottom);
205 if(!physDev->window)
206 return FALSE;
208 rect.left = left;
209 rect.top = top;
210 rect.right = right;
211 rect.bottom = bottom;
212 LPtoDP( physDev->hdc, (POINT *)&rect, 2 );
213 row1 = (physDev->org.y + rect.top) / physDev->cellHeight;
214 col1 = (physDev->org.x + rect.left) / physDev->cellWidth;
215 row2 = (physDev->org.y + rect.bottom) / physDev->cellHeight;
216 col2 = (physDev->org.x + rect.right) / physDev->cellWidth;
218 if(row1 > row2) {
219 INT tmp = row1;
220 row1 = row2;
221 row2 = tmp;
223 if(col1 > col2) {
224 INT tmp = col1;
225 col1 = col2;
226 col2 = tmp;
229 wmove(physDev->window, row1, col1);
230 whline(physDev->window, ACS_HLINE, col2-col1);
232 wmove(physDev->window, row1, col2);
233 wvline(physDev->window, ACS_VLINE, row2-row1);
235 wmove(physDev->window, row2, col1);
236 whline(physDev->window, ACS_HLINE, col2-col1);
238 wmove(physDev->window, row1, col1);
239 wvline(physDev->window, ACS_VLINE, row2-row1);
241 mvwaddch(physDev->window, row1, col1, ACS_ULCORNER);
242 mvwaddch(physDev->window, row1, col2, ACS_URCORNER);
243 mvwaddch(physDev->window, row2, col2, ACS_LRCORNER);
244 mvwaddch(physDev->window, row2, col1, ACS_LLCORNER);
246 wrefresh(physDev->window);
248 return TRUE;
249 #else /* defined(WINE_CURSES) */
250 FIXME("(%p, %d, %d, %d, %d): stub\n", physDev->hdc, left, top, right, bottom);
252 return TRUE;
253 #endif /* defined(WINE_CURSES) */
256 /***********************************************************************
257 * TTYDRV_DC_RoundRect
259 BOOL TTYDRV_DC_RoundRect(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right,
260 INT bottom, INT ell_width, INT ell_height)
262 FIXME("(%p, %d, %d, %d, %d, %d, %d): stub\n",
263 physDev->hdc, left, top, right, bottom, ell_width, ell_height);
265 return TRUE;
268 /***********************************************************************
269 * TTYDRV_DC_SetPixel
271 COLORREF TTYDRV_DC_SetPixel(TTYDRV_PDEVICE *physDev, INT x, INT y, COLORREF color)
273 #ifdef WINE_CURSES
274 INT row, col;
275 POINT pt;
277 TRACE("(%p, %d, %d, 0x%08lx)\n", physDev->hdc, x, y, color);
279 if(!physDev->window)
280 return FALSE;
282 pt.x = x;
283 pt.y = y;
284 LPtoDP( physDev->hdc, &pt, 1 );
285 row = (physDev->org.y + pt.y) / physDev->cellHeight;
286 col = (physDev->org.x + pt.x) / physDev->cellWidth;
288 mvwaddch(physDev->window, row, col, ACS_BULLET);
289 wrefresh(physDev->window);
291 return RGB(0,0,0); /* FIXME: Always returns black */
292 #else /* defined(WINE_CURSES) */
293 FIXME("(%p, %d, %d, 0x%08lx): stub\n", physDev->hdc, x, y, color);
295 return RGB(0,0,0); /* FIXME: Always returns black */
296 #endif /* defined(WINE_CURSES) */
299 /***********************************************************************
300 * TTYDRV_DC_BitBlt
302 BOOL TTYDRV_DC_BitBlt(TTYDRV_PDEVICE *physDevDst, INT xDst, INT yDst,
303 INT width, INT height, TTYDRV_PDEVICE *physDevSrc,
304 INT xSrc, INT ySrc, DWORD rop)
306 FIXME("(%p, %d, %d, %d, %d, %p, %d, %d, %lu): stub\n",
307 physDevDst->hdc, xDst, yDst, width, height, physDevSrc->hdc, xSrc, ySrc, rop );
308 return TRUE;
311 /***********************************************************************
312 * TTYDRV_DC_PatBlt
314 BOOL TTYDRV_DC_PatBlt(TTYDRV_PDEVICE *physDev, INT left, INT top,
315 INT width, INT height, DWORD rop)
317 FIXME("(%p, %d, %d, %d, %d, %lu): stub\n", physDev->hdc, left, top, width, height, rop );
318 return TRUE;
321 /***********************************************************************
322 * TTYDRV_DC_StretchBlt
324 BOOL TTYDRV_DC_StretchBlt(TTYDRV_PDEVICE *physDevDst, INT xDst, INT yDst,
325 INT widthDst, INT heightDst,
326 TTYDRV_PDEVICE *physDevSrc, INT xSrc, INT ySrc,
327 INT widthSrc, INT heightSrc, DWORD rop)
329 FIXME("(%p, %d, %d, %d, %d, %p, %d, %d, %d, %d, %lu): stub\n",
330 physDevDst->hdc, xDst, yDst, widthDst, heightDst,
331 physDevSrc->hdc, xSrc, ySrc, widthSrc, heightSrc, rop );
333 return TRUE;
336 /***********************************************************************
337 * TTYDRV_DC_ExtTextOut
339 BOOL TTYDRV_DC_ExtTextOut(TTYDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
340 const RECT *lpRect, LPCWSTR str, UINT count,
341 const INT *lpDx, INT breakExtra )
343 #ifdef WINE_CURSES
344 INT row, col;
345 LPSTR ascii;
346 DWORD len;
347 POINT pt;
348 UINT text_align = GetTextAlign( physDev->hdc );
350 TRACE("(%p, %d, %d, 0x%08x, %p, %s, %d, %p)\n",
351 physDev->hdc, x, y, flags, lpRect, debugstr_wn(str, count), count, lpDx);
353 if(!physDev->window)
354 return FALSE;
356 pt.x = x;
357 pt.y = y;
358 /* FIXME: Is this really correct? */
359 if(text_align & TA_UPDATECP) GetCurrentPositionEx( physDev->hdc, &pt );
361 LPtoDP( physDev->hdc, &pt, 1 );
362 row = (physDev->org.y + pt.y) / physDev->cellHeight;
363 col = (physDev->org.x + pt.x) / physDev->cellWidth;
364 len = WideCharToMultiByte( CP_ACP, 0, str, count, NULL, 0, NULL, NULL );
365 ascii = HeapAlloc( GetProcessHeap(), 0, len );
366 WideCharToMultiByte( CP_ACP, 0, str, count, ascii, len, NULL, NULL );
367 mvwaddnstr(physDev->window, row, col, ascii, len);
368 HeapFree( GetProcessHeap(), 0, ascii );
369 wrefresh(physDev->window);
371 if(text_align & TA_UPDATECP)
373 pt.x += count * physDev->cellWidth;
374 pt.y += physDev->cellHeight;
375 DPtoLP( physDev->hdc, &pt, 1 );
376 MoveToEx( physDev->hdc, pt.x, pt.y, NULL );
379 return TRUE;
380 #else /* defined(WINE_CURSES) */
381 FIXME("(%p, %d, %d, 0x%08x, %p, %s, %d, %p): stub\n",
382 physDev->hdc, x, y, flags, lpRect, debugstr_wn(str,count), count, lpDx);
384 return TRUE;
385 #endif /* defined(WINE_CURSES) */
388 /***********************************************************************
389 * TTYDRV_DC_GetCharWidth
391 BOOL TTYDRV_DC_GetCharWidth(TTYDRV_PDEVICE *physDev, UINT firstChar, UINT lastChar,
392 LPINT buffer)
394 UINT c;
396 FIXME("(%p, %u, %u, %p): semistub\n", physDev->hdc, firstChar, lastChar, buffer);
398 for(c=firstChar; c<=lastChar; c++) {
399 buffer[c-firstChar] = physDev->cellWidth;
402 return TRUE;
405 /***********************************************************************
406 * TTYDRV_DC_GetTextExtentPoint
408 BOOL TTYDRV_DC_GetTextExtentPoint(TTYDRV_PDEVICE *physDev, LPCWSTR str, INT count,
409 LPSIZE size)
411 TRACE("(%p, %s, %d, %p)\n", physDev->hdc, debugstr_wn(str, count), count, size);
413 size->cx = count * physDev->cellWidth;
414 size->cy = physDev->cellHeight;
416 return TRUE;
419 /***********************************************************************
420 * TTYDRV_DC_GetTextMetrics
422 BOOL TTYDRV_DC_GetTextMetrics(TTYDRV_PDEVICE *physDev, LPTEXTMETRICW lptm)
424 TRACE("(%p, %p)\n", physDev->hdc, lptm);
426 lptm->tmHeight = physDev->cellHeight;
427 lptm->tmAscent = 0;
428 lptm->tmDescent = 0;
429 lptm->tmInternalLeading = 0;
430 lptm->tmExternalLeading = 0;
431 lptm->tmAveCharWidth = physDev->cellWidth;
432 lptm->tmMaxCharWidth = physDev->cellWidth;
433 lptm->tmWeight = FW_MEDIUM;
434 lptm->tmOverhang = 0;
435 lptm->tmDigitizedAspectX = physDev->cellWidth;
436 lptm->tmDigitizedAspectY = physDev->cellHeight;
437 lptm->tmFirstChar = 32;
438 lptm->tmLastChar = 255;
439 lptm->tmDefaultChar = 0;
440 lptm->tmBreakChar = 32;
441 lptm->tmItalic = FALSE;
442 lptm->tmUnderlined = FALSE;
443 lptm->tmStruckOut = FALSE;
444 lptm->tmPitchAndFamily = TMPF_FIXED_PITCH|TMPF_DEVICE;
445 lptm->tmCharSet = ANSI_CHARSET;
447 return TRUE;