Sweden-Number/windows/ttydrv/wnd.c

270 lines
6.6 KiB
C
Raw Normal View History

1998-12-07 10:36:13 +01:00
/*
* TTY window driver
*
1999-02-04 14:14:42 +01:00
* Copyright 1998,1999 Patrik Stridvall
1998-12-07 10:36:13 +01:00
*/
1999-11-24 00:43:29 +01:00
#include "config.h"
1999-02-04 14:14:42 +01:00
#include "class.h"
#include "dc.h"
1999-11-24 00:43:29 +01:00
#include "heap.h"
1998-12-07 10:36:13 +01:00
#include "ttydrv.h"
1999-02-04 14:14:42 +01:00
#include "win.h"
1999-11-24 00:43:29 +01:00
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(ttydrv)
/***********************************************************************
* TTYDRV_WND_GetCursesWindow
*
* Return the Curses window associated to a window.
*/
#ifdef HAVE_LIBCURSES
WINDOW *TTYDRV_WND_GetCursesWindow(WND *wndPtr)
{
return wndPtr && wndPtr->pDriverData ?
((TTYDRV_WND_DATA *) wndPtr->pDriverData)->window : 0;
}
#endif /* defined(HAVE_LIBCURSES) */
/***********************************************************************
* TTYDRV_WND_GetCursesRootWindow
*
* Return the Curses root window of the Curses window associated
* to a window.
*/
#ifdef HAVE_LIBCURSES
WINDOW *TTYDRV_WND_GetCursesRootWindow(WND *wndPtr)
{
while(wndPtr->parent) wndPtr = wndPtr->parent;
return TTYDRV_DESKTOP_GetCursesRootWindow((struct tagDESKTOP *) wndPtr->wExtra);
}
#endif /* defined(HAVE_LIBCURSES) */
1999-02-04 14:14:42 +01:00
/**********************************************************************
* TTYDRV_WND_Initialize
*/
void TTYDRV_WND_Initialize(WND *wndPtr)
{
1999-11-24 00:43:29 +01:00
TTYDRV_WND_DATA *pWndDriverData =
(TTYDRV_WND_DATA *) HeapAlloc(SystemHeap, 0, sizeof(TTYDRV_WND_DATA));
TRACE("(%p)\n", wndPtr);
wndPtr->pDriverData = (void *) pWndDriverData;
#ifdef HAVE_LIBCURSES
pWndDriverData->window = NULL;
#endif /* defined(HAVE_LIBCURSES) */
1999-02-04 14:14:42 +01:00
}
/**********************************************************************
* TTYDRV_WND_Finalize
*/
void TTYDRV_WND_Finalize(WND *wndPtr)
{
1999-11-24 00:43:29 +01:00
TTYDRV_WND_DATA *pWndDriverData =
(TTYDRV_WND_DATA *) wndPtr->pDriverData;
TRACE("(%p)\n", wndPtr);
if(!pWndDriverData) {
ERR("WND already destroyed\n");
return;
}
#ifdef HAVE_LIBCURSES
if(pWndDriverData->window) {
ERR("WND destroyed without destroying the associated Curses Windows");
}
#endif /* defined(HAVE_LIBCURSES) */
HeapFree(SystemHeap, 0, pWndDriverData);
wndPtr->pDriverData = NULL;
1999-02-04 14:14:42 +01:00
}
/**********************************************************************
* TTYDRV_WND_CreateDesktopWindow
*/
BOOL TTYDRV_WND_CreateDesktopWindow(WND *wndPtr, CLASS *classPtr, BOOL bUnicode)
1999-02-04 14:14:42 +01:00
{
1999-11-24 00:43:29 +01:00
TTYDRV_WND_DATA *pWndDriverData =
(TTYDRV_WND_DATA *) wndPtr->pDriverData;
TRACE("(%p, %p, %d)\n", wndPtr, classPtr, bUnicode);
if(!pWndDriverData) { ERR("WND never initialized\n"); return FALSE; }
#ifdef HAVE_LIBCURSES
pWndDriverData->window = TTYDRV_WND_GetCursesRootWindow(wndPtr);
#endif /* defined(HAVE_LIBCURSES) */
return TRUE;
1999-02-04 14:14:42 +01:00
}
/**********************************************************************
* TTYDRV_WND_CreateWindow
*/
BOOL TTYDRV_WND_CreateWindow(WND *wndPtr, CLASS *classPtr, CREATESTRUCTA *cs, BOOL bUnicode)
1999-02-04 14:14:42 +01:00
{
1999-11-24 00:43:29 +01:00
#ifdef HAVE_LIBCURSES
WINDOW *window, *rootWindow;
INT cellWidth=8, cellHeight=8; /* FIXME: Hardcoded */
TRACE("(%p, %p, %p, %d)\n", wndPtr, classPtr, cs, bUnicode);
/* Only create top-level windows */
if(cs->style & WS_CHILD)
return TRUE;
1999-12-12 00:08:48 +01:00
if(!(rootWindow = TTYDRV_WND_GetCursesRootWindow(wndPtr)))
return FALSE;
1999-11-24 00:43:29 +01:00
window = subwin(rootWindow, cs->cy/cellHeight, cs->cx/cellWidth,
cs->y/cellHeight, cs->x/cellWidth);
werase(window);
wrefresh(window);
return TRUE;
#else /* defined(HAVE_LIBCURSES) */
FIXME("(%p, %p, %p, %d): stub\n", wndPtr, classPtr, cs, bUnicode);
return TRUE;
#endif /* defined(HAVE_LIBCURSES) */
1999-02-04 14:14:42 +01:00
}
/***********************************************************************
* TTYDRV_WND_DestroyWindow
*/
BOOL TTYDRV_WND_DestroyWindow(WND *wndPtr)
1999-02-04 14:14:42 +01:00
{
1999-11-24 00:43:29 +01:00
#ifdef HAVE_LIBCURSES
WINDOW *window;
TRACE("(%p)\n", wndPtr);
window = TTYDRV_WND_GetCursesWindow(wndPtr);
if(window && window != TTYDRV_WND_GetCursesRootWindow(wndPtr)) {
delwin(window);
}
return TRUE;
#else /* defined(HAVE_LIBCURSES) */
FIXME("(%p): stub\n", wndPtr);
return TRUE;
#endif /* defined(HAVE_LIBCURSES) */
1999-02-04 14:14:42 +01:00
}
/*****************************************************************
* TTYDRV_WND_SetParent
1999-02-04 14:14:42 +01:00
*/
WND *TTYDRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
{
1999-11-24 00:43:29 +01:00
FIXME("(%p, %p): stub\n", wndPtr, pWndParent);
1999-02-04 14:14:42 +01:00
return NULL;
}
/***********************************************************************
* TTYDRV_WND_ForceWindowRaise
*/
void TTYDRV_WND_ForceWindowRaise(WND *wndPtr)
{
1999-11-24 00:43:29 +01:00
FIXME("(%p): stub\n", wndPtr);
1999-02-04 14:14:42 +01:00
}
/***********************************************************************
1999-11-24 00:43:29 +01:00
* TTYDRV_WINPOS_SetWindowPos
1999-02-04 14:14:42 +01:00
*/
void TTYDRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bSMC_SETXPOS)
1999-02-04 14:14:42 +01:00
{
1999-11-24 00:43:29 +01:00
FIXME("(%p, %p, %d): stub\n", wndPtr, winpos, bSMC_SETXPOS);
1999-02-04 14:14:42 +01:00
}
/*****************************************************************
* TTYDRV_WND_SetText
*/
void TTYDRV_WND_SetText(WND *wndPtr, LPCSTR text)
1999-11-24 00:43:29 +01:00
{
FIXME("(%p, %s): stub\n", wndPtr, debugstr_a(text));
1999-02-04 14:14:42 +01:00
}
/*****************************************************************
* TTYDRV_WND_SetFocus
*/
void TTYDRV_WND_SetFocus(WND *wndPtr)
{
1999-11-24 00:43:29 +01:00
FIXME("(%p): stub\n", wndPtr);
1999-02-04 14:14:42 +01:00
}
/*****************************************************************
* TTYDRV_WND_PreSizeMove
*/
void TTYDRV_WND_PreSizeMove(WND *wndPtr)
{
1999-11-24 00:43:29 +01:00
FIXME("(%p): stub\n", wndPtr);
1999-02-04 14:14:42 +01:00
}
/*****************************************************************
* TTYDRV_WND_PostSizeMove
*/
void TTYDRV_WND_PostSizeMove(WND *wndPtr)
{
1999-11-24 00:43:29 +01:00
FIXME("(%p): stub\n", wndPtr);
1999-02-04 14:14:42 +01:00
}
/*****************************************************************
* TTYDRV_WND_ScrollWindow
*/
void TTYDRV_WND_ScrollWindow(
WND *wndPtr, DC *dcPtr, INT dx, INT dy,
const RECT *clipRect, BOOL bUpdate)
1999-02-04 14:14:42 +01:00
{
1999-11-24 00:43:29 +01:00
FIXME("(%p, %p, %d, %d, %p, %d): stub\n",
wndPtr, dcPtr, dx, dy, clipRect, bUpdate);
1999-02-04 14:14:42 +01:00
}
/***********************************************************************
* TTYDRV_WND_SetDrawable
*/
void TTYDRV_WND_SetDrawable(WND *wndPtr, DC *dc, WORD flags, BOOL bSetClipOrigin)
1999-02-04 14:14:42 +01:00
{
1999-12-12 00:08:48 +01:00
TRACE("(%p, %p, %d, %d)\n", wndPtr, dc, flags, bSetClipOrigin);
1999-11-24 00:43:29 +01:00
1999-12-12 00:08:48 +01:00
/* FIXME: Should be done in the common code instead */
if(!wndPtr) {
1999-11-24 00:43:29 +01:00
dc->w.DCOrgX = 0;
dc->w.DCOrgY = 0;
} else {
1999-12-12 00:08:48 +01:00
if(flags & DCX_WINDOW) {
1999-11-24 00:43:29 +01:00
dc->w.DCOrgX = wndPtr->rectWindow.left;
dc->w.DCOrgY = wndPtr->rectWindow.top;
} else {
dc->w.DCOrgX = wndPtr->rectClient.left;
dc->w.DCOrgY = wndPtr->rectClient.top;
}
}
1999-02-04 14:14:42 +01:00
}
/***********************************************************************
* TTYDRV_WND_SetHostAttr
*/
BOOL TTYDRV_WND_SetHostAttr(WND *wndPtr, INT attr, INT value)
{
1999-11-24 00:43:29 +01:00
FIXME("(%p): stub\n", wndPtr);
return TRUE;
}
1999-02-04 14:14:42 +01:00
/***********************************************************************
* TTYDRV_WND_IsSelfClipping
*/
BOOL TTYDRV_WND_IsSelfClipping(WND *wndPtr)
1999-02-04 14:14:42 +01:00
{
1999-11-24 00:43:29 +01:00
FIXME("(%p): semistub\n", wndPtr);
1999-02-04 14:14:42 +01:00
return FALSE;
}