Example #1
0
        /// <summary>
        /// <para>Process a color theme change for this widget.</para>
        /// </summary>
        public override void ThemeChange()
        {
            // Pass the theme change on to all of the child widgets.
            base.ThemeChange();

            // Change the background pixel to match the new theme
            // settings, and then force a repaint on the widget.
            try
            {
                IntPtr        display = dpy.Lock();
                XWindow       window  = GetWidgetHandle();
                StandardColor sc      = background.Index;
                if (sc != StandardColor.Inherit &&
                    sc != StandardColor.Pixmap &&
                    sc != StandardColor.RGB)
                {
                    Xlib.XSetWindowBackground
                        (display, window, ToPixel(background));
                }
                if (mapped && AncestorsMapped)
                {
                    Xlib.XClearArea(display, window,
                                    0, 0, (uint)0, (uint)0,
                                    XBool.True);
                }
            }
            finally
            {
                dpy.Unlock();
            }
        }
Example #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);
        }