source: trunk/src/user32/oslibgdi.cpp@ 1330

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

Lots of window fixes & changes

File size: 6.9 KB
Line 
1/* $Id: oslibgdi.cpp,v 1.3 1999-10-14 18:27:57 sandervl Exp $ */
2/*
3 * Window GDI wrapper functions 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 <oslibgdi.h>
21#include <oslibwin.h>
22
23//******************************************************************************
24//******************************************************************************
25inline ULONG MAPWIN32POINT(RECTLOS2 *parent, ULONG cy, ULONG y)
26{
27 return (parent->yTop - parent->yBottom - cy - y);
28}
29//******************************************************************************
30//Map win32 y coordinate (in parent window coordinates) to OS/2 y coord. (in parent window coordinates)
31//******************************************************************************
32ULONG MapOS2ToWin32Y(HWND hwndParent, ULONG cy, ULONG y)
33{
34 RECTLOS2 rectParent = {0};
35
36 if(hwndParent == OSLIB_HWND_DESKTOP) {
37 hwndParent = HWND_DESKTOP;
38 }
39 WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
40 return MAPWIN32POINT(&rectParent, cy, y);
41}
42//******************************************************************************
43//******************************************************************************
44BOOL MapOS2ToWin32Point(HWND hwndParent, HWND hwndChild, OSLIBPOINT *point)
45{
46 RECTLOS2 rectParent = {0};
47
48 if(hwndParent == OSLIB_HWND_DESKTOP) {
49 hwndParent = HWND_DESKTOP;
50 }
51 if(WinMapWindowPoints(hwndChild, hwndParent, (POINTL *)point, 1) != TRUE) {
52 dprintf(("MapOS2ToWin32Point:WinMapWindowPoint %x %x returned false", hwndParent, hwndChild));
53 return FALSE;
54 }
55 WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
56 point->y = rectParent.yTop - point->y - 1;
57 return TRUE;
58}
59//******************************************************************************
60// MapOS2ToWin32Rect
61// Map os/2 rectangle to screen coordinates and convert to win32 rect
62//
63// Parameters:
64// hwndParent: Parent window handle
65// hwndChild: Child window handle
66// rectOS2: OS/2 child window RECTL
67// rectWin32: Win32 Child window RECT (IN)
68//
69// Returns:
70// TRUE: Success
71// FALSE: Failures
72//******************************************************************************
73BOOL MapOS2ToWin32Rectl(HWND hwndParent, HWND hwndChild, PRECTLOS2 rectOS2, PRECT rectWin32)
74{
75 RECTLOS2 rectParent = {0};
76 Win32BaseWindow *window;
77 LONG height;
78
79 if(hwndParent == OSLIB_HWND_DESKTOP) {
80 hwndParent = HWND_DESKTOP;
81 }
82 if(WinMapWindowPoints(hwndChild, hwndParent, (PPOINTL)rectOS2, 2) != TRUE) {
83 dprintf(("MapOS2ToWin32Rect:WinMapWindowPoint %x %x returned false", hwndParent, hwndChild));
84 return FALSE;
85 }
86
87 if(hwndParent != HWND_DESKTOP)
88 {
89 window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndParent);
90 if(window == NULL)
91 return FALSE;
92 height = window->getWindowHeight();
93 }
94 else height = OSLibQueryScreenHeight();
95
96 rectWin32->bottom = height - rectOS2->yBottom;
97 rectWin32->top = height - rectOS2->yTop;
98 rectWin32->left = rectOS2->xLeft;
99 rectWin32->right = rectOS2->xRight;
100
101 return TRUE;
102}
103//******************************************************************************
104// MapOS2ToWin32Rectl
105// Convert OS/2 to Win32 RECTL structure
106//
107// Parameters:
108// rectOS2: OS/2 child window RECTL
109// rectWin32: Win32 Child window RECT (IN)
110//
111// Returns:
112// TRUE: Success
113// FALSE: Failures
114//******************************************************************************
115BOOL MapOS2ToWin32Rectl(PRECTLOS2 rectOS2, PRECT rectWin32)
116{
117 ULONG length = rectOS2->yTop - rectOS2->yBottom;
118
119 rectWin32->bottom = length - rectOS2->yBottom;
120 rectWin32->top = length - rectOS2->yTop;
121 rectWin32->left = rectOS2->xLeft;
122 rectWin32->right = rectOS2->xRight;
123 return TRUE;
124}
125//******************************************************************************
126// MapWin32ToOS2Rectl
127// Convert Win32 to OS/2 RECTL structure
128//
129// Parameters:
130// rectWin32: Win32 Child window RECT (IN)
131// rectOS2: OS/2 Child window RECTL (OUT)
132// Returns:
133// TRUE: Success
134// FALSE: Failures
135//******************************************************************************
136BOOL MapWin32ToOS2Rectl(PRECT rectWin32, PRECTLOS2 rectOS2)
137{
138 ULONG length = rectWin32->bottom - rectWin32->top;
139
140 rectOS2->yBottom = length - rectWin32->bottom;
141 rectOS2->yTop = length - rectWin32->top;
142 rectOS2->xLeft = rectWin32->left;
143 rectOS2->xRight = rectWin32->right;
144 return TRUE;
145}
146//******************************************************************************
147//******************************************************************************
148HDC OSLibWinBeginPaint(HWND hwnd, RECT *rectWin32)
149{
150 RECTL rectl;
151
152 if(WinQueryUpdateRect(hwnd, &rectl) == FALSE)
153 {
154 dprintf(("BeginPaint, NO update rectl"));
155 return 0;
156 }
157 MapOS2ToWin32Rectl((RECTLOS2 *)&rectl, rectWin32);
158 return WinBeginPaint(hwnd, NULLHANDLE, &rectl);
159}
160//******************************************************************************
161//******************************************************************************
162BOOL OSLibWinEndPaint(HDC hdc)
163{
164 return WinEndPaint((HPS)hdc);
165}
166//******************************************************************************
167//******************************************************************************
168HDC OSLibWinGetPS(HWND hwnd)
169{
170 if(hwnd == OSLIB_HWND_DESKTOP)
171 hwnd = HWND_DESKTOP;
172
173 return (HDC)WinGetPS(hwnd);
174}
175//******************************************************************************
176//******************************************************************************
177BOOL OSLibWinReleasePS(HDC hdc)
178{
179 return WinReleasePS((HPS)hdc);
180}
181//******************************************************************************
182//******************************************************************************
183BOOL OSLibWinInvalidateRect(HWND hwnd, PRECT pRect, BOOL fIncludeChildren)
184{
185 RECTLOS2 rectl;
186
187 if(pRect) {
188 MapWin32ToOS2Rectl(pRect, &rectl);
189 return WinInvalidateRect(hwnd, (PRECTL)&rectl, fIncludeChildren);
190 }
191 return WinInvalidateRect(hwnd, NULL, fIncludeChildren);
192}
193//******************************************************************************
194//Returns rectangle in Win32 window coordinates
195//******************************************************************************
196BOOL OSLibWinQueryUpdateRect(HWND hwnd, PRECT pRect)
197{
198 BOOL rc;
199 RECTLOS2 rectl;
200
201 rc = WinQueryUpdateRect(hwnd, (PRECTL)&rectl);
202 if(rc) {
203 MapOS2ToWin32Rectl(&rectl, pRect);
204 }
205 else memset(pRect, 0, sizeof(RECT));
206 return rc;
207}
208//******************************************************************************
209//******************************************************************************
210
Note: See TracBrowser for help on using the repository browser.