1 | /* $Id: oslibwin.cpp,v 1.1 1999-07-14 08:35:35 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 <oslibwin.h>
|
---|
17 | #include "oslibstyle.h"
|
---|
18 | #include "pmwindow.h"
|
---|
19 |
|
---|
20 | //******************************************************************************
|
---|
21 | //******************************************************************************
|
---|
22 | BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
|
---|
23 | {
|
---|
24 | if(hwndParent == OSLIB_HWND_DESKTOP)
|
---|
25 | {
|
---|
26 | hwndParent = HWND_DESKTOP;
|
---|
27 | }
|
---|
28 |
|
---|
29 | return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
|
---|
30 | }
|
---|
31 | //******************************************************************************
|
---|
32 | //******************************************************************************
|
---|
33 | HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
|
---|
34 | char *pszName, ULONG x, ULONG y, ULONG cx, ULONG cy,
|
---|
35 | HWND Owner, ULONG fHWND_BOTTOM)
|
---|
36 | {
|
---|
37 | HWND hwndClient;
|
---|
38 | HWND hwndFrame;
|
---|
39 | RECTL rectl;
|
---|
40 |
|
---|
41 | if(hwndParent == 0) {
|
---|
42 | hwndParent = HWND_DESKTOP;
|
---|
43 | }
|
---|
44 | if(WinQueryWindowRect(hwndParent, &rectl) == 0) {
|
---|
45 | y = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, y);
|
---|
46 | }
|
---|
47 | if(dwFrameStyle) {
|
---|
48 | dwWinStyle &= ~WS_CLIPCHILDREN; //invalid style according to docs
|
---|
49 | hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
|
---|
50 | &dwFrameStyle, WIN32_STDCLASS,
|
---|
51 | "", 0, 0, 0, &hwndClient) != 0;
|
---|
52 | if(hwndFrame) {
|
---|
53 | if(pszName) {
|
---|
54 | WinSetWindowText(hwndFrame, pszName);
|
---|
55 | }
|
---|
56 | WinSetWindowPos(hwndFrame, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP,
|
---|
57 | x, y, cx, cy, SWP_SIZE | SWP_MOVE);
|
---|
58 |
|
---|
59 | return hwndFrame;
|
---|
60 | }
|
---|
61 | return 0;
|
---|
62 | }
|
---|
63 | else return WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, x, y, cx, cy,
|
---|
64 | Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
|
---|
65 | NULL);
|
---|
66 | }
|
---|
67 | //******************************************************************************
|
---|
68 | //******************************************************************************
|
---|
69 | BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
|
---|
70 | {
|
---|
71 | *OSWinStyle = 0;
|
---|
72 | *OSFrameStyle = 0;
|
---|
73 |
|
---|
74 | /* Window styles */
|
---|
75 | if(dwStyle & WINWS_MINIMIZE)
|
---|
76 | *OSWinStyle |= WS_MINIMIZED;
|
---|
77 | if(dwStyle & WINWS_VISIBLE)
|
---|
78 | *OSWinStyle |= WS_VISIBLE;
|
---|
79 | if(dwStyle & WINWS_DISABLED)
|
---|
80 | *OSWinStyle |= WS_DISABLED;
|
---|
81 | if(dwStyle & WINWS_CLIPSIBLINGS)
|
---|
82 | *OSWinStyle |= WS_CLIPSIBLINGS;
|
---|
83 | if(dwStyle & WINWS_CLIPCHILDREN)
|
---|
84 | *OSWinStyle |= WS_CLIPCHILDREN;
|
---|
85 | if(dwStyle & WINWS_MAXIMIZE)
|
---|
86 | *OSWinStyle |= WS_MAXIMIZED;
|
---|
87 | if(dwStyle & WINWS_GROUP)
|
---|
88 | *OSWinStyle |= WS_GROUP;
|
---|
89 | if(dwStyle & WINWS_TABSTOP)
|
---|
90 | *OSWinStyle |= WS_TABSTOP;
|
---|
91 |
|
---|
92 | if(dwStyle & WINWS_CAPTION)
|
---|
93 | *OSFrameStyle |= FCF_TITLEBAR;
|
---|
94 | if(dwStyle & WINWS_BORDER)
|
---|
95 | *OSFrameStyle |= FCF_BORDER;
|
---|
96 | if(dwStyle & WINWS_DLGFRAME)
|
---|
97 | *OSFrameStyle |= FCF_DLGBORDER;
|
---|
98 | if(dwStyle & WINWS_VSCROLL)
|
---|
99 | *OSFrameStyle |= FCF_VERTSCROLL;
|
---|
100 | if(dwStyle & WINWS_HSCROLL)
|
---|
101 | *OSFrameStyle |= FCF_HORZSCROLL;
|
---|
102 | if(dwStyle & WINWS_SYSMENU)
|
---|
103 | *OSFrameStyle |= FCF_SYSMENU;
|
---|
104 | if(dwStyle & WINWS_THICKFRAME)
|
---|
105 | *OSFrameStyle |= FCF_SIZEBORDER; //??
|
---|
106 | if(dwStyle & WINWS_MINIMIZEBOX)
|
---|
107 | *OSFrameStyle |= FCF_MINBUTTON;
|
---|
108 | if(dwStyle & WINWS_MAXIMIZEBOX)
|
---|
109 | *OSFrameStyle |= FCF_MAXBUTTON;
|
---|
110 |
|
---|
111 | return TRUE;
|
---|
112 | }
|
---|
113 | //******************************************************************************
|
---|
114 | //******************************************************************************
|
---|
115 | BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
|
---|
116 | {
|
---|
117 | return WinSetWindowULong(hwnd, offset, value) == 0;
|
---|
118 | }
|
---|
119 | //******************************************************************************
|
---|
120 | //******************************************************************************
|
---|
121 | ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
|
---|
122 | {
|
---|
123 | return WinGetWindowULong(hwnd, offset);
|
---|
124 | }
|
---|
125 | //******************************************************************************
|
---|
126 | //******************************************************************************
|
---|