Changeset 3662 for trunk/src/user32/oslibgdi.cpp
- Timestamp:
- Jun 7, 2000, 4:51:33 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/oslibgdi.cpp
r3101 r3662 1 /* $Id: oslibgdi.cpp,v 1.1 1 2000-03-13 13:10:45sandervl Exp $ */1 /* $Id: oslibgdi.cpp,v 1.12 2000-06-07 14:51:26 sandervl Exp $ */ 2 2 /* 3 3 * Window GDI wrapper functions for OS/2 … … 30 30 Single y mapping: 31 31 mapScreenY() 32 mapY() 33 mapOS2ToWin32Y() 34 mapWin32ToOS2Y() 35 mapWin32Y() 32 mapY() //only reverses y 33 mapOS2ToWin32Y() //reverse y + subtract parent client offset 34 mapOS2ToWin32X() //subtract parent client offset 35 36 mapWin32ToOS2Y() //reverse y + add parent client offset 37 mapWin32ToOS2Y() //add parent client offset 36 38 37 39 Single point mapping: 38 40 mapScreenPoint() 39 mapPoint()40 41 mapOS2ToWin32Point() 41 42 mapWin32ToOS2Point() … … 52 53 copyOS2ToWin32Rect() 53 54 copyWin32ToOS2Rect() 54 55 Child origin:56 mapOS2ToWin32ChildOrigin()57 55 */ 58 56 … … 70 68 { 71 69 return screenH-1-screenPosY; 72 }73 //******************************************************************************74 // To translation between OS/2 <-> Win3275 //******************************************************************************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 desktop81 if (!WinQueryWindowRect(os2Client,&rect)) return 0;82 83 return rect.yTop-1-clientPosY;84 }85 //******************************************************************************86 // To translation between OS/2 <-> Win3287 //******************************************************************************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 70 } 161 71 //****************************************************************************** … … 182 92 // To translation between OS/2 <-> Win32 183 93 //****************************************************************************** 184 BOOL map Point(HWND os2Client,OSLIBPOINT *clientPt)94 BOOL mapOS2ToWin32Rect(int height, PRECTLOS2 rectOS2, PRECT rectWin32) 185 95 { 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; 96 if(!rectOS2 || !rectWin32) { 97 DebugInt3(); 98 return FALSE; 216 99 } 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; 100 rectWin32->bottom = height-rectOS2->yBottom; 101 rectWin32->top = height-rectOS2->yTop; 271 102 rectWin32->left = rectOS2->xLeft; 272 103 rectWin32->right = rectOS2->xRight; … … 276 107 //****************************************************************************** 277 108 //****************************************************************************** 278 BOOL mapWin32ToOS2 ScreenRect(PRECT rectWin32,PRECTLOS2 rectOS2)109 BOOL mapWin32ToOS2Rect(int height, PRECT rectWin32, PRECTLOS2 rectOS2) 279 110 { 280 if (!rectOS2 || !rectWin32) return FALSE; 281 rectOS2->yBottom = ScreenHeight-rectWin32->bottom; 282 rectOS2->yTop = ScreenHeight-rectWin32->top; 111 if(!rectOS2 || !rectWin32) { 112 DebugInt3(); 113 return FALSE; 114 } 115 rectOS2->yBottom = height-rectWin32->bottom; 116 rectOS2->yTop = height-rectWin32->top; 283 117 rectOS2->xLeft = rectWin32->left; 284 118 rectOS2->xRight = rectWin32->right; … … 288 122 //****************************************************************************** 289 123 //****************************************************************************** 290 BOOL map OS2ToWin32Rect(HWND os2Client,PRECTLOS2 rectOS2,PRECT rectWin32)124 BOOL mapWin32ToOS2RectClientToFrame(Win32BaseWindow *window, PRECT rectWin32,PRECTLOS2 rectOS2) 291 125 { 292 RECTL rect; 126 int height; 127 int xclientorg; 128 int yclientorg; 293 129 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;130 if(!window || !rectOS2 || !rectWin32) { 131 DebugInt3(); 132 return FALSE; 133 } 134 height = window->getWindowHeight(); 135 xclientorg = window->getClientRectPtr()->left; 136 yclientorg = window->getClientRectPtr()->top; 301 137 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); 138 rectOS2->yBottom = height - (rectWin32->bottom + yclientorg); 139 rectOS2->yTop = height - (rectWin32->top + yclientorg); 140 rectOS2->xLeft = rectWin32->left - xclientorg; 141 rectOS2->xRight = rectWin32->right - xclientorg; 442 142 443 143 return TRUE; … … 467 167 //****************************************************************************** 468 168 //****************************************************************************** 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 coordinates522 //******************************************************************************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
Note:
See TracChangeset
for help on using the changeset viewer.