Changeset 3705 for trunk/src


Ignore:
Timestamp:
Jun 14, 2000, 3:17:51 PM (25 years ago)
Author:
sandervl
Message:

region changes

Location:
trunk/src
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/blit.cpp

    r3638 r3705  
    1 /* $Id: blit.cpp,v 1.13 2000-05-29 22:43:54 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.14 2000-06-14 13:17:49 sandervl Exp $ */
    22
    33/*
     
    256256                               (PBITMAPINFO)infoLoc, DIB_RGB_COLORS, dwRop);
    257257
    258         if(rc != heightDst) {
     258        if(rc != heightSrc) {
    259259                dprintf(("StretchDIBits failed with rc %x", rc));
    260260        }
  • trunk/src/gdi32/dbglocal.cpp

    r2859 r3705  
    1 /* $Id: dbglocal.cpp,v 1.2 2000-02-22 19:11:48 sandervl Exp $ */
     1/* $Id: dbglocal.cpp,v 1.3 2000-06-14 13:17:49 sandervl Exp $ */
    22
    33/*
     
    3535"dibitmap",
    3636"blit",
    37 "rgbcvt"
     37"rgbcvt",
     38"objhandle"
    3839};
    3940//******************************************************************************
  • trunk/src/gdi32/dbglocal.h

    r2859 r3705  
    1 /* $Id: dbglocal.h,v 1.2 2000-02-22 19:11:49 sandervl Exp $ */
     1/* $Id: dbglocal.h,v 1.3 2000-06-14 13:17:49 sandervl Exp $ */
    22
    33/*
     
    3636#define DBG_blit            15
    3737#define DBG_rgbcvt          16
    38 #define DBG_MAXFILES        17
     38#define DBG_objhandle       17
     39#define DBG_MAXFILES        18
    3940
    4041extern USHORT DbgEnabled[DBG_MAXFILES];
  • trunk/src/gdi32/gdi32.DEF

    r3316 r3705  
    1 ; $Id: gdi32.DEF,v 1.7 2000-04-03 18:30:47 sandervl Exp $
     1; $Id: gdi32.DEF,v 1.8 2000-06-14 13:17:49 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    358358    InternalGetTabbedTextExtentA @1004
    359359    InternalGetTabbedTextExtentW @1005
     360
     361    setWinDeviceRegionFromPMDeviceRegion__FUlT1P7_DCDataT1     @1006
     362
     363    ObjAllocateHandle__FPUlUl10ObjectType                      @1007
     364    ObjFreeHandle__FUl                                         @1008
     365    ObjGetHandleData__FUl                                      @1009
     366    ObjGetHandleType__FUl                                      @1010
  • trunk/src/gdi32/gdi32.cpp

    r3677 r3705  
    1 /* $Id: gdi32.cpp,v 1.50 2000-06-08 18:07:06 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.51 2000-06-14 13:17:50 sandervl Exp $ */
    22
    33/*
     
    8585//******************************************************************************
    8686//******************************************************************************
    87 int WIN32API GetObjectA( HGDIOBJ hObject, int size, void *lpBuffer)
    88 {
    89  int rc;
    90 
    91   if(size == 0 || lpBuffer == NULL) {
    92         SetLastError(ERROR_INVALID_PARAMETER);
    93         return 0;
    94   }
    95 
    96   if(DIBSection::getSection() != NULL)
    97   {
    98         DIBSection *dsect = DIBSection::find(hObject);
    99         if(dsect)
    100         {
    101                 rc = dsect->GetDIBSection(size, lpBuffer);
    102                 if(rc == 0) {
    103                         SetLastError(ERROR_INVALID_PARAMETER);
    104                         return 0;
    105                 }
    106                 SetLastError(ERROR_SUCCESS);
    107                 return rc;
    108         }
    109   }
    110 
    111   dprintf(("GDI32: GetObject %X %X %X\n", hObject, size, lpBuffer));
    112   return O32_GetObject(hObject, size, lpBuffer);
    113 }
    114 //******************************************************************************
    115 //******************************************************************************
    116 int WIN32API GetObjectW( HGDIOBJ arg1, int arg2, void *  arg3)
    117 {
    118     dprintf(("GDI32: GetObjectW %X, %d %X not complete!", arg1, arg2, arg3));
    119     return GetObjectA(arg1, arg2, arg3);
    120 }
    121 //******************************************************************************
    122 //******************************************************************************
    123 DWORD WIN32API GetObjectType( HGDIOBJ arg1)
    124 {
    125     dprintf2(("GDI32: GetObjectType\n"));
    126     return O32_GetObjectType(arg1);
    127 }
    128 //******************************************************************************
    129 //******************************************************************************
    130 BOOL WIN32API DeleteObject(HANDLE hObj)
    131 {
    132     dprintf(("GDI32: DeleteObject %x", hObj));
    133     DIBSection::deleteSection((DWORD)hObj);
    134     return O32_DeleteObject(hObj);
    135 }
    136 //******************************************************************************
    137 //******************************************************************************
    13887BOOL WIN32API DeleteDC( HDC hdc)
    13988{
     
    205154    dprintf(("GDI32: StrokePath\n"));
    206155    return O32_StrokePath(arg1);
    207 }
    208 //******************************************************************************
    209 //******************************************************************************
    210 HGDIOBJ WIN32API SelectObject(HDC hdc, HGDIOBJ hObj)
    211 {
    212  HGDIOBJ rc;
    213 
    214     dprintf2(("GDI32: SelectObject %x %x", hdc, hObj));
    215 
    216     if(DIBSection::getSection() != NULL)
    217     {
    218       DIBSection *dsect;
    219 
    220       dsect = DIBSection::find(hdc);
    221       if(dsect)
    222       {
    223         //remove previously selected dibsection
    224         dsect->UnSelectDIBObject();
    225       }
    226       dsect = DIBSection::find((DWORD)hObj);
    227       if(dsect)
    228       {
    229         dsect->SelectDIBObject(hdc);
    230       }
    231     }
    232     rc = O32_SelectObject(hdc, hObj);
    233     if(rc != 0 && DIBSection::getSection != NULL)
    234     {
    235       DIBSection *dsect = DIBSection::find((DWORD)rc);
    236       if(dsect)
    237       {
    238         dsect->UnSelectDIBObject();
    239       }
    240     }
    241     return(rc);
    242156}
    243157//******************************************************************************
     
    14861400
    14871401//******************************************************************************
    1488 BOOL WIN32API SetObjectOwner( HGDIOBJ arg1, int arg2 )
    1489 {
    1490   // Here is a guess for a undocumented entry
    1491   dprintf(("GDI32: SetObjectOwner - stub (TRUE)\n"));
    1492   return TRUE;
    1493 }
    1494 //******************************************************************************
    14951402
    14961403
  • trunk/src/gdi32/initterm.cpp

    r2802 r3705  
    1 /* $Id: initterm.cpp,v 1.10 2000-02-16 14:18:10 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.11 2000-06-14 13:17:50 sandervl Exp $ */
    22
    33/*
     
    3838#define DBG_LOCALLOG    DBG_initterm
    3939#include "dbglocal.h"
     40#include "region.h"
    4041
    4142extern "C" {
     
    9798         /*******************************************************************/
    9899
     100         if(InitRegionSpace() == FALSE) {
     101                return 0UL;
     102         }
    99103         if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
    100104                return 0UL;
  • trunk/src/gdi32/makefile

    r3641 r3705  
    1 # $Id: makefile,v 1.25 2000-06-01 11:27:06 sandervl Exp $
     1# $Id: makefile,v 1.26 2000-06-14 13:17:50 sandervl Exp $
    22
    33#
     
    4141$(OBJDIR)\blit.obj \
    4242$(OBJDIR)\rgbcvt.obj \
     43$(OBJDIR)\objhandle.obj \
    4344$(OBJDIR)\dbglocal.obj \
    4445$(OBJDIR)\gdi32rsrc.obj
  • trunk/src/gdi32/oslibgpi.cpp

    r2802 r3705  
    1 /* $Id: oslibgpi.cpp,v 1.4 2000-02-16 14:18:11 sandervl Exp $ */
     1/* $Id: oslibgpi.cpp,v 1.5 2000-06-14 13:17:51 sandervl Exp $ */
    22
    33/*
     
    1717#include <math.h>
    1818#include "win32type.h"
     19#include <winconst.h>
    1920#include "oslibgpi.h"
    2021#include "dcdata.h"
     
    116117
    117118  return TRUE;
     119}
     120
     121BOOL includeBottomRightPoint(PVOID pHps,PPOINTLOS2 pptl)
     122{
     123    if(GetDCData(pHps)->graphicsMode != GM_COMPATIBLE_W)
     124    {
     125        return TRUE;  // already inclusive/inclusive
     126    }
     127
     128    if(pptl[0].x == pptl[1].x || pptl[0].y == pptl[1].y)
     129    {
     130        return FALSE; // empty rectangle
     131    }
     132
     133    if(GetDCData(pHps)->isLeftLeft)
     134    {
     135        pptl[1].x += abs(GetDCData(pHps)->worldXDeltaFor1Pixel);
     136        sortAscending(pptl[0].x, pptl[1].x);
     137    }
     138    else
     139    {
     140        pptl[0].x -= abs(GetDCData(pHps)->worldXDeltaFor1Pixel);
     141        sortAscending(pptl[1].x, pptl[0].x);
     142    }
     143
     144    if(GetDCData(pHps)->isTopTop)
     145    {
     146        pptl[1].y += abs(GetDCData(pHps)->worldYDeltaFor1Pixel);
     147        sortAscending(pptl[1].y, pptl[0].y);
     148    }
     149    else
     150    {
     151        pptl[0].y -= abs(GetDCData(pHps)->worldYDeltaFor1Pixel);
     152        sortAscending(pptl[0].y, pptl[1].y);
     153    }
     154    return TRUE;
    118155}
    119156
     
    351388}
    352389
     390
  • trunk/src/gdi32/oslibgpi.h

    r3315 r3705  
    1 /* $Id: oslibgpi.h,v 1.5 2000-04-03 18:29:05 sandervl Exp $ */
     1/* $Id: oslibgpi.h,v 1.6 2000-06-14 13:17:51 sandervl Exp $ */
    22
    33/*
     
    1212#define __OSLIBGPI_H__
    1313
    14 /* DC Graphics Mode */
    15 #define GM_COMPATIBLE_W     1
    16 #define GM_ADVANCED_W       2
    17 
    1814#define APIENTRYOS2 _System
    1915
     
    8884
    8985BOOL excludeBottomRightPoint(PVOID pHps,PPOINTLOS2 pptl);
     86BOOL includeBottomRightPoint(PVOID pHps,PPOINTLOS2 pptl);
    9087BOOL getAlignUpdateCP(PVOID pHps);
    9188INT  getWorldYDeltaFor1Pixel(PVOID pHps);
     
    192189BOOL  OSLibGpiSetCp(HDC hdc, ULONG codepage);
    193190
     191
     192   // from pmddi.h:
     193   /* CopyClipRegion */
     194
     195   #define COPYCRGN_ALLINTERSECT        0L
     196   #define COPYCRGN_VISRGN              1L
     197   #define COPYCRGN_CLIPRGN             2L
     198
     199   /* SetupDC */
     200
     201   #define SETUPDC_VISRGN               0x00000001L
     202   #define SETUPDC_ORIGIN               0x00000002L
     203   #define SETUPDC_ACCUMBOUNDSON        0x00000004L
     204   #define SETUPDC_ACCUMBOUNDSOFF       0x00000008L
     205   #define SETUPDC_RECALCCLIP           0x00000010L
     206   #define SETUPDC_SETOWNER             0x00000020L
     207   #define SETUPDC_CLEANDC              0x00000040L
     208
     209ULONG APIENTRY Gre32Entry4(ULONG,ULONG,ULONG,ULONG);
     210
     211inline ULONG APIENTRY _Gre32Entry4 (ULONG a, ULONG b, ULONG c, ULONG d)
     212{
     213 ULONG yyrc;
     214 USHORT sel = RestoreOS2FS();
     215
     216    yyrc = Gre32Entry4(a,b,c,d);
     217    SetFS(sel);
     218
     219    return yyrc;
     220}
     221
     222ULONG APIENTRY Gre32Entry5(ULONG,ULONG,ULONG,ULONG,ULONG);
     223
     224inline ULONG APIENTRY _Gre32Entry5 (ULONG a, ULONG b, ULONG c, ULONG d, ULONG e)
     225{
     226 ULONG yyrc;
     227 USHORT sel = RestoreOS2FS();
     228
     229    yyrc = Gre32Entry5(a,b,c,d,e);
     230    SetFS(sel);
     231
     232    return yyrc;
     233}
     234
     235
     236ULONG APIENTRY Gre32Entry6(ULONG,ULONG,ULONG,ULONG,ULONG,ULONG);
     237
     238inline ULONG APIENTRY _Gre32Entry6 (ULONG a, ULONG b, ULONG c, ULONG d, ULONG e, ULONG f)
     239{
     240 ULONG yyrc;
     241 USHORT sel = RestoreOS2FS();
     242
     243    yyrc = Gre32Entry6(a,b,c,d,e,f);
     244    SetFS(sel);
     245
     246    return yyrc;
     247}
     248
     249ULONG APIENTRY Gre32Entry7(ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG);
     250
     251inline ULONG APIENTRY _Gre32Entry7 (ULONG a, ULONG b, ULONG c, ULONG d, ULONG e, ULONG f, ULONG g)
     252{
     253 ULONG yyrc;
     254 USHORT sel = RestoreOS2FS();
     255
     256    yyrc = Gre32Entry7(a,b,c,d,e,f,g);
     257    SetFS(sel);
     258
     259    return yyrc;
     260}
     261
     262ULONG APIENTRY Gre32Entry8(ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG);
     263
     264inline ULONG APIENTRY _Gre32Entry8 (ULONG a, ULONG b, ULONG c, ULONG d, ULONG e, ULONG f, ULONG g, ULONG h)
     265{
     266 ULONG yyrc;
     267 USHORT sel = RestoreOS2FS();
     268
     269    yyrc = Gre32Entry8(a,b,c,d,e,f,g,h);
     270    SetFS(sel);
     271
     272    return yyrc;
     273}
     274
     275
     276   #define GreSetupDC(a,b,c,d,e,f) (BOOL) _Gre32Entry8((ULONG)(HDC)(a),(ULONG)(HRGN)(b),(ULONG)(LONG)(c),(ULONG)(LONG)(d),(ULONG)(PRECTL)(e),(ULONG)(ULONG)(f),0L,0x00004081L)
     277   #define GreCreateRectRegion(a,b,c) (HRGN) _Gre32Entry5((ULONG)(HDC)(a),(ULONG)(PRECTL)(b),(ULONG)(LONG)(c),0L,0x00004062L)
     278   #define GreGetPageUnits(a,b) (LONG) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(PULONG)(b),0L,0x00004083L)
     279   #define GreCopyClipRegion(a,b,c,d) (INT) _Gre32Entry6((ULONG)(HDC)(a),(ULONG)(HRGN)(b),(ULONG)(PRECTL)(c),(ULONG)(ULONG)(d),0L,0x00004080L)
     280   #define GreCombineRegion(a,b,c,d,e) (INT) _Gre32Entry7((ULONG)(HDC)(a),(ULONG)(HRGN)(b),(ULONG)(HRGN)(c),(ULONG)(HRGN)(d),(ULONG)(ULONG)(e),0L,0x00004065L)
     281   #define GreDestroyRegion(a,b) (BOOL) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(HRGN)(b),0L,0x00004063L)
     282   #define GreGetDCOrigin(a,b) (BOOL) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(PPOINTL)(b),0L,0x000040BAL)
     283   #define GreDeviceSetDCOrigin(a,b) (BOOL) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(PPOINTL)(b),0L,0x000040BBL)
     284   #define GreSelectClipRegion(a,b,c) (INT) _Gre32Entry5((ULONG)(HDC)(a),(ULONG)(HRGN)(b),(ULONG)(PHRGN)(c),0L,0x00004074L)
     285   #define GreIntersectClipRectangle(a,b) (INT) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(PRECTL)(b),0L,0x00004075L)
     286
    194287#endif
  • trunk/src/gdi32/region.cpp

    r3677 r3705  
    1 /* $Id: region.cpp,v 1.5 2000-06-08 18:07:07 sandervl Exp $ */
     1/* $Id: region.cpp,v 1.6 2000-06-14 13:17:51 sandervl Exp $ */
    22
    33/*
    44 * GDI32 region code
    55 *
    6  * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
     6 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
    77 * Copyright 1998 Patrick Haller
     8 *
     9 * TODO: Metafile recording
     10 * TODO: Do we need to translate & set the last error for Gpi operations?
    811 *
    912 * Project Odin Software License can be found in LICENSE.TXT
    1013 *
    1114 */
    12 #include <os2win.h>
     15#define  INCL_GPI
     16#define  INCL_WIN
     17#include <os2wrap.h>
     18
     19#include <win32type.h>
     20#include <win32api.h>
     21#include <winconst.h>
    1322#include <stdlib.h>
    1423#include <stdarg.h>
    1524#include <string.h>
    16 #include "misc.h"
    17 
    18 #define DBG_LOCALLOG    DBG_region
     25#include <misc.h>
     26#include <objhandle.h>
     27#include <dcdata.h>
     28#include <winuser32.h>
     29#include <win32wnd.h>
     30#include "oslibgpi.h"
     31
     32#define DBG_LOCALLOG    DBG_region
    1933#include "dbglocal.h"
    2034
    21 //******************************************************************************
    22 //******************************************************************************
    23 HRGN WIN32API CreatePolyPolygonRgn( const POINT * arg1, const INT * arg2, int arg3, int  arg4)
    24 {
    25     dprintf(("GDI32: CreatePolyPolygonRgn\n"));
    26     return O32_CreatePolyPolygonRgn(arg1, arg2, arg3, arg4);
    27 }
    28 //******************************************************************************
    29 //******************************************************************************
    30 HRGN WIN32API CreatePolygonRgn(const POINT * arg1, int arg2, int arg3)
    31 {
    32     dprintf(("GDI32: CreatePolygonRgn"));
    33     return O32_CreatePolygonRgn(arg1, arg2, arg3);
    34 }
    35 //******************************************************************************
    36 //******************************************************************************
    37 int WIN32API CombineRgn( HRGN arg1, HRGN  arg2, HRGN  arg3, int  arg4)
    38 {
    39     dprintf(("GDI32: CombineRgn"));
    40     return O32_CombineRgn(arg1, arg2, arg3, arg4);
    41 }
    42 //******************************************************************************
    43 //******************************************************************************
    44 HRGN WIN32API CreateEllipticRgn( int arg1, int arg2, int arg3, int  arg4)
    45 {
    46     dprintf(("GDI32: CreateEllipticRgn"));
    47     return O32_CreateEllipticRgn(arg1, arg2, arg3, arg4);
    48 }
    49 //******************************************************************************
    50 //******************************************************************************
    51 HRGN WIN32API CreateEllipticRgnIndirect( const RECT * arg1)
    52 {
    53     dprintf(("GDI32: CreateEllipticRgnIndirect"));
    54     return O32_CreateEllipticRgnIndirect(arg1);
    55 }
    56 //******************************************************************************
    57 //******************************************************************************
    58 HRGN WIN32API CreateRectRgn( int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
    59 {
    60     dprintf(("GDI32: CreateRectRgn (%d,%d)(%d,%d)", nLeftRect, nTopRect, nRightRect, nBottomRect));
    61     return O32_CreateRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect);
    62 }
    63 //******************************************************************************
    64 //******************************************************************************
    65 HRGN WIN32API CreateRectRgnIndirect( const RECT * lpRect)
    66 {
    67     if(lpRect == NULL) {
    68         SetLastError(ERROR_INVALID_PARAMETER);
    69         return 0;
    70     }
    71     dprintf(("GDI32: CreateRectRgnIndirect (%d,%d)(%d,%d)", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom));
    72     return O32_CreateRectRgnIndirect(lpRect);
    73 }
    74 //******************************************************************************
    75 //******************************************************************************
    76 HRGN WIN32API CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect,
    77                                  int nWidthEllipse, int nHeightEllipse)
    78 {
    79     dprintf(("GDI32: CreateRoundRectRgn (%d,%d)(%d,%d) (%d,%d)", nLeftRect, nTopRect, nRightRect, nBottomRect, nWidthEllipse, nHeightEllipse));
    80     return O32_CreateRoundRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect, nWidthEllipse, nHeightEllipse);
    81 }
    82 //******************************************************************************
    83 //******************************************************************************
    84 BOOL WIN32API EqualRgn( HRGN arg1, HRGN  arg2)
    85 {
    86     dprintf(("GDI32: EqualRgn"));
    87     return O32_EqualRgn(arg1, arg2);
    88 }
    89 //******************************************************************************
    90 //******************************************************************************
    91 HRGN WIN32API ExtCreateRegion( const XFORM * arg1, DWORD arg2, const RGNDATA *  arg3)
    92 {
    93  HRGN hRgn;
    94 
    95     hRgn = O32_ExtCreateRegion(arg1, arg2, arg3);
    96     dprintf(("GDI32: ExtCreateRegion %x %x %x returned %x", arg1, arg2, arg3, hRgn));
    97     return hRgn;
    98 }
    99 //******************************************************************************
    100 //******************************************************************************
    101 BOOL WIN32API FillRgn( HDC arg1, HRGN arg2, HBRUSH  arg3)
    102 {
    103     dprintf(("GDI32: FillRgn"));
    104     return O32_FillRgn(arg1, arg2, arg3);
    105 }
    106 //******************************************************************************
    107 //******************************************************************************
    108 BOOL WIN32API FrameRgn( HDC arg1, HRGN arg2, HBRUSH arg3, int arg4, int  arg5)
    109 {
    110     dprintf(("GDI32: FrameRgn"));
    111     return O32_FrameRgn(arg1, arg2, arg3, arg4, arg5);
    112 }
    113 //******************************************************************************
    114 //******************************************************************************
    115 DWORD WIN32API GetRegionData( HRGN arg1, DWORD arg2, PRGNDATA  arg3)
    116 {
    117     dprintf(("GDI32: GetRegionData"));
    118     return O32_GetRegionData(arg1, arg2, arg3);
    119 }
    120 //******************************************************************************
    121 //******************************************************************************
    122 int WIN32API GetRgnBox(HRGN hRgn, PRECT pRect)
    123 {
    124     dprintf(("GDI32: GetRgnBox %x %x", hRgn, pRect));
    125     if(hRgn == 0) {
    126 ////    SetLastError(ERROR_INVALID_PARAMETER);
    127         return NULLREGION;
    128     }
    129     return O32_GetRgnBox(hRgn, pRect);
    130 }
    131 //******************************************************************************
    132 //******************************************************************************
    133 BOOL WIN32API InvertRgn( HDC arg1, HRGN  arg2)
    134 {
    135     dprintf(("GDI32: InvertRgn"));
    136     return O32_InvertRgn(arg1, arg2);
    137 }
    138 //******************************************************************************
    139 //******************************************************************************
    140 int WIN32API OffsetRgn( HRGN arg1, int arg2, int  arg3)
    141 {
    142     dprintf(("GDI32: OffsetRgn"));
    143     return O32_OffsetRgn(arg1, arg2, arg3);
    144 }
    145 //******************************************************************************
    146 //******************************************************************************
    147 BOOL WIN32API PaintRgn( HDC arg1, HRGN  arg2)
    148 {
    149     dprintf(("GDI32: PaintRgn"));
    150     return O32_PaintRgn(arg1, arg2);
    151 }
    152 //******************************************************************************
    153 //******************************************************************************
    154 HRGN WIN32API PathToRegion( HDC arg1)
    155 {
    156     dprintf(("GDI32: PathToRegion"));
    157     return O32_PathToRegion(arg1);
    158 }
    159 //******************************************************************************
    160 //******************************************************************************
    161 BOOL WIN32API PtInRegion( HRGN arg1, int arg2, int  arg3)
    162 {
    163     dprintf(("GDI32: PtInRegion"));
    164     return O32_PtInRegion(arg1, arg2, arg3);
    165 }
    166 //******************************************************************************
    167 //******************************************************************************
    168 BOOL WIN32API RectInRegion( HRGN arg1, const RECT *  arg2)
    169 {
    170     dprintf(("GDI32: RectInRegion"));
    171     return O32_RectInRegion(arg1, arg2);
    172 }
    173 //******************************************************************************
    174 //******************************************************************************
    175 BOOL WIN32API SetRectRgn( HRGN arg1, int arg2, int arg3, int arg4, int  arg5)
    176 {
    177     dprintf(("GDI32: SetRectRgn"));
    178     return O32_SetRectRgn(arg1, arg2, arg3, arg4, arg5);
     35typedef enum
     36{
     37    AS_DEVICE,
     38    AS_WORLD
     39} InterpMode;
     40
     41#define MEM_HPS_MAX 768
     42
     43static void convertDeviceRect(HWND hwnd, pDCData pHps, PRECTL pRectl, ULONG count);
     44
     45#define convertWinDeviceRectToPMDeviceRect(arg1, arg2, arg3) convertDeviceRect(arg1, arg2, arg3)
     46#define convertPMDeviceRectToWinDeviceRect(arg1, arg2, arg3) convertDeviceRect(arg1, arg2, arg3)
     47
     48inline void convertDeviceRect(pDCData pHps, PRECTL pRectl, ULONG count)
     49{
     50   convertDeviceRect(0, pHps, pRectl, count);
     51}
     52inline void convertDeviceRect(HWND hwnd, PRECTL pRectl, ULONG count)
     53{
     54   convertDeviceRect(hwnd, 0, pRectl, count);
     55}
     56
     57HPS hpsRegion = 0;
     58
     59//******************************************************************************
     60//******************************************************************************
     61BOOL InitRegionSpace()
     62{
     63    hpsRegion = WinGetScreenPS(HWND_DESKTOP);
     64    return hpsRegion != 0;
     65}
     66//******************************************************************************
     67//******************************************************************************
     68static LONG clientHeight(HWND hwnd, pDCData pHps)
     69{
     70    if(hwnd == 0 && pHps != 0)
     71        hwnd = pHps->hwnd;
     72
     73    if(hwnd != 0 || pHps == 0)
     74    {
     75        RECT rect;
     76        RECTL rectl;
     77        LONG y = 0;
     78
     79        if(pHps == 0 || pHps->isClient) //client area
     80        {
     81            if(GetClientRect(OS2ToWin32Handle(hwnd), &rect) == TRUE) {
     82                y = rect.bottom - rect.top;
     83            }
     84        }
     85        else
     86        if(WinQueryWindowRect(hwnd, &rectl))    //whole window
     87            y = rectl.yTop;
     88
     89        return y;
     90   }
     91   else
     92   if(pHps->bitmapHandle)
     93   {
     94      return pHps->bitmapHeight;
     95   }
     96   else
     97   if(pHps->isMetaPS)
     98   {
     99      return 0;
     100   }
     101   else
     102   if(pHps->isPrinter)
     103   {
     104      return pHps->printPageHeight;
     105   }
     106   else
     107   {
     108      return MEM_HPS_MAX;
     109   }
     110}
     111//******************************************************************************
     112//******************************************************************************
     113static LONG clientWidth(HWND hwnd, pDCData pHps)
     114{
     115    if(hwnd == 0 && pHps != 0)
     116        hwnd = pHps->hwnd;
     117
     118    if(hwnd != 0 || pHps == 0)
     119    {
     120        RECT rect;
     121        RECTL rectl;
     122        LONG x = 0;
     123
     124        if(pHps == 0 || pHps->isClient) //client area
     125        {
     126            if(GetClientRect(OS2ToWin32Handle(hwnd), &rect) == TRUE) {
     127                x = rect.right - rect.left;
     128            }
     129        }
     130        else
     131        if(WinQueryWindowRect(hwnd, &rectl))    //whole window
     132            x = rectl.xRight;
     133
     134        return x;
     135   }
     136   else DebugInt3();
     137   return 0;
     138}
     139//******************************************************************************
     140//******************************************************************************
     141static void convertWinWorldRectToPMDeviceRect(pDCData pHps_Hdc, PRECTL pRects, UINT count = 1)
     142{
     143   PRECTL pRectl;
     144   for (int x=0; x < count; x++)
     145   {
     146        pRectl = &pRects[x];
     147
     148        if(pRectl->yTop < pRectl->yBottom) {
     149            ULONG temp      = pRectl->yBottom;
     150            pRectl->yBottom = pRectl->yTop;
     151            pRectl->yTop    = temp;
     152        }
     153        BOOL success = GpiConvert( pHps_Hdc->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)pRectl);
     154        if(!success)
     155        {
     156            break;
     157        }
     158        if(pRectl->yTop < pRectl->yBottom) {
     159            ULONG temp      = pRectl->yBottom;
     160            pRectl->yBottom = pRectl->yTop;
     161            pRectl->yTop    = temp;
     162        }
     163   }
     164}
     165//******************************************************************************
     166//******************************************************************************
     167static void convertDeviceRect(HWND hwnd, pDCData pHps, PRECTL pRectl, ULONG count)
     168{
     169   long wHeight, wWidth;
     170
     171    if(hwnd == HWND_DESKTOP) {
     172        wHeight = OSLibGetScreenHeight();
     173        wWidth  = OSLibGetScreenWidth();
     174    }
     175    else {
     176        wHeight = clientHeight(hwnd, pHps);
     177        wWidth  = clientWidth(hwnd, pHps);
     178    }
     179
     180    if(pHps)
     181    {
     182         wHeight += pHps->HPStoHDCInversionHeight;
     183    }
     184
     185    if(hwnd || (pHps && pHps->hwnd)) {
     186        for(int x=0; x < count; x++)
     187        {
     188            if(pRectl[x].xRight > wWidth) {
     189                 pRectl[x].xRight = wWidth;
     190            }
     191            if(pRectl[x].yTop > wHeight) {
     192                 pRectl[x].yTop = 0;
     193            }
     194            else pRectl[x].yTop    = wHeight - pRectl[x].yTop;
     195
     196            pRectl[x].yBottom = wHeight - pRectl[x].yBottom;
     197        }
     198    }
     199    else {
     200        for(int x=0; x < count; x++)
     201        {
     202            pRectl[x].yTop    = wHeight - pRectl[x].yTop;
     203            pRectl[x].yBottom = wHeight - pRectl[x].yBottom;
     204        }
     205    }
     206}
     207//******************************************************************************
     208//******************************************************************************
     209static void convertPMDeviceRectToWinWorldRect(pDCData pHps_Hdc, PRECTL pRectl)
     210{
     211   GpiConvert(pHps_Hdc->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)pRectl );
     212}
     213//******************************************************************************
     214//******************************************************************************
     215BOOL interpretRegionAs(pDCData pHps, HRGN hrgnDest, HRGN hrgnSrc, InterpMode mode)
     216{
     217 BOOL success = FALSE;
     218 int  x, i;
     219 HPS  hpsDest;
     220
     221    if(pHps)
     222    {
     223        if(!hrgnDest) {
     224                hrgnDest = pHps->hrgnHDC;
     225#ifdef DEBUG
     226                if(hrgnDest == 0) {
     227                    DebugInt3();
     228                }
     229#endif
     230        }
     231        hpsDest  = pHps->hps;
     232    }
     233    else {
     234        DebugInt3();
     235        return FALSE;
     236    }
     237
     238    RGNRECT  rgnRect;
     239    rgnRect.ircStart    = 1;
     240    rgnRect.crc         = 0;
     241    rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;
     242    success = GpiQueryRegionRects(hpsRegion, hrgnSrc, NULL, &rgnRect, NULL);
     243    if(success)
     244    {
     245        if(rgnRect.crcReturned > 0)
     246        {
     247            rgnRect.crc = rgnRect.crcReturned;
     248            PRECTL pRectl = new RECTL[rgnRect.crcReturned];
     249            success = GpiQueryRegionRects(hpsRegion, hrgnSrc, NULL, &rgnRect, pRectl);
     250            if(success)
     251            {
     252                if(mode == AS_DEVICE)
     253                {
     254                    ULONG temp;
     255                    for(x=0; x < rgnRect.crcReturned; x++)
     256                    {
     257                        temp = pRectl[x].yBottom;
     258                        pRectl[x].yBottom = pRectl[x].yTop;
     259                        pRectl[x].yTop    = temp;
     260                    }
     261                    convertWinDeviceRectToPMDeviceRect(pHps, pRectl, rgnRect.crcReturned);
     262                }
     263                else
     264                {
     265                    GpiConvert(pHps->hps, CVTC_WORLD, CVTC_DEVICE, rgnRect.crcReturned<<1, (PPOINTL)pRectl);
     266
     267                    ULONG temp;
     268                    for(i=0; i < rgnRect.crcReturned; i++)
     269                    {
     270                        if(pRectl[i].yTop < pRectl[i].yBottom)
     271                        {
     272                            temp              = pRectl[i].yBottom + 1;
     273                            pRectl[i].yBottom = pRectl[i].yTop + 1;
     274                            pRectl[i].yTop    = temp;
     275                        }
     276                        else
     277                        {
     278                            pRectl[i].yTop++;
     279                            pRectl[i].yBottom++;
     280                        }
     281                    }
     282                }
     283                success = GpiSetRegion(hpsDest, hrgnDest, rgnRect.crcReturned, pRectl);
     284            }
     285            delete[] pRectl;
     286        }
     287        else
     288        {
     289            success = GpiSetRegion(hpsDest, hrgnDest, 0, NULL);
     290        }
     291    }
     292    return success;
     293}
     294//******************************************************************************
     295//******************************************************************************
     296BOOL setWinDeviceRegionFromPMDeviceRegion(HRGN winHrgn, HRGN pmHrgn, pDCData pHpsPmHrgn, HWND hwndPmHrgn)
     297{
     298    BOOL    success;
     299    int     x;
     300    BOOL    mustReleaseScreenPS = FALSE;
     301    HPS     hps;
     302
     303    if(pHpsPmHrgn || hwndPmHrgn)
     304    {
     305        if(pHpsPmHrgn)
     306            hps = pHpsPmHrgn->hps;
     307        else
     308        {
     309            hps = WinGetScreenPS(HWND_DESKTOP);
     310            mustReleaseScreenPS = TRUE;
     311        }
     312
     313        RGNRECT  rgnRect;
     314        rgnRect.ircStart    = 1;
     315        rgnRect.crc         = 0;
     316        rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;
     317        success = GpiQueryRegionRects(hps, pmHrgn, NULL, &rgnRect, NULL);
     318        if(success )
     319        {
     320            if(rgnRect.crcReturned > 0)
     321            {
     322                rgnRect.crc = rgnRect.crcReturned;
     323                PRECTL pRectl = new RECTL[rgnRect.crcReturned];
     324                success = GpiQueryRegionRects(hps, pmHrgn, NULL, &rgnRect, pRectl);
     325                if(success)
     326                {
     327                    if(pHpsPmHrgn)
     328                        convertPMDeviceRectToWinDeviceRect(pHpsPmHrgn, pRectl, rgnRect.crcReturned);
     329                    else
     330                        convertPMDeviceRectToWinDeviceRect(hwndPmHrgn, pRectl, rgnRect.crcReturned);
     331
     332                    for(x=0; x < rgnRect.crcReturned; x++)
     333                    {
     334                        ULONG temp         = pRectl[x].yBottom;
     335                        pRectl[x].yBottom  = pRectl[x].yTop;
     336                        pRectl[x].yTop     = temp;
     337                    }
     338
     339                    success = GpiSetRegion(hpsRegion, winHrgn, rgnRect.crcReturned, pRectl);
     340                }
     341                delete[] pRectl;
     342            }
     343            else
     344            {
     345                success = GpiSetRegion(hpsRegion, winHrgn, 0, NULL);
     346            }
     347        }
     348    }
     349    else
     350        success = FALSE;
     351
     352    if(mustReleaseScreenPS)
     353        WinReleasePS(hps);
     354
     355   return success;
     356}
     357//******************************************************************************
     358//******************************************************************************
     359int WIN32API SelectClipRgn(HDC hdc, HRGN hrgn)
     360{
     361 LONG lComplexity = RGN_NULL;
     362 HRGN hrgnNewClip;
     363 HRGN hrgnOldClip;
     364
     365    pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     366    if(!pHps)
     367    {
     368        dprintf(("WARNING: SelectClipRgn: invalid hdc!", hdc, hrgn));
     369        SetLastError(ERROR_INVALID_HANDLE_W);
     370        return ERROR_W;
     371    }
     372
     373    if(hrgn)
     374    {
     375        hrgn = ObjGetHandleData(hrgn);
     376        if(hrgn == HANDLE_OBJ_ERROR) {
     377            dprintf(("WARNING: SelectClipRgn: invalid region!", hdc, hrgn));
     378            SetLastError(ERROR_INVALID_HANDLE_W);
     379            return ERROR_W;
     380        }
     381    }
     382
     383    if(hrgn)
     384    {
     385        RECTL rectl = {0,0,1,1};
     386        hrgnNewClip = GpiCreateRegion(pHps->hps, 1, &rectl);
     387        if(interpretRegionAs(pHps, hrgnNewClip, hrgn, AS_DEVICE) == 0)
     388        {
     389            lComplexity = RGN_ERROR;
     390        }
     391    }
     392    else
     393        hrgnNewClip = 0;
     394
     395    if(lComplexity != RGN_ERROR)
     396    {
     397        if(hrgnNewClip == 0) {
     398            GpiSetClipPath(pHps->hps, 0, SCP_RESET);
     399        }
     400        lComplexity = GpiSetClipRegion(pHps->hps, hrgnNewClip, &hrgnOldClip);
     401        if (lComplexity != RGN_ERROR )
     402        {
     403            dprintf(("SelectClipRgn: %x %x", hdc, hrgn));
     404            if(hrgnOldClip)
     405                GpiDestroyRegion(pHps->hps, hrgnOldClip);
     406
     407            //todo: metafile recording
     408            SetLastError(ERROR_SUCCESS_W);
     409            return lComplexity;
     410        }
     411    }
     412
     413    dprintf(("WARNING: SelectClipRgn: RGN_ERROR!", hdc, hrgn));
     414    if(hrgnNewClip)
     415        GpiDestroyRegion(pHps->hps, hrgnNewClip);
     416
     417    SetLastError(ERROR_SUCCESS_W);
     418    return lComplexity;
     419}
     420//******************************************************************************
     421//******************************************************************************
     422int WIN32API ExtSelectClipRgn(HDC hdc, HRGN hrgn, int mode)
     423{
     424   pDCData    pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     425   if (!pHps)
     426   {
     427        dprintf(("WARNING: ExtSelectRgn %x %x %d invalid hdc", hdc, hrgn, mode));
     428        SetLastError(ERROR_INVALID_HANDLE_W);
     429        return ERROR_W;
     430   }
     431
     432   LONG lComplexity;
     433   HRGN hrgnCurrent = NULLHANDLE;
     434
     435   if(!hrgn && mode != RGN_COPY_W)
     436   {
     437        SetLastError(ERROR_INVALID_PARAMETER_W);
     438        dprintf(("WARNING: ExtSelectRgn %x %x %d invalid parameter", hdc, hrgn, mode));
     439        return ERROR_W;
     440   }
     441
     442   LONG lMode;
     443   switch (mode)
     444   {
     445        case  RGN_AND_W  : lMode = CRGN_AND ; break;
     446        case  RGN_COPY_W : lMode = CRGN_COPY; break;
     447        case  RGN_DIFF_W : lMode = CRGN_DIFF; break;
     448        case  RGN_OR_W   : lMode = CRGN_OR  ; break;
     449        case  RGN_XOR_W  : lMode = CRGN_XOR ; break;
     450        default:
     451        {
     452            SetLastError(ERROR_INVALID_PARAMETER_W);
     453            dprintf(("WARNING: ExtSelectRgn %x %x %d invalid parameter", hdc, hrgn, mode));
     454            return ERROR_W;
     455        }
     456   }
     457
     458   if(hrgn)
     459   {
     460        hrgn = ObjGetHandleData(hrgn);
     461        if(hrgn == HANDLE_OBJ_ERROR) {
     462            dprintf(("WARNING: ExtSelectRgn %x %x %d invalid region handle", hdc, hrgn, mode));
     463            SetLastError(ERROR_INVALID_HANDLE_W);
     464            return 0;
     465        }
     466   }
     467
     468   dprintf(("WARNING: ExtSelectRgn %x %x %d", hdc, hrgn, mode));
     469   //TODO: metafile recording
     470   if(hrgn)
     471   {
     472        if(!interpretRegionAs(pHps, 0, hrgn, AS_DEVICE) )
     473        {
     474            return ERROR_W;
     475        }
     476   }
     477   else
     478   {
     479        //remove clip region
     480        GpiSetClipPath(pHps->hps, 0, SCP_RESET);
     481        GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnCurrent);
     482
     483        if(hrgnCurrent)
     484            GpiDestroyRegion(pHps->hps, hrgnCurrent);
     485
     486        return NULLREGION_W;
     487   }
     488
     489   GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnCurrent);
     490
     491   if(hrgnCurrent == NULLHANDLE)
     492   {
     493        lMode = CRGN_COPY;
     494        RECTL rectl = {0, 0, 1, 1};
     495        hrgnCurrent = GpiCreateRegion(pHps->hps, 1, &rectl);
     496   }
     497
     498   HRGN hrgnSrc1;
     499   HRGN hrgnSrc2;
     500   if(lMode != CRGN_COPY)
     501   {
     502        hrgnSrc1 = hrgnCurrent;
     503        hrgnSrc2 = pHps->hrgnHDC;
     504   }
     505   else
     506   {
     507        hrgnSrc1 = pHps->hrgnHDC;
     508        hrgnSrc2 = NULLHANDLE;
     509   }
     510
     511   lComplexity = GpiCombineRegion(pHps->hps, hrgnCurrent, hrgnSrc1, hrgnSrc2, lMode);
     512   if (lComplexity != RGN_ERROR)
     513   {
     514        HRGN hrgnOld;
     515        lComplexity = GpiSetClipRegion(pHps->hps, hrgnCurrent, &hrgnOld);
     516        SetLastError(ERROR_SUCCESS_W);
     517        if (lComplexity != RGN_ERROR)
     518            return lComplexity;
     519   }
     520   SetLastError(ERROR_SUCCESS_W);
     521   return ERROR_W;
     522}
     523//******************************************************************************
     524//******************************************************************************
     525int WIN32API GetClipBox(HDC hdc, PRECT lpRect)
     526{
     527 pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     528 RECTL    rectl;
     529 LONG     lComplexity;
     530 int      rc;
     531
     532    if(!hdc || !lpRect || !pHps) {
     533        dprintf(("GDI32: GetClipBox %x %x ERROR_INVALID_PARAMETER", hdc, lpRect));
     534        SetLastError(ERROR_INVALID_PARAMETER_W);
     535        return ERROR_W;
     536    }
     537    if(pHps->isPrinter)
     538    {
     539        lpRect->left   = 0;
     540        lpRect->top    = 0;
     541        lpRect->right  = GetDeviceCaps( hdc, HORZRES_W);
     542        lpRect->bottom = GetDeviceCaps( hdc, VERTRES_W);
     543        includeBottomRightPoint(pHps, (PPOINTLOS2)&rectl);
     544        convertPMDeviceRectToWinWorldRect(pHps, &rectl);
     545
     546        rc = SIMPLEREGION_W;
     547    }
     548    else {
     549        lComplexity = GpiQueryClipBox(pHps->hps, &rectl);
     550        if(lComplexity == RGN_ERROR)
     551        {
     552            rc = ERROR_W;
     553        }
     554        else
     555        if(lComplexity == RGN_NULL)
     556        {
     557            memset(lpRect, 0, sizeof(*lpRect));
     558            rc = NULLREGION_W;
     559        }
     560        else {
     561            //Convert including/including to including/excluding
     562            includeBottomRightPoint(pHps, (PPOINTLOS2)&rectl);
     563
     564            lpRect->left   = rectl.xLeft;
     565            lpRect->right  = rectl.xRight;
     566            //No conversion required as GpiQueryClipBox is affected by
     567            //the y-inversion of the window
     568            //NOTE: YINVERSION dependancy
     569            lpRect->top    = rectl.yBottom;
     570            lpRect->bottom = rectl.yTop;
     571
     572            rc = (lComplexity == RGN_RECT) ? SIMPLEREGION_W : COMPLEXREGION_W;
     573        }
     574    }
     575    dprintf(("GDI32: GetClipBox of %X returned %d\n", hdc, rc));
     576    return rc;
     577}
     578//******************************************************************************
     579//******************************************************************************
     580int WIN32API GetClipRgn(HDC hdc, HRGN hrgn)
     581{
     582   pDCData    pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     583   BOOL       success;
     584   LONG       lComplexity = RGN_RECT;
     585   HRGN       hrgnClip = NULL, hrgnTemp;
     586
     587    hrgn = ObjGetHandleData(hrgn);
     588    if(hrgn == HANDLE_OBJ_ERROR || !pHps) {
     589        dprintf(("WARNING: GetClipRgn %x %x invalid handle", hdc, hrgn));
     590        SetLastError(ERROR_INVALID_HANDLE_W);
     591        return 0;
     592    }
     593
     594    if(GpiSetClipRegion(pHps->hps, NULL, &hrgnClip) == RGN_ERROR) {
     595        dprintf(("WARNING: GetClipRgn GpiSetClipRegion failed! (%x)", WinGetLastError(0)));
     596        SetLastError(ERROR_INVALID_PARAMETER_W); //todo right errror
     597        return 0;
     598    }
     599    if(hrgnClip) {
     600        if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgnClip, pHps, NULL)) {
     601                dprintf(("WARNING: GetClipRgn setWinDeviceRegionFromPMDeviceRegion failed!"));
     602                GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnTemp);
     603                SetLastError(ERROR_INVALID_PARAMETER_W); //todo right errror
     604                return 0;
     605        }
     606        if(GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnTemp) == RGN_ERROR )
     607        {
     608            dprintf(("WARNING: GetClipRgn GpiSetClipRegion failed %x!", WinGetLastError(0)));
     609            SetLastError(ERROR_INVALID_PARAMETER_W); //todo right errror
     610            return 0;
     611        }
     612    }
     613    else lComplexity = RGN_NULL;
     614
     615    dprintf(("GetClipRgn %x %x returned %d", hdc, hrgn, lComplexity == RGN_NULL));
     616    SetLastError(ERROR_SUCCESS_W);
     617    if(lComplexity == RGN_NULL)
     618         return 0;
     619    else return 1;
     620}
     621//******************************************************************************
     622//******************************************************************************
     623int WIN32API ExcludeClipRect(HDC hdc, int left, int top, int right, int bottom)
     624{
     625    pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     626    if(!pHps)
     627    {
     628        dprintf(("WARNING: ExcludeClipRgn %x (%d,%d)(%d,%d) invalid hdc", hdc, left, top, right, bottom));
     629        SetLastError(ERROR_INVALID_HANDLE_W);
     630        return ERROR_W;
     631    }
     632
     633    LONG   lComplexity;
     634    RECTL  rectl = { left, bottom, right, top };
     635
     636    excludeBottomRightPoint(pHps, (PPOINTLOS2)&rectl);
     637    if(rectl.yTop < rectl.yBottom) {
     638        ULONG temp    = rectl.yBottom;
     639        rectl.yBottom = rectl.yTop;
     640        rectl.yTop    = temp;
     641    }
     642
     643    dprintf(("ExcludeClipRgn %x (%d,%d)(%d,%d)", hdc, left, top, right, bottom));
     644    lComplexity = GpiExcludeClipRectangle(pHps->hps, &rectl);
     645    if (lComplexity == RGN_ERROR) {
     646        SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
     647        return ERROR_W;
     648    }
     649
     650    //todo metafile recording
     651
     652    SetLastError(ERROR_SUCCESS_W);
     653    return lComplexity;
     654}
     655//******************************************************************************
     656//******************************************************************************
     657int WIN32API IntersectClipRect(HDC hdc, int left, int top, int right, int bottom)
     658{
     659    pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     660    LONG      lComplexity;
     661    BOOL      success;
     662
     663    if(!pHps) {
     664        dprintf(("WARNING: IntersectClipRgn %x (%d,%d)(%d,%d) invalid hdc", hdc, left, top, right, bottom));
     665        SetLastError(ERROR_INVALID_HANDLE_W);
     666        return ERROR_W;
     667    }
     668    RECTL rectl = { left, bottom, right, top };
     669
     670    excludeBottomRightPoint(pHps, (PPOINTLOS2)&rectl);
     671    if(rectl.yTop < rectl.yBottom) {
     672        ULONG temp    = rectl.yBottom;
     673        rectl.yBottom = rectl.yTop;
     674        rectl.yTop    = temp;
     675    }
     676
     677    dprintf(("IntersectClipRgn %x (%d,%d)(%d,%d)", hdc, left, top, right, bottom));
     678    lComplexity = GpiIntersectClipRectangle(pHps->hps, &rectl);
     679
     680    //todo metafile recording
     681
     682    SetLastError(ERROR_SUCCESS_W);
     683    return lComplexity;
     684}
     685//******************************************************************************
     686//******************************************************************************
     687int WIN32API OffsetClipRgn(HDC hdc, int nXOffset, int nYOffset )
     688{
     689   BOOL      success;
     690   pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     691   LONG      lComplexity;
     692
     693   if(!pHps) {
     694        dprintf(("OffsetClipRgn %x (%d,%d) invalid hdc", hdc, nXOffset, nYOffset));
     695        SetLastError(ERROR_INVALID_HANDLE_W);
     696        return ERROR_W;
     697   }
     698
     699   dprintf(("OffsetClipRgn %x (%d,%d)", hdc, nXOffset, nYOffset));
     700   POINTL  pointl = { nXOffset, nYOffset };
     701   lComplexity = GpiOffsetClipRegion(pHps->hps, &pointl);
     702
     703   //todo metafile recording
     704
     705   SetLastError(ERROR_SUCCESS_W);
     706   return lComplexity;
     707}
     708//******************************************************************************
     709//******************************************************************************
     710HRGN WIN32API CreatePolyPolygonRgn(const POINT * lppt, const int *pPolyCount, int nCount, int fnPolyFillMode)
     711{
     712 LONG  flMode;
     713
     714   switch(fnPolyFillMode)
     715   {
     716   case ALTERNATE_W:
     717        flMode = POLYGON_ALTERNATE;
     718        break;
     719   case WINDING_W:
     720        flMode = POLYGON_WINDING;
     721        break;
     722   default:
     723        dprintf(("WARNING: CreatePolyPolygonRgn %x %x %d %d invalid parameter", lppt, pPolyCount, nCount, fnPolyFillMode));
     724        SetLastError(ERROR_INVALID_PARAMETER_W);
     725        return 0;
     726   }
     727
     728   if(nCount < 1)
     729   {
     730        dprintf(("WARNING: CreatePolyPolygonRgn %x %x %d %d invalid parameter", lppt, pPolyCount, nCount, fnPolyFillMode));
     731        SetLastError(ERROR_INVALID_PARAMETER_W);
     732        return 0;
     733   }
     734
     735   PPOLYGON pPolygon = new POLYGON[nCount];
     736   if(!pPolygon) {
     737        dprintf(("ERROR: CreatePolyPolygonRgn: out of memory!!"));
     738        SetLastError(ERROR_OUTOFMEMORY_W);
     739        return 0;
     740   }
     741   dprintf(("CreatePolyPolygonRgn %x %x %d %d", lppt, pPolyCount, nCount, fnPolyFillMode));
     742
     743   PPOINTL pPointl = (PPOINTL)lppt+1;     // skip first point
     744   for (int x=0; x < nCount; x++) {
     745        pPolygon[x].ulPoints = (x == 0) ? pPolyCount[x] - 1 : pPolyCount[x];
     746        pPolygon[x].aPointl  = pPointl;
     747        pPointl += pPolygon[x].ulPoints;
     748   }
     749   GpiMove(hpsRegion, (PPOINTL)lppt);
     750   HRGN hrgn = GpiCreatePolygonRegion(hpsRegion, nCount, pPolygon, POLYGON_BOUNDARY | flMode);
     751
     752   delete[] pPolygon;
     753
     754   if(!hrgn) {
     755        SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
     756        return 0;
     757   }
     758
     759   if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {
     760        SetLastError(ERROR_OUTOFMEMORY_W);
     761        return 0;
     762   }
     763   SetLastError(ERROR_SUCCESS_W);
     764   return hrgn;
     765}
     766//******************************************************************************
     767//******************************************************************************
     768HRGN WIN32API CreateRectRgn( int left, int top, int right, int bottom)
     769{
     770 HRGN   hrgn;
     771 RECTL  rectl = { left, top < bottom ? top : bottom, right, top < bottom ? bottom : top };
     772
     773   hrgn = GpiCreateRegion(hpsRegion, 1, &rectl);
     774   if(!hrgn) {
     775        dprintf(("WARNING: CreateRectRgn: GpiCreateRectRegion failed! %x", WinGetLastError(0)));
     776        SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
     777        return 0;
     778   }
     779
     780   if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {
     781        SetLastError(ERROR_OUTOFMEMORY_W);
     782        return 0;
     783   }
     784   dprintf(("CreateRectRegion (%d,%d)(%d,%d) returned %x", left, top, right, bottom, hrgn));
     785   SetLastError(ERROR_SUCCESS_W);
     786   return hrgn;
     787}
     788//******************************************************************************
     789//******************************************************************************
     790HRGN WIN32API CreateRectRgnIndirect(const RECT *lprc)
     791{
     792   return CreateRectRgn(lprc->left, lprc->top, lprc->right, lprc->bottom);
     793}
     794//******************************************************************************
     795//******************************************************************************
     796HRGN WIN32API CreateRoundRectRgn(int left, int top, int right, int bottom, int nWidthEllipse, int nHeightEllipse)
     797{
     798 HRGN   hrgn;
     799 RECTL  rectl = { left, top < bottom ? top : bottom, right, top < bottom ? bottom : top };
     800
     801   PPOINTL pPointl = (PPOINTL)&rectl;
     802
     803   GpiMove(hpsRegion, &pPointl[0]);
     804   hrgn = GpiCreateRoundRectRegion(hpsRegion, &pPointl[1], labs(nWidthEllipse), labs(nHeightEllipse));
     805
     806   if(!hrgn) {
     807        SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
     808        dprintf(("WARNING: CreateRoundRectRgn: GpiCreateRoundRectRegion failed! %x", WinGetLastError(0)));
     809        return 0;
     810   }
     811
     812   if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {
     813        SetLastError(ERROR_OUTOFMEMORY_W);
     814        return 0;
     815   }
     816   dprintf(("CreateRoundRectRegion (%d,%d)(%d,%d) (%d,%d) returned %x", left, top, right, bottom, nWidthEllipse, nHeightEllipse, hrgn));
     817   SetLastError(ERROR_SUCCESS_W);
     818   return hrgn;
     819}
     820//******************************************************************************
     821//******************************************************************************
     822HRGN WIN32API ExtCreateRegion(const XFORM_W *pXform, DWORD count, const RGNDATA *pData)
     823{
     824   HRGN hrgn;
     825
     826    if(!pData || count < (sizeof(RGNDATAHEADER) +  pData->rdh.nCount * sizeof(RECT))) {
     827        dprintf(("WARNING: ExtCreateRegion %x %d %x; invalid parameter", pXform, count, pData));
     828        SetLastError(ERROR_INVALID_PARAMETER_W);
     829        return 0;
     830    }
     831
     832    PRECTL  pRectl     = new RECTL[pData->rdh.nCount];
     833    PRECT pDataRects = (PRECT)pData->Buffer;
     834    for(int i=0; i < pData->rdh.nCount; i++) {
     835        MapWin32ToOS2Rect(pDataRects[i], pRectl[i]);
     836    }
     837
     838    BOOL doShear = pXform && (pXform->eM12 || pXform->eM21);
     839    HPS  hpsTemp = NULLHANDLE;
     840
     841    dprintf(("ExtCreateRegion %x %d %x", pXform, count, pData));
     842    if(doShear) {
     843         hpsTemp = WinGetPS(HWND_DESKTOP);
     844         GpiBeginPath(hpsTemp, 1);
     845
     846         MATRIXLF  matrixlf;
     847         matrixlf.fxM11  = pXform->eM11 * (float)0x10000;
     848         matrixlf.fxM12  = pXform->eM12 * (float)0x10000;
     849         matrixlf.lM13   = 0;
     850         matrixlf.fxM21  = pXform->eM21 * (float)0x10000;
     851         matrixlf.fxM22  = pXform->eM22 * (float)0x10000;
     852         matrixlf.lM23   = 0;
     853         matrixlf.lM31   = pXform->eDx;
     854         matrixlf.lM32   = pXform->eDy;
     855         matrixlf.lM33   = 1;
     856
     857         GpiSetModelTransformMatrix(hpsTemp, 9, &matrixlf, TRANSFORM_REPLACE);
     858    }
     859
     860    for(i=0; i < pData->rdh.nCount; i++)
     861    {
     862         LONG temp         = pRectl[i].yTop;
     863         pRectl[i].yTop    = pRectl[i].yBottom;
     864         pRectl[i].yBottom = temp;
     865
     866         if(pXform)
     867         {
     868            PPOINTL pPointl = ((PPOINTL)&pRectl[i]);
     869
     870            if (doShear) {
     871                GpiMove(hpsTemp, pPointl);
     872                GpiBox(hpsTemp, DRO_OUTLINE, pPointl+1, 0, 0);
     873            }
     874            else
     875            {
     876                for(int j=0; j < 2; j++) {
     877                    pPointl[j].x = (pXform->eM11 * (float)pPointl[j].x) + (pXform->eM12 * (float)pPointl[j].y) + pXform->eDx;
     878                    pPointl[j].y = (pXform->eM21 * (float)pPointl[j].x) + (pXform->eM22 * (float)pPointl[j].y) + pXform->eDy;
     879                }
     880
     881                PRECTL pRectlT = (PRECTL)pPointl;
     882                if (pRectlT->xLeft > pRectlT->xRight) {
     883                    LONG temp       = pRectlT->xLeft;
     884                    pRectlT->xLeft  = pRectlT->xRight;
     885                    pRectlT->xRight = temp;
     886                }
     887                if (pRectlT->yBottom > pRectlT->yTop) {
     888                    LONG temp         = pRectlT->yBottom;
     889                    pRectlT->yBottom  = pRectlT->yTop;
     890                    pRectlT->yTop     = temp;
     891                }
     892            }
     893         }
     894    }
     895
     896    if(doShear) {
     897            GpiEndPath(hpsTemp);
     898            hrgn = GpiPathToRegion(hpsTemp, 1, FPATH_WINDING);
     899
     900            if(pRectl)
     901                delete[] pRectl;
     902
     903            if(hrgn == 0) {
     904                dprintf(("WARNING: ExtCreateRegion GpiCreateRegion failed! (%x)", WinGetLastError(0)));
     905                SetLastError(ERROR_INVALID_PARAMETER_W);
     906                return 0;
     907            }
     908            WinReleasePS(hpsTemp);
     909    }
     910    else {
     911            hrgn = GpiCreateRegion(hpsRegion, pData->rdh.nCount, pRectl);
     912            if(pRectl)
     913                delete[] pRectl;
     914
     915            if(hrgn == 0) {
     916                dprintf(("WARNING: ExtCreateRegion GpiCreateRegion failed! (%x)", WinGetLastError(0)));
     917                SetLastError(ERROR_INVALID_PARAMETER_W);
     918                return 0;
     919            }
     920    }
     921
     922    if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {
     923            SetLastError(ERROR_OUTOFMEMORY_W);
     924            return 0;
     925    }
     926    SetLastError(ERROR_SUCCESS_W);
     927    return hrgn;
     928}
     929//******************************************************************************
     930//******************************************************************************
     931HRGN WIN32API CreateEllipticRgn(int left, int top, int right, int bottom)
     932{
     933 HRGN hrgn;
     934
     935    RECTL  rectl = { left,
     936                     top < bottom ? top : bottom,
     937                     right,
     938                     top < bottom ? bottom : top };
     939
     940    dprintf(("CreateEllipticRgn (%d,%d)(%d,%d)", left, top, right, bottom));
     941    hrgn = GpiCreateEllipticRegion(hpsRegion, &rectl);
     942
     943    if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {
     944            SetLastError(ERROR_OUTOFMEMORY_W);
     945            return 0;
     946    }
     947    SetLastError(ERROR_SUCCESS_W);
     948    return hrgn;
     949}
     950//******************************************************************************
     951//******************************************************************************
     952HRGN WIN32API CreateEllipticRgnIndirect(const RECT *pRect)
     953{
     954   return CreateEllipticRgn(pRect->left, pRect->top, pRect->right, pRect->bottom);
     955}
     956//******************************************************************************
     957//******************************************************************************
     958HRGN WIN32API CreatePolygonRgn(const POINT *lppt, int cPoints, int fnPolyFillMode)
     959{
     960    HRGN hrgn;
     961    LONG flMode;
     962
     963    if(!lppt || cPoints < 2) {
     964        dprintf(("WARNING: CreatePolygonRgn %x %d %d invalid parameter", lppt, cPoints, fnPolyFillMode));
     965        SetLastError(ERROR_INVALID_PARAMETER_W);
     966        return 0;
     967    }
     968
     969    switch (fnPolyFillMode)
     970    {
     971    case ALTERNATE_W :
     972        flMode = POLYGON_ALTERNATE;
     973        break;
     974    case WINDING_W   :
     975        flMode = POLYGON_WINDING;
     976        break;
     977    default:
     978        dprintf(("WARNING: CreatePolygonRgn %x %d %d invalid parameter", lppt, cPoints, fnPolyFillMode));
     979        SetLastError(ERROR_INVALID_PARAMETER_W);
     980        return 0;
     981    }
     982
     983    dprintf(("CreatePolygonRgn %x %d %d", lppt, cPoints, fnPolyFillMode));
     984
     985    POLYGON  polygon;
     986    polygon.ulPoints = cPoints - 1;
     987    polygon.aPointl  = (PPOINTL)(lppt + 1);
     988
     989    GpiMove(hpsRegion, (PPOINTL)lppt);
     990    hrgn = GpiCreatePolygonRegion(hpsRegion, 1, &polygon, POLYGON_BOUNDARY | flMode);
     991
     992    if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {
     993            SetLastError(ERROR_OUTOFMEMORY_W);
     994            return 0;
     995    }
     996    SetLastError(ERROR_SUCCESS_W);
     997    return hrgn;
     998}
     999//******************************************************************************
     1000//******************************************************************************
     1001int WIN32API CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2, int combineMode)
     1002{
     1003    ULONG lComplexity;
     1004    LONG  mode;
     1005
     1006    switch(combineMode) {
     1007    case RGN_AND_W:
     1008        mode = CRGN_AND;
     1009        break;
     1010    case RGN_COPY_W:
     1011        mode = CRGN_COPY;
     1012        break;
     1013    case RGN_DIFF_W:
     1014        mode = CRGN_DIFF;
     1015        break;
     1016    case RGN_OR_W:
     1017        mode = CRGN_OR;
     1018        break;
     1019    case RGN_XOR_W:
     1020        mode = CRGN_XOR;
     1021        break;
     1022    default:
     1023        dprintf(("WARNING: CombineRgn %x %x %x %d; invalid mode!", hrgnDest, hrgnSrc1, hrgnSrc2, combineMode));
     1024        SetLastError(ERROR_INVALID_PARAMETER_W);
     1025        return ERROR_W;
     1026    }
     1027
     1028    hrgnDest = ObjGetHandleData(hrgnDest);
     1029    hrgnSrc1 = ObjGetHandleData(hrgnSrc1);
     1030    hrgnSrc2 = ObjGetHandleData(hrgnSrc2);
     1031    if(hrgnDest == HANDLE_OBJ_ERROR || hrgnSrc1 == HANDLE_OBJ_ERROR  || (hrgnSrc2 == HANDLE_OBJ_ERROR && combineMode != RGN_COPY_W)) {
     1032        dprintf(("WARNING: CombineRgn %x %x %x %d invalid region", hrgnDest, hrgnSrc1, hrgnSrc2, combineMode));
     1033        SetLastError(ERROR_INVALID_HANDLE_W);
     1034        return ERROR_W;
     1035    }
     1036
     1037    lComplexity = GpiCombineRegion(hpsRegion, hrgnDest, hrgnSrc1, hrgnSrc2, mode);
     1038    if(lComplexity == RGN_ERROR) {
     1039        dprintf(("WARNING: CombineRgn %x %x %x %d GpiCombineRegion failed (%x)", hrgnDest, hrgnSrc1, hrgnSrc2, mode, WinGetLastError(0)));
     1040        SetLastError(ERROR_INVALID_HANDLE_W);
     1041        return ERROR_W;
     1042    }
     1043    SetLastError(ERROR_SUCCESS_W);
     1044    return lComplexity;
     1045}
     1046//******************************************************************************
     1047//******************************************************************************
     1048BOOL WIN32API EqualRgn(HRGN hrgn1, HRGN hrgn2)
     1049{
     1050   LONG lEquality;
     1051
     1052   hrgn1 = ObjGetHandleData(hrgn1);
     1053   hrgn2 = ObjGetHandleData(hrgn2);
     1054   if(hrgn1 == HANDLE_OBJ_ERROR || hrgn2 == HANDLE_OBJ_ERROR) {
     1055        dprintf(("WARNING: EqualRgn %x %x invalid region", hrgn1, hrgn2));
     1056        SetLastError(ERROR_INVALID_HANDLE_W);
     1057        return FALSE;
     1058   }
     1059   lEquality = GpiEqualRegion(hpsRegion, hrgn1, hrgn2);
     1060
     1061   dprintf(("EqualRgn %x %x = %d", hrgn1, hrgn2, lEquality));
     1062   SetLastError(ERROR_SUCCESS_W);
     1063
     1064   if(lEquality == EQRGN_EQUAL)
     1065        return TRUE;
     1066   else
     1067   if(lEquality == EQRGN_NOTEQUAL)
     1068        return FALSE;
     1069   else {
     1070        return FALSE;
     1071   }
     1072}
     1073//******************************************************************************
     1074//******************************************************************************
     1075BOOL WIN32API SetRectRgn(HRGN hrgn, int left, int top, int right, int bottom)
     1076{
     1077   BOOL    result = FALSE;
     1078
     1079    hrgn = ObjGetHandleData(hrgn);
     1080    if(hrgn == HANDLE_OBJ_ERROR) {
     1081        dprintf(("WARNING: SetRectRgn %x (%d,%d)(%d,%d) invalid region handle", hrgn, left, top, right, bottom));
     1082        SetLastError(ERROR_INVALID_HANDLE_W);
     1083        return 0;
     1084    }
     1085    RECTL rectl = { left, top, right, bottom }; //reversed y coordinates
     1086    if(GpiSetRegion(hpsRegion, hrgn, 1, &rectl)) {
     1087        dprintf(("SetRectRgn %x (%d,%d)(%d,%d)", hrgn, left, top, right, bottom));
     1088        return TRUE;
     1089    }
     1090    dprintf(("WARNING: SetRectRgn %x (%d,%d)(%d,%d) GpiSetRegion failed %x", hrgn, left, top, right, bottom, WinGetLastError(0)));
     1091    return FALSE;
     1092}
     1093//******************************************************************************
     1094//******************************************************************************
     1095ULONG WIN32API GetRegionData(HRGN hrgn, ULONG count, PRGNDATA pData)
     1096{
     1097    if(!count && pData)
     1098    {
     1099        dprintf(("WARNING: GetRegionData %x %d %x; invalid parameter", hrgn, count, pData));
     1100        SetLastError(ERROR_INVALID_PARAMETER_W);
     1101        return 0;
     1102    }
     1103    hrgn = ObjGetHandleData(hrgn);
     1104    if(hrgn == HANDLE_OBJ_ERROR) {
     1105        dprintf(("WARNING: GetRegionData %x %d %x; invalid region handle", hrgn, count, pData));
     1106        SetLastError(ERROR_INVALID_HANDLE_W);
     1107        return 0;
     1108    }
     1109    RGNRECT rgnRect;
     1110    rgnRect.ircStart    = 1;
     1111    rgnRect.crc         = 0;
     1112    rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;
     1113    if(!GpiQueryRegionRects(hpsRegion, hrgn, NULL, &rgnRect, NULL))
     1114    {
     1115        dprintf(("WARNING: GetRegionData %x %d %x: GpiQueryRegionRects failed! (%x)", hrgn, count, pData, WinGetLastError(0)));
     1116        return 0;
     1117    }
     1118
     1119    dprintf(("GetRegionData %x %d %x", hrgn, count, pData));
     1120
     1121    ULONG bufSizeNeeded = rgnRect.crcReturned * sizeof(RECT) + sizeof (RGNDATAHEADER);
     1122
     1123    if(pData && (count >= (sizeof(RGNDATAHEADER) + rgnRect.crcReturned * sizeof(RECT))))
     1124    {
     1125        //we actually need to flip the top & bottom values, but as the layout of the PM RECTL and
     1126        //Win32 RECT have exactly those two members reversed, we don't do this for the returned
     1127        //rectangles (more efficient)
     1128        PRECTL pRectl = (PRECTL)pData->Buffer;
     1129        rgnRect.crc   = rgnRect.crcReturned;
     1130        if(!GpiQueryRegionRects(hpsRegion, hrgn, NULL, &rgnRect, pRectl))
     1131        {
     1132            dprintf(("WARNING: GetRegionData: GpiQueryRegionRects failed! (%x)", WinGetLastError(0)));
     1133            return 0;
     1134        }
     1135
     1136        RECTL boundRect;
     1137        GpiQueryRegionBox(hpsRegion, hrgn, &boundRect);  // no need to check rc
     1138
     1139        pData->rdh.dwSize   = sizeof(pData->rdh);
     1140        pData->rdh.iType    = RDH_RECTANGLES_W;    // one and only possible value
     1141        pData->rdh.nCount   = rgnRect.crcReturned;
     1142        pData->rdh.nRgnSize = rgnRect.crcReturned * sizeof(RECTL);
     1143
     1144        //flip top & bottom for bounding rectangle (not really necessary; but cleaner coding)
     1145        LONG temp          = boundRect.yTop;
     1146        boundRect.yTop     = boundRect.yBottom;
     1147        boundRect.yBottom  = temp;
     1148        MapOS2ToWin32Rect(boundRect, pData->rdh.rcBound);
     1149    }
     1150
     1151    //return size needed
     1152    return bufSizeNeeded;
     1153}
     1154//******************************************************************************
     1155//******************************************************************************
     1156int WIN32API GetRgnBox(HRGN hrgn, PRECT pRect)
     1157{
     1158   BOOL      success;
     1159   LONG      lComplexity;
     1160
     1161    hrgn = ObjGetHandleData(hrgn);
     1162    if(hrgn == HANDLE_OBJ_ERROR) {
     1163        dprintf(("WARNING: GetRgnBox %x %x invalid region!", hrgn, pRect));
     1164        SetLastError(ERROR_INVALID_HANDLE_W);
     1165        return FALSE;
     1166    }
     1167
     1168    dprintf(("GetRgnBox %x %x", hrgn, pRect));
     1169
     1170    RECTL  rectl;
     1171    lComplexity = GpiQueryRegionBox(hpsRegion, hrgn, &rectl);
     1172    if(lComplexity != RGN_ERROR)
     1173    {
     1174            //no conversion required, just flip top & bottom
     1175            ULONG temp    = rectl.yBottom;
     1176            rectl.yBottom = rectl.yTop;
     1177            rectl.yTop    = temp;
     1178
     1179            MapOS2ToWin32Rect(rectl, *pRect);
     1180    }
     1181    else {
     1182            lComplexity = ERROR_W;
     1183            dprintf(("WARNING: GetRgnBox error in region!"));
     1184    }
     1185
     1186    SetLastError(ERROR_SUCCESS_W);
     1187    return lComplexity;
     1188}
     1189//******************************************************************************
     1190//******************************************************************************
     1191BOOL WIN32API InvertRgn(HDC hdc, HRGN hrgn)
     1192{
     1193    pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     1194
     1195    hrgn = ObjGetHandleData(hrgn);
     1196    if(!pHps || hrgn == HANDLE_OBJ_ERROR) {
     1197        dprintf(("WARNING: InvertRgn %x %x invalid handle!", hdc, hrgn));
     1198        SetLastError(ERROR_INVALID_HANDLE_W);
     1199        return FALSE;
     1200    }
     1201    //todo metafile recording
     1202
     1203    dprintf(("InvertRgn %x %x", hdc, hrgn));
     1204
     1205    interpretRegionAs(pHps, NULL, hrgn, AS_WORLD);
     1206
     1207    LONG  lHits = GPI_ERROR;
     1208    HRGN  hrgnOld;
     1209    LONG  lComplexity ;
     1210    RECTL boundingRect;      // this gets a rectangle in world cordinates!
     1211
     1212    lComplexity = GpiQueryRegionBox(pHps->hps, pHps->hrgnHDC, &boundingRect);
     1213    if(lComplexity != RGN_ERROR)
     1214    {
     1215        lComplexity = GpiSetClipRegion(pHps->hps, pHps->hrgnHDC, &hrgnOld);
     1216        if(lComplexity != RGN_ERROR)
     1217        {
     1218            RECTL rectls[2];
     1219            rectls[0] = boundingRect;
     1220            rectls[1] = boundingRect;
     1221            lHits = GpiBitBlt(pHps->hps, NULL, 3, (PPOINTL)rectls,
     1222                              ROP_DSTINVERT, 0);
     1223
     1224            /* Restore the old region */
     1225            GpiSetClipRegion(pHps->hps, hrgnOld, &hrgnOld);
     1226        }
     1227    }
     1228
     1229    if(lHits == GPI_ERROR || lComplexity == RGN_ERROR)
     1230    {
     1231        dprintf(("WARNING: InvertRgn error during Gpi operation (%x) (%d,%d)", WinGetLastError(0), lHits, lComplexity));
     1232        return FALSE;
     1233    }
     1234
     1235    return TRUE;
     1236}
     1237//******************************************************************************
     1238//******************************************************************************
     1239int WIN32API OffsetRgn(HRGN hrgn, int xOffset, int yOffset)
     1240{
     1241   LONG   lComplexity;
     1242
     1243    hrgn = ObjGetHandleData(hrgn);
     1244    if(hrgn == HANDLE_OBJ_ERROR) {
     1245        dprintf(("WARNING: OffsetRgn %x %d %d invalid handle!", hrgn, xOffset, yOffset));
     1246        SetLastError(ERROR_INVALID_HANDLE_W);
     1247        return ERROR_W;
     1248    }
     1249    dprintf(("OffsetRgn %x %d %d", hrgn, xOffset, yOffset));
     1250
     1251    POINTL   ptlOffset = {xOffset, yOffset};
     1252    GpiOffsetRegion(hpsRegion, hrgn, &ptlOffset);
     1253
     1254    RGNRECT  rgnRect;
     1255    rgnRect.ircStart    = 1;
     1256    rgnRect.crc         = 0;
     1257    rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;     // doesn't make a difference
     1258    if(GpiQueryRegionRects(hpsRegion, hrgn, NULL, &rgnRect, NULL))
     1259    {
     1260        switch (rgnRect.crcReturned) {
     1261        case 0:
     1262                lComplexity = NULLREGION_W;
     1263                break;
     1264        case 1:
     1265                lComplexity = SIMPLEREGION_W;
     1266                break;
     1267        default:
     1268                lComplexity = COMPLEXREGION_W;
     1269                break;
     1270        }
     1271   }
     1272   else {
     1273        lComplexity = ERROR_W;
     1274        dprintf(("WARNING: OffsetRgn error in region! (%x)", WinGetLastError(0)));
     1275   }
     1276
     1277   SetLastError(ERROR_SUCCESS_W);
     1278
     1279   return lComplexity;
     1280}
     1281//******************************************************************************
     1282//******************************************************************************
     1283BOOL WIN32API FrameRgn(HDC hdc, HRGN hrgn, HBRUSH hBrush, int width, int height)
     1284{
     1285    HBRUSH hbrushRestore = 0;
     1286    pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     1287
     1288    hrgn = ObjGetHandleData(hrgn);
     1289    if(!pHps || hrgn == HANDLE_OBJ_ERROR) {
     1290        dprintf(("WARNING: FrameRgn %x %x %x (%d,%d) invalid handle!", hdc, hrgn, hBrush, width, height));
     1291        SetLastError(ERROR_INVALID_HANDLE_W);
     1292        return FALSE;
     1293    }
     1294
     1295    width  = abs(width);
     1296    height = abs(height);
     1297
     1298    if(pHps->lastBrushHandle != (UINT)hBrush)
     1299    {
     1300        hbrushRestore = SelectObject(hdc, hBrush);
     1301        if(!hbrushRestore)
     1302        {
     1303            dprintf(("WARNING: FrameRgn %x %x %x (%d,%d) invalid brush!", hdc, hrgn, hBrush, width, height));
     1304            SetLastError(ERROR_INVALID_HANDLE_W);
     1305            return FALSE;
     1306        }
     1307    }
     1308    dprintf(("FrameRgn %x %x %x (%d,%d)", hdc, hrgn, hBrush, width, height));
     1309    interpretRegionAs(pHps, NULL, hrgn, AS_WORLD);
     1310
     1311    SIZEL  thickness = { width, height };
     1312    LONG   lHits = GpiFrameRegion(pHps->hps, pHps->hrgnHDC, &thickness);
     1313
     1314    SetLastError(ERROR_SUCCESS_W);
     1315
     1316    // Restore the brush if necessary
     1317    if(hbrushRestore)
     1318        SelectObject(hdc, hbrushRestore);
     1319
     1320    //todo metafile recording
     1321    return (lHits != GPI_ERROR);
     1322}
     1323//******************************************************************************
     1324//******************************************************************************
     1325BOOL WIN32API FillRgn(HDC hdc, HRGN hrgn, HBRUSH hBrush)
     1326{
     1327 BOOL   success;
     1328 HBRUSH hbrushRestore = 0;
     1329
     1330    pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     1331
     1332    hrgn = ObjGetHandleData(hrgn);
     1333    if(!pHps || hrgn == HANDLE_OBJ_ERROR) {
     1334        dprintf(("WARNING: FillRgn %x %x %x invalid handle!", hdc, hrgn, hBrush));
     1335        SetLastError(ERROR_INVALID_HANDLE_W);
     1336        return FALSE;
     1337    }
     1338
     1339    if(pHps->lastBrushHandle != (UINT)hBrush)
     1340    {
     1341        hbrushRestore = SelectObject(hdc, hBrush);
     1342        if (!hbrushRestore)
     1343        {
     1344            dprintf(("WARNING: FillRgn %x %x %x invalid brush!", hdc, hrgn, hBrush));
     1345            SetLastError(ERROR_INVALID_HANDLE_W);
     1346            return FALSE;
     1347        }
     1348    }
     1349    dprintf(("FillRgn %x %x %x", hdc, hrgn, hBrush));
     1350
     1351    interpretRegionAs(pHps, NULL, hrgn, AS_WORLD);
     1352
     1353    success = GpiPaintRegion(pHps->hps, pHps->hrgnHDC);
     1354
     1355    //todo metafile recording
     1356
     1357    /* Restore the brush if necessary */
     1358    if(hbrushRestore)
     1359        SelectObject(hdc, hbrushRestore);
     1360
     1361    return(success);
     1362}
     1363//******************************************************************************
     1364//******************************************************************************
     1365BOOL WIN32API PaintRgn(HDC hdc, HRGN hrgn)
     1366{
     1367   pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     1368   if(!pHps)
     1369   {
     1370      SetLastError(ERROR_INVALID_HANDLE_W);
     1371      return FALSE;
     1372   }
     1373
     1374   return FillRgn(hdc, hrgn, (HBRUSH) pHps->lastBrushHandle);
     1375}
     1376//******************************************************************************
     1377//******************************************************************************
     1378BOOL WIN32API PtInRegion( HRGN hrgn, int x, int y)
     1379{
     1380   BOOL      success;
     1381   LONG      lInside;
     1382
     1383    hrgn = ObjGetHandleData(hrgn);
     1384    if(hrgn == HANDLE_OBJ_ERROR) {
     1385        dprintf(("WARNING: PtInRgn %x (%d,%d) invalid region!", hrgn, x, y));
     1386        SetLastError(ERROR_INVALID_HANDLE_W);
     1387        return FALSE;
     1388    }
     1389
     1390    POINTL pointl = {x,y};
     1391    lInside = GpiPtInRegion(hpsRegion, hrgn, &pointl);
     1392    if(lInside == PRGN_ERROR) {
     1393         success = FALSE;
     1394    }
     1395    else success = TRUE;
     1396
     1397    SetLastError(ERROR_SUCCESS_W);
     1398
     1399    dprintf(("WARNING: PtInRgn %x (%d,%d) returned %d", hrgn, x, y, (success && lInside == PRGN_INSIDE) ? 1 : 0));
     1400
     1401    if(success && lInside == PRGN_INSIDE)
     1402        return TRUE;
     1403    else
     1404        return FALSE;
     1405}
     1406//******************************************************************************
     1407//******************************************************************************
     1408BOOL WIN32API RectInRegion(HRGN hrgn, const RECT *pRect)
     1409{
     1410   BOOL      success;
     1411   LONG      lInside;
     1412
     1413    if(!pRect) {
     1414        dprintf(("WARNING: RectInRgn %x %x invalid parameter!", hrgn, pRect));
     1415        SetLastError(ERROR_INVALID_PARAMETER_W);
     1416        return FALSE;
     1417    }
     1418    hrgn = ObjGetHandleData(hrgn);
     1419    if(hrgn == HANDLE_OBJ_ERROR) {
     1420        dprintf(("WARNING: RectInRgn %x %x invalid region", hrgn, pRect));
     1421        SetLastError(ERROR_INVALID_HANDLE_W);
     1422        return FALSE;
     1423    }
     1424
     1425    RECTL rectl;
     1426    MapWin32ToOS2Rect(*pRect, rectl);
     1427    //switch bottom & top
     1428    UINT temp     = rectl.yBottom;
     1429    rectl.yBottom = rectl.yTop;
     1430    rectl.yTop    = temp;
     1431
     1432    lInside = GpiRectInRegion(hpsRegion, hrgn, &rectl);
     1433    if(lInside == RRGN_ERROR) {
     1434            success = FALSE;
     1435    }
     1436    else    success = TRUE;
     1437
     1438    SetLastError(ERROR_SUCCESS_W);
     1439
     1440    dprintf(("WARNING: RectInRgn %x %x returned %d", hrgn, pRect, (success && (lInside == RRGN_INSIDE || lInside == RRGN_PARTIAL)) ? 1 : 0));
     1441
     1442    if(success && (lInside == RRGN_INSIDE || lInside == RRGN_PARTIAL))
     1443        return TRUE;
     1444    else
     1445        return FALSE;
     1446}
     1447//******************************************************************************
     1448//Returned region in device coordinates (undocumented behaviour)
     1449//******************************************************************************
     1450HRGN WIN32API PathToRegion(HDC hdc)
     1451{
     1452    pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     1453    if(!pHps)
     1454    {
     1455        dprintf(("WARNING: PathToRegion %x; invalid hdc!", hdc));
     1456        SetLastError(ERROR_INVALID_HANDLE_W);
     1457        return NULLHANDLE;
     1458    }
     1459
     1460    HRGN hrgn, hrgnTemp, hrgnwin;
     1461
     1462    dprintf(("GDI32: PathToRegion %x", hdc));
     1463
     1464    hrgnTemp = GpiPathToRegion(pHps->hps, 1, (pHps->polyFillMode == ALTERNATE_W) ? FPATH_ALTERNATE : FPATH_WINDING);
     1465    if(hrgnTemp == NULLHANDLE)
     1466        goto error;
     1467
     1468    hrgnwin = CreateRectRgn(1, 1, 2, 2);
     1469    hrgn = ObjGetHandleData(hrgnwin);
     1470    if(hrgn == HANDLE_OBJ_ERROR) {
     1471        dprintf(("WARNING: PathToRegion invalid region", hrgnwin));
     1472        SetLastError(ERROR_INVALID_HANDLE_W);
     1473        return NULLHANDLE;
     1474    }
     1475
     1476    if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgnTemp, pHps, NULL))
     1477        goto error;
     1478
     1479    GpiDestroyRegion(pHps->hps, hrgnTemp);
     1480
     1481    return hrgnwin;
     1482
     1483error:
     1484    if(hrgnwin)
     1485        DeleteObject(hrgnwin);
     1486
     1487    SetLastError(ERROR_INVALID_HANDLE_W);       //todo right error
     1488    return NULLHANDLE;
     1489}
     1490//******************************************************************************
     1491//******************************************************************************
     1492void OSLibDeleteRegion(HANDLE hRegion)
     1493{
     1494    if(GpiDestroyRegion(hpsRegion, hRegion) == FALSE) {
     1495        dprintf(("WARNING: OSLibDeleteRegion %x; GpiDestroyRegion failed (%x)", hRegion, WinGetLastError(0)));
     1496    }
    1791497}
    1801498/*****************************************************************************
     
    1931511
    1941512int WIN32API GetMetaRgn(HDC  hdc,
    195                            HRGN hrgn)
     1513                        HRGN hrgn)
    1961514{
    1971515  dprintf(("GDI32: GetMetaRgn(%08xh, %08xh) not implemented.\n",
     
    1991517           hrgn));
    2001518
     1519  SetLastError(ERROR_SUCCESS_W);
    2011520  return (0);
    2021521}
     
    2211540           hdc));
    2221541
    223   return (NULLREGION);
    224 }
    225 //******************************************************************************
    226 //******************************************************************************
     1542  SetLastError(ERROR_SUCCESS_W);
     1543  return (NULLREGION_W);
     1544}
     1545//******************************************************************************
     1546//******************************************************************************
  • trunk/src/user32/USER32.DEF

    r3679 r3705  
    1 ; $Id: USER32.DEF,v 1.33 2000-06-08 18:10:08 sandervl Exp $
     1; $Id: USER32.DEF,v 1.34 2000-06-14 13:15:23 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    646646    _KEYBOARD_Enable@4                                           @2011
    647647
    648     ;SvL: Belongs in GDI32, but put in dc.cpp to group similar apis
    649     _GetClipBox@8                                                @2014
    650     _GetClipRgn@8                                                @2015
    651     _ExtSelectClipRgn@12                                         @2016
    652     _ExcludeClipRect@20                                          @2017
    653     _IntersectClipRect@20                                        @2018
    654     _OffsetClipRgn@12                                            @2019
    655     _SelectClipRgn@8                                             @2020
    656 
     648    ;SvL: Used by GDI32
     649    OSLibGetScreenHeight__Fv                                     @2013
     650    OSLibGetScreenWidth__Fv                                      @2014
  • trunk/src/user32/dcrgn.cpp

    r3679 r3705  
    1 /* $Id: dcrgn.cpp,v 1.1 2000-06-08 18:10:10 sandervl Exp $ */
     1/* $Id: dcrgn.cpp,v 1.2 2000-06-14 13:15:24 sandervl Exp $ */
    22
    33/*
     
    3333#include "oslibmsg.h"
    3434#include <dcdata.h>
     35#include <objhandle.h>
     36#include <wingdi32.h>
    3537
    3638#define INCLUDED_BY_DC
     
    4244//******************************************************************************
    4345//******************************************************************************
    44 int WIN32API GetClipBox( HDC hdc, PRECT lpRect)
    45 {
    46  pDCData  pHps = (pDCData)GpiQueryDCData((HPS)hdc);
    47  RECTL    rectl;
    48  LONG     lComplexity;
    49  int      rc;
    50 
    51     if(!hdc || !lpRect || !pHps) {
    52         dprintf(("GDI32: GetClipBox %x %x ERROR_INVALID_PARAMETER", hdc, lpRect));
    53         SetLastError(ERROR_INVALID_PARAMETER_W);
    54         return ERROR_W;
    55     }
    56     if(pHps->isPrinter)
    57     {
    58         lpRect->left   = 0;
    59         lpRect->top    = 0;
    60         lpRect->right  = GetDeviceCaps( hdc, HORZRES_W);
    61         lpRect->bottom = GetDeviceCaps( hdc, VERTRES_W);
    62 
    63         rc = SIMPLEREGION_W;
    64     }
    65     else {
    66         lComplexity = GpiQueryClipBox(pHps->hps, &rectl);
    67         if(lComplexity == RGN_ERROR)
    68         {
    69                 rc = ERROR_W;
    70         }
    71         else
    72         if(lComplexity == RGN_NULL)
    73         {
    74                 memset(lpRect, 0, sizeof(*lpRect));
    75                 rc = NULLREGION_W;
    76         }
    77         else {
    78                 lpRect->left   = rectl.xLeft;
    79                 lpRect->right  = rectl.xRight;
    80 #if 0
    81                 lpRect->top    = pHps->height - rectl.yTop;
    82                 lpRect->bottom = pHps->height - rectl.yBottom;
    83 #else
    84                 //No conversion required as GpiQueryClipBox is affected by
    85                 //the y-inversion of the window
    86                 lpRect->top    = rectl.yBottom;
    87                 lpRect->bottom = rectl.yTop;
    88 #endif
    89                 //Convert including/including to including/excluding
    90                 if(lpRect->left != lpRect->right) {
    91                         lpRect->right++;
    92                 }
    93                 if(lpRect->top != lpRect->bottom) {
    94                         lpRect->bottom++;
    95                 }
    96                 rc = (lComplexity == RGN_RECT) ? SIMPLEREGION_W : COMPLEXREGION_W;
    97         }
    98     }
    99     dprintf(("GDI32: GetClipBox of %X returned %d\n", hdc, rc));
    100     return rc;
    101 }
    102 //******************************************************************************
    103 //******************************************************************************
    104 int WIN32API GetClipRgn( HDC hdc, HRGN hRgn)
    105 {
    106  int rc;
    107 
    108     rc = O32_GetClipRgn(hdc, hRgn);
    109     dprintf(("GDI32: GetClipRgn %x %x returned %x", hdc, hRgn, rc));
    110     return rc;
    111 }
    112 //******************************************************************************
    113 //******************************************************************************
    114 int WIN32API ExcludeClipRect( HDC arg1, int arg2, int arg3, int arg4, int  arg5)
    115 {
    116     dprintf(("GDI32: ExcludeClipRect"));
    117     return O32_ExcludeClipRect(arg1, arg2, arg3, arg4, arg5);
    118 }
    119 //******************************************************************************
    120 //******************************************************************************
    121 int WIN32API IntersectClipRect(HDC arg1, int arg2, int arg3, int arg4, int  arg5)
    122 {
    123  int rc;
    124 
    125   rc = O32_IntersectClipRect(arg1, arg2, arg3, arg4, arg5);
    126   dprintf(("GDI32: IntersectClipRect returned %d\n", rc));
    127   return(rc);
    128 }
    129 //******************************************************************************
    130 //******************************************************************************
    131 int WIN32API ExtSelectClipRgn( HDC arg1, HRGN arg2, int  arg3)
    132 {
    133     dprintf(("GDI32: ExtSelectClipRgn"));
    134     return O32_ExtSelectClipRgn(arg1, arg2, arg3);
    135 }
    136 //******************************************************************************
    137 //******************************************************************************
    138 int WIN32API OffsetClipRgn( HDC arg1, int arg2, int  arg3)
    139 {
    140     dprintf(("GDI32: OffsetClipRgn"));
    141     return O32_OffsetClipRgn(arg1, arg2, arg3);
    142 }
    143 //******************************************************************************
    144 //******************************************************************************
    145 int WIN32API SelectClipRgn( HDC hdc, HRGN hRgn)
    146 {
    147     dprintf(("GDI32: SelectClipRgn %x %x", hdc, hRgn));
    148     return O32_SelectClipRgn(hdc, hRgn);
    149 }
    150 //******************************************************************************
    151 //******************************************************************************
    152 BOOL WIN32API GetUpdateRect (HWND hwnd, LPRECT pRect, BOOL erase)
     46BOOL WIN32API GetUpdateRect(HWND hwnd, LPRECT pRect, BOOL erase)
    15347{
    15448   if (!hwnd)
     
    228122//******************************************************************************
    229123//******************************************************************************
    230 int WIN32API GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
    231 {
    232    LONG Complexity;
    233 
     124int WIN32API GetUpdateRgn(HWND hwnd, HRGN hrgn, BOOL erase)
     125{
     126   LONG lComplexity;
    234127   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    235128
    236    if (!wnd)
    237    {
    238       SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    239       return ERROR_W;
    240    }
    241 
    242    Complexity = O32_GetUpdateRgn (wnd->getOS2WindowHandle(), hrgn, FALSE);
    243    if (erase && (Complexity > NULLREGION_W)) sendEraseBkgnd(wnd);
    244 
    245    return Complexity;
    246 }
    247 //******************************************************************************
    248 //******************************************************************************
    249 INT WIN32API ExcludeUpdateRgn( HDC hDC, HWND  hWnd)
    250 {
    251     dprintf(("USER32:  ExcludeUpdateRgn\n"));
    252     hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
    253 
    254     return O32_ExcludeUpdateRgn(hDC,hWnd);
     129   hrgn = ObjWinToOS2Region(hrgn);
     130   if(!wnd || !hrgn)
     131   {
     132        dprintf(("WARNING: GetUpdateRgn %x %x %d; invalid handle", hwnd, hrgn, erase));
     133        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     134        return ERROR_W;
     135   }
     136   lComplexity = WinQueryUpdateRegion(wnd->getOS2WindowHandle(), hrgn);
     137   if(lComplexity == RGN_ERROR) {
     138        dprintf(("WARNING: GetUpdateRgn %x %x %d; RGN_ERROR", hwnd, hrgn, erase));
     139        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     140        return ERROR_W;
     141   }
     142
     143   if(lComplexity != RGN_NULL)
     144   {
     145        if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgn, NULL, wnd->getOS2WindowHandle()))
     146        {
     147                dprintf(("WARNING: GetUpdateRgn %x %x %d; setWinDeviceRegionFromPMDeviceRegion failed!", hwnd, hrgn, erase));
     148                SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     149                return ERROR_W;
     150        }
     151
     152        if(erase) sendEraseBkgnd(wnd);
     153   }
     154
     155   return lComplexity;
     156}
     157//******************************************************************************
     158//TODO: Check
     159//******************************************************************************
     160INT WIN32API ExcludeUpdateRgn(HDC hdc, HWND hwnd)
     161{
     162   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     163   pDCData          pHps = (pDCData)GpiQueryDCData((HPS)hdc);
     164   LONG             lComplexity;
     165
     166   if(!wnd || !pHps)
     167   {
     168        dprintf(("WARNING: ExcludeUpdateRgn %x %x; invalid handle", hdc, hwnd));
     169        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     170        return ERROR_W;
     171   }
     172   dprintf(("USER32: ExcludeUpdateRgn %x %x", hdc, hwnd));
     173
     174   lComplexity = WinExcludeUpdateRegion(pHps->hps, wnd->getOS2WindowHandle());
     175   if(lComplexity == RGN_ERROR) {
     176        SetLastError(ERROR_INVALID_HANDLE_W); //todo: correct error
     177   }
     178   else SetLastError(ERROR_SUCCESS_W);
     179   return lComplexity;      // windows and PM values are identical
    255180}
    256181/*****************************************************************************
  • trunk/src/user32/oslibwin.cpp

    r3662 r3705  
    1 /* $Id: oslibwin.cpp,v 1.79 2000-06-07 14:51:26 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.80 2000-06-14 13:15:24 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    812812//******************************************************************************
    813813//******************************************************************************
     814ULONG OSLibGetScreenHeight()
     815{
     816  return ScreenHeight;
     817}
     818//******************************************************************************
     819//******************************************************************************
     820ULONG OSLibGetScreenWidth()
     821{
     822  return ScreenWidth;
     823}
     824//******************************************************************************
     825//******************************************************************************
  • trunk/src/user32/pmwindow.cpp

    r3679 r3705  
    1 /* $Id: pmwindow.cpp,v 1.93 2000-06-08 18:10:10 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.94 2000-06-14 13:15:24 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    200200    case WM_CREATE:
    201201    {
     202        RestoreOS2TIB();
     203        PMFrameWindowProc(hwnd, msg, mp1, mp2);
     204        SetWin32TIB();
    202205
    203206        if(thdb->newWindow == 0)
     
    213216            return (MRESULT)TRUE; //discontinue window creation
    214217        }
    215         RestoreOS2TIB();
    216         PMFrameWindowProc(hwnd, msg, mp1, mp2);
    217         SetWin32TIB();
    218218    createfail:
    219219        RestoreOS2TIB();
     
    235235        win32wnd->MsgDestroy();
    236236        WinSetVisibleRegionNotify(hwnd, FALSE);
    237         goto RunDefWndProc;
     237        goto RunDefFrameProc;
    238238
    239239    case WM_ENABLE:
     
    450450        dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
    451451
     452        WinSetWindowUShort(hwnd,QWS_FLAGS, SHORT1FROMMP(mp1) ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
    452453        if(win32wnd->IsWindowCreated())
    453454        {
    454           WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
    455455          win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
    456456
     
    463463          }
    464464        }
    465 
    466         break;
     465        RestoreOS2TIB();
     466        return 0;
    467467    }
    468468
     
    470470    {
    471471        dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
    472         break;
    473     }
    474 
     472        goto RunDefWndProc;
     473    }
    475474
    476475    case WM_MINMAXFRAME:
     
    737736
    738737    case WM_FOCUSCHANGE:
    739         dprintf(("OS2: WM_FOCUSCHANGE %x", win32wnd->getWindowHandle()));
    740         goto RunDefWndProc;
     738        dprintf(("OS2: WM_FOCUSCHANGE %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
     739        goto RunDefFrameProc;  //partly responsible for activation of frame windows
    741740
    742741    case WM_QUERYTRACKINFO:
  • trunk/src/user32/win32wbase.cpp

    r3679 r3705  
    1 /* $Id: win32wbase.cpp,v 1.200 2000-06-08 18:10:11 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.201 2000-06-14 13:15:25 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    20532053
    20542054    dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
    2055 
     2055    if(getWindowHandle() == 0x68000030 && nCmdShow == 0) {
     2056        rc = 0;
     2057    }
    20562058    wasVisible = (getStyle() & WS_VISIBLE) != 0;
    20572059
     
    23862388        else DebugInt3();
    23872389    }
    2388 
    23892390    /* Hide the window */
    23902391    if(IsWindowVisible())
Note: See TracChangeset for help on using the changeset viewer.