Exemple #1
0
        void DrawShadow(Cairo.Context ctx, Gdk.Rectangle ar, PositionType pos, List <Section> secs)
        {
            foreach (Section s in secs)
            {
                Cairo.Gradient pat = null;
                Gdk.Rectangle  r   = ar;
                switch (pos)
                {
                case PositionType.Top:
                    r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
                    r.X     += s.Offset;
                    r.Width  = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Y, r.X, r.Bottom);
                    break;

                case PositionType.Bottom:
                    r.Y      = r.Bottom - shadowSize;
                    r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
                    r.X      = r.X + s.Offset;
                    r.Width  = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Bottom, r.X, r.Y);
                    break;

                case PositionType.Left:
                    r.Width  = shadowSize > r.Width ? r.Width / 2 : shadowSize;
                    r.Y     += s.Offset;
                    r.Height = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Y, r.Right, r.Y);
                    break;

                case PositionType.Right:
                    r.X      = r.Right - shadowSize;
                    r.Width  = shadowSize > r.Width ? r.Width / 2 : shadowSize;
                    r.Y     += s.Offset;
                    r.Height = s.Size;
                    pat      = new Cairo.LinearGradient(r.Right, r.Y, r.X, r.Y);
                    break;
                }
                Cairo.Color c = GtkUtil.ToCairoColor(darkColor);
                pat.AddColorStop(0, c);
                c.A = 0;
                pat.AddColorStop(1, c);
                ctx.NewPath();
                ctx.Rectangle(r.X, r.Y, r.Width, r.Height);
                ctx.Pattern = pat;
                ctx.Fill();
                pat.Destroy();
            }
        }
Exemple #2
0
 protected override bool OnLeaveNotifyEvent(Gdk.EventCrossing evnt)
 {
     MouseIsOver = false;
     GtkUtil.HideTooltip(tree);
     return(base.OnLeaveNotifyEvent(evnt));
 }
Exemple #3
0
        public void DrawBackground(Gtk.Widget w, Gdk.Rectangle allocation)
        {
            if (shadowSize == 0)
            {
                Gdk.Rectangle wr = new Gdk.Rectangle(allocation.X, allocation.Y, allocation.Width, allocation.Height);
                using (Cairo.Context ctx = Gdk.CairoHelper.Create(w.GdkWindow)) {
                    ctx.Rectangle(wr.X, wr.Y, wr.Width, wr.Height);
                    ctx.Color = GtkUtil.ToCairoColor(lightColor);
                    ctx.Fill();
                }
                return;
            }

            List <Section> secsT = new List <Section> ();
            List <Section> secsB = new List <Section> ();
            List <Section> secsR = new List <Section> ();
            List <Section> secsL = new List <Section> ();

            int x, y;

            w.GdkWindow.GetOrigin(out x, out y);
            Gdk.Rectangle rect = new Gdk.Rectangle(x + allocation.X, y + allocation.Y, allocation.Width, allocation.Height);

            Section s = new Section();

            s.Size = rect.Width;
            secsT.Add(s);
            secsB.Add(s);
            s.Size = rect.Height;
            secsL.Add(s);
            secsR.Add(s);

            foreach (var rects in allocations)
            {
                int sx, sy;
                rects.Key.GdkWindow.GetOrigin(out sx, out sy);
                foreach (Gdk.Rectangle srt in rects.Value)
                {
                    if (srt == rect)
                    {
                        continue;
                    }
                    Gdk.Rectangle sr = srt;
                    sr.Offset(sx, sy);
                    if (sr.Right == rect.X)
                    {
                        RemoveSection(secsL, sr.Y - rect.Y, sr.Height);
                    }
                    if (sr.Bottom == rect.Y)
                    {
                        RemoveSection(secsT, sr.X - rect.X, sr.Width);
                    }
                    if (sr.X == rect.Right)
                    {
                        RemoveSection(secsR, sr.Y - rect.Y, sr.Height);
                    }
                    if (sr.Y == rect.Bottom)
                    {
                        RemoveSection(secsB, sr.X - rect.X, sr.Width);
                    }
                }
            }

            Gdk.Rectangle r = new Gdk.Rectangle(allocation.X, allocation.Y, allocation.Width, allocation.Height);
            using (Cairo.Context ctx = Gdk.CairoHelper.Create(w.GdkWindow)) {
                ctx.Rectangle(r.X, r.Y, r.Width, r.Height);
                ctx.Color = GtkUtil.ToCairoColor(lightColor);
                ctx.Fill();

                DrawShadow(ctx, r, PositionType.Left, secsL);
                DrawShadow(ctx, r, PositionType.Top, secsT);
                DrawShadow(ctx, r, PositionType.Right, secsR);
                DrawShadow(ctx, r, PositionType.Bottom, secsB);
            }
        }