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

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

Lots of changes

File size: 11.3 KB
Line 
1/* $Id: oslibwin.cpp,v 1.10 1999-07-18 10:39:51 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//******************************************************************************
145HWND OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate)
146{
147 return WinCreateMenu(hwndParent, menutemplate);
148}
149//******************************************************************************
150//******************************************************************************
151BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
152{
153 return WinAlarm(hwndDeskTop,flStyle);
154}
155//******************************************************************************
156//******************************************************************************
157APIRET OSLibDosBeep(ULONG freg,ULONG dur)
158{
159 return DosBeep(freg,dur);
160}
161//******************************************************************************
162//******************************************************************************
163//******************************************************************************
164//******************************************************************************
165HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
166{
167 return WinQueryWindow(hwnd, lCode);
168}
169//******************************************************************************
170//******************************************************************************
171BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
172 LONG cy, ULONG fl)
173{
174 if(fl & SWP_MOVE) {
175 y = MapOS2ToWin32Y(hwnd, cy, y);
176 }
177 dprintf(("WinSetWindowPos %x %x %d %d %d %d %x", hwnd, hwndInsertBehind, x, y, cx, cy, fl));
178 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
179}
180//******************************************************************************
181//******************************************************************************
182BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
183{
184 BOOL rc;
185
186 if(fl & SWP_SHOW) {
187 rc = WinShowWindow(hwnd, TRUE);
188 }
189 if(rc == 0)
190 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
191 rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl);
192 if(rc == 0)
193 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
194 return rc;
195}
196//******************************************************************************
197//******************************************************************************
198BOOL OSLibWinDestroyWindow(HWND hwnd)
199{
200 return WinDestroyWindow(hwnd);
201}
202//******************************************************************************
203//******************************************************************************
204BOOL OSLibWinQueryUpdateRect(HWND hwnd, PRECT pRect)
205{
206 BOOL rc;
207 RECTLOS2 rectl;
208
209 rc = WinQueryUpdateRect(hwnd, (PRECTL)&rectl);
210 if(rc) {
211 MapOS2ToWin32Rectl(hwnd, &rectl, pRect);
212 }
213 return rc;
214}
215//******************************************************************************
216//******************************************************************************
217BOOL OSLibWinIsIconic(HWND hwnd)
218{
219 SWP swp;
220 BOOL rc;
221
222 rc = WinQueryWindowPos(hwnd, &swp);
223 if(rc == FALSE) {
224 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
225 return FALSE;
226 }
227
228 if(swp.fl & SWP_MINIMIZE)
229 return TRUE;
230 else return FALSE;
231}
232//******************************************************************************
233//******************************************************************************
234BOOL OSLibWinSetActiveWindow(HWND hwnd)
235{
236 return WinSetActiveWindow(HWND_DESKTOP, hwnd);
237}
238//******************************************************************************
239//******************************************************************************
240BOOL OSLibWinSetFocus(HWND hwnd)
241{
242 return WinSetFocus(HWND_DESKTOP, hwnd);
243}
244//******************************************************************************
245//******************************************************************************
246BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
247{
248 return WinEnableWindow(hwnd, fEnable);
249}
250//******************************************************************************
251//******************************************************************************
252BOOL OSLibWinIsWindowEnabled(HWND hwnd)
253{
254 return WinIsWindowEnabled(hwnd);
255}
256//******************************************************************************
257//******************************************************************************
258BOOL OSLibWinIsWindowVisible(HWND hwnd)
259{
260 return WinIsWindowVisible(hwnd);
261}
262//******************************************************************************
263//******************************************************************************
264BOOL OSLibWinQueryActiveWindow()
265{
266 return WinQueryActiveWindow(HWND_DESKTOP);
267}
268//******************************************************************************
269//******************************************************************************
270void OSLibWinPostQuitMessage(ULONG nExitCode)
271{
272 WinPostQueueMsg(GetThreadMessageQueue(), WM_QUIT, (MPARAM)nExitCode, 0);
273}
274//******************************************************************************
275//******************************************************************************
276LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
277{
278 QMSG qmsg;
279
280 WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
281 return (LONG)WinDispatchMsg(GetThreadHAB(), &qmsg);
282}
283//******************************************************************************
284//******************************************************************************
285BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax, BOOL isUnicode)
286{
287 QMSG qmsg;
288 BOOL rc;
289
290 rc = WinGetMsg(GetThreadHAB(), &qmsg, TranslateWinMsg(uMsgFilterMin), TranslateWinMsg(uMsgFilterMax), 0);
291 OS2ToWinMsgTranslate(&qmsg, pMsg, isUnicode);
292 return rc;
293}
294//******************************************************************************
295//******************************************************************************
296LONG OSLibWinQueryWindowTextLength(HWND hwnd)
297{
298 return WinQueryWindowTextLength(hwnd);
299}
300//******************************************************************************
301//******************************************************************************
302LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
303{
304 return WinQueryWindowText(hwnd, length, lpsz);
305}
306//******************************************************************************
307//******************************************************************************
308BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
309{
310 return WinSetWindowText(hwnd, lpsz);
311}
312//******************************************************************************
313//******************************************************************************
Note: See TracBrowser for help on using the repository browser.