- Remove <string.h> from winnt.h.
[wine/hacks.git] / dlls / ttydrv / wnd.c
blobeed7a96d2d0fd06c7f1ff169428beca7940840b8
1 /*
2 * TTY window driver
4 * Copyright 1998,1999 Patrik Stridvall
5 */
7 #include "config.h"
9 #include "gdi.h"
10 #include "heap.h"
11 #include "ttydrv.h"
12 #include "win.h"
13 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(ttydrv);
17 WND_DRIVER TTYDRV_WND_Driver =
19 TTYDRV_WND_Initialize,
20 TTYDRV_WND_Finalize,
21 TTYDRV_WND_CreateDesktopWindow,
22 TTYDRV_WND_CreateWindow,
23 TTYDRV_WND_DestroyWindow,
24 TTYDRV_WND_SetParent,
25 TTYDRV_WND_ForceWindowRaise,
26 TTYDRV_WND_SetWindowPos,
27 TTYDRV_WND_SetText,
28 TTYDRV_WND_SetFocus,
29 TTYDRV_WND_PreSizeMove,
30 TTYDRV_WND_PostSizeMove,
31 TTYDRV_WND_ScrollWindow,
32 TTYDRV_WND_SetDrawable,
33 TTYDRV_WND_SetHostAttr,
34 TTYDRV_WND_IsSelfClipping,
35 TTYDRV_WND_SetWindowRgn
39 /***********************************************************************
40 * TTYDRV_WND_GetCursesWindow
42 * Return the Curses window associated to a window.
44 WINDOW *TTYDRV_WND_GetCursesWindow(WND *wndPtr)
46 return wndPtr && wndPtr->pDriverData ?
47 ((TTYDRV_WND_DATA *) wndPtr->pDriverData)->window : 0;
50 /**********************************************************************
51 * TTYDRV_WND_Initialize
53 void TTYDRV_WND_Initialize(WND *wndPtr)
55 TTYDRV_WND_DATA *pWndDriverData =
56 (TTYDRV_WND_DATA *) HeapAlloc(SystemHeap, 0, sizeof(TTYDRV_WND_DATA));
58 TRACE("(%p)\n", wndPtr);
60 wndPtr->pDriverData = (void *) pWndDriverData;
62 pWndDriverData->window = NULL;
65 /**********************************************************************
66 * TTYDRV_WND_Finalize
68 void TTYDRV_WND_Finalize(WND *wndPtr)
70 TTYDRV_WND_DATA *pWndDriverData =
71 (TTYDRV_WND_DATA *) wndPtr->pDriverData;
73 TRACE("(%p)\n", wndPtr);
75 if(!pWndDriverData) {
76 ERR("WND already destroyed\n");
77 return;
80 if(pWndDriverData->window) {
81 ERR("WND destroyed without destroying the associated Curses Windows");
84 HeapFree(SystemHeap, 0, pWndDriverData);
85 wndPtr->pDriverData = NULL;
88 /**********************************************************************
89 * TTYDRV_WND_CreateDesktopWindow
91 BOOL TTYDRV_WND_CreateDesktopWindow(WND *wndPtr)
93 TTYDRV_WND_DATA *pWndDriverData =
94 (TTYDRV_WND_DATA *) wndPtr->pDriverData;
96 TRACE("(%p)\n", wndPtr);
98 if(!pWndDriverData) { ERR("WND never initialized\n"); return FALSE; }
100 pWndDriverData->window = TTYDRV_GetRootWindow();
101 return TRUE;
104 /**********************************************************************
105 * TTYDRV_WND_CreateWindow
107 BOOL TTYDRV_WND_CreateWindow(WND *wndPtr, CREATESTRUCTA *cs, BOOL bUnicode)
109 #ifdef WINE_CURSES
110 WINDOW *window;
111 INT cellWidth=8, cellHeight=8; /* FIXME: Hardcoded */
113 TRACE("(%p, %p, %d)\n", wndPtr, cs, bUnicode);
115 /* Only create top-level windows */
116 if(cs->style & WS_CHILD)
117 return TRUE;
119 window = subwin(TTYDRV_GetRootWindow(), cs->cy/cellHeight, cs->cx/cellWidth,
120 cs->y/cellHeight, cs->x/cellWidth);
121 werase(window);
122 wrefresh(window);
124 return TRUE;
125 #else /* defined(WINE_CURSES) */
126 FIXME("(%p, %p, %p, %d): stub\n", wndPtr, cs, bUnicode);
128 return TRUE;
129 #endif /* defined(WINE_CURSES) */
132 /***********************************************************************
133 * TTYDRV_WND_DestroyWindow
135 BOOL TTYDRV_WND_DestroyWindow(WND *wndPtr)
137 #ifdef WINE_CURSES
138 WINDOW *window;
140 TRACE("(%p)\n", wndPtr);
142 window = TTYDRV_WND_GetCursesWindow(wndPtr);
143 if(window && window != TTYDRV_GetRootWindow()) {
144 delwin(window);
147 return TRUE;
148 #else /* defined(WINE_CURSES) */
149 FIXME("(%p): stub\n", wndPtr);
151 return TRUE;
152 #endif /* defined(WINE_CURSES) */
155 /*****************************************************************
156 * TTYDRV_WND_SetParent
158 WND *TTYDRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
160 FIXME("(%p, %p): stub\n", wndPtr, pWndParent);
162 return NULL;
165 /***********************************************************************
166 * TTYDRV_WND_ForceWindowRaise
168 void TTYDRV_WND_ForceWindowRaise(WND *wndPtr)
170 FIXME("(%p): stub\n", wndPtr);
173 /***********************************************************************
174 * TTYDRV_WINPOS_SetWindowPos
176 void TTYDRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bSMC_SETXPOS)
178 FIXME("(%p, %p, %d): stub\n", wndPtr, winpos, bSMC_SETXPOS);
181 /*****************************************************************
182 * TTYDRV_WND_SetText
184 void TTYDRV_WND_SetText(WND *wndPtr, LPCWSTR text)
186 FIXME("(%p, %s): stub\n", wndPtr, debugstr_w(text));
189 /*****************************************************************
190 * TTYDRV_WND_SetFocus
192 void TTYDRV_WND_SetFocus(WND *wndPtr)
194 FIXME("(%p): stub\n", wndPtr);
197 /*****************************************************************
198 * TTYDRV_WND_PreSizeMove
200 void TTYDRV_WND_PreSizeMove(WND *wndPtr)
202 FIXME("(%p): stub\n", wndPtr);
205 /*****************************************************************
206 * TTYDRV_WND_PostSizeMove
208 void TTYDRV_WND_PostSizeMove(WND *wndPtr)
210 FIXME("(%p): stub\n", wndPtr);
213 /*****************************************************************
214 * TTYDRV_WND_ScrollWindow
216 void TTYDRV_WND_ScrollWindow( WND *wndPtr, HDC hdc, INT dx, INT dy,
217 const RECT *clipRect, BOOL bUpdate)
219 FIXME("(%p, %x, %d, %d, %p, %d): stub\n",
220 wndPtr, hdc, dx, dy, clipRect, bUpdate);
223 /***********************************************************************
224 * TTYDRV_WND_SetDrawable
226 void TTYDRV_WND_SetDrawable(WND *wndPtr, HDC hdc, WORD flags, BOOL bSetClipOrigin)
228 DC *dc = DC_GetDCPtr( hdc );
229 if (!dc) return;
230 TRACE("(%p, %p, %d, %d)\n", wndPtr, dc, flags, bSetClipOrigin);
232 /* FIXME: Should be done in the common code instead */
233 if(!wndPtr) {
234 dc->DCOrgX = 0;
235 dc->DCOrgY = 0;
236 } else {
237 if(flags & DCX_WINDOW) {
238 dc->DCOrgX = wndPtr->rectWindow.left;
239 dc->DCOrgY = wndPtr->rectWindow.top;
240 } else {
241 dc->DCOrgX = wndPtr->rectClient.left;
242 dc->DCOrgY = wndPtr->rectClient.top;
245 GDI_ReleaseObj( hdc );
248 /***********************************************************************
249 * TTYDRV_WND_SetHostAttr
251 BOOL TTYDRV_WND_SetHostAttr(WND *wndPtr, INT attr, INT value)
253 FIXME("(%p): stub\n", wndPtr);
255 return TRUE;
258 /***********************************************************************
259 * TTYDRV_WND_IsSelfClipping
261 BOOL TTYDRV_WND_IsSelfClipping(WND *wndPtr)
263 FIXME("(%p): semistub\n", wndPtr);
265 return FALSE;
268 /***********************************************************************
269 * TTYDRV_WND_SetWindowRgn
271 void TTYDRV_WND_SetWindowRgn(struct tagWND *wndPtr, HRGN hrgnWnd)