Apply() public method

public Apply ( Cairo cr ) : void
cr Cairo
return void
        protected override void ClippedRender(Cairo.Context cr)
        {
            Brush brush = Background;

            if (!brush.IsValid)
            {
                return;
            }

            double x = Double.IsNaN(brush.Width)
                ? 0
                : (RenderSize.Width - brush.Width) * XAlign;

            double y = Double.IsNaN(brush.Height)
                ? 0
                : (RenderSize.Height - brush.Height) * YAlign;

            cr.Rectangle(0, 0, RenderSize.Width, RenderSize.Height);
            cr.ClipPreserve();

            if (x != 0 || y != 0)
            {
                cr.Translate(x, y);
            }

            cr.Antialias = Cairo.Antialias.None;
            brush.Apply(cr);
            cr.Fill();
        }
Exemplo n.º 2
0
        protected override void ClippedRender(Data.Gui.CellContext context)
        {
            if (!EnsureLayout())
            {
                return;
            }

            var cr = context.Context;

            Foreground = new Brush(context.Theme.Colors.GetWidgetColor(
                                       context.TextAsForeground ? GtkColorClass.Foreground : GtkColorClass.Text, context.State));

            var foreground = Foreground;

            if (!foreground.IsValid)
            {
                return;
            }

            cr.Rectangle(0, 0, RenderSize.Width, RenderSize.Height);
            cr.Clip();

            bool fade = Fade && text_alloc.Width > RenderSize.Width;

            if (fade)
            {
                cr.PushGroup();
            }

            cr.MoveTo(text_alloc.X, text_alloc.Y);
            Foreground.Apply(cr);
            UpdateLayout(GetText(), RenderSize.Width, RenderSize.Height, true);
            if (Hyena.PlatformDetection.IsWindows)
            {
                // FIXME windows; working around some unknown issue with ShowLayout; bgo#644311

                cr.Antialias = Cairo.Antialias.None;
                PangoCairoHelper.LayoutPath(cr, layout, true);
            }
            else
            {
                PangoCairoHelper.ShowLayout(cr, layout);
            }
            cr.Fill();

            TooltipMarkup = layout.IsEllipsized ? last_formatted_text : null;

            if (fade)
            {
                var mask = new LinearGradient(RenderSize.Width - 20, 0, RenderSize.Width, 0);
                mask.AddColorStop(0, new Color(0, 0, 0, 1));
                mask.AddColorStop(1, new Color(0, 0, 0, 0));

                cr.PopGroupToSource();
                cr.Mask(mask);
                mask.Dispose();
            }

            cr.ResetClip();
        }
Exemplo n.º 3
0
        protected override void ClippedRender(Hyena.Data.Gui.CellContext context)
        {
            if (!EnsureLayout ()) {
                return;
            }

            var cr = context.Context;
            context.Theme.Widget.StyleContext.Save ();
            if (context.TextAsForeground) {
                context.Theme.Widget.StyleContext.AddClass ("button");
            } else {
                context.Theme.Widget.StyleContext.AddClass ("entry");
            }
            Foreground = new Brush (context.Theme.Widget.StyleContext.GetColor (context.State));

            Brush foreground = Foreground;
            if (!foreground.IsValid) {
                return;
            }

            cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
            cr.Clip ();

            bool fade = Fade && text_alloc.Width > RenderSize.Width;

            if (fade) {
                cr.PushGroup ();
            }

            Foreground.Apply (cr);
            UpdateLayout (GetText (), RenderSize.Width, RenderSize.Height, true);
            if (Hyena.PlatformDetection.IsWindows) {
              // FIXME windows; working around some unknown issue with ShowLayout; bgo#644311

              cr.Antialias = Cairo.Antialias.None;
              PangoCairoHelper.LayoutPath (cr, layout, true);
            } else {
              PangoCairoHelper.ShowLayout (cr, layout);
            }

            TooltipMarkup = layout.IsEllipsized ? last_formatted_text : null;

            if (fade) {
                LinearGradient mask = new LinearGradient (RenderSize.Width - 20, 0, RenderSize.Width, 0);
                mask.AddColorStop (0, new Color (0, 0, 0, 1));
                mask.AddColorStop (1, new Color (0, 0, 0, 0));

                cr.PopGroupToSource ();
                cr.Mask (mask);
                mask.Destroy ();
            }

            cr.ResetClip ();
            context.Theme.Widget.StyleContext.Restore ();
        }
Exemplo n.º 4
0
        protected override void ClippedRender(Hyena.Data.Gui.CellContext context)
        {
            if (!EnsureLayout())
            {
                return;
            }

            var cr = context.Context;

            context.StyleContext.Save();
            context.StyleContext.State |= context.State;
            if (context.TextAsForeground)
            {
                context.StyleContext.AddClass("button");
            }
            else
            {
                context.StyleContext.AddClass("entry");
            }
            Foreground = new Brush(context.StyleContext.GetColor(context.StyleContext.State));

            Brush foreground = Foreground;

            if (!foreground.IsValid)
            {
                return;
            }

            cr.Rectangle(0, 0, RenderSize.Width, RenderSize.Height);
            cr.Clip();

            bool fade = Fade && text_alloc.Width > RenderSize.Width;

            if (fade)
            {
                cr.PushGroup();
            }

            Foreground.Apply(cr);
            UpdateLayout(GetText(), RenderSize.Width, RenderSize.Height, true);
            if (Hyena.PlatformDetection.IsWindows)
            {
                // FIXME windows; working around some unknown issue with ShowLayout; bgo#644311

                cr.Antialias = Cairo.Antialias.None;
                Pango.CairoHelper.LayoutPath(cr, layout);
            }
            else
            {
                Pango.CairoHelper.ShowLayout(cr, layout);
            }

            TooltipMarkup = layout.IsEllipsized ? last_formatted_text : null;

            if (fade)
            {
                using (var mask = new LinearGradient(RenderSize.Width - 20, 0, RenderSize.Width, 0)) {
                    mask.AddColorStop(0, new Color(0, 0, 0, 1));
                    mask.AddColorStop(1, new Color(0, 0, 0, 0));

                    cr.PopGroupToSource();
                    cr.Mask(mask);
                }
            }

            cr.ResetClip();
            context.StyleContext.Restore();
        }