Ignore:
Timestamp:
Jul 18, 1999, 3:57:48 PM (26 years ago)
Author:
cbratschi
Message:

API Open32 -> PM

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 sandervl Exp $ */
     1/* $Id: user32.cpp,v 1.6 1999-07-18 13:57:47 cbratschi Exp $ */
    22
    33/*
     
    1919 *****************************************************************************/
    2020
     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
    2128#include <os2win.h>
    2229#include "misc.h"
     
    3138#include <string.h>
    3239#include <oslibwin.h>
     40#include <win32wnd.h>
    3341
    3442//undocumented stuff
     
    6977// WIN32API YieldTask
    7078
    71 
    72 
     79//Window handle transformation
     80
     81inline 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
     90inline 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
     101inline 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
     109inline 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
     117inline 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
     123inline void Win32ToOS2ScreenPos(POINT *dest,POINT *source)
     124{
     125  OS2ToWin32ScreenPos(dest,source); //transform back
     126}
    73127
    74128//******************************************************************************
     
    185239//******************************************************************************
    186240//******************************************************************************
    187 BOOL WIN32API MessageBeep( UINT arg1)
     241BOOL WIN32API MessageBeep( UINT uType)
    188242{
    189243    INT flStyle;
     
    193247#endif
    194248
    195     switch (arg1)
     249    switch (uType)
    196250    {
    197251      case 0xFFFFFFFF:
     
    199253        return TRUE;
    200254      case MB_ICONASTERISK:
    201         flStyle = WA_NOTE;
     255        flStyle = WAOS_NOTE;
    202256        break;
    203257      case MB_ICONEXCLAMATION:
    204         flStyle = WA_WARNING;
     258        flStyle = WAOS_WARNING;
    205259        break;
    206260      case MB_ICONHAND:
    207261      case MB_ICONQUESTION:
    208262      case MB_OK:
    209         flStyle = WA_NOTE;
     263        flStyle = WAOS_NOTE;
    210264        break;
    211265      default:
    212         flStyle = WA_ERROR; //CB: should be right
     266        flStyle = WAOS_ERROR; //CB: should be right
    213267        break;
    214268    }
    215     return OSLibWinAlarm(HWND_DESKTOP,flStyle);
    216 }
     269    return OSLibWinAlarm(OSLIB_HWND_DESKTOP,flStyle);
     270}
     271//******************************************************************************
    217272//******************************************************************************
    218273
     
    231286    return GetWindowTextW(hwnd,lpString,nMaxCount);
    232287}
    233 
    234 
    235 //******************************************************************************
    236288//******************************************************************************
    237289//******************************************************************************
    238290HWND WIN32API GetFocus(void)
    239291{
     292    HWND hwnd;
    240293//    dprintf(("USER32:  GetFocus\n"));
    241     //return OS2LibWinQueryFocus(HWND_DESKTOP);
    242     return O32_GetFocus();
     294
     295    hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
     296    return OS2ToWin32Handle(hwnd);
    243297}
    244298//******************************************************************************
     
    247301{
    248302    dprintf(("USER32:  GetDesktopWindow\n"));
    249     //return HWND_DESKTOP //CB: WinQueryDesktopWindow();, hab and hdc not available!
    250     return O32_GetDesktopWindow();
     303    return OSLIB_HWND_DESKTOP;
    251304}
    252305//******************************************************************************
     
    258311
    259312  dprintf(("USER32:  EnumThreadWindows\n"));
    260   //replace
     313  //CB: replace
    261314  rc = O32_EnumThreadWindows(dwThreadId, callback->GetOS2Callback(), (LPARAM)callback);
    262315  if(callback)
     
    271324////    WriteLog("USER32:  OffsetRect\n");
    272325#endif
    273     //CB: inc values
    274326    if (lprc)
    275327    {
     
    295347//******************************************************************************
    296348//******************************************************************************
    297 HWND WIN32API SetFocus( HWND arg1)
    298 {
     349HWND WIN32API SetFocus( HWND hwnd)
     350{
     351    HWND lastFocus;
     352
    299353    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//******************************************************************************
     361BOOL 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//******************************************************************************
     383BOOL WIN32API GetUpdateRect( HWND hWnd, PRECT lpRect, BOOL  bErase)
     384{
     385    OSRECTL rect;
     386    ULONG windowH;
     387    BOOL rc;
     388
    319389#ifdef DEBUG
    320390    WriteLog("USER32:  GetUpdateRect\n");
    321391#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//******************************************************************************
     401int WIN32API GetSystemMetrics(int nIndex)
     402{
     403   int rc = 0;
     404
     405   switch(nIndex) {
    335406    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 size
    338         rc = 32;
     407        rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CXICON);
     408        //CB: return standard windows icon size?
     409        //rc = 32;
    339410        break;
    340411    case SM_CYICONSPACING:
     412        rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CYICON);
    341413        //read SM_CXICONSPACING comment
    342         rc = 32;
     414        //rc = 32;
    343415        break;
    344416    case SM_PENWINDOWS:
     
    355427        break;
    356428    case SM_CXMINSPACING: //can be SM_CXMINIMIZED or larger
     429        //CB: replace with const
    357430        rc = O32_GetSystemMetrics(SM_CXMINIMIZED);
    358431        break;
    359432    case SM_CYMINSPACING:
     433        //CB: replace with const
    360434        rc = GetSystemMetrics(SM_CYMINIMIZED);
    361435        break;
     
    390464    case SM_CXMAXTRACK: //max window size
    391465    case SM_CXMAXIMIZED:    //max toplevel window size
    392         rc = O32_GetSystemMetrics(SM_CXSCREEN);
     466        rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CXSCREEN);
    393467        break;
    394468    case SM_CYMAXTRACK:
    395469    case SM_CYMAXIMIZED:
    396         rc = O32_GetSystemMetrics(SM_CYSCREEN);
     470        rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CYSCREEN);
    397471        break;
    398472    case SM_NETWORK:
     
    415489        break;
    416490    case SM_CYMENUCHECK:
    417         rc = O32_GetSystemMetrics(SM_CYMENU);
     491        rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CYMENU);
    418492        break;
    419493    case SM_SLOWMACHINE:
     
    424498        break;
    425499    case SM_CMETRICS:
     500        //CB: replace with const
    426501        rc = O32_GetSystemMetrics(44);  //Open32 changed this one
    427502        break;
    428503    default:
    429         rc = O32_GetSystemMetrics(arg1);
     504        //better than nothing
     505        rc = O32_GetSystemMetrics(nIndex);
    430506        break;
    431507    }
    432508#ifdef DEBUG
    433     WriteLog("USER32:  GetSystemMetrics %d returned %d\n", arg1, rc);
     509    WriteLog("USER32:  GetSystemMetrics %d returned %d\n", nIndex, rc);
    434510#endif
    435511    return(rc);
     
    437513//******************************************************************************
    438514//******************************************************************************
    439 UINT WIN32API SetTimer( HWND arg1, UINT arg2, UINT arg3, TIMERPROC  arg4)
     515UINT WIN32API SetTimer( HWND hwnd, UINT idTimer, UINT uTimeout, TIMERPROC  tmprc)
    440516{
    441517#ifdef DEBUG
    442518    WriteLog("USER32: SetTimer INCORRECT CALLING CONVENTION FOR HANDLER!!!!!\n");
    443519#endif
     520    hwnd = Win32ToOS2Handle(hwnd);
    444521    //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//******************************************************************************
     527BOOL WIN32API KillTimer(HWND hWnd, UINT uIDEvent)
    450528{
    451529#ifdef DEBUG
    452530    WriteLog("USER32:  KillTimer\n");
    453531#endif
     532    hWnd = Win32ToOS2Handle(hWnd);
    454533    //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//******************************************************************************
     539BOOL WIN32API InflateRect( PRECT lprc, int dx, int  dy)
    460540{
    461541#ifdef DEBUG
    462542    WriteLog("USER32:  InflateRect\n");
    463543#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;
    466552}
    467553//******************************************************************************
     
    486572    WriteLog("USER32:  ShowCursor\n");
    487573#endif
    488     //WinShowCursor(HWND_DESKTOP,arg1); //not the same
     574    //WinShowCursor(OSLIB_HWND_DESKTOP,arg1); //CB: not the same
    489575    return O32_ShowCursor(arg1);
    490576}
     
    497583#endif
    498584
     585    if (!lprc) return FALSE;
    499586    lprc->left   = nLeft;
    500587    lprc->top    = nTop;
     
    506593//******************************************************************************
    507594//******************************************************************************
    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
     595BOOL 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);
    513601//    return O32_WinHelp(arg1, arg2, arg3, arg4);
     602
    514603    return(TRUE);
    515604}
    516605//******************************************************************************
    517606//******************************************************************************
    518 int WIN32API TranslateAcceleratorA(HWND arg1, HACCEL arg2, LPMSG  arg3)
     607int WIN32API TranslateAcceleratorA(HWND hwnd, HACCEL haccel, LPMSG  lpmsg)
    519608{
    520609#ifdef DEBUG
    521610////    WriteLog("USER32:  TranslateAccelerator\n");
    522611#endif
     612    //CB: needs more work
    523613    //WinTranslateAccel();
    524614    //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//******************************************************************************
     620BOOL WIN32API SubtractRect( PRECT lprcDest, const RECT * lprcSrc1, const RECT * lprcSrc2)
    530621{
    531622#ifdef DEBUG
    532623    WriteLog("USER32:  SubtractRect");
    533624#endif
    534     // how?
    535     return O32_SubtractRect(arg1, arg2, arg3);
     625    //CB: how?
     626    return O32_SubtractRect(lprcDest,lprcSrc1,lprcSrc2);
    536627}
    537628//******************************************************************************
    538629//SvL: 24-6-'97 - Added
    539630//******************************************************************************
    540 BOOL WIN32API ClipCursor(const RECT * arg1)
     631BOOL WIN32API ClipCursor(const RECT * lpRect)
    541632{
    542633#ifdef DEBUG
    543634    WriteLog("USER32:  ClipCursor\n");
    544635#endif
    545     return O32_ClipCursor(arg1);
     636    //CB: how to replace?
     637    return O32_ClipCursor(lpRect);
    546638}
    547639//******************************************************************************
     
    569661//SvL: 24-6-'97 - Added
    570662//******************************************************************************
    571 BOOL WIN32API GetCursorPos( PPOINT arg1)
    572 {
     663BOOL WIN32API GetCursorPos( PPOINT lpPoint)
     664{
     665    BOOL rc;
     666    POINT point;
    573667#ifdef DEBUG
    574668////    WriteLog("USER32:  GetCursorPos\n");
    575669#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;
    577676}
    578677//******************************************************************************
    579678//SvL: 24-6-'97 - Added
    580679//******************************************************************************
    581 WORD WIN32API VkKeyScanA( char arg1)
     680WORD WIN32API VkKeyScanA( char ch)
    582681{
    583682#ifdef DEBUG
    584683    WriteLog("USER32:  VkKeyScanA\n");
    585684#endif
    586     return O32_VkKeyScan(arg1);
     685    return O32_VkKeyScan(ch);
    587686}
    588687//******************************************************************************
    589688//SvL: 24-6-'97 - Added
    590689//******************************************************************************
    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)
     690SHORT 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//******************************************************************************
     699HCURSOR WIN32API SetCursor( HCURSOR hcur)
    601700{
    602701#ifdef DEBUG
    603702    WriteLog("USER32:  SetCursor\n");
    604703#endif
    605     return O32_SetCursor(arg1);
     704    return O32_SetCursor(hcur);
    606705}
    607706//******************************************************************************
     
    612711    WriteLog("USER32:  SetCursorPos\n");
    613712#endif
     713//CB:{a} stopped here
    614714    return O32_SetCursorPos(arg1, arg2);
    615715}
     
    621721    WriteLog("USER32:  EnableScrollBar\n");
    622722#endif
     723    //CB: implement in window class
    623724    return O32_EnableScrollBar(arg1, arg2, arg3);
    624725}
Note: See TracChangeset for help on using the changeset viewer.