Ignore:
Timestamp:
Dec 29, 1999, 11:54:04 PM (26 years ago)
Author:
cbratschi
Message:

new mapping functions, fixed 1 pixel and window handle bugs

File:
1 edited

Legend:

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

    r2228 r2257  
    1 /* $Id: oslibgdi.cpp,v 1.6 1999-12-28 17:04:23 cbratschi Exp $ */
     1/* $Id: oslibgdi.cpp,v 1.7 1999-12-29 22:54:00 cbratschi Exp $ */
    22/*
    33 * Window GDI wrapper functions for OS/2
     
    55 *
    66 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
    7  *
     7 * Copyright 1999 Christoph Bratschi (cbratschi@datacomm.ch)
    88 *
    99 * Project Odin Software License can be found in LICENSE.TXT
     
    2121#include "win32wbase.h"
    2222
    23 //CB: new mapping infrastructure to avoid transformation bugs -> available soon
    24 
    2523/*
    26 All mapScreen/Window can be used to transform from Win32 to OS/2 and vice versa
    2724First letter is lower case to avoid conflicts with Win32 API names
     25All transformations are for screen or client windows, for frame windows use OS/2 API's
    2826
    2927Single y mapping:
    3028 mapScreenY()
    31  mapClientY()
    32  mapChildY()
     29 mapY()
     30 mapOS2ToWin32Y()
     31 mapWin32ToOS2Y()
     32 mapWin32Y()
    3333
    3434Single point mapping:
    3535 mapScreenPoint()
    36  mapClientPoint()
    37  mapChildPoint()
     36 mapPoint()
     37 mapOS2ToWin32Point()
     38 mapWin32ToOS2Point()
     39 mapWin32Point()
    3840
    3941Single rect mapping:
    40  mapScreenRect()
    41  mapClientRect()
     42 mapOS2ToWin32ScreenRect()
     43 mapWin32ToOS2ScreenRect()
     44 mapOS2ToWin32Rect()
     45 mapWin32ToOS2Rect()
     46 mapWin32Rect()
    4247
    4348Rect transformation:
    44  copyOS2Rect()
    45  copyWin32Rect()
     49 copyOS2ToWin32Rect()
     50 copyWin32ToOS2Rect()
     51
     52Child origin:
     53 mapOS2ToWin32ChildOrigin()
    4654*/
    4755
     56//******************************************************************************
     57// To translation between OS/2 <-> Win32
     58//******************************************************************************
    4859INT mapScreenY(INT screenPosY)
    4960{
    50   return WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN)-1-screenPosY;
    51 }
    52 //******************************************************************************
     61  return ScreenHeight-1-screenPosY;
     62}
     63//******************************************************************************
     64// To translation between OS/2 <-> Win32
    5365//******************************************************************************
    5466INT mapScreenY(INT screenH,INT screenPosY)
     
    5769}
    5870//******************************************************************************
    59 //******************************************************************************
    60 INT mapClientY(INT clientH,INT clientPosY)
    61 {
    62   return clientH-1-clientPosY;
    63 }
    64 //******************************************************************************
    65 //******************************************************************************
    66 INT mapClientY(HWND os2Client,INT clientPosY)
     71// To translation between OS/2 <-> Win32
     72//******************************************************************************
     73INT mapY(HWND os2Client,INT clientPosY)
    6774{
    6875  RECTL rect;
     
    7077  if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //client shouldn't be desktop
    7178  if (!WinQueryWindowRect(os2Client,&rect)) return 0;
     79
    7280  return rect.yTop-1-clientPosY;
    7381}
    7482//******************************************************************************
    75 //******************************************************************************
    76 INT mapClientY(Win32BaseWindow *win32wnd,INT clientPosY)
    77 {
    78   return win32wnd->getWindowHeight()-1-clientPosY;
    79 }
    80 //******************************************************************************
    81 //******************************************************************************
    82 INT mapChildY(INT parentH,INT childY,INT childPosY)
    83 {
    84   return parentH-1-childY-childPosY;
    85 }
    86 //******************************************************************************
    87 //******************************************************************************
    88 INT mapChildY(HWND os2Parent,INT childY,INT childPosY)
    89 {
    90   RECTL rect;
    91 
    92   if (os2Parent == OSLIB_HWND_DESKTOP) os2Parent = HWND_DESKTOP;
    93   if (!WinQueryWindowRect(os2Parent,&rect)) return 0;
    94   return rect.yTop-1-childY-childPosY;
    95 }
    96 //******************************************************************************
    97 //******************************************************************************
    98 INT mapChildY(HWND os2Parent,HWND os2Child,INT childPosY)
    99 {
    100   RECTL rect;
    101   SWP swp;
    102 
    103   if (os2Parent == OSLIB_HWND_DESKTOP) os2Parent = HWND_DESKTOP;
    104   if (!WinQueryWindowRect(os2Parent,&rect)) return 0;
    105   if (!WinQueryWindowPos(os2Child,&swp)) return 0;
    106   return rect.yTop-1-swp.y-childPosY;
    107 }
    108 //******************************************************************************
     83// To translation between OS/2 <-> Win32
     84//******************************************************************************
     85INT mapY(Win32BaseWindow *win32wnd,INT clientPosY)
     86{
     87  if (!win32wnd) return 0;
     88
     89  return win32wnd->getClientHeight()-1-clientPosY;
     90}
     91//******************************************************************************
     92//******************************************************************************
     93INT mapOS2ToWin32Y(HWND os2From,HWND os2To,INT fromPosY)
     94{
     95  POINTL pt;
     96  RECTL rect;
     97
     98  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     99  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     100  if (os2From != os2To)
     101  {
     102    pt.x = 0;
     103    pt.y = fromPosY;
     104    if (!WinMapWindowPoints(os2From,os2To,&pt,1)) return 0;
     105  } else pt.y = fromPosY;
     106  if (!WinQueryWindowRect(os2To,&rect)) return 0;
     107
     108  return rect.yTop-1-pt.y;
     109}
     110//******************************************************************************
     111//******************************************************************************
     112INT mapOS2ToWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY)
     113{
     114  POINTL pt;
     115
     116  if (!wndFrom || !wndTo) return 0;
     117  if (wndFrom != wndTo)
     118  {
     119    pt.x = 0;
     120    pt.y = fromPosY;
     121    if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),&pt,1)) return 0;
     122  } else pt.y = fromPosY;
     123
     124  return wndTo->getClientHeight()-1-pt.y;
     125}
     126//******************************************************************************
     127//******************************************************************************
     128INT mapWin32Y(HWND os2From,HWND os2To,INT fromPosY)
     129{
     130  POINTL pt;
     131  RECTL rect;
     132
     133  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     134  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     135  if (os2From == os2To) return fromPosY;
     136  if (!WinQueryWindowRect(os2From,&rect)) return 0;
     137  pt.y = rect.yTop-1-fromPosY;
     138  pt.x = 0;
     139  if (!WinMapWindowPoints(os2From,os2To,&pt,1)) return 0;
     140  if (!WinQueryWindowRect(os2To,&rect)) return 0;
     141
     142  return rect.yTop-1-pt.y;
     143}
     144//******************************************************************************
     145//******************************************************************************
     146INT mapWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY)
     147{
     148  POINTL pt;
     149
     150  if (!wndFrom || !wndTo) return 0;
     151  if (wndFrom == wndTo) return fromPosY;
     152  pt.y = wndFrom->getClientHeight()-1-fromPosY;
     153  pt.x = 0;
     154  if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),&pt,1)) return 0;
     155
     156  return wndTo->getClientHeight()-1-pt.y;
     157}
     158//******************************************************************************
     159// To translation between OS/2 <-> Win32
    109160//******************************************************************************
    110161BOOL mapScreenPoint(OSLIBPOINT *screenPt)
    111162{
    112163  if(!screenPt) return FALSE;
    113   screenPt->y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN)-1-screenPt->y;
    114   return TRUE;
    115 }
    116 //******************************************************************************
    117 //******************************************************************************
    118 INT mapScreenY(INT screenH,OSLIBPOINT *screenPt)
     164  screenPt->y = ScreenHeight-1-screenPt->y;
     165
     166  return TRUE;
     167}
     168//******************************************************************************
     169// To translation between OS/2 <-> Win32
     170//******************************************************************************
     171BOOL mapScreenPoint(INT screenH,OSLIBPOINT *screenPt)
    119172{
    120173  if (!screenPt) return FALSE;
    121174  screenPt->y = screenH-1-screenPt->y;
    122   return TRUE;
    123 }
    124 
    125 //old mapping functions
    126 
    127 //******************************************************************************
    128 //******************************************************************************
    129 inline ULONG MAPWIN32POINT(RECTLOS2 *parent, ULONG cy, ULONG y)
    130 {
    131     return (parent->yTop - parent->yBottom - cy - y);
    132 }
    133 //******************************************************************************
    134 //Map win32 y coordinate (in parent window coordinates) to OS/2 y coord. (in parent window coordinates)
    135 //******************************************************************************
    136 ULONG MapOS2ToWin32Y(HWND hwndParent, ULONG cy, ULONG y)
    137 {
    138  RECTLOS2 rectParent = {0};
    139 
    140     if(hwndParent == OSLIB_HWND_DESKTOP) {
    141         hwndParent = HWND_DESKTOP;
    142     }
    143     WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    144     return MAPWIN32POINT(&rectParent, cy, y);
    145 }
    146 //******************************************************************************
    147 //******************************************************************************
    148 BOOL MapOS2ToWin32Point(HWND hwndParent, HWND hwndChild, OSLIBPOINT *point)
    149 {
    150  RECTLOS2 rectParent = {0};
    151 
    152     if(hwndParent == OSLIB_HWND_DESKTOP) {
    153         hwndParent = HWND_DESKTOP;
    154     }
    155     if(WinMapWindowPoints(hwndChild, hwndParent, (POINTL *)point, 1) != TRUE) {
    156         dprintf(("MapOS2ToWin32Point:WinMapWindowPoint %x %x returned false", hwndParent, hwndChild));
    157         return FALSE;
    158     }
    159     WinQueryWindowRect(hwndParent, (PRECTL)&rectParent);
    160     point->y = rectParent.yTop - point->y - 1;
    161     return TRUE;
    162 }
    163 //******************************************************************************
    164 // MapOS2ToWin32Rect
    165 //   Map os/2 rectangle to screen coordinates and convert to win32 rect
    166 //
    167 // Parameters:
    168 //   hwndParent: Parent window handle
    169 //   hwndChild:  Child window handle
    170 //   rectOS2:    OS/2 child window RECTL
    171 //   rectWin32:  Win32 Child window RECT   (IN)
    172 //
    173 // Returns:
    174 //   TRUE:      Success
    175 //   FALSE:     Failures
    176 //******************************************************************************
    177 BOOL MapOS2ToWin32Rectl(HWND hwndParent, HWND hwndChild, PRECTLOS2 rectOS2, PRECT rectWin32)
    178 {
    179  RECTLOS2 rectParent = {0};
    180  Win32BaseWindow *window;
    181  LONG height;
    182 
    183     if(hwndParent == OSLIB_HWND_DESKTOP) {
    184         hwndParent = HWND_DESKTOP;
    185     }
    186     if(WinMapWindowPoints(hwndChild, hwndParent, (PPOINTL)rectOS2, 2) != TRUE) {
    187         dprintf(("MapOS2ToWin32Rect:WinMapWindowPoint %x %x returned false", hwndParent, hwndChild));
    188         return FALSE;
    189     }
    190 
    191     if(hwndParent != HWND_DESKTOP)
    192     {
    193          window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndParent);
    194          if(window == NULL)
    195                 return FALSE;
    196          height = window->getWindowHeight();
    197     }
    198     else height = OSLibQueryScreenHeight();
    199 
    200     rectWin32->bottom = height - rectOS2->yBottom;
    201     rectWin32->top    = height - rectOS2->yTop;
    202     rectWin32->left   = rectOS2->xLeft;
    203     rectWin32->right  = rectOS2->xRight;
    204 
    205     return TRUE;
    206 }
    207 //******************************************************************************
    208 // MapOS2ToWin32Rectl
    209 //   Convert OS/2 to Win32 RECTL structure
    210 //
    211 // Parameters:
    212 //   hwnd:       OS/2 window handle
    213 //   rectOS2:    OS/2 child window RECTL
    214 //   rectWin32:  Win32 Child window RECT   (IN)
    215 //
    216 // Returns:
    217 //   TRUE:      Success
    218 //   FALSE:     Failures
    219 //******************************************************************************
    220 BOOL MapOS2ToWin32Rectl(HWND hwnd,PRECTLOS2 rectOS2, PRECT rectWin32)
    221 {
    222    RECTL rect;
    223 
    224    if (!WinQueryWindowRect(hwnd,&rect)) return FALSE;
    225 
    226    rectWin32->bottom = rect.yTop-rectOS2->yBottom;
    227    rectWin32->top    = rect.yTop-rectOS2->yTop;
    228    rectWin32->left   = rectOS2->xLeft;
    229    rectWin32->right  = rectOS2->xRight;
    230 
    231    return TRUE;
    232 }
    233 //******************************************************************************
    234 // MapWin32ToOS2Rectl
    235 //   Convert Win32 to OS/2 RECTL structure
    236 //
    237 // Parameters:
    238 //   hwnd:       OS/2 window handle
    239 //   rectWin32:  Win32 Child window RECT   (IN)
    240 //   rectOS2:    OS/2  Child window RECTL  (OUT)
    241 // Returns:
    242 //   TRUE:       Success
    243 //   FALSE:      Failures
    244 //******************************************************************************
    245 BOOL MapWin32ToOS2Rectl(HWND hwnd,PRECT rectWin32, PRECTLOS2 rectOS2)
    246 {
    247     RECTL rect;
    248 
    249     if (!WinQueryWindowRect(hwnd,&rect)) return FALSE;
    250 
    251     rectOS2->yBottom = rect.yTop-rectWin32->bottom;
    252     rectOS2->yTop    = rect.yTop-rectWin32->top;
    253     rectOS2->xLeft   = rectWin32->left;
    254     rectOS2->xRight  = rectWin32->right;
    255 
    256     return TRUE;
    257 }
    258 //******************************************************************************
    259 //******************************************************************************
    260 BOOL MapOS2ToWin32WindowRect(PRECTLOS2 rectOS2,PRECT rectWin32)
    261 {
    262   rectWin32->bottom = rectOS2->yTop;
    263   rectWin32->top    = rectOS2->yBottom;
     175
     176  return TRUE;
     177}
     178//******************************************************************************
     179// To translation between OS/2 <-> Win32
     180//******************************************************************************
     181BOOL mapPoint(HWND os2Client,OSLIBPOINT *clientPt)
     182{
     183  RECTL rect;
     184
     185  if (!clientPt) return FALSE;
     186  if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //client shouldn't be desktop
     187  if (!WinQueryWindowRect(os2Client,&rect)) return 0;
     188  clientPt->y = rect.yTop-1-clientPt->y;
     189
     190  return TRUE;
     191}
     192//******************************************************************************
     193// To translation between OS/2 <-> Win32
     194//******************************************************************************
     195BOOL mapPoint(Win32BaseWindow *win32wnd,OSLIBPOINT *clientPt)
     196{
     197  if (!win32wnd || !clientPt) return FALSE;
     198  clientPt->y = win32wnd->getClientHeight()-1-clientPt->y;
     199
     200  return TRUE;
     201}
     202//******************************************************************************
     203//******************************************************************************
     204BOOL mapOS2ToWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt)
     205{
     206  RECTL rect;
     207
     208  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     209  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     210  if (os2From != os2To)
     211  {
     212    if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)fromPt,1)) return FALSE;
     213  }
     214  if (!WinQueryWindowRect(os2To,&rect)) return FALSE;
     215  fromPt->y = rect.yTop-1-fromPt->y;
     216
     217  return TRUE;
     218}
     219//******************************************************************************
     220//******************************************************************************
     221BOOL mapOS2ToWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt)
     222{
     223  if (!wndFrom || !wndTo) return 0;
     224  if (wndFrom != wndTo)
     225  {
     226    if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)fromPt,1)) return FALSE;
     227  }
     228  fromPt->y = wndTo->getClientHeight()-1-fromPt->y;
     229
     230  return TRUE;
     231}
     232//******************************************************************************
     233//******************************************************************************
     234BOOL mapWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt)
     235{
     236  RECTL rect;
     237
     238  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     239  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     240  if (os2From == os2To) return TRUE;
     241  if (!WinQueryWindowRect(os2From,&rect)) return 0;
     242  fromPt->y = rect.yTop-1-fromPt->y;
     243  if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)fromPt,1)) return 0;
     244  if (!WinQueryWindowRect(os2To,&rect)) return 0;
     245  fromPt->y = rect.yTop-1-fromPt->y;
     246
     247  return TRUE;
     248}
     249//******************************************************************************
     250//******************************************************************************
     251BOOL mapWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt)
     252{
     253  if (!wndFrom || !wndTo) return FALSE;
     254  if (wndFrom == wndTo) return TRUE;
     255  fromPt->y = wndFrom->getClientHeight()-1-fromPt->y;
     256  if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)fromPt,1)) return 0;
     257  fromPt->y = wndTo->getClientHeight()-1-fromPt->y;
     258
     259  return TRUE;
     260}
     261//******************************************************************************
     262//******************************************************************************
     263BOOL mapOS2ToWin32ScreenRect(PRECTLOS2 rectOS2,PRECT rectWin32)
     264{
     265  if (!rectOS2 || !rectWin32) return FALSE;
     266  rectWin32->bottom = ScreenHeight-rectOS2->yBottom;
     267  rectWin32->top    = ScreenHeight-rectOS2->yTop;
    264268  rectWin32->left   = rectOS2->xLeft;
    265269  rectWin32->right  = rectOS2->xRight;
     
    269273//******************************************************************************
    270274//******************************************************************************
    271 BOOL MapWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2)
    272 {
    273   rectOS2->yBottom = rectWin32->top;
    274   rectOS2->yTop    = rectWin32->bottom;
     275BOOL mapWin32ToOS2ScreenRect(PRECT rectWin32,PRECTLOS2 rectOS2)
     276{
     277  if (!rectOS2 || !rectWin32) return FALSE;
     278  rectOS2->yBottom = ScreenHeight-rectWin32->bottom;
     279  rectOS2->yTop    = ScreenHeight-rectWin32->top;
    275280  rectOS2->xLeft   = rectWin32->left;
    276281  rectOS2->xRight  = rectWin32->right;
    277282
    278283  return TRUE;
     284}
     285//******************************************************************************
     286//******************************************************************************
     287BOOL mapOS2ToWin32Rect(HWND os2Client,PRECTLOS2 rectOS2,PRECT rectWin32)
     288{
     289  RECTL rect;
     290
     291  if (!rectOS2 || !rectWin32) return FALSE;
     292  if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //shouldn't be the case
     293  if (!WinQueryWindowRect(os2Client,&rect)) return FALSE;
     294  rectWin32->bottom = rect.yTop-rectOS2->yBottom;
     295  rectWin32->top    = rect.yTop-rectOS2->yTop;
     296  rectWin32->left   = rectOS2->xLeft;
     297  rectWin32->right  = rectOS2->xRight;
     298
     299  return TRUE;
     300}
     301//******************************************************************************
     302//******************************************************************************
     303BOOL mapOS2ToWin32Rect(Win32BaseWindow *win32wnd,PRECTLOS2 rectOS2,PRECT rectWin32)
     304{
     305  INT windowH;
     306
     307  if (!win32wnd || !rectOS2 || !rectWin32) return FALSE;
     308  windowH = win32wnd->getClientHeight();
     309  rectWin32->bottom = windowH-rectOS2->yBottom;
     310  rectWin32->top    = windowH-rectOS2->yTop;
     311  rectWin32->left   = rectOS2->xLeft;
     312  rectWin32->right  = rectOS2->xRight;
     313
     314  return TRUE;
     315}
     316//******************************************************************************
     317//******************************************************************************
     318BOOL mapOS2ToWin32Rect(HWND os2From,HWND os2To,PRECTLOS2 rectOS2,PRECT rectWin32)
     319{
     320  RECTL rect,temp;
     321
     322  if (!rectOS2 || !rectWin32) return FALSE;
     323  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     324  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     325  temp = *((PRECTL)rectOS2);
     326  if (os2From != os2To)
     327  {
     328    if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)&temp,2)) return FALSE;
     329  }
     330  if (!WinQueryWindowRect(os2To,&rect)) return FALSE;
     331  rectWin32->bottom = rect.yTop-temp.yBottom;
     332  rectWin32->top    = rect.yTop-temp.yTop;
     333  rectWin32->left   = temp.xLeft;
     334  rectWin32->right  = temp.xRight;
     335
     336  return TRUE;
     337}
     338//******************************************************************************
     339//******************************************************************************
     340BOOL mapOS2ToWin32Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECTLOS2 rectOS2,PRECT rectWin32)
     341{
     342  RECTL temp;
     343  INT windowH;
     344
     345  if (!wndFrom || !wndTo || !rectOS2 || !rectWin32) return FALSE;
     346  temp = *((PRECTL)rectOS2);
     347  if (wndFrom != wndTo)
     348  {
     349    if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)&temp,2)) return FALSE;
     350  }
     351  windowH = wndTo->getClientHeight();
     352  rectWin32->bottom = windowH-temp.yBottom;
     353  rectWin32->top    = windowH-temp.yTop;
     354  rectWin32->left   = temp.xLeft;
     355  rectWin32->right  = temp.xRight;
     356
     357  return TRUE;
     358}
     359//******************************************************************************
     360//******************************************************************************
     361BOOL mapWin32ToOS2Rect(HWND os2Client,PRECT rectWin32,PRECTLOS2 rectOS2)
     362{
     363  RECTL rect;
     364
     365  if (!rectOS2 || !rectWin32) return FALSE;
     366  if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //shouldn't be the case
     367  if (!WinQueryWindowRect(os2Client,&rect)) return FALSE;
     368  rectOS2->yBottom = rect.yTop-rectWin32->bottom;
     369  rectOS2->yTop    = rect.yTop-rectWin32->top;
     370  rectOS2->xLeft   = rectWin32->left;
     371  rectOS2->xRight  = rectWin32->right;
     372
     373  return TRUE;
     374}
     375//******************************************************************************
     376//******************************************************************************
     377BOOL mapWin32ToOS2Rect(Win32BaseWindow *win32wnd,PRECT rectWin32,PRECTLOS2 rectOS2)
     378{
     379  INT windowH;
     380
     381  if (!win32wnd || !rectOS2 || !rectWin32) return FALSE;
     382  windowH = win32wnd->getClientHeight();
     383  rectOS2->yBottom = windowH-rectWin32->bottom;
     384  rectOS2->yTop    = windowH-rectWin32->top;
     385  rectOS2->xLeft   = rectWin32->left;
     386  rectOS2->xRight  = rectWin32->right;
     387
     388  return TRUE;
     389}
     390//******************************************************************************
     391//******************************************************************************
     392BOOL mapWin32ToOS2Rect(HWND os2From,HWND os2To,PRECT rectWin32,PRECTLOS2 rectOS2)
     393{
     394  RECTL rect;
     395
     396  if (!rectOS2 || !rectWin32) return FALSE;
     397  if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
     398  if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
     399  if (!WinQueryWindowRect(os2From,&rect)) return FALSE;
     400  rectOS2->yBottom = rect.yTop-rectWin32->bottom;
     401  rectOS2->yTop    = rect.yTop-rectWin32->top;
     402  rectOS2->xLeft   = rectWin32->left;
     403  rectOS2->xRight  = rectWin32->right;
     404  if (os2From != os2To)
     405  {
     406    if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)rectOS2,2)) return FALSE;
     407  }
     408
     409  return TRUE;
     410}
     411//******************************************************************************
     412//******************************************************************************
     413BOOL mapWin32ToOS2Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECT rectWin32,PRECTLOS2 rectOS2)
     414{
     415  INT windowH;
     416
     417  if (!wndFrom || !wndTo || !rectOS2 || !rectWin32) return FALSE;
     418  windowH = wndFrom->getClientHeight();
     419  rectOS2->yBottom = windowH-rectWin32->bottom;
     420  rectOS2->yTop    = windowH-rectWin32->top;
     421  rectOS2->xLeft   = rectWin32->left;
     422  rectOS2->xRight  = rectWin32->right;
     423  if (wndFrom != wndTo)
     424  {
     425    if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)rectOS2,2)) return FALSE;
     426  }
     427
     428  return TRUE;
     429}
     430//******************************************************************************
     431//******************************************************************************
     432BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32)
     433{
     434  rectWin32->bottom = rectOS2->yBottom;
     435  rectWin32->top    = rectOS2->yTop;
     436  rectWin32->left   = rectOS2->xLeft;
     437  rectWin32->right  = rectOS2->xRight;
     438
     439  return TRUE;
     440}
     441//******************************************************************************
     442//******************************************************************************
     443BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2)
     444{
     445  rectOS2->yBottom = rectWin32->bottom;
     446  rectOS2->yTop    = rectWin32->top;
     447  rectOS2->xLeft   = rectWin32->left;
     448  rectOS2->xRight  = rectWin32->right;
     449
     450  return TRUE;
     451}
     452//******************************************************************************
     453//******************************************************************************
     454INT mapOS2ToWin32ChildOrigin(INT parentH,INT parentPosY,INT childH)
     455{
     456  return parentH-parentPosY-childH;//Does: parentH-1-parentPosY-(childH-1)
    279457}
    280458//******************************************************************************
     
    289467        return 0;
    290468    }
    291     MapOS2ToWin32Rectl(hwnd,(RECTLOS2 *)&rectl, rectWin32);
     469    mapOS2ToWin32Rect(hwnd,(RECTLOS2 *)&rectl, rectWin32);
    292470    return WinBeginPaint(hwnd, NULLHANDLE, &rectl);
    293471}
     
    320498
    321499    if(pRect) {
    322         MapWin32ToOS2Rectl(hwnd,pRect, &rectl);
     500        mapWin32ToOS2Rect(hwnd,pRect, &rectl);
    323501        return WinInvalidateRect(hwnd, (PRECTL)&rectl, fIncludeChildren);
    324502    }
     
    335513  rc = WinQueryUpdateRect(hwnd, (PRECTL)&rectl);
    336514  if(rc) {
    337         MapOS2ToWin32Rectl(hwnd,&rectl, pRect);
     515        mapOS2ToWin32Rect(hwnd,&rectl, pRect);
    338516  }
    339517  else  memset(pRect, 0, sizeof(RECT));
Note: See TracChangeset for help on using the changeset viewer.