| 1 | /* $Id: oslibgdi.cpp,v 1.11 2000-01-06 17:05:52 cbratschi Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Window GDI wrapper functions for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 7 | * Copyright 1999 Christoph Bratschi (cbratschi@datacomm.ch)
|
|---|
| 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 | #include <misc.h>
|
|---|
| 19 | #include <oslibgdi.h>
|
|---|
| 20 | #include <oslibwin.h>
|
|---|
| 21 | #include "win32wbase.h"
|
|---|
| 22 |
|
|---|
| 23 | /*
|
|---|
| 24 | First letter is lower case to avoid conflicts with Win32 API names
|
|---|
| 25 | All transformations are for screen or client windows, for frame windows use OS/2 API's
|
|---|
| 26 |
|
|---|
| 27 | Single y mapping:
|
|---|
| 28 | mapScreenY()
|
|---|
| 29 | mapY()
|
|---|
| 30 | mapOS2ToWin32Y()
|
|---|
| 31 | mapWin32ToOS2Y()
|
|---|
| 32 | mapWin32Y()
|
|---|
| 33 |
|
|---|
| 34 | Single point mapping:
|
|---|
| 35 | mapScreenPoint()
|
|---|
| 36 | mapPoint()
|
|---|
| 37 | mapOS2ToWin32Point()
|
|---|
| 38 | mapWin32ToOS2Point()
|
|---|
| 39 | mapWin32Point()
|
|---|
| 40 |
|
|---|
| 41 | Single rect mapping:
|
|---|
| 42 | mapOS2ToWin32ScreenRect()
|
|---|
| 43 | mapWin32ToOS2ScreenRect()
|
|---|
| 44 | mapOS2ToWin32Rect()
|
|---|
| 45 | mapWin32ToOS2Rect()
|
|---|
| 46 | mapWin32Rect()
|
|---|
| 47 |
|
|---|
| 48 | Rect transformation:
|
|---|
| 49 | copyOS2ToWin32Rect()
|
|---|
| 50 | copyWin32ToOS2Rect()
|
|---|
| 51 |
|
|---|
| 52 | Child origin:
|
|---|
| 53 | mapOS2ToWin32ChildOrigin()
|
|---|
| 54 | */
|
|---|
| 55 |
|
|---|
| 56 | //******************************************************************************
|
|---|
| 57 | // To translation between OS/2 <-> Win32
|
|---|
| 58 | //******************************************************************************
|
|---|
| 59 | INT mapScreenY(INT screenPosY)
|
|---|
| 60 | {
|
|---|
| 61 | return ScreenHeight-1-screenPosY;
|
|---|
| 62 | }
|
|---|
| 63 | //******************************************************************************
|
|---|
| 64 | // To translation between OS/2 <-> Win32
|
|---|
| 65 | //******************************************************************************
|
|---|
| 66 | INT mapScreenY(INT screenH,INT screenPosY)
|
|---|
| 67 | {
|
|---|
| 68 | return screenH-1-screenPosY;
|
|---|
| 69 | }
|
|---|
| 70 | //******************************************************************************
|
|---|
| 71 | // To translation between OS/2 <-> Win32
|
|---|
| 72 | //******************************************************************************
|
|---|
| 73 | INT mapY(HWND os2Client,INT clientPosY)
|
|---|
| 74 | {
|
|---|
| 75 | RECTL rect;
|
|---|
| 76 |
|
|---|
| 77 | if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //client shouldn't be desktop
|
|---|
| 78 | if (!WinQueryWindowRect(os2Client,&rect)) return 0;
|
|---|
| 79 |
|
|---|
| 80 | return rect.yTop-1-clientPosY;
|
|---|
| 81 | }
|
|---|
| 82 | //******************************************************************************
|
|---|
| 83 | // To translation between OS/2 <-> Win32
|
|---|
| 84 | //******************************************************************************
|
|---|
| 85 | INT mapY(Win32BaseWindow *win32wnd,INT clientPosY)
|
|---|
| 86 | {
|
|---|
| 87 | if (!win32wnd) return 0;
|
|---|
| 88 |
|
|---|
| 89 | return win32wnd->getClientHeight()-1-clientPosY;
|
|---|
| 90 | }
|
|---|
| 91 | //******************************************************************************
|
|---|
| 92 | //******************************************************************************
|
|---|
| 93 | INT mapOS2ToWin32Y(HWND os2From,HWND os2To,INT fromPosY)
|
|---|
| 94 | {
|
|---|
| 95 | POINTL pt;
|
|---|
| 96 | RECTL rect;
|
|---|
| 97 |
|
|---|
| 98 | if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
|
|---|
| 99 | if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
|
|---|
| 100 | if (os2From != os2To)
|
|---|
| 101 | {
|
|---|
| 102 | pt.x = 0;
|
|---|
| 103 | pt.y = fromPosY;
|
|---|
| 104 | if (!WinMapWindowPoints(os2From,os2To,&pt,1)) return 0;
|
|---|
| 105 | } else pt.y = fromPosY;
|
|---|
| 106 | if (!WinQueryWindowRect(os2To,&rect)) return 0;
|
|---|
| 107 |
|
|---|
| 108 | return rect.yTop-1-pt.y;
|
|---|
| 109 | }
|
|---|
| 110 | //******************************************************************************
|
|---|
| 111 | //******************************************************************************
|
|---|
| 112 | INT mapOS2ToWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY)
|
|---|
| 113 | {
|
|---|
| 114 | POINTL pt;
|
|---|
| 115 |
|
|---|
| 116 | if (!wndFrom || !wndTo) return 0;
|
|---|
| 117 | if (wndFrom != wndTo)
|
|---|
| 118 | {
|
|---|
| 119 | pt.x = 0;
|
|---|
| 120 | pt.y = fromPosY;
|
|---|
| 121 | if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),&pt,1)) return 0;
|
|---|
| 122 | } else pt.y = fromPosY;
|
|---|
| 123 |
|
|---|
| 124 | return wndTo->getClientHeight()-1-pt.y;
|
|---|
| 125 | }
|
|---|
| 126 | //******************************************************************************
|
|---|
| 127 | //******************************************************************************
|
|---|
| 128 | INT mapWin32Y(HWND os2From,HWND os2To,INT fromPosY)
|
|---|
| 129 | {
|
|---|
| 130 | POINTL pt;
|
|---|
| 131 | RECTL rect;
|
|---|
| 132 |
|
|---|
| 133 | if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
|
|---|
| 134 | if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
|
|---|
| 135 | if (os2From == os2To) return fromPosY;
|
|---|
| 136 | if (!WinQueryWindowRect(os2From,&rect)) return 0;
|
|---|
| 137 | pt.y = rect.yTop-1-fromPosY;
|
|---|
| 138 | pt.x = 0;
|
|---|
| 139 | if (!WinMapWindowPoints(os2From,os2To,&pt,1)) return 0;
|
|---|
| 140 | if (!WinQueryWindowRect(os2To,&rect)) return 0;
|
|---|
| 141 |
|
|---|
| 142 | return rect.yTop-1-pt.y;
|
|---|
| 143 | }
|
|---|
| 144 | //******************************************************************************
|
|---|
| 145 | //******************************************************************************
|
|---|
| 146 | INT mapWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY)
|
|---|
| 147 | {
|
|---|
| 148 | POINTL pt;
|
|---|
| 149 |
|
|---|
| 150 | if (!wndFrom || !wndTo) return 0;
|
|---|
| 151 | if (wndFrom == wndTo) return fromPosY;
|
|---|
| 152 | pt.y = wndFrom->getClientHeight()-1-fromPosY;
|
|---|
| 153 | pt.x = 0;
|
|---|
| 154 | if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),&pt,1)) return 0;
|
|---|
| 155 |
|
|---|
| 156 | return wndTo->getClientHeight()-1-pt.y;
|
|---|
| 157 | }
|
|---|
| 158 | //******************************************************************************
|
|---|
| 159 | // To translation between OS/2 <-> Win32
|
|---|
| 160 | //******************************************************************************
|
|---|
| 161 | BOOL mapScreenPoint(OSLIBPOINT *screenPt)
|
|---|
| 162 | {
|
|---|
| 163 | if(!screenPt) return FALSE;
|
|---|
| 164 | screenPt->y = ScreenHeight-1-screenPt->y;
|
|---|
| 165 |
|
|---|
| 166 | return TRUE;
|
|---|
| 167 | }
|
|---|
| 168 | //******************************************************************************
|
|---|
| 169 | // To translation between OS/2 <-> Win32
|
|---|
| 170 | //******************************************************************************
|
|---|
| 171 | BOOL mapScreenPoint(INT screenH,OSLIBPOINT *screenPt)
|
|---|
| 172 | {
|
|---|
| 173 | if (!screenPt) return FALSE;
|
|---|
| 174 | screenPt->y = screenH-1-screenPt->y;
|
|---|
| 175 |
|
|---|
| 176 | return TRUE;
|
|---|
| 177 | }
|
|---|
| 178 | //******************************************************************************
|
|---|
| 179 | // To translation between OS/2 <-> Win32
|
|---|
| 180 | //******************************************************************************
|
|---|
| 181 | BOOL mapPoint(HWND os2Client,OSLIBPOINT *clientPt)
|
|---|
| 182 | {
|
|---|
| 183 | RECTL rect;
|
|---|
| 184 |
|
|---|
| 185 | if (!clientPt) return FALSE;
|
|---|
| 186 | if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //client shouldn't be desktop
|
|---|
| 187 | if (!WinQueryWindowRect(os2Client,&rect)) return 0;
|
|---|
| 188 | clientPt->y = rect.yTop-1-clientPt->y;
|
|---|
| 189 |
|
|---|
| 190 | return TRUE;
|
|---|
| 191 | }
|
|---|
| 192 | //******************************************************************************
|
|---|
| 193 | // To translation between OS/2 <-> Win32
|
|---|
| 194 | //******************************************************************************
|
|---|
| 195 | BOOL mapPoint(Win32BaseWindow *win32wnd,OSLIBPOINT *clientPt)
|
|---|
| 196 | {
|
|---|
| 197 | if (!win32wnd || !clientPt) return FALSE;
|
|---|
| 198 | clientPt->y = win32wnd->getClientHeight()-1-clientPt->y;
|
|---|
| 199 |
|
|---|
| 200 | return TRUE;
|
|---|
| 201 | }
|
|---|
| 202 | //******************************************************************************
|
|---|
| 203 | //******************************************************************************
|
|---|
| 204 | BOOL mapOS2ToWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt)
|
|---|
| 205 | {
|
|---|
| 206 | RECTL rect;
|
|---|
| 207 |
|
|---|
| 208 | if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
|
|---|
| 209 | if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
|
|---|
| 210 | if (os2From != os2To)
|
|---|
| 211 | {
|
|---|
| 212 | if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)fromPt,1)) return FALSE;
|
|---|
| 213 | }
|
|---|
| 214 | if (!WinQueryWindowRect(os2To,&rect)) return FALSE;
|
|---|
| 215 | fromPt->y = rect.yTop-1-fromPt->y;
|
|---|
| 216 |
|
|---|
| 217 | return TRUE;
|
|---|
| 218 | }
|
|---|
| 219 | //******************************************************************************
|
|---|
| 220 | //******************************************************************************
|
|---|
| 221 | BOOL mapOS2ToWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt)
|
|---|
| 222 | {
|
|---|
| 223 | if (!wndFrom || !wndTo) return 0;
|
|---|
| 224 | if (wndFrom != wndTo)
|
|---|
| 225 | {
|
|---|
| 226 | if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)fromPt,1)) return FALSE;
|
|---|
| 227 | }
|
|---|
| 228 | fromPt->y = wndTo->getClientHeight()-1-fromPt->y;
|
|---|
| 229 |
|
|---|
| 230 | return TRUE;
|
|---|
| 231 | }
|
|---|
| 232 | //******************************************************************************
|
|---|
| 233 | //******************************************************************************
|
|---|
| 234 | BOOL mapWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt)
|
|---|
| 235 | {
|
|---|
| 236 | RECTL rect;
|
|---|
| 237 |
|
|---|
| 238 | if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
|
|---|
| 239 | if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
|
|---|
| 240 | if (os2From == os2To) return TRUE;
|
|---|
| 241 | if (!WinQueryWindowRect(os2From,&rect)) return 0;
|
|---|
| 242 | fromPt->y = rect.yTop-1-fromPt->y;
|
|---|
| 243 | if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)fromPt,1)) return 0;
|
|---|
| 244 | if (!WinQueryWindowRect(os2To,&rect)) return 0;
|
|---|
| 245 | fromPt->y = rect.yTop-1-fromPt->y;
|
|---|
| 246 |
|
|---|
| 247 | return TRUE;
|
|---|
| 248 | }
|
|---|
| 249 | //******************************************************************************
|
|---|
| 250 | //******************************************************************************
|
|---|
| 251 | BOOL mapWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt)
|
|---|
| 252 | {
|
|---|
| 253 | if (!wndFrom || !wndTo) return FALSE;
|
|---|
| 254 | if (wndFrom == wndTo) return TRUE;
|
|---|
| 255 | fromPt->y = wndFrom->getClientHeight()-1-fromPt->y;
|
|---|
| 256 | if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)fromPt,1)) return 0;
|
|---|
| 257 | fromPt->y = wndTo->getClientHeight()-1-fromPt->y;
|
|---|
| 258 |
|
|---|
| 259 | return TRUE;
|
|---|
| 260 | }
|
|---|
| 261 | //******************************************************************************
|
|---|
| 262 | //******************************************************************************
|
|---|
| 263 | BOOL mapOS2ToWin32ScreenRect(PRECTLOS2 rectOS2,PRECT rectWin32)
|
|---|
| 264 | {
|
|---|
| 265 | if (!rectOS2 || !rectWin32) return FALSE;
|
|---|
| 266 | rectWin32->bottom = ScreenHeight-rectOS2->yBottom;
|
|---|
| 267 | rectWin32->top = ScreenHeight-rectOS2->yTop;
|
|---|
| 268 | rectWin32->left = rectOS2->xLeft;
|
|---|
| 269 | rectWin32->right = rectOS2->xRight;
|
|---|
| 270 |
|
|---|
| 271 | return TRUE;
|
|---|
| 272 | }
|
|---|
| 273 | //******************************************************************************
|
|---|
| 274 | //******************************************************************************
|
|---|
| 275 | BOOL mapWin32ToOS2ScreenRect(PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 276 | {
|
|---|
| 277 | if (!rectOS2 || !rectWin32) return FALSE;
|
|---|
| 278 | rectOS2->yBottom = ScreenHeight-rectWin32->bottom;
|
|---|
| 279 | rectOS2->yTop = ScreenHeight-rectWin32->top;
|
|---|
| 280 | rectOS2->xLeft = rectWin32->left;
|
|---|
| 281 | rectOS2->xRight = rectWin32->right;
|
|---|
| 282 |
|
|---|
| 283 | return TRUE;
|
|---|
| 284 | }
|
|---|
| 285 | //******************************************************************************
|
|---|
| 286 | //******************************************************************************
|
|---|
| 287 | BOOL mapOS2ToWin32Rect(HWND os2Client,PRECTLOS2 rectOS2,PRECT rectWin32)
|
|---|
| 288 | {
|
|---|
| 289 | RECTL rect;
|
|---|
| 290 |
|
|---|
| 291 | if (!rectOS2 || !rectWin32) return FALSE;
|
|---|
| 292 | if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //shouldn't be the case
|
|---|
| 293 | if (!WinQueryWindowRect(os2Client,&rect)) return FALSE;
|
|---|
| 294 | rectWin32->bottom = rect.yTop-rectOS2->yBottom;
|
|---|
| 295 | rectWin32->top = rect.yTop-rectOS2->yTop;
|
|---|
| 296 | rectWin32->left = rectOS2->xLeft;
|
|---|
| 297 | rectWin32->right = rectOS2->xRight;
|
|---|
| 298 |
|
|---|
| 299 | return TRUE;
|
|---|
| 300 | }
|
|---|
| 301 | //******************************************************************************
|
|---|
| 302 | //******************************************************************************
|
|---|
| 303 | BOOL mapOS2ToWin32Rect(Win32BaseWindow *win32wnd,PRECTLOS2 rectOS2,PRECT rectWin32)
|
|---|
| 304 | {
|
|---|
| 305 | INT windowH;
|
|---|
| 306 |
|
|---|
| 307 | if (!win32wnd || !rectOS2 || !rectWin32) return FALSE;
|
|---|
| 308 | windowH = win32wnd->getClientHeight();
|
|---|
| 309 | rectWin32->bottom = windowH-rectOS2->yBottom;
|
|---|
| 310 | rectWin32->top = windowH-rectOS2->yTop;
|
|---|
| 311 | rectWin32->left = rectOS2->xLeft;
|
|---|
| 312 | rectWin32->right = rectOS2->xRight;
|
|---|
| 313 |
|
|---|
| 314 | return TRUE;
|
|---|
| 315 | }
|
|---|
| 316 | //******************************************************************************
|
|---|
| 317 | //******************************************************************************
|
|---|
| 318 | BOOL mapOS2ToWin32Rect(HWND os2From,HWND os2To,PRECTLOS2 rectOS2,PRECT rectWin32)
|
|---|
| 319 | {
|
|---|
| 320 | RECTL rect,temp;
|
|---|
| 321 |
|
|---|
| 322 | if (!rectOS2 || !rectWin32) return FALSE;
|
|---|
| 323 | if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
|
|---|
| 324 | if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
|
|---|
| 325 | temp = *((PRECTL)rectOS2);
|
|---|
| 326 | if (os2From != os2To)
|
|---|
| 327 | {
|
|---|
| 328 | if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)&temp,2)) return FALSE;
|
|---|
| 329 | }
|
|---|
| 330 | if (!WinQueryWindowRect(os2To,&rect)) return FALSE;
|
|---|
| 331 | rectWin32->bottom = rect.yTop-temp.yBottom;
|
|---|
| 332 | rectWin32->top = rect.yTop-temp.yTop;
|
|---|
| 333 | rectWin32->left = temp.xLeft;
|
|---|
| 334 | rectWin32->right = temp.xRight;
|
|---|
| 335 |
|
|---|
| 336 | return TRUE;
|
|---|
| 337 | }
|
|---|
| 338 | //******************************************************************************
|
|---|
| 339 | //******************************************************************************
|
|---|
| 340 | BOOL mapOS2ToWin32Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECTLOS2 rectOS2,PRECT rectWin32)
|
|---|
| 341 | {
|
|---|
| 342 | RECTL temp;
|
|---|
| 343 | INT windowH;
|
|---|
| 344 |
|
|---|
| 345 | if (!wndFrom || !wndTo || !rectOS2 || !rectWin32) return FALSE;
|
|---|
| 346 | temp = *((PRECTL)rectOS2);
|
|---|
| 347 | if (wndFrom != wndTo)
|
|---|
| 348 | {
|
|---|
| 349 | if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)&temp,2)) return FALSE;
|
|---|
| 350 | }
|
|---|
| 351 | windowH = wndTo->getClientHeight();
|
|---|
| 352 | rectWin32->bottom = windowH-temp.yBottom;
|
|---|
| 353 | rectWin32->top = windowH-temp.yTop;
|
|---|
| 354 | rectWin32->left = temp.xLeft;
|
|---|
| 355 | rectWin32->right = temp.xRight;
|
|---|
| 356 |
|
|---|
| 357 | return TRUE;
|
|---|
| 358 | }
|
|---|
| 359 | //******************************************************************************
|
|---|
| 360 | //******************************************************************************
|
|---|
| 361 | BOOL mapWin32ToOS2Rect(HWND os2Client,PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 362 | {
|
|---|
| 363 | RECTL rect;
|
|---|
| 364 |
|
|---|
| 365 | if (!rectOS2 || !rectWin32) return FALSE;
|
|---|
| 366 | if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //shouldn't be the case
|
|---|
| 367 | if (!WinQueryWindowRect(os2Client,&rect)) return FALSE;
|
|---|
| 368 | rectOS2->yBottom = rect.yTop-rectWin32->bottom;
|
|---|
| 369 | rectOS2->yTop = rect.yTop-rectWin32->top;
|
|---|
| 370 | rectOS2->xLeft = rectWin32->left;
|
|---|
| 371 | rectOS2->xRight = rectWin32->right;
|
|---|
| 372 |
|
|---|
| 373 | return TRUE;
|
|---|
| 374 | }
|
|---|
| 375 | //******************************************************************************
|
|---|
| 376 | //******************************************************************************
|
|---|
| 377 | BOOL mapWin32ToOS2Rect(Win32BaseWindow *win32wnd,PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 378 | {
|
|---|
| 379 | INT windowH;
|
|---|
| 380 |
|
|---|
| 381 | if (!win32wnd || !rectOS2 || !rectWin32) return FALSE;
|
|---|
| 382 | windowH = win32wnd->getClientHeight();
|
|---|
| 383 | rectOS2->yBottom = windowH-rectWin32->bottom;
|
|---|
| 384 | rectOS2->yTop = windowH-rectWin32->top;
|
|---|
| 385 | rectOS2->xLeft = rectWin32->left;
|
|---|
| 386 | rectOS2->xRight = rectWin32->right;
|
|---|
| 387 |
|
|---|
| 388 | return TRUE;
|
|---|
| 389 | }
|
|---|
| 390 | //******************************************************************************
|
|---|
| 391 | //******************************************************************************
|
|---|
| 392 | BOOL mapWin32ToOS2Rect(HWND os2From,HWND os2To,PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 393 | {
|
|---|
| 394 | RECTL rect;
|
|---|
| 395 |
|
|---|
| 396 | if (!rectOS2 || !rectWin32) return FALSE;
|
|---|
| 397 | if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
|
|---|
| 398 | if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
|
|---|
| 399 | if (!WinQueryWindowRect(os2From,&rect)) return FALSE;
|
|---|
| 400 | rectOS2->yBottom = rect.yTop-rectWin32->bottom;
|
|---|
| 401 | rectOS2->yTop = rect.yTop-rectWin32->top;
|
|---|
| 402 | rectOS2->xLeft = rectWin32->left;
|
|---|
| 403 | rectOS2->xRight = rectWin32->right;
|
|---|
| 404 | if (os2From != os2To)
|
|---|
| 405 | {
|
|---|
| 406 | if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)rectOS2,2)) return FALSE;
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | return TRUE;
|
|---|
| 410 | }
|
|---|
| 411 | //******************************************************************************
|
|---|
| 412 | //******************************************************************************
|
|---|
| 413 | BOOL mapWin32ToOS2Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 414 | {
|
|---|
| 415 | INT windowH;
|
|---|
| 416 |
|
|---|
| 417 | if (!wndFrom || !wndTo || !rectOS2 || !rectWin32) return FALSE;
|
|---|
| 418 | windowH = wndFrom->getClientHeight();
|
|---|
| 419 | rectOS2->yBottom = windowH-rectWin32->bottom;
|
|---|
| 420 | rectOS2->yTop = windowH-rectWin32->top;
|
|---|
| 421 | rectOS2->xLeft = rectWin32->left;
|
|---|
| 422 | rectOS2->xRight = rectWin32->right;
|
|---|
| 423 | if (wndFrom != wndTo)
|
|---|
| 424 | {
|
|---|
| 425 | if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)rectOS2,2)) return FALSE;
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 | return TRUE;
|
|---|
| 429 | }
|
|---|
| 430 | //******************************************************************************
|
|---|
| 431 | //******************************************************************************
|
|---|
| 432 | BOOL mapWin32Rect(HWND os2From,HWND os2To,PRECT rectWin32)
|
|---|
| 433 | {
|
|---|
| 434 | RECTL rect;
|
|---|
| 435 |
|
|---|
| 436 | mapWin32ToOS2Rect(os2From,rectWin32,(PRECTLOS2)&rect);
|
|---|
| 437 | WinMapWindowPoints((os2From == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP:os2From,(os2To == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP:os2To,(PPOINTL)&rect,2);
|
|---|
| 438 | mapOS2ToWin32Rect(os2To,(PRECTLOS2)&rect,rectWin32);
|
|---|
| 439 |
|
|---|
| 440 | return TRUE;
|
|---|
| 441 | }
|
|---|
| 442 | //******************************************************************************
|
|---|
| 443 | //******************************************************************************
|
|---|
| 444 | BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32)
|
|---|
| 445 | {
|
|---|
| 446 | rectWin32->bottom = rectOS2->yBottom;
|
|---|
| 447 | rectWin32->top = rectOS2->yTop;
|
|---|
| 448 | rectWin32->left = rectOS2->xLeft;
|
|---|
| 449 | rectWin32->right = rectOS2->xRight;
|
|---|
| 450 |
|
|---|
| 451 | return TRUE;
|
|---|
| 452 | }
|
|---|
| 453 | //******************************************************************************
|
|---|
| 454 | //******************************************************************************
|
|---|
| 455 | BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 456 | {
|
|---|
| 457 | rectOS2->yBottom = rectWin32->bottom;
|
|---|
| 458 | rectOS2->yTop = rectWin32->top;
|
|---|
| 459 | rectOS2->xLeft = rectWin32->left;
|
|---|
| 460 | rectOS2->xRight = rectWin32->right;
|
|---|
| 461 |
|
|---|
| 462 | return TRUE;
|
|---|
| 463 | }
|
|---|
| 464 | //******************************************************************************
|
|---|
| 465 | //******************************************************************************
|
|---|
| 466 | INT mapOS2ToWin32ChildOrigin(INT parentH,INT parentPosY,INT childH)
|
|---|
| 467 | {
|
|---|
| 468 | return parentH-parentPosY-childH;//Does: parentH-1-parentPosY-(childH-1)
|
|---|
| 469 | }
|
|---|
| 470 | //******************************************************************************
|
|---|
| 471 | //******************************************************************************
|
|---|
| 472 | HDC OSLibWinBeginPaint(HWND hwnd, RECT *rectWin32)
|
|---|
| 473 | {
|
|---|
| 474 | RECTL rectl;
|
|---|
| 475 |
|
|---|
| 476 | if(WinQueryUpdateRect(hwnd, &rectl) == FALSE)
|
|---|
| 477 | {
|
|---|
| 478 | dprintf(("BeginPaint, NO update rectl"));
|
|---|
| 479 | return 0;
|
|---|
| 480 | }
|
|---|
| 481 | mapOS2ToWin32Rect(hwnd,(RECTLOS2 *)&rectl, rectWin32);
|
|---|
| 482 | return WinBeginPaint(hwnd, NULLHANDLE, &rectl);
|
|---|
| 483 | }
|
|---|
| 484 | //******************************************************************************
|
|---|
| 485 | //******************************************************************************
|
|---|
| 486 | BOOL OSLibWinEndPaint(HDC hdc)
|
|---|
| 487 | {
|
|---|
| 488 | return WinEndPaint((HPS)hdc);
|
|---|
| 489 | }
|
|---|
| 490 | //******************************************************************************
|
|---|
| 491 | //******************************************************************************
|
|---|
| 492 | HDC OSLibWinGetPS(HWND hwnd)
|
|---|
| 493 | {
|
|---|
| 494 | if(hwnd == OSLIB_HWND_DESKTOP)
|
|---|
| 495 | hwnd = HWND_DESKTOP;
|
|---|
| 496 |
|
|---|
| 497 | return (HDC)WinGetPS(hwnd);
|
|---|
| 498 | }
|
|---|
| 499 | //******************************************************************************
|
|---|
| 500 | //******************************************************************************
|
|---|
| 501 | BOOL OSLibWinReleasePS(HDC hdc)
|
|---|
| 502 | {
|
|---|
| 503 | return WinReleasePS((HPS)hdc);
|
|---|
| 504 | }
|
|---|
| 505 | //******************************************************************************
|
|---|
| 506 | //******************************************************************************
|
|---|
| 507 | BOOL OSLibWinInvalidateRect(HWND hwnd, PRECT pRect, BOOL fIncludeChildren)
|
|---|
| 508 | {
|
|---|
| 509 | RECTLOS2 rectl;
|
|---|
| 510 |
|
|---|
| 511 | if(pRect) {
|
|---|
| 512 | mapWin32ToOS2Rect(hwnd,pRect, &rectl);
|
|---|
| 513 | return WinInvalidateRect(hwnd, (PRECTL)&rectl, fIncludeChildren);
|
|---|
| 514 | }
|
|---|
| 515 | return WinInvalidateRect(hwnd, NULL, fIncludeChildren);
|
|---|
| 516 | }
|
|---|
| 517 | //******************************************************************************
|
|---|
| 518 | //Returns rectangle in Win32 window coordinates
|
|---|
| 519 | //******************************************************************************
|
|---|
| 520 | BOOL OSLibWinQueryUpdateRect(HWND hwnd, PRECT pRect)
|
|---|
| 521 | {
|
|---|
| 522 | BOOL rc;
|
|---|
| 523 | RECTLOS2 rectl;
|
|---|
| 524 |
|
|---|
| 525 | rc = WinQueryUpdateRect(hwnd, (PRECTL)&rectl);
|
|---|
| 526 | if(rc) {
|
|---|
| 527 | mapOS2ToWin32Rect(hwnd,&rectl, pRect);
|
|---|
| 528 | }
|
|---|
| 529 | else memset(pRect, 0, sizeof(RECT));
|
|---|
| 530 | return rc;
|
|---|
| 531 | }
|
|---|
| 532 | //******************************************************************************
|
|---|
| 533 | //******************************************************************************
|
|---|
| 534 |
|
|---|