コード例 #1
0
        public void DrawCellBackground(Context cr, ColumnBackgroundType bgType, int x, int y, int width, int height)
        {
            Color bg_color  = GetWidgetColor(GtkColorClass.Background, StateType.Active);
            Color bg_normal = GetWidgetColor(GtkColorClass.Background, StateType.Normal);

            switch (bgType)
            {
            case ColumnBackgroundType.Normal:
                cr.Color = bg_normal;
                cr.Rectangle(x, y, width, height);
                cr.Fill();
                break;

            case ColumnBackgroundType.Hint:
                cr.Color = bg_color.ColorShade(1.2);
                cr.Rectangle(x, y, width, height);
                cr.Fill();
                break;

            case ColumnBackgroundType.Sorted:
                cr.Color = bg_color.ColorShade(1.2);
                cr.Rectangle(x, y, width, height);
                cr.Fill();
                break;

            case ColumnBackgroundType.SortedHint:
                cr.Color = bg_color.ColorShade(1.1);;
                cr.Rectangle(x, y, width, height);
                cr.Fill();
                break;

            default:
                throw new ArgumentOutOfRangeException("bgType");
            }
        }
コード例 #2
0
        public void DrawFooterBackground(Cairo.Context cr, Gdk.Rectangle alloc, int top_offset, bool fill)
        {
            Color gtk_background_color = GetWidgetColor(GtkColorClass.Background, StateType.Normal);
            Color gtk_base_color       = GetWidgetColor(GtkColorClass.Base, StateType.Normal);
            Color light_color          = gtk_background_color.ColorShade(1.1);
            Color dark_color           = gtk_background_color.ColorShade(0.95);

            const CairoCorners corners = CairoCorners.BottomLeft | CairoCorners.BottomRight;

            if (fill)
            {
                LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height);
                grad.AddColorStop(0, light_color);
                grad.AddColorStop(0.75, dark_color);
                grad.AddColorStop(0, light_color);

                cr.Pattern = grad;
                cr.RoundedRectangle(alloc.X, alloc.Y + top_offset, alloc.Width, alloc.Height - top_offset, BORDER_RADIUS, corners);
                cr.Fill();

                cr.Color = gtk_base_color;
                cr.Rectangle(alloc.X, alloc.Y, alloc.Width, top_offset);
                cr.Fill();
            }
            else
            {
                cr.Color = gtk_base_color;
                cr.RoundedRectangle(alloc.X, alloc.Y, alloc.Width, alloc.Height, BORDER_RADIUS, corners);
                cr.Fill();
            }

            cr.LineWidth = 1.0;
            cr.Translate(alloc.Y + 0.5, alloc.Y - 0.5);

            cr.Color = border_color;
            cr.RoundedRectangle(alloc.X, alloc.Y - 4, alloc.Width - 1, alloc.Height + 4, BORDER_RADIUS, corners);
            cr.Stroke();

            if (fill)
            {
                cr.LineWidth = 1;
                cr.Antialias = Cairo.Antialias.None;
                cr.MoveTo(alloc.X + 1, alloc.Y + 1 + top_offset);
                cr.LineTo(alloc.X + alloc.Width - 1, alloc.Y + 1 + top_offset);
                cr.Stroke();
                cr.Antialias = Cairo.Antialias.Default;
            }
        }
コード例 #3
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height)
        {
            Color selection_color = GetWidgetColor(GtkColorClass.Background, StateType.Selected);

            LinearGradient grad = new LinearGradient(x, y, x, y + height);

            grad.AddColorStop(0, selection_color.ColorShade(1.1));
            grad.AddColorStop(1, selection_color.ColorShade(0.85));

            cr.Pattern = grad;
            cr.RoundedRectangle(x, y, width, height, BORDER_RADIUS);
            cr.Fill();

            cr.LineWidth = 0.5;
            cr.Color     = selection_color.ColorShade(0.75);
            cr.RoundedRectangle(x + 1, y + 1, width - 2, height - 2, BORDER_RADIUS);
            cr.Stroke();
        }
コード例 #4
0
        public void DrawFooterSeparator(Cairo.Context cr, Gdk.Rectangle alloc, int x, int top_offset)
        {
            Color gtk_background_color = GetWidgetColor(GtkColorClass.Background, StateType.Normal);
            Color dark_color           = gtk_background_color.ColorShade(0.80);
            Color light_color          = gtk_background_color.ColorShade(1.1);

            int y_1 = alloc.Y + 3 + top_offset;
            int y_2 = alloc.Y + alloc.Height - 3;

            cr.LineWidth = 1;
            cr.Antialias = Antialias.None;

            cr.Color = dark_color;
            cr.MoveTo(x, y_1);
            cr.LineTo(x, y_2);
            cr.Stroke();

            cr.Color = light_color;
            cr.MoveTo(x + 1, y_1);
            cr.LineTo(x + 1, y_2);
            cr.Stroke();

            cr.Antialias = Cairo.Antialias.Default;
        }