Ejemplo n.º 1
0
 /// <summary>
 /// <para>Determine if two regions are equal.</para>
 /// </summary>
 ///
 /// <param name="obj">
 /// <para>The region object to compare against.</para>
 /// </param>
 ///
 /// <returns>
 /// <para>Returns <see langword="true"/> if the two regions are equal;
 /// <see langword="false"/> otherwise.  For the purposes of this
 /// method, disposed regions are considered the same as empty
 /// regions.</para>
 /// </returns>
 public override bool Equals(Object obj)
 {
     lock (typeof(Region))
     {
         Region other = (obj as Region);
         if (other != null)
         {
             if (this == other)
             {
                 return(true);
             }
             else if (IsEmpty())
             {
                 return(other.IsEmpty());
             }
             else if (other.IsEmpty())
             {
                 return(false);
             }
             else
             {
                 return(Xlib.XEqualRegion
                            (region, other.region) != 0);
             }
         }
         else
         {
             return(false);
         }
     }
 }
Ejemplo n.º 2
0
        // 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);
        }
	// 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;
			}