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