Changeset 327 for trunk/src/user32/new/user32.cpp
- Timestamp:
- Jul 18, 1999, 3:57:48 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/user32.cpp
r325 r327 1 /* $Id: user32.cpp,v 1. 5 1999-07-18 10:39:51 sandervlExp $ */1 /* $Id: user32.cpp,v 1.6 1999-07-18 13:57:47 cbratschi Exp $ */ 2 2 3 3 /* … … 19 19 *****************************************************************************/ 20 20 21 /* 22 CB: 23 - don't replace GDI functions (hdc), only convert window handle 24 - always use OSRECTL for PM functions 25 - POINT == POINTL 26 */ 27 21 28 #include <os2win.h> 22 29 #include "misc.h" … … 31 38 #include <string.h> 32 39 #include <oslibwin.h> 40 #include <win32wnd.h> 33 41 34 42 //undocumented stuff … … 69 77 // WIN32API YieldTask 70 78 71 72 79 //Window handle transformation 80 81 inline HWND Win32ToOS2Handle(HWND hwnd) 82 { 83 Win32Window *window; 84 85 window = Win32Window::GetWindowFromHandle(hwnd); 86 if (window) return window->getOS2WindowHandle(); 87 else return hwnd; //already OS/2 handle? 88 } 89 90 inline HWND OS2ToWin32Handle(HWND hwnd) 91 { 92 Win32Window *window; 93 94 window = Win32Window::GetWindowFromOS2Handle(hwnd); 95 if (window) return window->getWindowHandle(); 96 else return hwnd; //OS/2 window 97 } 98 99 //Coordinate transformation 100 101 inline void Win32ToOS2Rect(POSRECTL dest,PRECT source,ULONG windowH) 102 { 103 dest->xLeft = source->left; 104 dest->xRight = source->right; 105 dest->yTop = windowH-source->top; 106 dest->yBottom = windowH-source->bottom; 107 } 108 109 inline void OS2ToWin32Rect(PRECT dest,POSRECTL source,ULONG windowH) 110 { 111 dest->left = source->xLeft; 112 dest->right = source->xRight; 113 dest->top = windowH-source->yTop; 114 dest->bottom = windowH-source->yBottom; 115 } 116 117 inline void OS2ToWin32ScreenPos(POINT *dest,POINT *source) 118 { 119 dest->x = source->x; 120 dest->y = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CYSCREEN)-source->y; 121 } 122 123 inline void Win32ToOS2ScreenPos(POINT *dest,POINT *source) 124 { 125 OS2ToWin32ScreenPos(dest,source); //transform back 126 } 73 127 74 128 //****************************************************************************** … … 185 239 //****************************************************************************** 186 240 //****************************************************************************** 187 BOOL WIN32API MessageBeep( UINT arg1)241 BOOL WIN32API MessageBeep( UINT uType) 188 242 { 189 243 INT flStyle; … … 193 247 #endif 194 248 195 switch ( arg1)249 switch (uType) 196 250 { 197 251 case 0xFFFFFFFF: … … 199 253 return TRUE; 200 254 case MB_ICONASTERISK: 201 flStyle = WA _NOTE;255 flStyle = WAOS_NOTE; 202 256 break; 203 257 case MB_ICONEXCLAMATION: 204 flStyle = WA _WARNING;258 flStyle = WAOS_WARNING; 205 259 break; 206 260 case MB_ICONHAND: 207 261 case MB_ICONQUESTION: 208 262 case MB_OK: 209 flStyle = WA _NOTE;263 flStyle = WAOS_NOTE; 210 264 break; 211 265 default: 212 flStyle = WA _ERROR; //CB: should be right266 flStyle = WAOS_ERROR; //CB: should be right 213 267 break; 214 268 } 215 return OSLibWinAlarm(HWND_DESKTOP,flStyle); 216 } 269 return OSLibWinAlarm(OSLIB_HWND_DESKTOP,flStyle); 270 } 271 //****************************************************************************** 217 272 //****************************************************************************** 218 273 … … 231 286 return GetWindowTextW(hwnd,lpString,nMaxCount); 232 287 } 233 234 235 //******************************************************************************236 288 //****************************************************************************** 237 289 //****************************************************************************** 238 290 HWND WIN32API GetFocus(void) 239 291 { 292 HWND hwnd; 240 293 // dprintf(("USER32: GetFocus\n")); 241 //return OS2LibWinQueryFocus(HWND_DESKTOP); 242 return O32_GetFocus(); 294 295 hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP); 296 return OS2ToWin32Handle(hwnd); 243 297 } 244 298 //****************************************************************************** … … 247 301 { 248 302 dprintf(("USER32: GetDesktopWindow\n")); 249 //return HWND_DESKTOP //CB: WinQueryDesktopWindow();, hab and hdc not available! 250 return O32_GetDesktopWindow(); 303 return OSLIB_HWND_DESKTOP; 251 304 } 252 305 //****************************************************************************** … … 258 311 259 312 dprintf(("USER32: EnumThreadWindows\n")); 260 // replace313 //CB: replace 261 314 rc = O32_EnumThreadWindows(dwThreadId, callback->GetOS2Callback(), (LPARAM)callback); 262 315 if(callback) … … 271 324 //// WriteLog("USER32: OffsetRect\n"); 272 325 #endif 273 //CB: inc values274 326 if (lprc) 275 327 { … … 295 347 //****************************************************************************** 296 348 //****************************************************************************** 297 HWND WIN32API SetFocus( HWND arg1) 298 { 349 HWND WIN32API SetFocus( HWND hwnd) 350 { 351 HWND lastFocus; 352 299 353 dprintf(("USER32: SetFocus\n")); 300 //return OSLibWinSetFocus(HWND_DESKTOP,arg1); 301 return O32_SetFocus(arg1); 302 } 303 //****************************************************************************** 304 //****************************************************************************** 305 BOOL WIN32API InvalidateRect(HWND arg1, const RECT *arg2, BOOL arg3) 306 { 307 #ifdef DEBUG 308 if(arg2) 309 WriteLog("USER32: InvalidateRect for window %X (%d,%d)(%d,%d) %d\n", arg1, arg2->left, arg2->top, arg2->right, arg2->bottom, arg3); 310 else WriteLog("USER32: InvalidateRect for window %X NULL, %d\n", arg1, arg3); 311 #endif 312 //return OSLibWinInvalidateRect(arg1,arg2,arg3); 313 return O32_InvalidateRect(arg1, arg2, arg3); 314 } 315 //****************************************************************************** 316 //****************************************************************************** 317 BOOL WIN32API GetUpdateRect( HWND arg1, PRECT arg2, BOOL arg3) 318 { 354 355 lastFocus = GetFocus(); 356 hwnd = Win32ToOS2Handle(hwnd); 357 return (OSLibWinSetFocus(OSLIB_HWND_DESKTOP,hwnd)) ? lastFocus:0; 358 } 359 //****************************************************************************** 360 //****************************************************************************** 361 BOOL WIN32API InvalidateRect(HWND hWnd, const RECT *lpRect, BOOL bErase) 362 { 363 #ifdef DEBUG 364 if(lpRect) 365 WriteLog("USER32: InvalidateRect for window %X (%d,%d)(%d,%d) %d\n", hWnd, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, bErase); 366 else WriteLog("USER32: InvalidateRect for window %X NULL, %d\n", hWnd, bErase); 367 #endif 368 369 //CB: bErase no quite the same 370 hWnd = Win32ToOS2Handle(hWnd); 371 if (lpRect) 372 { 373 OSRECTL rect; 374 ULONG windowH; 375 376 windowH = OSLibGetWindowHeight(hWnd); 377 Win32ToOS2Rect(&rect,(PRECT)lpRect,windowH); 378 return OSLibWinInvalidateRect(hWnd,&rect,bErase); //rect == RECTL 379 } else return OSLibWinInvalidateRect(hWnd,NULL,bErase); 380 } 381 //****************************************************************************** 382 //****************************************************************************** 383 BOOL WIN32API GetUpdateRect( HWND hWnd, PRECT lpRect, BOOL bErase) 384 { 385 OSRECTL rect; 386 ULONG windowH; 387 BOOL rc; 388 319 389 #ifdef DEBUG 320 390 WriteLog("USER32: GetUpdateRect\n"); 321 391 #endif 322 // OSLibWinQueryUpdateRect(arg1,arg2); 323 // translate top,bottom 324 return O32_GetUpdateRect(arg1, arg2, arg3); 325 } 326 //****************************************************************************** 327 //****************************************************************************** 328 //****************************************************************************** 329 //****************************************************************************** 330 int WIN32API GetSystemMetrics(int arg1) 331 { 332 int rc; 333 334 switch(arg1) { 392 if (!lpRect) return FALSE; 393 hWnd = Win32ToOS2Handle(hWnd); 394 rc = OSLibWinQueryUpdateRect(hWnd,&rect); 395 windowH = OSLibGetWindowHeight(hWnd); 396 OS2ToWin32Rect(lpRect,&rect,windowH); 397 return rc; 398 } 399 //****************************************************************************** 400 //****************************************************************************** 401 int WIN32API GetSystemMetrics(int nIndex) 402 { 403 int rc = 0; 404 405 switch(nIndex) { 335 406 case SM_CXICONSPACING: //TODO: size of grid cell for large icons 336 //rc = OSLibWinQuerySysValue(HWND_DESKTOP,SV_CXICON);337 //CB: better: return standard windows icon size338 rc = 32;407 rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CXICON); 408 //CB: return standard windows icon size? 409 //rc = 32; 339 410 break; 340 411 case SM_CYICONSPACING: 412 rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CYICON); 341 413 //read SM_CXICONSPACING comment 342 rc = 32;414 //rc = 32; 343 415 break; 344 416 case SM_PENWINDOWS: … … 355 427 break; 356 428 case SM_CXMINSPACING: //can be SM_CXMINIMIZED or larger 429 //CB: replace with const 357 430 rc = O32_GetSystemMetrics(SM_CXMINIMIZED); 358 431 break; 359 432 case SM_CYMINSPACING: 433 //CB: replace with const 360 434 rc = GetSystemMetrics(SM_CYMINIMIZED); 361 435 break; … … 390 464 case SM_CXMAXTRACK: //max window size 391 465 case SM_CXMAXIMIZED: //max toplevel window size 392 rc = O 32_GetSystemMetrics(SM_CXSCREEN);466 rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CXSCREEN); 393 467 break; 394 468 case SM_CYMAXTRACK: 395 469 case SM_CYMAXIMIZED: 396 rc = O 32_GetSystemMetrics(SM_CYSCREEN);470 rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CYSCREEN); 397 471 break; 398 472 case SM_NETWORK: … … 415 489 break; 416 490 case SM_CYMENUCHECK: 417 rc = O 32_GetSystemMetrics(SM_CYMENU);491 rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CYMENU); 418 492 break; 419 493 case SM_SLOWMACHINE: … … 424 498 break; 425 499 case SM_CMETRICS: 500 //CB: replace with const 426 501 rc = O32_GetSystemMetrics(44); //Open32 changed this one 427 502 break; 428 503 default: 429 rc = O32_GetSystemMetrics(arg1); 504 //better than nothing 505 rc = O32_GetSystemMetrics(nIndex); 430 506 break; 431 507 } 432 508 #ifdef DEBUG 433 WriteLog("USER32: GetSystemMetrics %d returned %d\n", arg1, rc);509 WriteLog("USER32: GetSystemMetrics %d returned %d\n", nIndex, rc); 434 510 #endif 435 511 return(rc); … … 437 513 //****************************************************************************** 438 514 //****************************************************************************** 439 UINT WIN32API SetTimer( HWND arg1, UINT arg2, UINT arg3, TIMERPROC arg4)515 UINT WIN32API SetTimer( HWND hwnd, UINT idTimer, UINT uTimeout, TIMERPROC tmprc) 440 516 { 441 517 #ifdef DEBUG 442 518 WriteLog("USER32: SetTimer INCORRECT CALLING CONVENTION FOR HANDLER!!!!!\n"); 443 519 #endif 520 hwnd = Win32ToOS2Handle(hwnd); 444 521 //SvL: Write callback handler class for this one 445 return O32_SetTimer(arg1, arg2, arg3, (TIMERPROC_O32)arg4); 446 } 447 //****************************************************************************** 448 //****************************************************************************** 449 BOOL WIN32API KillTimer(HWND arg1, UINT arg2) 522 //CB: replace 523 return O32_SetTimer(hwnd,idTimer,uTimeout,(TIMERPROC_O32)tmprc); 524 } 525 //****************************************************************************** 526 //****************************************************************************** 527 BOOL WIN32API KillTimer(HWND hWnd, UINT uIDEvent) 450 528 { 451 529 #ifdef DEBUG 452 530 WriteLog("USER32: KillTimer\n"); 453 531 #endif 532 hWnd = Win32ToOS2Handle(hWnd); 454 533 //WinStopTimer 455 return O32_KillTimer(arg1, arg2); 456 } 457 //****************************************************************************** 458 //****************************************************************************** 459 BOOL WIN32API InflateRect( PRECT arg1, int arg2, int arg3) 534 //CB: replace 535 return O32_KillTimer(hWnd,uIDEvent); 536 } 537 //****************************************************************************** 538 //****************************************************************************** 539 BOOL WIN32API InflateRect( PRECT lprc, int dx, int dy) 460 540 { 461 541 #ifdef DEBUG 462 542 WriteLog("USER32: InflateRect\n"); 463 543 #endif 464 //don't know how Win32 handles this 465 return O32_InflateRect(arg1, arg2, arg3); 544 if (!lprc) return FALSE; 545 //right? 546 lprc->left -= dx; 547 lprc->right += dx; 548 lprc->top -= dy; 549 lprc->bottom += dy; 550 551 return TRUE; 466 552 } 467 553 //****************************************************************************** … … 486 572 WriteLog("USER32: ShowCursor\n"); 487 573 #endif 488 //WinShowCursor( HWND_DESKTOP,arg1); //not the same574 //WinShowCursor(OSLIB_HWND_DESKTOP,arg1); //CB: not the same 489 575 return O32_ShowCursor(arg1); 490 576 } … … 497 583 #endif 498 584 585 if (!lprc) return FALSE; 499 586 lprc->left = nLeft; 500 587 lprc->top = nTop; … … 506 593 //****************************************************************************** 507 594 //****************************************************************************** 508 BOOL WIN32API WinHelpA( HWND arg1, LPCSTR arg2, UINT arg3, DWORD arg4) 509 { 510 #ifdef DEBUG 511 WriteLog("USER32: WinHelp not implemented %s\n", arg2); 512 #endif 595 BOOL WIN32API WinHelpA( HWND hwnd, LPCSTR lpszHelp, UINT uCommand, DWORD dwData) 596 { 597 #ifdef DEBUG 598 WriteLog("USER32: WinHelp not implemented %s\n", lpszHelp); 599 #endif 600 // hwnd = Win32ToOS2Handle(hwnd); 513 601 // return O32_WinHelp(arg1, arg2, arg3, arg4); 602 514 603 return(TRUE); 515 604 } 516 605 //****************************************************************************** 517 606 //****************************************************************************** 518 int WIN32API TranslateAcceleratorA(HWND arg1, HACCEL arg2, LPMSG arg3)607 int WIN32API TranslateAcceleratorA(HWND hwnd, HACCEL haccel, LPMSG lpmsg) 519 608 { 520 609 #ifdef DEBUG 521 610 //// WriteLog("USER32: TranslateAccelerator\n"); 522 611 #endif 612 //CB: needs more work 523 613 //WinTranslateAccel(); 524 614 //get hab, translate 525 return O32_TranslateAccelerator(arg1, arg2, arg3); 526 } 527 //****************************************************************************** 528 //****************************************************************************** 529 BOOL WIN32API SubtractRect( PRECT arg1, const RECT * arg2, const RECT * arg3) 615 hwnd = Win32ToOS2Handle(hwnd); 616 return O32_TranslateAccelerator(hwnd,haccel,lpmsg); 617 } 618 //****************************************************************************** 619 //****************************************************************************** 620 BOOL WIN32API SubtractRect( PRECT lprcDest, const RECT * lprcSrc1, const RECT * lprcSrc2) 530 621 { 531 622 #ifdef DEBUG 532 623 WriteLog("USER32: SubtractRect"); 533 624 #endif 534 // how?535 return O32_SubtractRect( arg1, arg2, arg3);625 //CB: how? 626 return O32_SubtractRect(lprcDest,lprcSrc1,lprcSrc2); 536 627 } 537 628 //****************************************************************************** 538 629 //SvL: 24-6-'97 - Added 539 630 //****************************************************************************** 540 BOOL WIN32API ClipCursor(const RECT * arg1)631 BOOL WIN32API ClipCursor(const RECT * lpRect) 541 632 { 542 633 #ifdef DEBUG 543 634 WriteLog("USER32: ClipCursor\n"); 544 635 #endif 545 return O32_ClipCursor(arg1); 636 //CB: how to replace? 637 return O32_ClipCursor(lpRect); 546 638 } 547 639 //****************************************************************************** … … 569 661 //SvL: 24-6-'97 - Added 570 662 //****************************************************************************** 571 BOOL WIN32API GetCursorPos( PPOINT arg1) 572 { 663 BOOL WIN32API GetCursorPos( PPOINT lpPoint) 664 { 665 BOOL rc; 666 POINT point; 573 667 #ifdef DEBUG 574 668 //// WriteLog("USER32: GetCursorPos\n"); 575 669 #endif 576 return O32_GetCursorPos(arg1); 670 if (!lpPoint) return FALSE; 671 if (OSLibWinQueryPointerPos(OSLIB_HWND_DESKTOP,&point)) //POINT == POINTL 672 { 673 OS2ToWin32ScreenPos(lpPoint,&point); 674 return TRUE; 675 } else return FALSE; 577 676 } 578 677 //****************************************************************************** 579 678 //SvL: 24-6-'97 - Added 580 679 //****************************************************************************** 581 WORD WIN32API VkKeyScanA( char arg1)680 WORD WIN32API VkKeyScanA( char ch) 582 681 { 583 682 #ifdef DEBUG 584 683 WriteLog("USER32: VkKeyScanA\n"); 585 684 #endif 586 return O32_VkKeyScan( arg1);685 return O32_VkKeyScan(ch); 587 686 } 588 687 //****************************************************************************** 589 688 //SvL: 24-6-'97 - Added 590 689 //****************************************************************************** 591 SHORT WIN32API GetKeyState( int arg1)592 { 593 #ifdef DEBUG 594 WriteLog("USER32: GetKeyState %d\n", arg1);595 #endif 596 return O32_GetKeyState( arg1);597 } 598 //****************************************************************************** 599 //****************************************************************************** 600 HCURSOR WIN32API SetCursor( HCURSOR arg1)690 SHORT WIN32API GetKeyState( int nVirtKey) 691 { 692 #ifdef DEBUG 693 WriteLog("USER32: GetKeyState %d\n", nVirtKey); 694 #endif 695 return O32_GetKeyState(nVirtKey); 696 } 697 //****************************************************************************** 698 //****************************************************************************** 699 HCURSOR WIN32API SetCursor( HCURSOR hcur) 601 700 { 602 701 #ifdef DEBUG 603 702 WriteLog("USER32: SetCursor\n"); 604 703 #endif 605 return O32_SetCursor( arg1);704 return O32_SetCursor(hcur); 606 705 } 607 706 //****************************************************************************** … … 612 711 WriteLog("USER32: SetCursorPos\n"); 613 712 #endif 713 //CB:{a} stopped here 614 714 return O32_SetCursorPos(arg1, arg2); 615 715 } … … 621 721 WriteLog("USER32: EnableScrollBar\n"); 622 722 #endif 723 //CB: implement in window class 623 724 return O32_EnableScrollBar(arg1, arg2, arg3); 624 725 }
Note:
See TracChangeset
for help on using the changeset viewer.