Ignore:
Timestamp:
Jun 7, 2000, 4:51:33 PM (25 years ago)
Author:
sandervl
Message:

Major rewrite: frame/client -> frame

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/window.cpp

    r3513 r3662  
    1 /* $Id: window.cpp,v 1.67 2000-05-10 13:14:44 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.68 2000-06-07 14:51:33 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    77 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
    88 *
    9  * Parts based on Wine Windows code (windows\win.c, windows\property.c)
     9 * Parts based on Wine Windows code (windows\win.c, windows\property.c, windows\winpos.c)
    1010 *
    11  * Copyright 1993, 1994 Alexandre Julliard
     11 * Copyright 1993, 1994, 1995 Alexandre Julliard
     12 *           1995, 1996, 1999 Alex Korobka
    1213 *
    1314 * Project Odin Software License can be found in LICENSE.TXT
     
    445446{
    446447    return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
     448}
     449/***********************************************************************
     450 *           SetInternalWindowPos   (USER32.483)
     451 */
     452void WIN32API SetInternalWindowPos(HWND    hwnd,
     453                                   UINT    showCmd,
     454                                   LPRECT  lpRect,
     455                                   LPPOINT lpPoint )
     456{
     457    dprintf(("USER32: SetInternalWindowPos(%08xh,%08xh,%08xh,%08xh)",
     458           hwnd, showCmd, lpRect, lpPoint));
     459
     460    if( IsWindow(hwnd) )
     461    {
     462        WINDOWPLACEMENT wndpl;
     463        UINT flags;
     464
     465        GetWindowPlacement(hwnd, &wndpl);
     466        wndpl.length  = sizeof(wndpl);
     467        wndpl.showCmd = showCmd;
     468        wndpl.flags = 0;
     469
     470        if(lpPoint)
     471        {
     472            wndpl.flags |= WPF_SETMINPOSITION;
     473            wndpl.ptMinPosition = *lpPoint;
     474        }
     475        if(lpRect)
     476        {
     477            wndpl.rcNormalPosition = *lpRect;
     478        }
     479        SetWindowPlacement( hwnd, &wndpl);
     480    }
     481
     482}
     483/***********************************************************************
     484 *           GetInternalWindowPos   (USER32.245)
     485 */
     486UINT WIN32API GetInternalWindowPos(HWND    hwnd,
     487                                   LPRECT  rectWnd,
     488                                   LPPOINT ptIcon )
     489{
     490    WINDOWPLACEMENT wndpl;
     491
     492    dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
     493             hwnd,
     494             rectWnd,
     495             ptIcon));
     496
     497    if(GetWindowPlacement( hwnd, &wndpl ))
     498    {
     499        if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
     500        if (ptIcon)  *ptIcon = wndpl.ptMinPosition;
     501        return wndpl.showCmd;
     502    }
     503    return 0;
    447504}
    448505//******************************************************************************
     
    519576        dprintf(("SetWindowPlacement, window %x not found", hwnd));
    520577        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    521         return 0;
    522     }
     578        return FALSE;
     579    }
     580    if(!winpos) {
     581        dprintf(("SetWindowPlacement %x invalid parameter", hwnd));
     582        SetLastError(ERROR_INVALID_PARAMETER);
     583        return FALSE;
     584    }
     585    dprintf(("USER32: SetWindowPlacement %x %x", hwnd, winpos));
    523586    return window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
    524587}
    525588//******************************************************************************
    526589//******************************************************************************
    527 BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT arg2)
    528 {
    529     dprintf(("USER32:  GetWindowPlacement\n"));
    530     return O32_GetWindowPlacement(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd), arg2);
     590BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT winpos)
     591{
     592  Win32BaseWindow *window;
     593
     594    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     595    if(!window) {
     596        dprintf(("GetWindowPlacement, window %x not found", hwnd));
     597        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     598        return FALSE;
     599    }
     600    if(!winpos) {
     601        dprintf(("GetWindowPlacement %x invalid parameter", hwnd));
     602        SetLastError(ERROR_INVALID_PARAMETER);
     603        return FALSE;
     604    }
     605    dprintf(("USER32: GetWindowPlacement %x %x", hwnd, winpos));
     606    return window->GetWindowPlacement(winpos);
    531607}
    532608//******************************************************************************
     
    609685//******************************************************************************
    610686//******************************************************************************
    611 /***********************************************************************
    612  *           GetInternalWindowPos   (USER32.245)
    613  */
    614 UINT WIN32API GetInternalWindowPos(HWND    hwnd,
    615                                    LPRECT  rectWnd,
    616                                    LPPOINT ptIcon )
    617 {
    618     WINDOWPLACEMENT wndpl;
    619 
    620     dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
    621              hwnd,
    622              rectWnd,
    623              ptIcon));
    624 
    625     if (GetWindowPlacement( hwnd, &wndpl ))
    626     {
    627         if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
    628         if (ptIcon)  *ptIcon = wndpl.ptMinPosition;
    629         return wndpl.showCmd;
    630     }
    631     return 0;
    632 }
    633 //******************************************************************************
    634 //******************************************************************************
    635687BOOL WIN32API IsZoomed(HWND hwnd)
    636688{
    637689    dprintf(("USER32:  IsZoomed\n"));
    638     return O32_IsZoomed(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
     690    return O32_IsZoomed(Win32BaseWindow::Win32ToOS2Handle(hwnd));
    639691}
    640692//******************************************************************************
     
    643695{
    644696    dprintf(("USER32:  LockWindowUpdate\n"));
    645     return O32_LockWindowUpdate(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
     697    return O32_LockWindowUpdate(Win32BaseWindow::Win32ToOS2Handle(hwnd));
    646698}
    647699//******************************************************************************
     
    665717        return FALSE;
    666718    }
    667     *pRect = *window->getWindowRect(); //always in screen coordinates
     719    *pRect = *window->getWindowRect();
     720
     721    //convert from parent coordinates to screen (if necessary)
     722    if(window->getParent()) {
     723         MapWindowPoints(window->getParent()->getWindowHandle(), 0, (PPOINT)pRect, 2);
     724    }
    668725
    669726    dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
     
    862919/* Coordinate Space and Transformation Functions */
    863920//******************************************************************************
     921/*******************************************************************
     922 *         WINPOS_GetWinOffset
     923 *
     924 * Calculate the offset between the origin of the two windows. Used
     925 * to implement MapWindowPoints.
     926 */
     927static void WINPOS_GetWinOffset( Win32BaseWindow *wndFrom, Win32BaseWindow *wndTo,
     928                                 POINT *offset )
     929{
     930 Win32BaseWindow *window;
     931
     932    offset->x = offset->y = 0;
     933
     934    /* Translate source window origin to screen coords */
     935    if(wndFrom != windowDesktop)
     936    {
     937        window = wndFrom;
     938        while(window)
     939        {
     940            offset->x += window->getClientRectPtr()->left + window->getWindowRect()->left;
     941            offset->y += window->getClientRectPtr()->top + window->getWindowRect()->top;
     942            window = window->getParent();
     943        }
     944    }
     945
     946    /* Translate origin to destination window coords */
     947    if(wndTo != windowDesktop)
     948    {
     949        window = wndTo;
     950        while(window)
     951        {
     952            offset->x -= window->getClientRectPtr()->left + window->getWindowRect()->left;
     953            offset->y -= window->getClientRectPtr()->top + window->getWindowRect()->top;
     954            window = window->getParent();
     955        }
     956    }
     957}
     958//******************************************************************************
     959//******************************************************************************
    864960int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
    865961                             UINT cPoints)
     
    867963 Win32BaseWindow *wndfrom, *wndto;
    868964 int retval = 0;
    869  OSLIBPOINT point;
     965 POINT offset;
    870966
    871967    SetLastError(0);
     
    899995        return 0; //nothing to do
    900996
    901     dprintf(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
    902     point.x = lpPoints->x;
    903     point.y = lpPoints->y;
    904     if (!mapWin32Point(wndfrom,wndto,&point))
    905     {
    906         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    907         return 0;
    908     }
    909 
    910     short int xinc = point.x - lpPoints->x;
    911     short int yinc = point.y - lpPoints->y;
     997    dprintf2(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
     998    WINPOS_GetWinOffset(wndfrom, wndto, &offset);
    912999
    9131000    for(int i=0;i<cPoints;i++)
    9141001    {
    915         lpPoints[i].x += xinc;
    916         lpPoints[i].y += yinc;
    917     }
    918     retval = ((LONG)yinc << 16) | xinc;
     1002        lpPoints[i].x += offset.x;
     1003        lpPoints[i].y += offset.y;
     1004    }
     1005    retval = ((LONG)offset.y << 16) | offset.x;
    9191006    return retval;
    9201007}
     
    9271014    BOOL rc;
    9281015
    929     if (!hwnd) return (TRUE);
     1016    if(!hwnd) {
     1017        return (TRUE);
     1018    }
    9301019    wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    9311020    if (!wnd) {
     
    9381027    POINT tmp = *pt;
    9391028#endif
    940     rc = mapWin32Point(OSLIB_HWND_DESKTOP, wnd->getOS2WindowHandle(), (OSLIBPOINT*)pt);
    941     dprintf(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
    942     return rc;
     1029    MapWindowPoints(0, hwnd, pt, 1);
     1030    dprintf2(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
     1031    return TRUE;
    9431032}
    9441033//******************************************************************************
     
    10491138    Win32BaseWindow *wnd;
    10501139    PRECT rcl;
    1051     BOOL rc;
    10521140
    10531141    if (!hwnd) {
     
    10641152    POINT tmp = *pt;
    10651153#endif
    1066     rc = mapWin32Point(wnd->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,(OSLIBPOINT*)pt);
    1067     dprintf(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
    1068 
    1069     return rc;
     1154    MapWindowPoints(hwnd, 0, pt, 1);
     1155    dprintf2(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
     1156
     1157    return TRUE;
    10701158}
    10711159//******************************************************************************
     
    13971485{
    13981486    dprintf(("USER32:  ArrangeIconicWindows %x", hwnd));
    1399     return O32_ArrangeIconicWindows(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
     1487    return O32_ArrangeIconicWindows(Win32BaseWindow::Win32ToOS2Handle(hwnd));
    14001488}
    14011489//******************************************************************************
     
    14161504{
    14171505    dprintf(("USER32:  ShowOwnedPopups (OPEN32: todo) %x", hwnd));
    1418     return O32_ShowOwnedPopups(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd), arg2);
     1506    return O32_ShowOwnedPopups(Win32BaseWindow::Win32ToOS2Handle(hwnd), arg2);
    14191507}
    14201508//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.