GlobalAlloc as GlobalAlloc16 should round size to 32.
[wine/gsoc_dplay.git] / dlls / ttydrv / wnd.c
blob5e32ded1aa77a2150993cc0953a7d131b8bdc96b
1 /*
2 * TTY window driver
4 * Copyright 1998,1999 Patrik Stridvall
5 */
7 #include "config.h"
9 #include "class.h"
10 #include "gdi.h"
11 #include "heap.h"
12 #include "ttydrv.h"
13 #include "win.h"
14 #include "debugtools.h"
16 DEFAULT_DEBUG_CHANNEL(ttydrv);
18 WND_DRIVER TTYDRV_WND_Driver =
20 TTYDRV_WND_Initialize,
21 TTYDRV_WND_Finalize,
22 TTYDRV_WND_CreateDesktopWindow,
23 TTYDRV_WND_CreateWindow,
24 TTYDRV_WND_DestroyWindow,
25 TTYDRV_WND_SetParent,
26 TTYDRV_WND_ForceWindowRaise,
27 TTYDRV_WND_SetWindowPos,
28 TTYDRV_WND_SetText,
29 TTYDRV_WND_SetFocus,
30 TTYDRV_WND_PreSizeMove,
31 TTYDRV_WND_PostSizeMove,
32 TTYDRV_WND_ScrollWindow,
33 TTYDRV_WND_SetDrawable,
34 TTYDRV_WND_SetHostAttr,
35 TTYDRV_WND_IsSelfClipping,
36 TTYDRV_WND_SetWindowRgn
40 /***********************************************************************
41 * TTYDRV_WND_GetCursesWindow
43 * Return the Curses window associated to a window.
45 WINDOW *TTYDRV_WND_GetCursesWindow(WND *wndPtr)
47 return wndPtr && wndPtr->pDriverData ?
48 ((TTYDRV_WND_DATA *) wndPtr->pDriverData)->window : 0;
51 /**********************************************************************
52 * TTYDRV_WND_Initialize
54 void TTYDRV_WND_Initialize(WND *wndPtr)
56 TTYDRV_WND_DATA *pWndDriverData =
57 (TTYDRV_WND_DATA *) HeapAlloc(SystemHeap, 0, sizeof(TTYDRV_WND_DATA));
59 TRACE("(%p)\n", wndPtr);
61 wndPtr->pDriverData = (void *) pWndDriverData;
63 pWndDriverData->window = NULL;
66 /**********************************************************************
67 * TTYDRV_WND_Finalize
69 void TTYDRV_WND_Finalize(WND *wndPtr)
71 TTYDRV_WND_DATA *pWndDriverData =
72 (TTYDRV_WND_DATA *) wndPtr->pDriverData;
74 TRACE("(%p)\n", wndPtr);
76 if(!pWndDriverData) {
77 ERR("WND already destroyed\n");
78 return;
81 if(pWndDriverData->window) {
82 ERR("WND destroyed without destroying the associated Curses Windows");
85 HeapFree(SystemHeap, 0, pWndDriverData);
86 wndPtr->pDriverData = NULL;
89 /**********************************************************************
90 * TTYDRV_WND_CreateDesktopWindow
92 BOOL TTYDRV_WND_CreateDesktopWindow(WND *wndPtr, CLASS *classPtr, BOOL bUnicode)
94 TTYDRV_WND_DATA *pWndDriverData =
95 (TTYDRV_WND_DATA *) wndPtr->pDriverData;
97 TRACE("(%p, %p, %d)\n", wndPtr, classPtr, bUnicode);
99 if(!pWndDriverData) { ERR("WND never initialized\n"); return FALSE; }
101 pWndDriverData->window = TTYDRV_GetRootWindow();
102 return TRUE;
105 /**********************************************************************
106 * TTYDRV_WND_CreateWindow
108 BOOL TTYDRV_WND_CreateWindow(WND *wndPtr, CLASS *classPtr, CREATESTRUCTA *cs, BOOL bUnicode)
110 #ifdef WINE_CURSES
111 WINDOW *window;
112 INT cellWidth=8, cellHeight=8; /* FIXME: Hardcoded */
114 TRACE("(%p, %p, %p, %d)\n", wndPtr, classPtr, cs, bUnicode);
116 /* Only create top-level windows */
117 if(cs->style & WS_CHILD)
118 return TRUE;
120 window = subwin(TTYDRV_GetRootWindow(), cs->cy/cellHeight, cs->cx/cellWidth,
121 cs->y/cellHeight, cs->x/cellWidth);
122 werase(window);
123 wrefresh(window);
125 return TRUE;
126 #else /* defined(WINE_CURSES) */
127 FIXME("(%p, %p, %p, %d): stub\n", wndPtr, classPtr, cs, bUnicode);
129 return TRUE;
130 #endif /* defined(WINE_CURSES) */
133 /***********************************************************************
134 * TTYDRV_WND_DestroyWindow
136 BOOL TTYDRV_WND_DestroyWindow(WND *wndPtr)
138 #ifdef WINE_CURSES
139 WINDOW *window;
141 TRACE("(%p)\n", wndPtr);
143 window = TTYDRV_WND_GetCursesWindow(wndPtr);
144 if(window && window != TTYDRV_GetRootWindow()) {
145 delwin(window);
148 return TRUE;
149 #else /* defined(WINE_CURSES) */
150 FIXME("(%p): stub\n", wndPtr);
152 return TRUE;
153 #endif /* defined(WINE_CURSES) */
156 /*****************************************************************
157 * TTYDRV_WND_SetParent
159 WND *TTYDRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
161 FIXME("(%p, %p): stub\n", wndPtr, pWndParent);
163 return NULL;
166 /***********************************************************************
167 * TTYDRV_WND_ForceWindowRaise
169 void TTYDRV_WND_ForceWindowRaise(WND *wndPtr)
171 FIXME("(%p): stub\n", wndPtr);
174 /***********************************************************************
175 * TTYDRV_WINPOS_SetWindowPos
177 void TTYDRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bSMC_SETXPOS)
179 FIXME("(%p, %p, %d): stub\n", wndPtr, winpos, bSMC_SETXPOS);
182 /*****************************************************************
183 * TTYDRV_WND_SetText
185 void TTYDRV_WND_SetText(WND *wndPtr, LPCWSTR text)
187 FIXME("(%p, %s): stub\n", wndPtr, debugstr_w(text));
190 /*****************************************************************
191 * TTYDRV_WND_SetFocus
193 void TTYDRV_WND_SetFocus(WND *wndPtr)
195 FIXME("(%p): stub\n", wndPtr);
198 /*****************************************************************
199 * TTYDRV_WND_PreSizeMove
201 void TTYDRV_WND_PreSizeMove(WND *wndPtr)
203 FIXME("(%p): stub\n", wndPtr);
206 /*****************************************************************
207 * TTYDRV_WND_PostSizeMove
209 void TTYDRV_WND_PostSizeMove(WND *wndPtr)
211 FIXME("(%p): stub\n", wndPtr);
214 /*****************************************************************
215 * TTYDRV_WND_ScrollWindow
217 void TTYDRV_WND_ScrollWindow( WND *wndPtr, HDC hdc, INT dx, INT dy,
218 const RECT *clipRect, BOOL bUpdate)
220 FIXME("(%p, %x, %d, %d, %p, %d): stub\n",
221 wndPtr, hdc, dx, dy, clipRect, bUpdate);
224 /***********************************************************************
225 * TTYDRV_WND_SetDrawable
227 void TTYDRV_WND_SetDrawable(WND *wndPtr, HDC hdc, WORD flags, BOOL bSetClipOrigin)
229 DC *dc = DC_GetDCPtr( hdc );
230 if (!dc) return;
231 TRACE("(%p, %p, %d, %d)\n", wndPtr, dc, flags, bSetClipOrigin);
233 /* FIXME: Should be done in the common code instead */
234 if(!wndPtr) {
235 dc->DCOrgX = 0;
236 dc->DCOrgY = 0;
237 } else {
238 if(flags & DCX_WINDOW) {
239 dc->DCOrgX = wndPtr->rectWindow.left;
240 dc->DCOrgY = wndPtr->rectWindow.top;
241 } else {
242 dc->DCOrgX = wndPtr->rectClient.left;
243 dc->DCOrgY = wndPtr->rectClient.top;
246 GDI_ReleaseObj( hdc );
249 /***********************************************************************
250 * TTYDRV_WND_SetHostAttr
252 BOOL TTYDRV_WND_SetHostAttr(WND *wndPtr, INT attr, INT value)
254 FIXME("(%p): stub\n", wndPtr);
256 return TRUE;
259 /***********************************************************************
260 * TTYDRV_WND_IsSelfClipping
262 BOOL TTYDRV_WND_IsSelfClipping(WND *wndPtr)
264 FIXME("(%p): semistub\n", wndPtr);
266 return FALSE;
269 /***********************************************************************
270 * TTYDRV_WND_SetWindowRgn
272 void TTYDRV_WND_SetWindowRgn(struct tagWND *wndPtr, HRGN hrgnWnd)