Sweden-Number/dlls/ttydrv/graphics.c

433 lines
12 KiB
C
Raw Normal View History

1999-11-24 00:43:29 +01:00
/*
* TTY DC graphics
*
* Copyright 1999 Patrik Stridvall
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1999-11-24 00:43:29 +01:00
*/
#include "config.h"
#include <stdarg.h>
#include "windef.h"
2003-08-20 20:22:31 +02:00
#include "winbase.h"
#include "winnls.h"
#include "wine/debug.h"
1999-11-24 00:43:29 +01:00
#include "ttydrv.h"
WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
1999-11-24 00:43:29 +01:00
/***********************************************************************
* TTYDRV_DC_Arc
*/
BOOL TTYDRV_DC_Arc(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom,
1999-11-24 00:43:29 +01:00
INT xstart, INT ystart, INT xend, INT yend)
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d, %d, %d, %d, %d, %d, %d): stub\n",
physDev->hdc, left, top, right, bottom, xstart, ystart, xend, yend);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_Chord
*/
BOOL TTYDRV_DC_Chord(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom,
1999-11-24 00:43:29 +01:00
INT xstart, INT ystart, INT xend, INT yend)
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d, %d, %d, %d, %d, %d, %d): stub\n",
physDev->hdc, left, top, right, bottom, xstart, ystart, xend, yend);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_Ellipse
*/
BOOL TTYDRV_DC_Ellipse(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom)
1999-11-24 00:43:29 +01:00
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d, %d, %d): stub\n", physDev->hdc, left, top, right, bottom);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_ExtFloodFill
*/
BOOL TTYDRV_DC_ExtFloodFill(TTYDRV_PDEVICE *physDev, INT x, INT y,
1999-11-24 00:43:29 +01:00
COLORREF color, UINT fillType)
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d, 0x%08lx, %u): stub\n", physDev->hdc, x, y, color, fillType);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_GetPixel
*/
COLORREF TTYDRV_DC_GetPixel(TTYDRV_PDEVICE *physDev, INT x, INT y)
1999-11-24 00:43:29 +01:00
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d): stub\n", physDev->hdc, x, y);
1999-11-24 00:43:29 +01:00
return RGB(0,0,0); /* FIXME: Always returns black */
}
/***********************************************************************
* TTYDRV_DC_LineTo
*/
BOOL TTYDRV_DC_LineTo(TTYDRV_PDEVICE *physDev, INT x, INT y)
1999-11-24 00:43:29 +01:00
{
#ifdef WINE_CURSES
1999-11-24 00:43:29 +01:00
INT row1, col1, row2, col2;
POINT pt[2];
1999-11-24 00:43:29 +01:00
2002-10-25 21:00:49 +02:00
TRACE("(%p, %d, %d)\n", physDev->hdc, x, y);
1999-11-24 00:43:29 +01:00
1999-12-12 00:08:48 +01:00
if(!physDev->window)
return FALSE;
GetCurrentPositionEx( physDev->hdc, &pt[0] );
pt[1].x = x;
pt[1].y = y;
LPtoDP( physDev->hdc, pt, 2 );
row1 = (physDev->org.y + pt[0].y) / physDev->cellHeight;
col1 = (physDev->org.x + pt[0].x) / physDev->cellWidth;
row2 = (physDev->org.y + pt[1].y) / physDev->cellHeight;
col2 = (physDev->org.x + pt[1].x) / physDev->cellWidth;
1999-11-24 00:43:29 +01:00
if(row1 > row2) {
INT tmp = row1;
row1 = row2;
2002-06-01 01:06:46 +02:00
row2 = tmp;
}
1999-11-24 00:43:29 +01:00
if(col1 > col2) {
INT tmp = col1;
col1 = col2;
2002-06-01 01:06:46 +02:00
col2 = tmp;
}
1999-11-24 00:43:29 +01:00
wmove(physDev->window, row1, col1);
if(col1 == col2) {
1999-12-12 00:08:48 +01:00
wvline(physDev->window, ACS_VLINE, row2-row1);
1999-11-24 00:43:29 +01:00
} else if(row1 == row2) {
1999-12-12 00:08:48 +01:00
whline(physDev->window, ACS_HLINE, col2-col1);
1999-11-24 00:43:29 +01:00
} else {
FIXME("Diagonal line drawing not yet supported\n");
}
wrefresh(physDev->window);
return TRUE;
#else /* defined(WINE_CURSES) */
2003-11-11 01:25:10 +01:00
FIXME("(%p, %d, %d): stub\n", physDev->hdc, x, y);
1999-11-24 00:43:29 +01:00
return TRUE;
#endif /* defined(WINE_CURSES) */
1999-11-24 00:43:29 +01:00
}
/***********************************************************************
* TTYDRV_DC_PaintRgn
*/
BOOL TTYDRV_DC_PaintRgn(TTYDRV_PDEVICE *physDev, HRGN hrgn)
1999-11-24 00:43:29 +01:00
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %p): stub\n", physDev->hdc, hrgn);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_Pie
*/
BOOL TTYDRV_DC_Pie(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom,
1999-11-24 00:43:29 +01:00
INT xstart, INT ystart, INT xend, INT yend)
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d, %d, %d, %d, %d, %d, %d): stub\n",
physDev->hdc, left, top, right, bottom, xstart, ystart, xend, yend);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_Polygon
*/
BOOL TTYDRV_DC_Polygon(TTYDRV_PDEVICE *physDev, const POINT* pt, INT count)
1999-11-24 00:43:29 +01:00
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %p, %d): stub\n", physDev->hdc, pt, count);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_Polyline
*/
BOOL TTYDRV_DC_Polyline(TTYDRV_PDEVICE *physDev, const POINT* pt, INT count)
1999-11-24 00:43:29 +01:00
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %p, %d): stub\n", physDev->hdc, pt, count);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_PolyPolygon
*/
BOOL TTYDRV_DC_PolyPolygon(TTYDRV_PDEVICE *physDev, const POINT* pt, const INT* counts, UINT polygons)
1999-11-24 00:43:29 +01:00
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %p, %p, %u): stub\n", physDev->hdc, pt, counts, polygons);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_PolyPolyline
*/
BOOL TTYDRV_DC_PolyPolyline(TTYDRV_PDEVICE *physDev, const POINT* pt, const DWORD* counts, DWORD polylines)
1999-11-24 00:43:29 +01:00
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %p, %p, %lu): stub\n", physDev->hdc, pt, counts, polylines);
2002-06-01 01:06:46 +02:00
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_Rectangle
*/
BOOL TTYDRV_DC_Rectangle(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom)
1999-11-24 00:43:29 +01:00
{
#ifdef WINE_CURSES
1999-11-24 00:43:29 +01:00
INT row1, col1, row2, col2;
RECT rect;
1999-11-24 00:43:29 +01:00
2002-10-25 21:00:49 +02:00
TRACE("(%p, %d, %d, %d, %d)\n", physDev->hdc, left, top, right, bottom);
1999-11-24 00:43:29 +01:00
1999-12-12 00:08:48 +01:00
if(!physDev->window)
return FALSE;
rect.left = left;
rect.top = top;
rect.right = right;
rect.bottom = bottom;
LPtoDP( physDev->hdc, (POINT *)&rect, 2 );
row1 = (physDev->org.y + rect.top) / physDev->cellHeight;
col1 = (physDev->org.x + rect.left) / physDev->cellWidth;
row2 = (physDev->org.y + rect.bottom) / physDev->cellHeight;
col2 = (physDev->org.x + rect.right) / physDev->cellWidth;
1999-11-24 00:43:29 +01:00
if(row1 > row2) {
INT tmp = row1;
row1 = row2;
2002-06-01 01:06:46 +02:00
row2 = tmp;
}
1999-11-24 00:43:29 +01:00
if(col1 > col2) {
INT tmp = col1;
col1 = col2;
2002-06-01 01:06:46 +02:00
col2 = tmp;
}
1999-11-24 00:43:29 +01:00
wmove(physDev->window, row1, col1);
1999-12-12 00:08:48 +01:00
whline(physDev->window, ACS_HLINE, col2-col1);
1999-11-24 00:43:29 +01:00
wmove(physDev->window, row1, col2);
1999-12-12 00:08:48 +01:00
wvline(physDev->window, ACS_VLINE, row2-row1);
1999-11-24 00:43:29 +01:00
wmove(physDev->window, row2, col1);
1999-12-12 00:08:48 +01:00
whline(physDev->window, ACS_HLINE, col2-col1);
1999-11-24 00:43:29 +01:00
wmove(physDev->window, row1, col1);
1999-12-12 00:08:48 +01:00
wvline(physDev->window, ACS_VLINE, row2-row1);
1999-11-24 00:43:29 +01:00
1999-12-12 00:08:48 +01:00
mvwaddch(physDev->window, row1, col1, ACS_ULCORNER);
mvwaddch(physDev->window, row1, col2, ACS_URCORNER);
mvwaddch(physDev->window, row2, col2, ACS_LRCORNER);
mvwaddch(physDev->window, row2, col1, ACS_LLCORNER);
1999-11-24 00:43:29 +01:00
wrefresh(physDev->window);
return TRUE;
#else /* defined(WINE_CURSES) */
2003-11-11 01:25:10 +01:00
FIXME("(%p, %d, %d, %d, %d): stub\n", physDev->hdc, left, top, right, bottom);
1999-11-24 00:43:29 +01:00
return TRUE;
#endif /* defined(WINE_CURSES) */
1999-11-24 00:43:29 +01:00
}
/***********************************************************************
* TTYDRV_DC_RoundRect
*/
BOOL TTYDRV_DC_RoundRect(TTYDRV_PDEVICE *physDev, INT left, INT top, INT right,
1999-11-24 00:43:29 +01:00
INT bottom, INT ell_width, INT ell_height)
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d, %d, %d, %d, %d): stub\n",
physDev->hdc, left, top, right, bottom, ell_width, ell_height);
2002-06-01 01:06:46 +02:00
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_SetPixel
*/
COLORREF TTYDRV_DC_SetPixel(TTYDRV_PDEVICE *physDev, INT x, INT y, COLORREF color)
1999-11-24 00:43:29 +01:00
{
#ifdef WINE_CURSES
1999-11-24 00:43:29 +01:00
INT row, col;
POINT pt;
1999-11-24 00:43:29 +01:00
2002-10-25 21:00:49 +02:00
TRACE("(%p, %d, %d, 0x%08lx)\n", physDev->hdc, x, y, color);
1999-11-24 00:43:29 +01:00
1999-12-12 00:08:48 +01:00
if(!physDev->window)
return FALSE;
pt.x = x;
pt.y = y;
LPtoDP( physDev->hdc, &pt, 1 );
row = (physDev->org.y + pt.y) / physDev->cellHeight;
col = (physDev->org.x + pt.x) / physDev->cellWidth;
1999-11-24 00:43:29 +01:00
1999-12-12 00:08:48 +01:00
mvwaddch(physDev->window, row, col, ACS_BULLET);
1999-11-24 00:43:29 +01:00
wrefresh(physDev->window);
return RGB(0,0,0); /* FIXME: Always returns black */
#else /* defined(WINE_CURSES) */
2003-11-11 01:25:10 +01:00
FIXME("(%p, %d, %d, 0x%08lx): stub\n", physDev->hdc, x, y, color);
1999-11-24 00:43:29 +01:00
return RGB(0,0,0); /* FIXME: Always returns black */
#endif /* defined(WINE_CURSES) */
1999-11-24 00:43:29 +01:00
}
/***********************************************************************
* TTYDRV_DC_BitBlt
*/
BOOL TTYDRV_DC_BitBlt(TTYDRV_PDEVICE *physDevDst, INT xDst, INT yDst,
INT width, INT height, TTYDRV_PDEVICE *physDevSrc,
INT xSrc, INT ySrc, DWORD rop)
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d, %d, %d, %p, %d, %d, %lu): stub\n",
physDevDst->hdc, xDst, yDst, width, height, physDevSrc->hdc, xSrc, ySrc, rop );
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_PatBlt
*/
BOOL TTYDRV_DC_PatBlt(TTYDRV_PDEVICE *physDev, INT left, INT top,
INT width, INT height, DWORD rop)
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d, %d, %d, %lu): stub\n", physDev->hdc, left, top, width, height, rop );
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_StretchBlt
*/
BOOL TTYDRV_DC_StretchBlt(TTYDRV_PDEVICE *physDevDst, INT xDst, INT yDst,
INT widthDst, INT heightDst,
TTYDRV_PDEVICE *physDevSrc, INT xSrc, INT ySrc,
INT widthSrc, INT heightSrc, DWORD rop)
{
2002-10-25 21:00:49 +02:00
FIXME("(%p, %d, %d, %d, %d, %p, %d, %d, %d, %d, %lu): stub\n",
physDevDst->hdc, xDst, yDst, widthDst, heightDst,
physDevSrc->hdc, xSrc, ySrc, widthSrc, heightSrc, rop );
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_ExtTextOut
*/
BOOL TTYDRV_DC_ExtTextOut(TTYDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
const RECT *lpRect, LPCWSTR str, UINT count,
const INT *lpDx )
{
#ifdef WINE_CURSES
INT row, col;
LPSTR ascii;
DWORD len;
2002-10-25 21:00:49 +02:00
TRACE("(%p, %d, %d, 0x%08x, %p, %s, %d, %p)\n",
physDev->hdc, x, y, flags, lpRect, debugstr_wn(str, count), count, lpDx);
if(!physDev->window)
return FALSE;
row = (physDev->org.y + y) / physDev->cellHeight;
col = (physDev->org.x + x) / physDev->cellWidth;
len = WideCharToMultiByte( CP_ACP, 0, str, count, NULL, 0, NULL, NULL );
ascii = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, str, count, ascii, len, NULL, NULL );
mvwaddnstr(physDev->window, row, col, ascii, len);
HeapFree( GetProcessHeap(), 0, ascii );
wrefresh(physDev->window);
return TRUE;
#else /* defined(WINE_CURSES) */
2003-11-11 01:25:10 +01:00
FIXME("(%p, %d, %d, 0x%08x, %p, %s, %d, %p): stub\n",
physDev->hdc, x, y, flags, lpRect, debugstr_wn(str,count), count, lpDx);
return TRUE;
#endif /* defined(WINE_CURSES) */
}
/***********************************************************************
* TTYDRV_DC_GetCharWidth
*/
BOOL TTYDRV_DC_GetCharWidth(TTYDRV_PDEVICE *physDev, UINT firstChar, UINT lastChar,
LPINT buffer)
{
UINT c;
2002-10-25 21:00:49 +02:00
FIXME("(%p, %u, %u, %p): semistub\n", physDev->hdc, firstChar, lastChar, buffer);
for(c=firstChar; c<=lastChar; c++) {
buffer[c-firstChar] = physDev->cellWidth;
}
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_GetTextExtentPoint
*/
BOOL TTYDRV_DC_GetTextExtentPoint(TTYDRV_PDEVICE *physDev, LPCWSTR str, INT count,
LPSIZE size)
{
2002-10-25 21:00:49 +02:00
TRACE("(%p, %s, %d, %p)\n", physDev->hdc, debugstr_wn(str, count), count, size);
size->cx = count * physDev->cellWidth;
size->cy = physDev->cellHeight;
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_GetTextMetrics
*/
BOOL TTYDRV_DC_GetTextMetrics(TTYDRV_PDEVICE *physDev, LPTEXTMETRICW lptm)
{
2002-10-25 21:00:49 +02:00
TRACE("(%p, %p)\n", physDev->hdc, lptm);
lptm->tmHeight = physDev->cellHeight;
lptm->tmAscent = 0;
lptm->tmDescent = 0;
lptm->tmInternalLeading = 0;
lptm->tmExternalLeading = 0;
2002-06-01 01:06:46 +02:00
lptm->tmAveCharWidth = physDev->cellWidth;
lptm->tmMaxCharWidth = physDev->cellWidth;
lptm->tmWeight = FW_MEDIUM;
lptm->tmOverhang = 0;
lptm->tmDigitizedAspectX = physDev->cellWidth;
lptm->tmDigitizedAspectY = physDev->cellHeight;
lptm->tmFirstChar = 32;
lptm->tmLastChar = 255;
lptm->tmDefaultChar = 0;
lptm->tmBreakChar = 32;
lptm->tmItalic = FALSE;
lptm->tmUnderlined = FALSE;
lptm->tmStruckOut = FALSE;
lptm->tmPitchAndFamily = TMPF_FIXED_PITCH|TMPF_DEVICE;
lptm->tmCharSet = ANSI_CHARSET;
return TRUE;
}