dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp Region.cs, 1.1, 1.2 Xlib.cs.in


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/Xsharp Region.cs, 1.1, 1.2 Xlib.cs.in, 1.12, 1.13 XsharpSupport.c, 1.11, 1.12
Date: Wed, 23 Jul 2003 20:54:21 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/Xsharp
In directory subversions:/tmp/cvs-serv17112/Xsharp

Modified Files:
        Region.cs Xlib.cs.in XsharpSupport.c 
Log Message:


Add a "GetRectangles()" method to "Xsharp.Region" to allow callers
to query the list of rectangles that make up the region.


Index: Region.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/Region.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Region.cs   28 May 2003 04:17:53 -0000      1.1
--- Region.cs   24 Jul 2003 00:54:19 -0000      1.2
***************
*** 1284,1287 ****
--- 1284,1324 ----
                        }
  
+       /// <summary>
+       /// <para>Get the list of rectangles that defines this region.</para>
+       /// </summary>
+       ///
+       /// <returns>
+       /// <para>An array of <see cref="T:Xsharp.Rectangle"/> instances
+       /// corresponding to the rectangles that make up the region.
+       /// Returns a zero-length array if the region is empty.</para>
+       /// </returns>
+       public Rectangle[] GetRectangles()
+                       {
+                               lock(typeof(Region))
+                               {
+                                       if(region == IntPtr.Zero)
+                                       {
+                                               return new Rectangle [0];
+                                       }
+                                       else
+                                       {
+                                               Rectangle[] rects;
+                                               XRectangle xrect;
+                                               int size, index;
+                                               size = 
Xlib.XSharpGetRegionSize(region);
+                                               rects = new Rectangle [size];
+                                               for(index = 0; index < size; 
++index)
+                                               {
+                                                       
Xlib.XSharpGetRegionRect(region, index, out xrect);
+                                                       rects[index].x = 
xrect.x;
+                                                       rects[index].y = 
xrect.y;
+                                                       rects[index].width = 
xrect.width;
+                                                       rects[index].height = 
xrect.height;
+                                               }
+                                               return rects;
+                                       }
+                               }
+                       }
+ 
        // Get the Xlib region structure, and make sure it is non-NULL.
        internal IntPtr GetRegion()

Index: Xlib.cs.in
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/Xlib.cs.in,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** Xlib.cs.in  8 Jul 2003 02:09:06 -0000       1.12
--- Xlib.cs.in  24 Jul 2003 00:54:19 -0000      1.13
***************
*** 548,551 ****
--- 548,558 ----
        extern public static void XSharpFreeResources(IntPtr value);
  
+       [DllImport("XsharpSupport")]
+       extern public static @X_int@ XSharpGetRegionSize(IntPtr region);
+ 
+       [DllImport("XsharpSupport")]
+       extern public static void XSharpGetRegionRect
+                       (IntPtr region, @X_int@ index, out XRectangle rect);
+ 
        // Helper functions from "libImlib.so" for loading images.
  

Index: XsharpSupport.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/XsharpSupport.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** XsharpSupport.c     22 Jul 2003 05:59:59 -0000      1.11
--- XsharpSupport.c     24 Jul 2003 00:54:19 -0000      1.12
***************
*** 910,913 ****
--- 910,951 ----
  }
  
+ /*
+  * Internal structure of X11 region objects.  We have to define
+  * this here because there is no public header that contains it.
+  */
+ typedef struct
+ {
+     short x1, x2, y1, y2;
+ 
+ } BOX;
+ typedef struct
+ {
+     long size;
+     long numRects;
+     BOX *rects;
+     BOX extents;
+ 
+ } REGION;
+ 
+ /*
+  * Get the number of rectangles contained in a region structure.
+  */
+ int XSharpGetRegionSize(Region region)
+ {
+       return (int)(((REGION *)region)->numRects);
+ }
+ 
+ /*
+  * Get the bounding area of a particular rectangle within a region structure.
+  */
+ void XSharpGetRegionRect(Region region, int index, XRectangle *rect)
+ {
+       BOX *box = &(((REGION *)region)->rects[index]);
+       rect->x = box->x1;
+       rect->y = box->y1;
+       rect->width = box->x2 - box->x1;
+       rect->height = box->y2 - box->y1;
+ }
+ 
  #else /* X_DISPLAY_MISSING || !HAVE_SELECT */
  
***************
*** 972,975 ****
--- 1010,1024 ----
  
  void XSharpDestroyImage(void *image)
+ {
+       /* Nothing to do here */
+ }
+ 
+ int XSharpGetRegionSize(void *region)
+ {
+       /* Nothing to do here */
+       return 0;
+ }
+ 
+ void XSharpGetRegionRect(void *region, int index, void *rect)
  {
        /* Nothing to do here */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]