Improved the TTY driver.
[wine/multimedia.git] / graphics / ttydrv / graphics.c
blobf2bff6a4787b8f2aeb38b74e8edce8c7ac6d509d
1 /*
2 * TTY DC graphics
4 * Copyright 1999 Patrik Stridvall
5 */
7 #include "config.h"
9 #include "dc.h"
10 #include "debugtools.h"
11 #include "ttydrv.h"
13 DEFAULT_DEBUG_CHANNEL(ttydrv)
15 /***********************************************************************
16 * TTYDRV_DC_Arc
18 BOOL TTYDRV_DC_Arc(DC *dc, INT left, INT top, INT right, INT bottom,
19 INT xstart, INT ystart, INT xend, INT yend)
21 FIXME("(%p, %d, %d, %d, %d, %d, %d, %d, %d): stub\n",
22 dc, left, top, right, bottom, xstart, ystart, xend, yend);
24 return TRUE;
27 /***********************************************************************
28 * TTYDRV_DC_Chord
30 BOOL TTYDRV_DC_Chord(DC *dc, INT left, INT top, INT right, INT bottom,
31 INT xstart, INT ystart, INT xend, INT yend)
33 FIXME("(%p, %d, %d, %d, %d, %d, %d, %d, %d): stub\n",
34 dc, left, top, right, bottom, xstart, ystart, xend, yend);
36 return TRUE;
39 /***********************************************************************
40 * TTYDRV_DC_Ellipse
42 BOOL TTYDRV_DC_Ellipse(DC *dc, INT left, INT top, INT right, INT bottom)
44 FIXME("(%p, %d, %d, %d, %d): stub\n",
45 dc, left, top, right, bottom);
47 return TRUE;
50 /***********************************************************************
51 * TTYDRV_DC_ExtFloodFill
53 BOOL TTYDRV_DC_ExtFloodFill(DC *dc, INT x, INT y,
54 COLORREF color, UINT fillType)
56 FIXME("(%p, %d, %d, 0x%08lx, %u): stub\n", dc, x, y, color, fillType);
58 return TRUE;
61 /***********************************************************************
62 * TTYDRV_DC_GetPixel
64 COLORREF TTYDRV_DC_GetPixel(DC *dc, INT x, INT y)
66 FIXME("(%p, %d, %d): stub\n", dc, x, y);
68 return RGB(0,0,0); /* FIXME: Always returns black */
71 /***********************************************************************
72 * TTYDRV_DC_LineTo
74 BOOL TTYDRV_DC_LineTo(DC *dc, INT x, INT y)
76 #ifdef HAVE_LIBCURSES
77 TTYDRV_PDEVICE *physDev = (TTYDRV_PDEVICE *) dc->physDev;
78 INT row1, col1, row2, col2;
80 TRACE("(%p, %d, %d)\n", dc, x, y);
82 if(!physDev->window)
83 return FALSE;
85 row1 = (dc->w.DCOrgY + XLPTODP(dc, dc->w.CursPosY)) / physDev->cellHeight;
86 col1 = (dc->w.DCOrgX + XLPTODP(dc, dc->w.CursPosX)) / physDev->cellWidth;
87 row2 = (dc->w.DCOrgY + XLPTODP(dc, y)) / physDev->cellHeight;
88 col2 = (dc->w.DCOrgX + XLPTODP(dc, x)) / physDev->cellWidth;
90 if(row1 > row2) {
91 INT tmp = row1;
92 row1 = row2;
93 row2 = tmp;
96 if(col1 > col2) {
97 INT tmp = col1;
98 col1 = col2;
99 col2 = tmp;
102 wmove(physDev->window, row1, col1);
103 if(col1 == col2) {
104 wvline(physDev->window, ACS_VLINE, row2-row1);
105 } else if(row1 == row2) {
106 whline(physDev->window, ACS_HLINE, col2-col1);
107 } else {
108 FIXME("Diagonal line drawing not yet supported\n");
110 wrefresh(physDev->window);
112 return TRUE;
113 #else /* defined(HAVE_LIBCURSES) */
114 FIXME("(%p, %d, %d): stub\n", dc, x, y);
116 return TRUE;
117 #endif /* defined(HAVE_LIBCURSES) */
120 /***********************************************************************
121 * TTYDRV_DC_PaintRgn
123 BOOL TTYDRV_DC_PaintRgn(DC *dc, HRGN hrgn)
125 FIXME("(%p, 0x%04x): stub\n", dc, hrgn);
127 return TRUE;
130 /***********************************************************************
131 * TTYDRV_DC_Pie
133 BOOL TTYDRV_DC_Pie(DC *dc, INT left, INT top, INT right, INT bottom,
134 INT xstart, INT ystart, INT xend, INT yend)
136 FIXME("(%p, %d, %d, %d, %d, %d, %d, %d, %d): stub\n",
137 dc, left, top, right, bottom, xstart, ystart, xend, yend);
139 return TRUE;
142 /***********************************************************************
143 * TTYDRV_DC_PolyBezier
145 BOOL TTYDRV_DC_PolyBezier(DC *dc, const POINT* BezierPoints, DWORD count)
147 FIXME("(%p, %p, %lu): stub\n", dc, BezierPoints, count);
149 return TRUE;
152 /***********************************************************************
153 * TTYDRV_DC_Polygon
155 BOOL TTYDRV_DC_Polygon(DC *dc, const POINT* pt, INT count)
157 FIXME("(%p, %p, %d): stub\n", dc, pt, count);
159 return TRUE;
162 /***********************************************************************
163 * TTYDRV_DC_Polyline
165 BOOL TTYDRV_DC_Polyline(DC *dc, const POINT* pt, INT count)
167 FIXME("(%p, %p, %d): stub\n", dc, pt, count);
169 return TRUE;
172 /***********************************************************************
173 * TTYDRV_DC_PolyPolygon
175 BOOL TTYDRV_DC_PolyPolygon(DC *dc, const POINT* pt, const INT* counts, UINT polygons)
177 FIXME("(%p, %p, %p, %u): stub\n", dc, pt, counts, polygons);
179 return TRUE;
182 /***********************************************************************
183 * TTYDRV_DC_PolyPolyline
185 BOOL TTYDRV_DC_PolyPolyline(DC *dc, const POINT* pt, const DWORD* counts, DWORD polylines)
187 FIXME("(%p, %p, %p, %lu): stub\n", dc, pt, counts, polylines);
189 return TRUE;
192 /***********************************************************************
193 * TTYDRV_DC_Rectangle
195 BOOL TTYDRV_DC_Rectangle(DC *dc, INT left, INT top, INT right, INT bottom)
197 #ifdef HAVE_LIBCURSES
198 TTYDRV_PDEVICE *physDev = (TTYDRV_PDEVICE *) dc->physDev;
199 INT row1, col1, row2, col2;
201 TRACE("(%p, %d, %d, %d, %d)\n", dc, left, top, right, bottom);
203 if(!physDev->window)
204 return FALSE;
206 row1 = (dc->w.DCOrgY + XLPTODP(dc, top)) / physDev->cellHeight;
207 col1 = (dc->w.DCOrgX + XLPTODP(dc, left)) / physDev->cellWidth;
208 row2 = (dc->w.DCOrgY + XLPTODP(dc, bottom)) / physDev->cellHeight;
209 col2 = (dc->w.DCOrgX + XLPTODP(dc, right)) / physDev->cellWidth;
211 if(row1 > row2) {
212 INT tmp = row1;
213 row1 = row2;
214 row2 = tmp;
216 if(col1 > col2) {
217 INT tmp = col1;
218 col1 = col2;
219 col2 = tmp;
222 wmove(physDev->window, row1, col1);
223 whline(physDev->window, ACS_HLINE, col2-col1);
225 wmove(physDev->window, row1, col2);
226 wvline(physDev->window, ACS_VLINE, row2-row1);
228 wmove(physDev->window, row2, col1);
229 whline(physDev->window, ACS_HLINE, col2-col1);
231 wmove(physDev->window, row1, col1);
232 wvline(physDev->window, ACS_VLINE, row2-row1);
234 mvwaddch(physDev->window, row1, col1, ACS_ULCORNER);
235 mvwaddch(physDev->window, row1, col2, ACS_URCORNER);
236 mvwaddch(physDev->window, row2, col2, ACS_LRCORNER);
237 mvwaddch(physDev->window, row2, col1, ACS_LLCORNER);
239 wrefresh(physDev->window);
241 return TRUE;
242 #else /* defined(HAVE_LIBCURSES) */
243 FIXME("(%p, %d, %d, %d, %d): stub\n", dc, left, top, right, bottom);
245 return TRUE;
246 #endif /* defined(HAVE_LIBCURSES) */
249 /***********************************************************************
250 * TTYDRV_DC_RoundRect
252 BOOL TTYDRV_DC_RoundRect(DC *dc, INT left, INT top, INT right,
253 INT bottom, INT ell_width, INT ell_height)
255 FIXME("(%p, %d, %d, %d, %d, %d, %d): stub\n",
256 dc, left, top, right, bottom, ell_width, ell_height);
258 return TRUE;
261 /***********************************************************************
262 * TTYDRV_DC_SetBkColor
264 COLORREF TTYDRV_DC_SetBkColor(DC *dc, COLORREF color)
266 COLORREF oldColor;
268 TRACE("(%p, 0x%08lx)\n", dc, color);
270 oldColor = dc->w.backgroundColor;
271 dc->w.backgroundColor = color;
273 return oldColor;
276 /***********************************************************************
277 * TTYDRV_DC_SetPixel
279 COLORREF TTYDRV_DC_SetPixel(DC *dc, INT x, INT y, COLORREF color)
281 #ifdef HAVE_LIBCURSES
282 TTYDRV_PDEVICE *physDev = (TTYDRV_PDEVICE *) dc->physDev;
283 INT row, col;
285 TRACE("(%p, %d, %d, 0x%08lx)\n", dc, x, y, color);
287 if(!physDev->window)
288 return FALSE;
290 row = (dc->w.DCOrgY + XLPTODP(dc, y)) / physDev->cellHeight;
291 col = (dc->w.DCOrgX + XLPTODP(dc, x)) / physDev->cellWidth;
293 mvwaddch(physDev->window, row, col, ACS_BULLET);
294 wrefresh(physDev->window);
296 return RGB(0,0,0); /* FIXME: Always returns black */
297 #else /* defined(HAVE_LIBCURSES) */
298 FIXME("(%p, %d, %d, 0x%08lx): stub\n", dc, x, y, color);
300 return RGB(0,0,0); /* FIXME: Always returns black */
301 #endif /* defined(HAVE_LIBCURSES) */
304 /***********************************************************************
305 * TTYDRV_DC_SetTextColor
307 COLORREF TTYDRV_DC_SetTextColor(DC *dc, COLORREF color)
309 COLORREF oldColor;
311 TRACE("(%p, 0x%08lx)\n", dc, color);
313 oldColor = dc->w.textColor;
314 dc->w.textColor = color;
316 return oldColor;