1 | /* $Id: oslibgdi.cpp,v 1.3 1999-07-19 18:40:43 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 | //******************************************************************************
|
---|
25 | inline 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 | //******************************************************************************
|
---|
32 | ULONG 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 | //******************************************************************************
|
---|
44 | BOOL 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) != 0) {
|
---|
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;
|
---|
57 | return TRUE;
|
---|
58 | }
|
---|
59 | //******************************************************************************
|
---|
60 | // MapOS2ToWin32Rectl
|
---|
61 | // Convert OS/2 to Win32 RECTL structure
|
---|
62 | //
|
---|
63 | // Parameters:
|
---|
64 | // rectOS2: OS/2 child window RECTL
|
---|
65 | // rectWin32: Win32 Child window RECT (IN)
|
---|
66 | //
|
---|
67 | // Returns:
|
---|
68 | // TRUE: Success
|
---|
69 | // FALSE: Failures
|
---|
70 | //******************************************************************************
|
---|
71 | BOOL MapOS2ToWin32Rectl(PRECTLOS2 rectOS2, PRECT rectWin32)
|
---|
72 | {
|
---|
73 | ULONG length = rectOS2->yTop - rectOS2->yBottom;
|
---|
74 |
|
---|
75 | rectWin32->bottom = length - rectOS2->yBottom;
|
---|
76 | rectWin32->top = length - rectOS2->yTop;
|
---|
77 | rectWin32->left = rectOS2->xLeft;
|
---|
78 | rectWin32->right = rectOS2->xRight;
|
---|
79 | return TRUE;
|
---|
80 | }
|
---|
81 | //******************************************************************************
|
---|
82 | // MapWin32ToOS2Rectl
|
---|
83 | // Convert Win32 to OS/2 RECTL structure
|
---|
84 | //
|
---|
85 | // Parameters:
|
---|
86 | // rectWin32: Win32 Child window RECT (IN)
|
---|
87 | // rectOS2: OS/2 Child window RECTL (OUT)
|
---|
88 | // Returns:
|
---|
89 | // TRUE: Success
|
---|
90 | // FALSE: Failures
|
---|
91 | //******************************************************************************
|
---|
92 | BOOL MapWin32ToOS2Rectl(PRECT rectWin32, PRECTLOS2 rectOS2)
|
---|
93 | {
|
---|
94 | ULONG length = rectWin32->top - rectWin32->bottom;
|
---|
95 |
|
---|
96 | rectOS2->yBottom = length - rectWin32->bottom;
|
---|
97 | rectOS2->yTop = length - rectWin32->top;
|
---|
98 | rectOS2->xLeft = rectWin32->left;
|
---|
99 | rectOS2->xRight = rectWin32->right;
|
---|
100 | return TRUE;
|
---|
101 | }
|
---|
102 | //******************************************************************************
|
---|
103 | //******************************************************************************
|
---|
104 | HDC OSLibWinBeginPaint(HWND hwnd, RECT *rectWin32)
|
---|
105 | {
|
---|
106 | RECTL rectl;
|
---|
107 |
|
---|
108 | if(WinQueryUpdateRect(hwnd, &rectl) == FALSE)
|
---|
109 | {
|
---|
110 | dprintf(("BeginPaint, NO update rectl"));
|
---|
111 | return 0;
|
---|
112 | }
|
---|
113 | MapOS2ToWin32Rectl((RECTLOS2 *)&rectl, rectWin32);
|
---|
114 | return WinBeginPaint(hwnd, NULLHANDLE, &rectl);
|
---|
115 | }
|
---|
116 | //******************************************************************************
|
---|
117 | //******************************************************************************
|
---|
118 | BOOL OSLibWinEndPaint(HDC hdc)
|
---|
119 | {
|
---|
120 | return WinEndPaint((HPS)hdc);
|
---|
121 | }
|
---|
122 | //******************************************************************************
|
---|
123 | //******************************************************************************
|
---|
124 | HDC OSLibWinGetPS(HWND hwnd)
|
---|
125 | {
|
---|
126 | return (HDC)WinGetPS(hwnd);
|
---|
127 | }
|
---|
128 | //******************************************************************************
|
---|
129 | //******************************************************************************
|
---|
130 | BOOL OSLibWinReleasePS(HDC hdc)
|
---|
131 | {
|
---|
132 | return WinReleasePS((HPS)hdc);
|
---|
133 | }
|
---|
134 | //******************************************************************************
|
---|
135 | //******************************************************************************
|
---|