Beispiel #1
0
        public void Render(Cairo.Context cr,
                           Widget widget,
                           Gdk.Rectangle background_area,
                           Gdk.Rectangle cell_area,
                           CairoCellRendererState state)
        {
            int x = cell_area.X, bg_x = cell_area.X - (spacing / 2);
            int y = cell_area.Y, bg_y = cell_area.Y - (spacing / 2);

            Gdk.Rectangle child_area = new Gdk.Rectangle();
            Gdk.Rectangle bg_area = new Gdk.Rectangle();

            foreach (BoxCellRendererChild child in children)
            {
                int child_w, child_h;
                child.Renderer.GetSize(out child_w, out child_h);

                child_area.X = x;
                child_area.Y = y;

                bg_area.X = bg_x;
                bg_area.Y = bg_y;
                if (orientation == Orientation.Vertical)
                {
                    child_area.Width  = cell_area.Width;
                    child_area.Height = child_h;

                    y += child_area.Height + spacing;

                    bg_y = y - (spacing / 2);
                }
                else
                {
                    child_area.Width  = child_w;
                    child_area.Height = cell_area.Height;

                    x += child_area.Width + spacing;

                    bg_x = x - (spacing / 2);
                }

                bg_area.Width  = child_area.Width + spacing;
                bg_area.Height = child_area.Height + spacing;

                child.Renderer.Render(cr, widget, bg_area,
                                      child_area, state);
            }
        }
Beispiel #2
0
        private CairoCellRendererState GetCellState(TreePath path)
        {
            CairoCellRendererState state = CairoCellRendererState.None;

            if (selected_paths.Contains(path))
            {
                state |= CairoCellRendererState.Selected;
            }

            if (HasFocus &&
                focused_path != null &&
                focused_path.Equals(path))
            {
                state |= CairoCellRendererState.Focused;
            }

            return(state);
        }
Beispiel #3
0
        public void Render(Cairo.Context cr,
                           Widget widget,
                           Gdk.Rectangle background_area,
                           Gdk.Rectangle cell_area,
                           CairoCellRendererState state)
        {
            if (!visible || pixbuf == null)
            {
                return;
            }

            int x = cell_area.X + (cell_area.Width / 2) - (pixbuf.Width / 2);
            int y = cell_area.Y + (cell_area.Height / 2) - (pixbuf.Height / 2);

            int w = pixbuf.Width;
            int h = pixbuf.Height;

            cr.Save();

            Gdk.CairoHelper.SetSourcePixbuf(cr, pixbuf, x, y);
            cr.Rectangle(x, y, w, h);
            cr.Fill();

            if ((state & CairoCellRendererState.Selected)
                == CairoCellRendererState.Selected)
            {
                cr.Save();

                //cr.Color = CairoHelper.GetCairoColorWithAlpha (widget.Style.Background (StateType.Selected), 0.4f);
                cr.SetSourceRGBA(CairoHelper.GetCairoColorWithAlpha(widget.Style.Background(StateType.Selected), 0.4f).R, CairoHelper.GetCairoColorWithAlpha(widget.Style.Background(StateType.Selected), 0.4f).G, CairoHelper.GetCairoColorWithAlpha(widget.Style.Background(StateType.Selected), 0.4f).B, CairoHelper.GetCairoColorWithAlpha(widget.Style.Background(StateType.Selected), 0.4f).A);

                cr.Rectangle(x, y, w, h);
                cr.Operator = Operator.Xor;
                cr.Fill();

                cr.Restore();
            }

            if ((state & CairoCellRendererState.Focused)
                == CairoCellRendererState.Focused)
            {
                cr.Save();

                cr.Rectangle((int)x - 0.5f, y - 0.5f,
                             w + 1.5f, h + 1.0f);
                CairoHelper.PaintFocus(cr, widget.Style, StateType.Normal);

                cr.Restore();
            }

            // draw the emblem over everything (with no selection
            // or focus outline
            if (emblem_pixbuf != null && emblem_visible)
            {
                switch (emblem_corner)
                {
                case Corner.TopLeft:
                    x -= (emblem_pixbuf.Width / 2);
                    y -= (emblem_pixbuf.Height / 2);
                    break;

                case Corner.TopRight:
                    x += w - (emblem_pixbuf.Width / 2);
                    y -= (emblem_pixbuf.Height / 2);
                    break;

                case Corner.BottomLeft:
                    x -= (emblem_pixbuf.Width / 2);
                    y += h - (emblem_pixbuf.Height / 2);
                    break;

                case Corner.BottomRight:
                    x += w - (emblem_pixbuf.Width / 2);
                    y += h - (emblem_pixbuf.Height / 2);
                    break;
                }

                Gdk.CairoHelper.SetSourcePixbuf(cr, emblem_pixbuf, x, y);
                cr.Rectangle(x, y, emblem_pixbuf.Width, emblem_pixbuf.Height);
                cr.Fill();
            }

            cr.Restore();
        }
