Sun Jan 2 12:38:53 1994 David Metcalfe <david@prism.demon.co.uk> * [windows/class.c] Implemented GetClassName and GetClassInfo. * [windows/caret.c] Various improvements to text caret code. Fri Dec 31 15:22:22 1993 John Brezak <brezak@apollo.hp.com> * [misc/comm.c] Patches to work with NetBSD. Thu Dec 30 12:11:55 1993 John Richardson <jrichard@cs.uml.edu> * [objects/bitblt.c] Added StretchBlt(). Tue Jan 4 05:22:07 1994 julliard@di.epfl.ch (Alexandre Julliard) * [misc/user.c] Added creation of system message queue. * [objects/bitmap.c] [objects/dcvalues.c] [windows/dc.c] Added DC size fields into DC structure. * [objects/clipping.c] Bug fix in CLIPPING_IntersectRect(). * [windows/class.c] Allocate a DCE instead of a DC for CS_CLASSDC classes. * [windows/clipping.c] Fixed GetUpdateRect() and GetUpdateRgn() to clip to the client area. * [windows/dce.c] Implemented GetDCEx() and GetWindowDC(). * [windows/defwnd.c] Implemented WM_WINDOWPOSCHANGED handling. * [windows/event.c] Preliminary support for Xlib event handling instead of Xt callbacks. Changed MSG_AddMsg() calls to hardware_event() or PostMessage(). * [windows/message.c] Preliminary support for multiple message queues. Implemented hardware_event() to store messages into the system queue. Implemented Get/SetTaskQueue(). Better WM_PAINT and WM_TIMER handling. Changes to use Xlib instead of Xt for events. * [windows/painting.c] Use GetDCEx() to retrieve the DC, to get a correct visible region. * [windows/timer.c] Moved the timer procedure callback into DispatchMessage(). Changed implementation to get rid of Xt timeouts. Timer checking is now done inside GetMessage(). * [windows/win.c] Allocate a DCE instead of a DC for CS_OWNDC windows. Replaced Xt calls with Xlib calls. Moved window positioning functions into windows/winpos.c * [windows/winpos.c] (New file) Rewritten most of the window positioning functions. Implemented SetWindowPos() and MapWindowPoints(). Jan 3, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [if1632/user.spec] Bad arguments description for function SetDlgItemText. * [objects/text.c] Function DrawText now handle DT_CALCRECT request. * [misc/message.c] Message boxes now use DrawText with DT_CALCRECT. * [windows/graphics.c] Bug fix in function FrameRect, (it was using PEN instead of BRUSH). * [windows/win.c] Bug fix for flags in function ShowWindow. More accurate WM_SIZE generated by function ShowWindow. * [controls/listbox.c] More code for LBS_MULTIPLESEL. More code for LBS_MULTICOLUMN. * [include/windows.h] Bad define for MF_SEPARATOR. * [controls/menu.c] New functions: PopMenuWndProc() with 'glues', CreatePopupMenu(), AppendMenu(), InsertMenu(), RemoveMenu(), DeleteMenu(), ModifyMenu(), TrackPopupMenu(). Code in stubs: CreateMenu(), DestroyMenu(). Sat Jan 1 10:22:43 1994 Bob Amstadt (bob@pooh) * loader/wine.c: Added support for relocation types 5 and 6. Mon Dec 27 11:06:03 1993 Erik Bos (erik@trashcan.hacktic.nl) * [misc/comm.c] new functions: BuildCommDCB(), OpenComm(), CloseComm(), SetCommBreak(), ClearCommBreak(), EscapeCommFunction(), FlushComm(), GetCommError(), SetCommEventMask(), GetCommEventMask(), SetCommState(), GetCommState(), TransmitCommChar(), ReadComm(), WriteComm(). Wed Dec 22 13:00:15 1993 David Metcalfe <david@prism.demon.co.uk> * [windows/caret.c] Implemented text caret functions. Tue Dec 21 06:13:58 1993 julliard@di.epfl.ch (Alexandre Julliard) * [loader/wine.c] Bug fix in LoadImage(). * [objects/bitblt.c] [objects/clipping.c] [objects/text.c] [windows/dc.c] [windows/dce.c] [windows/graphics.c] Modified graphics calls to take into account the DC origin. * [windows/defwnd.c] Added preliminary WM_NCCALCSIZE handling. * [windows/event.c] Send WM_NCCALCSIZE message on resize event. * [windows/win.c] Send WM_NCCALCSIZE message in CreateWindow(). Realize widgets at creation time (should prevent problems with unrealized widgets). Dec 19, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [controls/static.c] Send mouse & keyboard message received to its parent. * [controls/scroll.c] Send keyboard message received to its parent. * [controls/listbox.c] Add Navigation keys . ListBox now use VSCROLL & HSCROLL instead of children. Alpha version of LBS_MULTIPLESEL. Alpha version of LBS_MULTICOLUMN. * [controls/combo.c] Add Navigation keys on closed ComboBox. Remove useless 'COMBOBOX_CreateComboBox' function. Mon Dec 19 20:39:34 1993 Erik Bos (erik@trashcan.hacktic.nl) * [loader/wine. LoadImage() modified to use FindFile(). * [misc/file.c] SetErrorMode added * [misc/dos_fs.c] bug fixes. Dec 13, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [memory/global.c] bug fix in GlobalGetFreeSegment : good ptr in 'g_prev'. * [sysres.dll] preliminary version of a 'glass of wine' bitmap * [windows/event.c] New function 'GetCapture'. * [controls/scroll.c] Remove useless 'SCROLLBAR_CreateScrollBar' function. * [controls/listbox.c] Remove useless 'LISTBOX_CreateListBox' function. Mon Dec 13 13:51:00 1993 David Metcalfe <david@prism.demon.co.uk> * [objects/font.c] Corrected bugs in GetCharWidth(). * [windows/event.c] Modified EVENT_key to send Windows virtual key codes for WM_KEYDOWN and WM_KEYUP messages, and a WM_CHAR message for printable characters. Wed Dec 08 19:20:00 1993 Karl Guenter Wuensch (hn324wu@unidui.uni-duisburg.de) * [windows/graphics.c] Added Polyline and Polygon Mon Dec 13 14:51:54 1993 Erik Bos (erik@trashcan.hacktic.nl) * [controls/listbox.c] ListBoxDirectory() modified to use dos_fs.c's functions to access files&|drives. Sat Dec 04 17:04:23 1993 Erik Bos (erik@trashcan.hacktic.nl) * [misc/dos_fs.c] Added FindFile() to search a file in a dos/unix style path. * [misc/file.c] New Win31 functions: OpenFile, _lcreate, _llseek, GetTempDrive, GetTempFileName, GetWindowsDirectory, GetSystemDirectory, GetDriveType. * [misc/int21.c] Modified. Wed Dec 1 16:20:45 1993 Miguel de Icaza (miguel@roxanne.nuclecu.unam.mx) * [misc/profile.c] The Profile functions now return the correct values. They now implement all the features described in the SDK. Tue Nov 30 13:55:27 1993 Bob Amstadt (bob at amscons) * [loader/selector.c] Rewrote selector aliasing routines to use System V IPC routine to alias memory segments. Nov 28, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [controls/listbox.c] More consistency in functions using wIndexes * [controls/scroll.c] New function : ShowScrollBar(). * [loader/cursor.c] ... New file Move cursor functions from [loader/resource.c]. New function : ClipCursor(). New function : GetClipCursor(). New function : CreateCursor(). SetCursor() now working using gloabal variable 'winHasCursor'. *[object/palette.c] New stub only : SelectPalette(). New stub only : RealizePalette(). *[win/event.c] New function : EVENT_enter_notify(), update 'winHasCursor' and send WM_SETCURSOR. *[win/defwnd.c] Add processing of WM_SETCURSOR message. *[win/win.c] New members in WND structure : hCursor, hWndVScroll & hWndHScroll. CreateWindowEx() now create children for WM_HSCROLL & WM_VSCROLL. New function ClientToScreen(). New function ScreenToClient(). Mon Nov 25 18:25:40 1993 Erik Bos (erik@trashcan.hacktic.nl) * [files.h / regfunc.h / misc/dos.c] Removed. * [misc/dos_fs.c] Added support for loading dosdrive cfg from wine.ini. * [misc/int21.c] Modified. Wed Nov 24 11:37:33 1993 julliard@disuns2.epfl.ch (Alexandre Julliard) * [include/atom.h] [memory/atom.c] Implemented atoms. * [windows/class.c] Modified RegisterClass() to use atoms. Implemented CS_GLOBALCLASS style. * [windows/message.c] Implemented RegisterWindowMessage(). * [loader/resource.c] Bug fix in LoadResource(). * [windows/dialog.c] Modified CreateDialogParam() to use Find/LoadResource().
618 lines
17 KiB
C
618 lines
17 KiB
C
/*
|
|
* GDI region objects
|
|
*
|
|
* Copyright 1993 Alexandre Julliard
|
|
*/
|
|
|
|
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "gdi.h"
|
|
|
|
|
|
/* GC used for region operations */
|
|
static GC regionGC = 0;
|
|
|
|
|
|
/***********************************************************************
|
|
* REGION_Init
|
|
*/
|
|
BOOL REGION_Init()
|
|
{
|
|
Pixmap tmpPixmap;
|
|
|
|
/* CreateGC needs a drawable */
|
|
tmpPixmap = XCreatePixmap( XT_display, DefaultRootWindow(XT_display),
|
|
1, 1, 1 );
|
|
if (tmpPixmap)
|
|
{
|
|
regionGC = XCreateGC( XT_display, tmpPixmap, 0, NULL );
|
|
XFreePixmap( XT_display, tmpPixmap );
|
|
if (!regionGC) return FALSE;
|
|
XSetForeground( XT_display, regionGC, 1 );
|
|
XSetGraphicsExposures( XT_display, regionGC, False );
|
|
return TRUE;
|
|
}
|
|
else return FALSE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* REGION_SetRect
|
|
*
|
|
* Set the bounding box of the region and create the pixmap.
|
|
* The hrgn must be valid.
|
|
*/
|
|
static BOOL REGION_SetRect( HRGN hrgn, LPRECT rect )
|
|
{
|
|
int width, height;
|
|
|
|
/* Fill region */
|
|
|
|
REGION * region = &((RGNOBJ *)GDI_HEAP_ADDR( hrgn ))->region;
|
|
width = rect->right - rect->left;
|
|
height = rect->bottom - rect->top;
|
|
if ((width <= 0) || (height <= 0))
|
|
{
|
|
region->type = NULLREGION;
|
|
region->box.left = 0;
|
|
region->box.right = 0;
|
|
region->box.top = 0;
|
|
region->box.bottom = 0;
|
|
region->pixmap = 0;
|
|
return TRUE;
|
|
}
|
|
region->type = SIMPLEREGION;
|
|
region->box = *rect;
|
|
|
|
/* Create pixmap */
|
|
|
|
region->pixmap = XCreatePixmap( XT_display, DefaultRootWindow(XT_display),
|
|
width, height, 1 );
|
|
if (!region->pixmap) return FALSE;
|
|
|
|
/* Fill pixmap */
|
|
|
|
XSetFunction( XT_display, regionGC, GXclear );
|
|
XFillRectangle( XT_display, region->pixmap, regionGC,
|
|
0, 0, width, height );
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* REGION_DeleteObject
|
|
*/
|
|
BOOL REGION_DeleteObject( HRGN hrgn, RGNOBJ * obj )
|
|
{
|
|
if (obj->region.pixmap) XFreePixmap( XT_display, obj->region.pixmap );
|
|
return GDI_FreeObject( hrgn );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* OffsetRgn (GDI.101)
|
|
*/
|
|
int OffsetRgn( HRGN hrgn, short x, short y )
|
|
{
|
|
RGNOBJ * obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC );
|
|
if (!obj) return ERROR;
|
|
#ifdef DEBUG_REGION
|
|
printf( "OffsetRgn: %d %d,%d\n", hrgn, x, y );
|
|
#endif
|
|
OffsetRect( &obj->region.box, x, y );
|
|
return obj->region.type;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetRgnBox (GDI.134)
|
|
*/
|
|
int GetRgnBox( HRGN hrgn, LPRECT rect )
|
|
{
|
|
RGNOBJ * obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC );
|
|
if (!obj) return ERROR;
|
|
#ifdef DEBUG_REGION
|
|
printf( "GetRgnBox: %d\n", hrgn );
|
|
#endif
|
|
*rect = obj->region.box;
|
|
return obj->region.type;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateRectRgn (GDI.64)
|
|
*/
|
|
HRGN CreateRectRgn( short left, short top, short right, short bottom )
|
|
{
|
|
RECT rect = { left, top, right, bottom };
|
|
return CreateRectRgnIndirect( &rect );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateRectRgnIndirect (GDI.65)
|
|
*/
|
|
HRGN CreateRectRgnIndirect( LPRECT rect )
|
|
{
|
|
RGNOBJ * rgnObj;
|
|
HRGN hrgn;
|
|
|
|
#ifdef DEBUG_REGION
|
|
printf( "CreateRectRgnIndirect: %d,%d-%d,%d\n",
|
|
rect->left, rect->top, rect->right, rect->bottom );
|
|
#endif
|
|
|
|
/* Create region */
|
|
|
|
if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC ))) return 0;
|
|
if (!REGION_SetRect( hrgn, rect ))
|
|
{
|
|
GDI_FreeObject( hrgn );
|
|
return 0;
|
|
}
|
|
rgnObj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn );
|
|
|
|
/* Fill pixmap */
|
|
|
|
if (rgnObj->region.type != NULLREGION)
|
|
{
|
|
int width = rgnObj->region.box.right - rgnObj->region.box.left;
|
|
int height = rgnObj->region.box.bottom - rgnObj->region.box.top;
|
|
XSetFunction( XT_display, regionGC, GXcopy );
|
|
XFillRectangle( XT_display, rgnObj->region.pixmap, regionGC,
|
|
0, 0, width, height );
|
|
}
|
|
|
|
return hrgn;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateRoundRectRgn (GDI.444)
|
|
*/
|
|
HRGN CreateRoundRectRgn( short left, short top, short right, short bottom,
|
|
short ellipse_width, short ellipse_height )
|
|
{
|
|
RECT rect = { left, top, right, bottom };
|
|
RGNOBJ * rgnObj;
|
|
HRGN hrgn;
|
|
|
|
#ifdef DEBUG_REGION
|
|
printf( "CreateRoundRectRgn: %d,%d-%d,%d %dx%d\n",
|
|
left, top, right, bottom, ellipse_width, ellipse_height );
|
|
#endif
|
|
|
|
/* Create region */
|
|
|
|
if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC ))) return 0;
|
|
if (!REGION_SetRect( hrgn, &rect ))
|
|
{
|
|
GDI_FreeObject( hrgn );
|
|
return 0;
|
|
}
|
|
rgnObj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn );
|
|
|
|
/* Fill pixmap */
|
|
|
|
if (rgnObj->region.type != NULLREGION)
|
|
{
|
|
int width = rgnObj->region.box.right - rgnObj->region.box.left;
|
|
int height = rgnObj->region.box.bottom - rgnObj->region.box.top;
|
|
XSetFunction( XT_display, regionGC, GXcopy );
|
|
XFillRectangle( XT_display, rgnObj->region.pixmap, regionGC,
|
|
0, ellipse_height / 2,
|
|
width, height - ellipse_height );
|
|
XFillRectangle( XT_display, rgnObj->region.pixmap, regionGC,
|
|
ellipse_width / 2, 0,
|
|
width - ellipse_width, height );
|
|
XFillArc( XT_display, rgnObj->region.pixmap, regionGC,
|
|
0, 0,
|
|
ellipse_width, ellipse_height, 0, 360*64 );
|
|
XFillArc( XT_display, rgnObj->region.pixmap, regionGC,
|
|
width - ellipse_width, 0,
|
|
ellipse_width, ellipse_height, 0, 360*64 );
|
|
XFillArc( XT_display, rgnObj->region.pixmap, regionGC,
|
|
0, height - ellipse_height,
|
|
ellipse_width, ellipse_height, 0, 360*64 );
|
|
XFillArc( XT_display, rgnObj->region.pixmap, regionGC,
|
|
width - ellipse_width, height - ellipse_height,
|
|
ellipse_width, ellipse_height, 0, 360*64 );
|
|
}
|
|
|
|
return hrgn;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* SetRectRgn (GDI.172)
|
|
*/
|
|
void SetRectRgn( HRGN hrgn, short left, short top, short right, short bottom )
|
|
{
|
|
RECT rect = { left, top, right, bottom };
|
|
RGNOBJ * rgnObj;
|
|
|
|
#ifdef DEBUG_REGION
|
|
printf( "SetRectRgn: %d %d,%d-%d,%d\n", hrgn, left, top, right, bottom );
|
|
#endif
|
|
|
|
/* Free previous pixmap */
|
|
|
|
if (!(rgnObj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ))) return;
|
|
if (rgnObj->region.pixmap)
|
|
XFreePixmap( XT_display, rgnObj->region.pixmap );
|
|
|
|
if (!REGION_SetRect( hrgn, &rect )) return;
|
|
|
|
/* Fill pixmap */
|
|
|
|
if (rgnObj->region.type != NULLREGION)
|
|
{
|
|
int width = rgnObj->region.box.right - rgnObj->region.box.left;
|
|
int height = rgnObj->region.box.bottom - rgnObj->region.box.top;
|
|
XSetFunction( XT_display, regionGC, GXcopy );
|
|
XFillRectangle( XT_display, rgnObj->region.pixmap, regionGC,
|
|
0, 0, width, height );
|
|
}
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateEllipticRgn (GDI.54)
|
|
*/
|
|
HRGN CreateEllipticRgn( short left, short top, short right, short bottom )
|
|
{
|
|
RECT rect = { left, top, right, bottom };
|
|
return CreateEllipticRgnIndirect( &rect );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateEllipticRgnIndirect (GDI.55)
|
|
*/
|
|
HRGN CreateEllipticRgnIndirect( LPRECT rect )
|
|
{
|
|
RGNOBJ * rgnObj;
|
|
HRGN hrgn;
|
|
|
|
#ifdef DEBUG_REGION
|
|
printf( "CreateEllipticRgnIndirect: %d,%d-%d,%d\n",
|
|
rect->left, rect->top, rect->right, rect->bottom );
|
|
#endif
|
|
|
|
/* Create region */
|
|
|
|
if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC ))) return 0;
|
|
if (!REGION_SetRect( hrgn, rect ))
|
|
{
|
|
GDI_FreeObject( hrgn );
|
|
return 0;
|
|
}
|
|
rgnObj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn );
|
|
|
|
/* Fill pixmap */
|
|
|
|
if (rgnObj->region.type != NULLREGION)
|
|
{
|
|
int width = rgnObj->region.box.right - rgnObj->region.box.left;
|
|
int height = rgnObj->region.box.bottom - rgnObj->region.box.top;
|
|
XSetFunction( XT_display, regionGC, GXcopy );
|
|
XFillArc( XT_display, rgnObj->region.pixmap, regionGC,
|
|
0, 0, width, height, 0, 360*64 );
|
|
}
|
|
|
|
return hrgn;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreatePolygonRgn (GDI.63)
|
|
*/
|
|
HRGN CreatePolygonRgn( POINT * points, short count, short mode )
|
|
{
|
|
return CreatePolyPolygonRgn( points, &count, 1, mode );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreatePolyPolygonRgn (GDI.451)
|
|
*/
|
|
HRGN CreatePolyPolygonRgn( POINT * points, short * count,
|
|
short nbpolygons, short mode )
|
|
{
|
|
RGNOBJ * rgnObj;
|
|
HRGN hrgn;
|
|
RECT box;
|
|
int i, j, totalPoints;
|
|
POINT * pt;
|
|
XPoint * xpoints;
|
|
|
|
if (!nbpolygons) return 0;
|
|
#ifdef DEBUG_REGION
|
|
printf( "CreatePolyPolygonRgn: %d polygons\n", nbpolygons );
|
|
#endif
|
|
|
|
/* Find bounding box */
|
|
|
|
box.top = box.left = 32767;
|
|
box.right = box.bottom = 0;
|
|
for (i = totalPoints = 0, pt = points; i < nbpolygons; i++)
|
|
{
|
|
totalPoints += count[i];
|
|
for (j = 0; j < count[i]; j++, pt++)
|
|
{
|
|
if (pt->x < box.left) box.left = pt->x;
|
|
if (pt->x > box.right) box.right = pt->x;
|
|
if (pt->y < box.top) box.top = pt->y;
|
|
if (pt->y > box.bottom) box.bottom = pt->y;
|
|
}
|
|
}
|
|
if (!totalPoints) return 0;
|
|
|
|
/* Build points array */
|
|
|
|
xpoints = (XPoint *) malloc( sizeof(XPoint) * totalPoints );
|
|
if (!xpoints) return 0;
|
|
for (i = 0, pt = points; i < totalPoints; i++, pt++)
|
|
{
|
|
xpoints[i].x = pt->x - box.left;
|
|
xpoints[i].y = pt->y - box.top;
|
|
}
|
|
|
|
/* Create region */
|
|
|
|
if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC )) ||
|
|
!REGION_SetRect( hrgn, &box ))
|
|
{
|
|
if (hrgn) GDI_FreeObject( hrgn );
|
|
free( xpoints );
|
|
return 0;
|
|
}
|
|
rgnObj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn );
|
|
|
|
/* Fill pixmap */
|
|
|
|
if (rgnObj->region.type != NULLREGION)
|
|
{
|
|
XSetFunction( XT_display, regionGC, GXcopy );
|
|
if (mode == WINDING) XSetFillRule( XT_display, regionGC, WindingRule );
|
|
else XSetFillRule( XT_display, regionGC, EvenOddRule );
|
|
for (i = j = 0; i < nbpolygons; i++)
|
|
{
|
|
XFillPolygon( XT_display, rgnObj->region.pixmap, regionGC,
|
|
&xpoints[j], count[i], Complex, CoordModeOrigin );
|
|
j += count[i];
|
|
}
|
|
}
|
|
|
|
free( xpoints );
|
|
return hrgn;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* PtInRegion (GDI.161)
|
|
*/
|
|
BOOL PtInRegion( HRGN hrgn, short x, short y )
|
|
{
|
|
XImage * image;
|
|
BOOL res;
|
|
RGNOBJ * obj;
|
|
POINT pt = { x, y };
|
|
|
|
if (!(obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ))) return FALSE;
|
|
if (!PtInRect( &obj->region.box, pt )) return FALSE;
|
|
image = XGetImage( XT_display, obj->region.pixmap,
|
|
x - obj->region.box.left, y - obj->region.box.top,
|
|
1, 1, AllPlanes, ZPixmap );
|
|
if (!image) return FALSE;
|
|
res = (XGetPixel( image, 0, 0 ) != 0);
|
|
XDestroyImage( image );
|
|
return res;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* RectInRegion (GDI.181)
|
|
*/
|
|
BOOL RectInRegion( HRGN hrgn, LPRECT rect )
|
|
{
|
|
XImage * image;
|
|
RGNOBJ * obj;
|
|
RECT intersect;
|
|
int x, y;
|
|
|
|
if (!(obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ))) return FALSE;
|
|
if (!IntersectRect( &intersect, &obj->region.box, rect )) return FALSE;
|
|
|
|
image = XGetImage( XT_display, obj->region.pixmap,
|
|
intersect.left - obj->region.box.left,
|
|
intersect.top - obj->region.box.top,
|
|
intersect.right - intersect.left,
|
|
intersect.bottom - intersect.top,
|
|
AllPlanes, ZPixmap );
|
|
if (!image) return FALSE;
|
|
for (y = 0; y < image->height; y++)
|
|
for (x = 0; x < image->width; x++)
|
|
if (XGetPixel( image, x, y ) != 0)
|
|
{
|
|
XDestroyImage( image );
|
|
return TRUE;
|
|
}
|
|
|
|
XDestroyImage( image );
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* EqualRgn (GDI.72)
|
|
*/
|
|
BOOL EqualRgn( HRGN rgn1, HRGN rgn2 )
|
|
{
|
|
RGNOBJ *obj1, *obj2;
|
|
XImage *image1, *image2;
|
|
int width, height, x, y;
|
|
|
|
/* Compare bounding boxes */
|
|
|
|
if (!(obj1 = (RGNOBJ *) GDI_GetObjPtr( rgn1, REGION_MAGIC ))) return FALSE;
|
|
if (!(obj2 = (RGNOBJ *) GDI_GetObjPtr( rgn2, REGION_MAGIC ))) return FALSE;
|
|
if (obj1->region.type == NULLREGION)
|
|
return (obj2->region.type == NULLREGION);
|
|
else if (obj2->region.type == NULLREGION) return FALSE;
|
|
if (!EqualRect( &obj1->region.box, &obj2->region.box )) return FALSE;
|
|
|
|
/* Get pixmap contents */
|
|
|
|
width = obj1->region.box.right - obj1->region.box.left;
|
|
height = obj1->region.box.bottom - obj1->region.box.top;
|
|
image1 = XGetImage( XT_display, obj1->region.pixmap,
|
|
0, 0, width, height, AllPlanes, ZPixmap );
|
|
if (!image1) return FALSE;
|
|
image2 = XGetImage( XT_display, obj2->region.pixmap,
|
|
0, 0, width, height, AllPlanes, ZPixmap );
|
|
if (!image2)
|
|
{
|
|
XDestroyImage( image1 );
|
|
return FALSE;
|
|
}
|
|
|
|
/* Compare pixmaps */
|
|
for (y = 0; y < height; y++)
|
|
for (x = 0; x < width; x++)
|
|
if (XGetPixel( image1, x, y ) != XGetPixel( image2, x, y))
|
|
{
|
|
XDestroyImage( image1 );
|
|
XDestroyImage( image2 );
|
|
return FALSE;
|
|
}
|
|
|
|
XDestroyImage( image1 );
|
|
XDestroyImage( image2 );
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* REGION_CopyIntersection
|
|
*
|
|
* Copy to dest->pixmap the area of src->pixmap delimited by
|
|
* the intersection of dest and src regions, using the current GC function.
|
|
*/
|
|
void REGION_CopyIntersection( REGION * dest, REGION * src )
|
|
{
|
|
RECT inter;
|
|
if (!IntersectRect( &inter, &dest->box, &src->box )) return;
|
|
XCopyArea( XT_display, src->pixmap, dest->pixmap, regionGC,
|
|
inter.left - src->box.left, inter.top - src->box.top,
|
|
inter.right - inter.left, inter.bottom - inter.top,
|
|
inter.left - dest->box.left, inter.top - dest->box.top );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CombineRgn (GDI.451)
|
|
*/
|
|
int CombineRgn( HRGN hDest, HRGN hSrc1, HRGN hSrc2, short mode )
|
|
{
|
|
RGNOBJ *destObj, *src1Obj, *src2Obj;
|
|
REGION * region;
|
|
int width, height;
|
|
BOOL res;
|
|
|
|
#ifdef DEBUG_REGION
|
|
printf( "CombineRgn: %d %d %d %d\n", hDest, hSrc1, hSrc2, mode );
|
|
#endif
|
|
|
|
if (!(destObj = (RGNOBJ *) GDI_GetObjPtr( hDest, REGION_MAGIC )))
|
|
return ERROR;
|
|
if (!(src1Obj = (RGNOBJ *) GDI_GetObjPtr( hSrc1, REGION_MAGIC )))
|
|
return ERROR;
|
|
if (mode != RGN_COPY)
|
|
if (!(src2Obj = (RGNOBJ *) GDI_GetObjPtr( hSrc2, REGION_MAGIC )))
|
|
return ERROR;
|
|
region = &destObj->region;
|
|
|
|
switch(mode)
|
|
{
|
|
case RGN_AND:
|
|
res = IntersectRect( ®ion->box, &src1Obj->region.box,
|
|
&src2Obj->region.box );
|
|
region->type = COMPLEXREGION;
|
|
break;
|
|
|
|
case RGN_OR:
|
|
case RGN_XOR:
|
|
res = UnionRect( ®ion->box, &src1Obj->region.box,
|
|
&src2Obj->region.box );
|
|
region->type = COMPLEXREGION;
|
|
break;
|
|
|
|
case RGN_DIFF:
|
|
res = SubtractRect( ®ion->box, &src1Obj->region.box,
|
|
&src2Obj->region.box );
|
|
region->type = COMPLEXREGION;
|
|
break;
|
|
|
|
case RGN_COPY:
|
|
region->box = src1Obj->region.box;
|
|
region->type = src1Obj->region.type;
|
|
res = (region->type != NULLREGION);
|
|
break;
|
|
|
|
default:
|
|
return ERROR;
|
|
}
|
|
|
|
if (region->pixmap) XFreePixmap( XT_display, region->pixmap );
|
|
if (!res)
|
|
{
|
|
region->type = NULLREGION;
|
|
region->pixmap = 0;
|
|
return NULLREGION;
|
|
}
|
|
|
|
width = region->box.right - region->box.left;
|
|
height = region->box.bottom - region->box.top;
|
|
region->pixmap = XCreatePixmap( XT_display, DefaultRootWindow(XT_display),
|
|
width, height, 1 );
|
|
|
|
switch(mode)
|
|
{
|
|
case RGN_AND:
|
|
XSetFunction( XT_display, regionGC, GXcopy );
|
|
REGION_CopyIntersection( region, &src1Obj->region );
|
|
XSetFunction( XT_display, regionGC, GXand );
|
|
REGION_CopyIntersection( region, &src2Obj->region );
|
|
break;
|
|
|
|
case RGN_OR:
|
|
case RGN_XOR:
|
|
XSetFunction( XT_display, regionGC, GXclear );
|
|
XFillRectangle( XT_display, region->pixmap, regionGC,
|
|
0, 0, width, height );
|
|
XSetFunction( XT_display, regionGC, (mode == RGN_OR) ? GXor : GXxor);
|
|
REGION_CopyIntersection( region, &src1Obj->region );
|
|
REGION_CopyIntersection( region, &src2Obj->region );
|
|
break;
|
|
|
|
case RGN_DIFF:
|
|
XSetFunction( XT_display, regionGC, GXclear );
|
|
XFillRectangle( XT_display, region->pixmap, regionGC,
|
|
0, 0, width, height );
|
|
XSetFunction( XT_display, regionGC, GXcopy );
|
|
REGION_CopyIntersection( region, &src1Obj->region );
|
|
XSetFunction( XT_display, regionGC, GXandInverted );
|
|
REGION_CopyIntersection( region, &src2Obj->region );
|
|
break;
|
|
|
|
case RGN_COPY:
|
|
XSetFunction( XT_display, regionGC, GXcopy );
|
|
XCopyArea( XT_display, src1Obj->region.pixmap, region->pixmap,
|
|
regionGC, 0, 0, width, height, 0, 0 );
|
|
break;
|
|
}
|
|
return region->type;
|
|
}
|