Ignore:
Timestamp:
Jul 19, 1999, 8:40:44 PM (26 years ago)
Author:
sandervl
Message:

Point/Rectangle bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/oslibgdi.cpp

    r328 r340  
    1 /* $Id: oslibgdi.cpp,v 1.2 1999-07-18 14:39:35 sandervl Exp $ */
     1/* $Id: oslibgdi.cpp,v 1.3 1999-07-19 18:40:43 sandervl Exp $ */
    22/*
    33 * Window GDI wrapper functions for OS/2
     
    1919#include <misc.h>
    2020#include <oslibgdi.h>
     21#include <oslibwin.h>
    2122
    22 //******************************************************************************
    23 //******************************************************************************
    24 inline PRECTL Win32ToOS2Rect(PVOID pRectl)
    25 {
    26  PRECTL pWinRect = (PRECTL)pRectl;
    27  ULONG  tmp;
    28 
    29   tmp = pWinRect->yBottom;
    30   pWinRect->yBottom = pWinRect->yTop;
    31   pWinRect->yTop = tmp;
    32   return pWinRect;
    33 }
    34 //******************************************************************************
    35 //******************************************************************************
    36 inline ULONG MAPWIN32POINT(RECTLOS2 *parent, RECTLOS2 *child, ULONG y)
    37 {
    38   return (parent->yTop - parent->yBottom - (child->yTop - child->yBottom) - y - 1);
    39 }
    4023//******************************************************************************
    4124//******************************************************************************
    4225inline ULONG MAPWIN32POINT(RECTLOS2 *parent, ULONG cy, ULONG y)
    4326{
    44   return (parent->yTop - parent->yBottom - cy - y - 1);
     27    return (parent->yTop - parent->yBottom - cy - y);
     28}
     29//******************************************************************************
     30//Map win32 y coordinate (in parent window coordinates) to OS/2 y coord. (in parent window coordinates)
     31//******************************************************************************
     32ULONG MapOS2ToWin32Y(HWND hwndParent, ULONG cy, ULONG y)
     33{
     34 RECTLOS2 rectParent = {0};
     35
     36    if(hwndParent == OSLIB_HWND_DESKTOP) {
     37        hwndParent = HWND_DESKTOP;
     38    }
     39    WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
     40    return MAPWIN32POINT(&rectParent, cy, y);
    4541}
    4642//******************************************************************************
    4743//******************************************************************************
    48 ULONG MapOS2ToWin32Y(HWND hwndChild)
     44BOOL MapOS2ToWin32Point(HWND hwndParent, HWND hwndChild, OSLIBPOINT *point)
    4945{
    50  HWND     hwndParent;
    51  RECTLOS2 rectParent = {0}, rectChild = {0};
    52 
    53    WinQueryWindowRect(hwndChild, (PRECTL)&rectChild);
    54    hwndParent = WinQueryWindow(hwndChild, QW_PARENT);
    55    WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    56    return MAPWIN32POINT(&rectParent, &rectChild, rectChild.yBottom);
    57 }
    58 //******************************************************************************
    59 //******************************************************************************
    60 ULONG MapOS2ToWin32Y(HWND hwndChild, ULONG y)
    61 {
    62  HWND     hwndParent;
    63  RECTLOS2 rectParent = {0}, rectChild = {0};
    64 
    65    WinQueryWindowRect(hwndChild, (PRECTL)&rectChild);
    66    hwndParent = WinQueryWindow(hwndChild, QW_PARENT);
    67    WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    68    return MAPWIN32POINT(&rectParent, &rectChild, y);
    69 }
    70 //******************************************************************************
    71 //******************************************************************************
    72 ULONG MapOS2ToWin32Y(HWND hwndChild, ULONG cy, ULONG y)
    73 {
    74  HWND     hwndParent;
    7546 RECTLOS2 rectParent = {0};
    7647
    77    hwndParent = WinQueryWindow(hwndChild, QW_PARENT);
    78    WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    79    return MAPWIN32POINT(&rectParent, cy, y);
    80 }
    81 //******************************************************************************
    82 //******************************************************************************
    83 ULONG MapOS2ToWin32Y(PRECTLOS2 rectParent, PRECTLOS2 rectChild, ULONG y)
    84 {
    85    return MAPWIN32POINT(rectParent, rectChild, y);
    86 }
    87 //******************************************************************************
    88 //******************************************************************************
    89 ULONG MapOS2ToWin32Y(PRECTLOS2 rectParent, HWND hwndChild, ULONG y)
    90 {
    91  RECTLOS2 rectChild = {0};
    92 
    93    WinQueryWindowRect(hwndChild, (PRECTL)&rectChild);
    94    return MAPWIN32POINT(rectParent, &rectChild, y);
    95 }
    96 //******************************************************************************
    97 //******************************************************************************
    98 ULONG MapOS2ToWin32Y(HWND hwndChild, PRECTLOS2 rectChild, ULONG y)
    99 {
    100  HWND     hwndParent;
    101  RECTLOS2 rectParent = {0};
    102 
    103    hwndParent = WinQueryWindow(hwndChild, QW_PARENT);
    104    WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    105    return MAPWIN32POINT(&rectParent, rectChild, y);
     48    if(hwndParent == OSLIB_HWND_DESKTOP) {
     49        hwndParent = HWND_DESKTOP;
     50    }
     51    if(WinMapWindowPoints(hwndChild, hwndParent, (POINTL *)point, 1) != 0) {
     52        dprintf(("MapOS2ToWin32Point:WinMapWindowPoint %x %x returned false", hwndParent, hwndChild));
     53        return FALSE;
     54    }
     55    WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
     56    point->y = rectParent.yTop - point->y;
     57    return TRUE;
    10658}
    10759//******************************************************************************
     
    11062//
    11163// Parameters:
    112 //   hwndChild: Child window handle
    113 //   rectChild: OS/2 child window RECTL
     64//   rectOS2:    OS/2 child window RECTL
     65//   rectWin32:  Win32 Child window RECT   (IN)
    11466//
    11567// Returns:
    116 //   rectChild: Converted OS/2 rectange stored in Win32 RECTL (yTop & yBottom reversed)
    11768//   TRUE:      Success
    11869//   FALSE:     Failures
    11970//******************************************************************************
    120 BOOL MapOS2ToWin32Rectl(HWND hwndChild, PRECTLOS2 rectChild, PRECT rectWin32)
     71BOOL MapOS2ToWin32Rectl(PRECTLOS2 rectOS2, PRECT rectWin32)
    12172{
    122  HWND     hwndParent;
    123  RECTLOS2 rectParent = {0};
     73 ULONG length = rectOS2->yTop - rectOS2->yBottom;
    12474
    125    hwndParent = WinQueryWindow(hwndChild, QW_PARENT);
    126    WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    127 
    128    rectWin32->yTop    = MAPWIN32POINT(&rectParent, rectChild->yTop - rectChild->yBottom, rectChild->yBottom);
    129    rectWin32->yBottom = MAPWIN32POINT(&rectParent, rectChild->yTop - rectChild->yBottom, rectChild->yTop);
    130    rectWin32->xLeft   = rectChild->xLeft;
    131    rectWin32->xRight  = rectChild->xRight;
    132    return TRUE;
    133 }
    134 //******************************************************************************
    135 // MapOS2ToWin32Rectl
    136 //   Convert OS/2 to Win32 RECTL structure
    137 //
    138 // Parameters:
    139 //   rectParent: OS/2 Parent window RECTL
    140 //   rectChild:  OS/2 Child window RECTL
    141 //
    142 // Returns:
    143 //   rectChild:  Converted OS/2 rectange stored in Win32 RECTL (yTop & yBottom reversed)
    144 //   TRUE:       Success
    145 //   FALSE:      Failures
    146 //******************************************************************************
    147 BOOL MapOS2ToWin32Rectl(PRECTLOS2 rectParent, PRECTLOS2 rectChild, PRECT rectWin32)
    148 {
    149    rectWin32->yTop    = MAPWIN32POINT(rectParent, rectChild->yTop - rectChild->yBottom, rectChild->yBottom);
    150    rectWin32->yBottom = MAPWIN32POINT(rectParent, rectChild->yTop - rectChild->yBottom, rectChild->yTop);
    151    rectWin32->xLeft   = rectChild->xLeft;
    152    rectWin32->xRight  = rectChild->xRight;
     75   rectWin32->bottom = length - rectOS2->yBottom;
     76   rectWin32->top    = length - rectOS2->yTop;
     77   rectWin32->left   = rectOS2->xLeft;
     78   rectWin32->right  = rectOS2->xRight;
    15379   return TRUE;
    15480}
     
    15884//
    15985// Parameters:
    160 //   hwndChild:  OS/2  Child window handle (IN)
    16186//   rectWin32:  Win32 Child window RECT   (IN)
    162 //   rectChild:  OS/2  Child window RECTL  (OUT)
     87//   rectOS2:    OS/2  Child window RECTL  (OUT)
    16388// Returns:
    16489//   TRUE:       Success
    16590//   FALSE:      Failures
    16691//******************************************************************************
    167 BOOL MapWin32ToOS2Rectl(HWND hwndChild, PRECT rectWin32, PRECTLOS2 rectChild)
     92BOOL MapWin32ToOS2Rectl(PRECT rectWin32, PRECTLOS2 rectOS2)
    16893{
    169  HWND     hwndParent;
    170  RECTLOS2 rectParent = {0};
     94 ULONG length = rectWin32->top - rectWin32->bottom;
    17195
    172    hwndParent = WinQueryWindow(hwndChild, QW_PARENT);
    173    WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    174 
    175    rectChild->yTop    = MAPWIN32POINT(&rectParent, rectWin32->yBottom - rectWin32->yTop, rectWin32->yBottom);
    176    rectChild->yBottom = MAPWIN32POINT(&rectParent, rectWin32->yBottom - rectWin32->yTop, rectWin32->yTop);
    177    rectChild->xLeft   = rectWin32->xLeft;
    178    rectChild->xRight  = rectWin32->xRight;
    179    return TRUE;
    180 }
    181 //******************************************************************************
    182 // MapWin32ToOS2Rectl
    183 //   Convert Win32 to OS/2 RECTL structure
    184 //
    185 // Parameters:
    186 //   rectParent: OS/2  Parent window RECTL (IN)
    187 //   rectWin32:  Win32 Child window RECT   (IN)
    188 //   rectChild:  OS/2  Child window RECTL  (OUT)
    189 // Returns:
    190 //   TRUE:       Success
    191 //   FALSE:      Failures
    192 //******************************************************************************
    193 BOOL MapWin32ToOS2Rectl(PRECTLOS2 rectParent, PRECT rectWin32, PRECTLOS2 rectChild)
    194 {
    195    rectChild->yTop    = MAPWIN32POINT(rectParent, rectWin32->yBottom - rectWin32->yTop, rectWin32->yBottom);
    196    rectChild->yBottom = MAPWIN32POINT(rectParent, rectWin32->yBottom - rectWin32->yTop, rectWin32->yTop);
    197    rectChild->xLeft   = rectWin32->xLeft;
    198    rectChild->xRight  = rectWin32->xRight;
    199    return TRUE;
     96    rectOS2->yBottom = length - rectWin32->bottom;
     97    rectOS2->yTop    = length - rectWin32->top;
     98    rectOS2->xLeft   = rectWin32->left;
     99    rectOS2->xRight  = rectWin32->right;
     100    return TRUE;
    200101}
    201102//******************************************************************************
    202103//******************************************************************************
    203 HDC OSLibWinBeginPaint(HWND hwnd, PVOID pRectl)
     104HDC OSLibWinBeginPaint(HWND hwnd, RECT *rectWin32)
    204105{
    205  RECTLOS2 rectlOS2;
     106 RECTL rectl;
    206107
    207   MapWin32ToOS2Rectl(hwnd, (PRECT)pRectl, &rectlOS2);
    208   return WinBeginPaint(hwnd, NULLHANDLE, (PRECTL)&rectlOS2);
     108    if(WinQueryUpdateRect(hwnd, &rectl) == FALSE)
     109    {
     110        dprintf(("BeginPaint, NO update rectl"));
     111        return 0;
     112    }
     113    MapOS2ToWin32Rectl((RECTLOS2 *)&rectl, rectWin32);
     114    return WinBeginPaint(hwnd, NULLHANDLE, &rectl);
    209115}
    210116//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.