Beispiel #4
0
        public void Render(Cairo.Context cr,
                           Widget widget,
                           Gdk.Rectangle background_area,
                           Gdk.Rectangle cell_area,
                           CairoCellRendererState state)
        {
            if (!visible)
            {
                return;
            }

            int width, height;

            CairoHelper.GetToyTextMetrics(font_size, text,
                                          out width, out height);

            // pad the requested size with the selection outline
            width  += SELECTION_PAD * 2;
            height += SELECTION_PAD * 2;

            int x = cell_area.X + (cell_area.Width / 2) - (width / 2) + SELECTION_PAD;
            int y = cell_area.Y + SELECTION_PAD;

            cr.Save();

            Gtk.StateType state_type = StateType.Normal;
            if ((state & CairoCellRendererState.Selected)
                == CairoCellRendererState.Selected)
            {
                state_type = StateType.Selected;

                CairoHelper.RoundedRectangle(cr, x - SELECTION_PAD, y - SELECTION_PAD,
                                             width, height, 10);
                //cr.Color = CairoHelper.GetCairoColor (widget.Style.Background (state_type));
                cr.SetSourceRGBA(CairoHelper.GetCairoColor(widget.Style.Background(state_type)).R, CairoHelper.GetCairoColor(widget.Style.Background(state_type)).G, CairoHelper.GetCairoColor(widget.Style.Background(state_type)).B, CairoHelper.GetCairoColor(widget.Style.Background(state_type)).A);

                cr.Fill();
            }

            if (font_color.Equal(Gdk.Color.Zero))
            {
                //cr.Color = CairoHelper.GetCairoColor (widget.Style.Text (state_type));
                cr.SetSourceRGBA(CairoHelper.GetCairoColor(widget.Style.Text(state_type)).R, CairoHelper.GetCairoColor(widget.Style.Text(state_type)).G, CairoHelper.GetCairoColor(widget.Style.Text(state_type)).B, CairoHelper.GetCairoColor(widget.Style.Text(state_type)).A);
            }
            else
            {
                //cr.Color = CairoHelper.GetCairoColor (font_color);
                cr.SetSourceRGBA(CairoHelper.GetCairoColor(font_color).R, CairoHelper.GetCairoColor(font_color).G, CairoHelper.GetCairoColor(font_color).B, CairoHelper.GetCairoColor(font_color).A);
            }

            CairoHelper.PaintToyText(cr, font_size, text, x, y, true,
                                     width - (SELECTION_PAD * 2));

            if ((state & CairoCellRendererState.Focused)
                == CairoCellRendererState.Focused)
            {
                cr.Rectangle(x - SELECTION_PAD, y - SELECTION_PAD, width, height);
                CairoHelper.PaintFocus(cr, widget.Style, StateType.Normal);
            }

            cr.Restore();
        }