Exemplo n.º 1
0
	/// <summary>
	/// <para>Set the clip area to a region object, with a
	/// specified origin.</para>
	/// </summary>
	///
	/// <param name="r">
	/// <para>The clipping region to set.</para>
	/// </param>
	///
	/// <param name="xorigin">
	/// <para>The X co-ordinate of the clipping origin.</para>
	/// </param>
	///
	/// <param name="yorigin">
	/// <para>The Y co-ordinate of the clipping origin.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException">
	/// <para>The <paramref name="r"/> value is
	/// <see langword="null"/>.</para>
	/// </exception>
	///
	/// <exception cref="T:Xsharp.XException">
	/// <para>The <paramref name="xorigin"/> or <paramref name="yorigin"/>
	/// value is out of range.</para>
	/// </exception>
	public void SetClipRegion(Region r, int xorigin, int yorigin)
			{
				if(r == null)
				{
					throw new ArgumentNullException("r");
				}
				if(xorigin < -32768 || xorigin > 32767 ||
				   yorigin < -32768 || yorigin > 32767)
				{
					throw new XException(S._("X_PointCoordRange"));
				}
				try
				{
					IntPtr display = Lock();
					Xlib.XSetClipOrigin(display, gc, xorigin, yorigin);
					Xlib.XSetRegion(display, gc, r.GetRegion());
					if(clipRegion != r)
					{
						if(clipRegion != null)
							clipRegion.Dispose();
						clipRegion = new Region(r);
					}
				}
				finally
				{
					dpy.Unlock();
				}
			}
	// Clear a region to the background and optionally queue expose events.
	private bool ClearRegion(Region region, XBool exposures)
			{
				// Intersect the region with the widget boundaries.
				region.Intersect(0, 0, width, height);

				// Remove areas that are occupied by mapped child widgets.
				Widget child = TopChild;
				while(child != null)
				{
					if(child.mapped)
					{
						region.Subtract(child.x, child.y,
										child.width, child.height);
					}
					child = child.NextBelow;
				}

				// Bail out if the region is now empty.
				if(region.IsEmpty())
				{
					return false;
				}

				// Lock down the display and send the "XClearArea" requests.
				try
				{
					IntPtr display = dpy.Lock();
					XWindow handle = GetWidgetHandle();
					IntPtr xregion = region.GetRegion();
					XRectangle xrect;
					int size, index;
					size = Xlib.XSharpGetRegionSize(xregion);
					for(index = 0; index < size; ++index)
					{
						Xlib.XSharpGetRegionRect(xregion, index, out xrect);
						Xlib.XClearArea(display, handle, xrect.x, xrect.y,
										xrect.width, xrect.height, exposures);
					}
				}
				finally
				{
					dpy.Unlock();
				}
				return true;
			}
Exemplo n.º 3
0
	/// <summary>
	/// <para>Set the clip area to a region object.</para>
	/// </summary>
	///
	/// <param name="r">
	/// <para>The clipping region to set.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException">
	/// <para>The <paramref name="r"/> value is
	/// <see langword="null"/>.</para>
	/// </exception>
	public void SetClipRegion(Region r)
			{
				if(r == null)
				{
					throw new ArgumentNullException("r");
				}
				try
				{
					IntPtr display = Lock();
					Xlib.XSetClipOrigin(display, gc, 0, 0);
					Xlib.XSetRegion(display, gc, r.GetRegion());
					if(clipRegion != r)
					{
						if(clipRegion != null)
							clipRegion.Dispose();
						clipRegion = new Region(r);
					}
				}
				finally
				{
					dpy.Unlock();
				}
			}