1 | /* $Id: oslibwin.cpp,v 1.5 1999-07-17 09:17:58 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 <misc.h>
|
---|
17 | #include <oslibwin.h>
|
---|
18 | #include "oslibstyle.h"
|
---|
19 | #include "oslibutil.h"
|
---|
20 | #include "pmwindow.h"
|
---|
21 |
|
---|
22 | //******************************************************************************
|
---|
23 | //******************************************************************************
|
---|
24 | BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
|
---|
25 | {
|
---|
26 | if(hwndParent == OSLIB_HWND_DESKTOP)
|
---|
27 | {
|
---|
28 | hwndParent = HWND_DESKTOP;
|
---|
29 | }
|
---|
30 |
|
---|
31 | return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
|
---|
32 | }
|
---|
33 | //******************************************************************************
|
---|
34 | //******************************************************************************
|
---|
35 | HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
|
---|
36 | char *pszName, ULONG x, ULONG y, ULONG cx, ULONG cy,
|
---|
37 | HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame)
|
---|
38 | {
|
---|
39 | HWND hwndClient;
|
---|
40 | RECTL rectl;
|
---|
41 |
|
---|
42 | if(hwndParent == 0) {
|
---|
43 | hwndParent = HWND_DESKTOP;
|
---|
44 | }
|
---|
45 | if(WinQueryWindowRect(hwndParent, &rectl) == TRUE) {
|
---|
46 | y = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, y);
|
---|
47 | }
|
---|
48 | if(dwFrameStyle) {
|
---|
49 | dwWinStyle &= ~WS_CLIPCHILDREN; //invalid style according to docs
|
---|
50 | *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
|
---|
51 | &dwFrameStyle, WIN32_STDCLASS,
|
---|
52 | "", 0, 0, 0, &hwndClient) != 0;
|
---|
53 | if(*hwndFrame) {
|
---|
54 | if(pszName) {
|
---|
55 | WinSetWindowText(*hwndFrame, pszName);
|
---|
56 | }
|
---|
57 | WinSetWindowPos(*hwndFrame, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP,
|
---|
58 | x, y, cx, cy, SWP_SIZE | SWP_MOVE);
|
---|
59 |
|
---|
60 | return hwndClient;
|
---|
61 | }
|
---|
62 | dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
|
---|
63 | return 0;
|
---|
64 | }
|
---|
65 | hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, x, y, cx, cy,
|
---|
66 | Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
|
---|
67 | NULL);
|
---|
68 | *hwndFrame = hwndClient;
|
---|
69 | return hwndClient;
|
---|
70 | }
|
---|
71 | //******************************************************************************
|
---|
72 | //******************************************************************************
|
---|
73 | BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
|
---|
74 | {
|
---|
75 | *OSWinStyle = 0;
|
---|
76 | *OSFrameStyle = 0;
|
---|
77 |
|
---|
78 | /* Window styles */
|
---|
79 | if(dwStyle & WINWS_MINIMIZE)
|
---|
80 | *OSWinStyle |= WS_MINIMIZED;
|
---|
81 | if(dwStyle & WINWS_VISIBLE)
|
---|
82 | *OSWinStyle |= WS_VISIBLE;
|
---|
83 | if(dwStyle & WINWS_DISABLED)
|
---|
84 | *OSWinStyle |= WS_DISABLED;
|
---|
85 | if(dwStyle & WINWS_CLIPSIBLINGS)
|
---|
86 | *OSWinStyle |= WS_CLIPSIBLINGS;
|
---|
87 | if(dwStyle & WINWS_CLIPCHILDREN)
|
---|
88 | *OSWinStyle |= WS_CLIPCHILDREN;
|
---|
89 | if(dwStyle & WINWS_MAXIMIZE)
|
---|
90 | *OSWinStyle |= WS_MAXIMIZED;
|
---|
91 | if(dwStyle & WINWS_GROUP)
|
---|
92 | *OSWinStyle |= WS_GROUP;
|
---|
93 | if(dwStyle & WINWS_TABSTOP)
|
---|
94 | *OSWinStyle |= WS_TABSTOP;
|
---|
95 |
|
---|
96 | if(dwStyle & WINWS_CAPTION)
|
---|
97 | *OSFrameStyle |= FCF_TITLEBAR;
|
---|
98 | if(dwStyle & WINWS_BORDER)
|
---|
99 | *OSFrameStyle |= FCF_BORDER;
|
---|
100 | if(dwStyle & WINWS_DLGFRAME)
|
---|
101 | *OSFrameStyle |= FCF_DLGBORDER;
|
---|
102 | if(dwStyle & WINWS_VSCROLL)
|
---|
103 | *OSFrameStyle |= FCF_VERTSCROLL;
|
---|
104 | if(dwStyle & WINWS_HSCROLL)
|
---|
105 | *OSFrameStyle |= FCF_HORZSCROLL;
|
---|
106 | if(dwStyle & WINWS_SYSMENU)
|
---|
107 | *OSFrameStyle |= FCF_SYSMENU;
|
---|
108 | if(dwStyle & WINWS_THICKFRAME)
|
---|
109 | *OSFrameStyle |= FCF_SIZEBORDER; //??
|
---|
110 | if(dwStyle & WINWS_MINIMIZEBOX)
|
---|
111 | *OSFrameStyle |= FCF_MINBUTTON;
|
---|
112 | if(dwStyle & WINWS_MAXIMIZEBOX)
|
---|
113 | *OSFrameStyle |= FCF_MAXBUTTON;
|
---|
114 |
|
---|
115 | return TRUE;
|
---|
116 | }
|
---|
117 | //******************************************************************************
|
---|
118 | //******************************************************************************
|
---|
119 | BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
|
---|
120 | {
|
---|
121 | return WinSetWindowULong(hwnd, offset, value);
|
---|
122 | }
|
---|
123 | //******************************************************************************
|
---|
124 | //******************************************************************************
|
---|
125 | ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
|
---|
126 | {
|
---|
127 | return WinQueryWindowULong(hwnd, offset);
|
---|
128 | }
|
---|
129 | //******************************************************************************
|
---|
130 | //******************************************************************************
|
---|
131 | BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
|
---|
132 | {
|
---|
133 | return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
|
---|
134 | }
|
---|
135 | //******************************************************************************
|
---|
136 | //******************************************************************************
|
---|
137 | HWND OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate)
|
---|
138 | {
|
---|
139 | return WinCreateMenu(hwndParent, menutemplate);
|
---|
140 | }
|
---|
141 | //******************************************************************************
|
---|
142 | //******************************************************************************
|
---|
143 | HWND OSLibWinQueryTopMostChildWindow(HWND hwndParent)
|
---|
144 | {
|
---|
145 | return WinQueryWindow(hwndParent, QW_TOP);
|
---|
146 | }
|
---|
147 | //******************************************************************************
|
---|
148 | //******************************************************************************
|
---|
149 | BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
|
---|
150 | LONG cy, ULONG fl)
|
---|
151 | {
|
---|
152 | return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
|
---|
153 | }
|
---|
154 | //******************************************************************************
|
---|
155 | //******************************************************************************
|
---|
156 | BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
|
---|
157 | {
|
---|
158 | return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, fl);
|
---|
159 | }
|
---|
160 | //******************************************************************************
|
---|
161 | //******************************************************************************
|
---|
162 | BOOL OSLibWinDestroyWindow(HWND hwnd)
|
---|
163 | {
|
---|
164 | return WinDestroyWindow(hwnd);
|
---|
165 | }
|
---|
166 | //******************************************************************************
|
---|
167 | //******************************************************************************
|
---|
168 | BOOL OSLibWinQueryUpdateRect(HWND hwnd, PVOID pRect)
|
---|
169 | {
|
---|
170 | return WinQueryUpdateRect(hwnd, (RECTL *)pRect);
|
---|
171 | }
|
---|
172 | //******************************************************************************
|
---|
173 | //******************************************************************************
|
---|
174 | BOOL OSLibWinIsIconic(HWND hwnd)
|
---|
175 | {
|
---|
176 | SWP swp;
|
---|
177 | BOOL rc;
|
---|
178 |
|
---|
179 | rc = WinQueryWindowPos(hwnd, &swp);
|
---|
180 | if(rc == FALSE) {
|
---|
181 | dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
|
---|
182 | return FALSE;
|
---|
183 | }
|
---|
184 |
|
---|
185 | if(swp.fl & SWP_MINIMIZE)
|
---|
186 | return TRUE;
|
---|
187 | else return FALSE;
|
---|
188 | }
|
---|
189 | //******************************************************************************
|
---|
190 | //******************************************************************************
|
---|