source: trunk/src/user32/new/oslibwin.cpp@ 345

Last change on this file since 345 was 345, checked in by sandervl, 26 years ago

Accelerator + icon changes

File size: 13.7 KB
Line 
1/* $Id: oslibwin.cpp,v 1.18 1999-07-20 15:46:53 sandervl Exp $ */
2/*
3 * Window API wrappers for OS/2
4 *
5 *
6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#define INCL_WIN
13#define INCL_PM
14#include <os2.h>
15#include <os2wrap.h>
16#include <stdlib.h>
17#include <string.h>
18
19#include <misc.h>
20#include <oslibwin.h>
21#include "oslibstyle.h"
22#include "oslibutil.h"
23#include "oslibmsg.h"
24#include "oslibgdi.h"
25#include "pmwindow.h"
26
27//******************************************************************************
28//******************************************************************************
29BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
30{
31 if(hwndParent == OSLIB_HWND_DESKTOP)
32 {
33 hwndParent = HWND_DESKTOP;
34 }
35
36 return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
37}
38//******************************************************************************
39//******************************************************************************
40HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
41 char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame)
42{
43 HWND hwndClient;
44
45 dprintf(("WinCreateWindow %x %x %x %s", hwndParent, dwWinStyle, dwFrameStyle, pszName));
46
47 if(pszName && *pszName == 0) {
48 pszName = NULL;
49 }
50 if(hwndParent == 0) {
51 hwndParent = HWND_DESKTOP;
52 }
53 if(dwFrameStyle) {
54 dwWinStyle &= ~WS_CLIPCHILDREN; //invalid style according to docs
55 if(pszName)
56 dwFrameStyle |= FCF_TITLEBAR;
57
58 *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
59 &dwFrameStyle, WIN32_STDCLASS,
60 "", 0, 0, 0, &hwndClient);
61 if(*hwndFrame) {
62 if(pszName) {
63 WinSetWindowText(*hwndFrame, pszName);
64 }
65 return hwndClient;
66 }
67 dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
68 return 0;
69 }
70 hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, 0, 0, 0, 0,
71 Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
72 NULL);
73 *hwndFrame = hwndClient;
74 return hwndClient;
75}
76//******************************************************************************
77//******************************************************************************
78BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
79{
80 *OSWinStyle = 0;
81 *OSFrameStyle = 0;
82
83 /* Window styles */
84 if(dwStyle & WINWS_MINIMIZE)
85 *OSWinStyle |= WS_MINIMIZED;
86//Done explicitely in CreateWindowExA
87#if 0
88 if(dwStyle & WINWS_VISIBLE)
89 *OSWinStyle |= WS_VISIBLE;
90#endif
91 if(dwStyle & WINWS_DISABLED)
92 *OSWinStyle |= WS_DISABLED;
93 if(dwStyle & WINWS_CLIPSIBLINGS)
94 *OSWinStyle |= WS_CLIPSIBLINGS;
95 if(dwStyle & WINWS_CLIPCHILDREN)
96 *OSWinStyle |= WS_CLIPCHILDREN;
97 if(dwStyle & WINWS_MAXIMIZE)
98 *OSWinStyle |= WS_MAXIMIZED;
99 if(dwStyle & WINWS_GROUP)
100 *OSWinStyle |= WS_GROUP;
101 if(dwStyle & WINWS_TABSTOP)
102 *OSWinStyle |= WS_TABSTOP;
103
104 if(dwStyle & WINWS_CAPTION)
105 *OSFrameStyle |= FCF_TITLEBAR;
106 if(dwStyle & WINWS_BORDER)
107 *OSFrameStyle |= FCF_BORDER;
108 if(dwStyle & WINWS_DLGFRAME)
109 *OSFrameStyle |= FCF_DLGBORDER;
110 if(dwStyle & WINWS_VSCROLL)
111 *OSFrameStyle |= FCF_VERTSCROLL;
112 if(dwStyle & WINWS_HSCROLL)
113 *OSFrameStyle |= FCF_HORZSCROLL;
114 if(dwStyle & WINWS_SYSMENU)
115 *OSFrameStyle |= FCF_SYSMENU;
116 if(dwStyle & WINWS_THICKFRAME)
117 *OSFrameStyle |= FCF_SIZEBORDER; //??
118 if(dwStyle & WINWS_MINIMIZEBOX)
119 *OSFrameStyle |= FCF_MINBUTTON;
120 if(dwStyle & WINWS_MAXIMIZEBOX)
121 *OSFrameStyle |= FCF_MAXBUTTON;
122
123 return TRUE;
124}
125//******************************************************************************
126//******************************************************************************
127BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
128{
129 return WinSetWindowULong(hwnd, offset, value);
130}
131//******************************************************************************
132//******************************************************************************
133ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
134{
135 return WinQueryWindowULong(hwnd, offset);
136}
137//******************************************************************************
138//******************************************************************************
139BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
140{
141 return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
142}
143//******************************************************************************
144//******************************************************************************
145//******************************************************************************
146//******************************************************************************
147BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
148{
149 return WinAlarm(hwndDeskTop,flStyle);
150}
151//******************************************************************************
152//******************************************************************************
153APIRET OSLibDosBeep(ULONG freg,ULONG dur)
154{
155 return DosBeep(freg,dur);
156}
157//******************************************************************************
158//******************************************************************************
159HWND OSLibWinQueryFocus(HWND hwndDeskTop)
160{
161 return WinQueryFocus(hwndDeskTop);
162}
163//******************************************************************************
164//******************************************************************************
165HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
166{
167 return WinWindowFromID(hwndParent,id);
168}
169//******************************************************************************
170//******************************************************************************
171BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus)
172{
173 return WinSetFocus(hwndDeskTop,hwndNewFocus);
174}
175//******************************************************************************
176//******************************************************************************
177ULONG OSLibGetWindowHeight(HWND hwnd)
178{
179 RECTL rect;
180
181 return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
182}
183//******************************************************************************
184//******************************************************************************
185BOOL OSLibWinInvalidateRect(HWND hwnd,POSRECTL pwrc,BOOL fIncludeChildren)
186{
187 return WinInvalidateRect(hwnd,(PRECTL)pwrc,fIncludeChildren);
188}
189//******************************************************************************
190//******************************************************************************
191LONG OSLibWinQuerySysValue(HWND hwndDeskTop,LONG iSysValue)
192{
193 return WinQuerySysValue(hwndDeskTop,iSysValue);
194}
195//******************************************************************************
196//******************************************************************************
197ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
198{
199 return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
200}
201//******************************************************************************
202//******************************************************************************
203BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
204{
205 return WinSetDlgItemText(hwndDlg,idItem,pszText);
206}
207//******************************************************************************
208//******************************************************************************
209BOOL OSLibWinQueryPointerPos(HWND hwndDeskTop,PPOINT pptlPoint)
210{
211 return WinQueryPointerPos(hwndDeskTop,(PPOINTL)pptlPoint);
212}
213//******************************************************************************
214//******************************************************************************
215HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
216{
217 return WinQueryWindow(hwnd, lCode);
218}
219//******************************************************************************
220//******************************************************************************
221BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
222 LONG cy, ULONG fl)
223{
224 HWND hwndParent = hwndInsertBehind;
225
226 if(fl & SWP_MOVE) {
227 switch(hwndParent)
228 {
229 case HWNDOS_TOP:
230 case HWNDOS_BOTTOM:
231 hwndParent = HWND_DESKTOP;
232 break;
233 }
234 y = MapOS2ToWin32Y(hwndParent, cy, y);
235 }
236 dprintf(("WinSetWindowPos %x %x %d %d %d %d %x", hwnd, hwndInsertBehind, x, y, cx, cy, fl));
237 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
238}
239//******************************************************************************
240//******************************************************************************
241BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
242{
243 BOOL rc;
244
245 if(fl & SWP_SHOW) {
246 rc = WinShowWindow(hwnd, TRUE);
247 }
248 if(rc == 0)
249 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
250 rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl);
251 if(rc == 0)
252 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
253 return rc;
254}
255//******************************************************************************
256//******************************************************************************
257BOOL OSLibWinDestroyWindow(HWND hwnd)
258{
259 return WinDestroyWindow(hwnd);
260}
261//******************************************************************************
262//Returns rectangle in Win32 window coordinates
263//******************************************************************************
264BOOL OSLibWinQueryUpdateRect(HWND hwnd, PVOID pRect)
265{
266 BOOL rc;
267 RECTLOS2 rectl;
268
269 rc = WinQueryUpdateRect(hwnd, (PRECTL)&rectl);
270 if(rc) {
271 MapOS2ToWin32Rectl(&rectl, (PRECT)pRect);
272 }
273 else memset(pRect, 0, sizeof(RECT));
274 return rc;
275}
276//******************************************************************************
277//******************************************************************************
278BOOL OSLibWinIsIconic(HWND hwnd)
279{
280 SWP swp;
281 BOOL rc;
282
283 rc = WinQueryWindowPos(hwnd, &swp);
284 if(rc == FALSE) {
285 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
286 return FALSE;
287 }
288
289 if(swp.fl & SWP_MINIMIZE)
290 return TRUE;
291 else return FALSE;
292}
293//******************************************************************************
294//******************************************************************************
295BOOL OSLibWinSetActiveWindow(HWND hwnd)
296{
297 return WinSetActiveWindow(HWND_DESKTOP, hwnd);
298}
299//******************************************************************************
300//******************************************************************************
301BOOL OSLibWinSetFocus(HWND hwnd)
302{
303 return WinSetFocus(HWND_DESKTOP, hwnd);
304}
305//******************************************************************************
306//******************************************************************************
307BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
308{
309 return WinEnableWindow(hwnd, fEnable);
310}
311//******************************************************************************
312//******************************************************************************
313BOOL OSLibWinIsWindowEnabled(HWND hwnd)
314{
315 return WinIsWindowEnabled(hwnd);
316}
317//******************************************************************************
318//******************************************************************************
319BOOL OSLibWinIsWindowVisible(HWND hwnd)
320{
321 return WinIsWindowVisible(hwnd);
322}
323//******************************************************************************
324//******************************************************************************
325BOOL OSLibWinQueryActiveWindow()
326{
327 return WinQueryActiveWindow(HWND_DESKTOP);
328}
329//******************************************************************************
330//******************************************************************************
331LONG OSLibWinQueryWindowTextLength(HWND hwnd)
332{
333 return WinQueryWindowTextLength(hwnd);
334}
335//******************************************************************************
336//******************************************************************************
337LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
338{
339 return WinQueryWindowText(hwnd, length, lpsz);
340}
341//******************************************************************************
342//******************************************************************************
343BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
344{
345 return WinSetWindowText(hwnd, lpsz);
346}
347//******************************************************************************
348//******************************************************************************
349BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
350{
351 return WinFlashWindow(hwnd, fFlash);
352}
353//******************************************************************************
354//******************************************************************************
355HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
356{
357 return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
358}
359//******************************************************************************
360//******************************************************************************
361BOOL OSLibWinMinimizeWindow(HWND hwnd)
362{
363 return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
364}
365//******************************************************************************
366//******************************************************************************
367
Note: See TracBrowser for help on using the repository browser.