extern public static void XSharpFontExtentsPCF (IntPtr fontSet, out XRectangle max_ink_return, out XRectangle max_logical_return);
extern public static void XSharpGetRegionRect (IntPtr region, int index, out XRectangle rect);
extern public static void XSharpTextExtentsSet (IntPtr display, IntPtr fontSet, String str, out XRectangle overall_ink_return, out XRectangle overall_logical_return);
extern public static void XSharpTextExtentsPCF (IntPtr display, IntPtr fontSet, [MarshalAs(UnmanagedType.Interface)] String str, int offset, int count, out XRectangle overall_ink_return, out XRectangle overall_logical_return);
extern public static int XClipBox(IntPtr region, out XRectangle rect);
extern public static int XFillRectangles (IntPtr display, XDrawable drawable, IntPtr gc, XRectangle[] rectangles, int nrectangles);
extern public static int XUnionRectWithRegion (ref XRectangle rectangle, IntPtr src, IntPtr dest);
/// <summary> /// <para>Xor an explicitly-specified rectangle with /// this region.</para> /// </summary> /// /// <param name="x"> /// <para>The X co-ordinate of the top-left corner of the rectangle.</para> /// </param> /// /// <param name="y"> /// <para>The Y co-ordinate of the top-left corner of the rectangle.</para> /// </param> /// /// <param name="width"> /// <para>The width of the rectangle.</para> /// </param> /// /// <param name="height"> /// <para>The height of the rectangle.</para> /// </param> /// /// <exception cref="T:Xsharp.XException"> /// <para>Raised if the rectangle co-ordinates are out of range.</para> /// </exception> /// /// <remarks> /// <para>If this region has been disposed, then it will be treated /// as empty prior to the xor operation.</para> /// </remarks> public void Xor(int x, int y, int width, int height) { lock(typeof(Region)) { if(region == IntPtr.Zero) { region = Xlib.XCreateRegion(); if(region == IntPtr.Zero) { Display.OutOfMemory(); } } XRectangle xrect = new XRectangle(x, y, width, height); IntPtr reg = Xlib.XCreateRegion(); if(reg == IntPtr.Zero) { Display.OutOfMemory(); } Xlib.XUnionRectWithRegion(ref xrect, reg, reg); Xlib.XXorRegion(region, reg, region); Xlib.XDestroyRegion(reg); } }
/// <summary> /// <para>Subtract a rectangle from this region.</para> /// </summary> /// /// <param name="rect"> /// <para>The rectangle to subtract from this region.</para> /// </param> /// /// <exception cref="T:Xsharp.XException"> /// <para>Raised if the rectangle co-ordinates are out of range.</para> /// </exception> /// /// <remarks> /// <para>If this region has been disposed, then it will be re-created /// with its initial contents set to empty.</para> /// </remarks> public void Subtract(Rectangle rect) { lock(typeof(Region)) { if(region == IntPtr.Zero) { region = Xlib.XCreateRegion(); if(region == IntPtr.Zero) { Display.OutOfMemory(); } } else { XRectangle xrect = new XRectangle (rect.x, rect.y, rect.width, rect.height); IntPtr reg = Xlib.XCreateRegion(); if(reg == IntPtr.Zero) { Display.OutOfMemory(); } Xlib.XUnionRectWithRegion(ref xrect, reg, reg); Xlib.XSubtractRegion(region, reg, region); Xlib.XDestroyRegion(reg); } } }
/// <summary> /// <para>Union a rectangle with this region.</para> /// </summary> /// /// <param name="rect"> /// <para>The rectangle to union with this region.</para> /// </param> /// /// <exception cref="T:Xsharp.XException"> /// <para>Raised if the rectangle co-ordinates are out of range.</para> /// </exception> /// /// <remarks> /// <para>If this region has been disposed, then it will be re-created /// with its initial contents set to <paramref name="rect"/>.</para> /// </remarks> public void Union(Rectangle rect) { lock(typeof(Region)) { XRectangle xrect = new XRectangle (rect.x, rect.y, rect.width, rect.height); if(region == IntPtr.Zero) { region = Xlib.XCreateRegion(); if(region == IntPtr.Zero) { Display.OutOfMemory(); } } Xlib.XUnionRectWithRegion(ref xrect, region, region); } }
/// <summary> /// <para>Fill a list of rectangles.</para> /// </summary> /// /// <param name="rects"> /// <para>The list of rectangles to be drawn.</para> /// </param> /// /// <exception cref="T:System.ArgumentNullException"> /// <para>Raised if <paramref name="rects"/> is <see langword="null"/>. /// </para> /// </exception> /// /// <exception cref="T:Xsharp.XException"> /// <para>One of the co-ordinate or size values is out of range, or /// <paramref name="rects"/> has less than 1 element.</para> /// </exception> public void FillRectangles(Rectangle[] rects) { int len; // Validate the parameter. if(rects == null) { throw new ArgumentNullException("rects"); } len = rects.Length; if(len < 1) { throw new XException(S._("X_Need1Rect")); } else if(len > ((dpy.MaxRequestSize() - 3) / 2)) { throw new XException(S._("X_MaxReqSizeExceeded")); } // Convert the "Rectangle" array into an "XRectangle" array. XRectangle[] xrects = new XRectangle [len]; int r; for(r = 0; r < len; ++r) { xrects[r] = new XRectangle(rects[r].x, rects[r].y, rects[r].width, rects[r].height); } // Draw the rectangles. try { IntPtr display = Lock(); Xlib.XFillRectangles(display, drawableHandle, gc, xrects, len); } finally { dpy.Unlock(); } }