private void DrawBox(Rectangle area, int item)
        {
            Box       box = new Box(this, item);
            Rectangle bar = box.Bar;

            if (bar.Intersect(area, out area))
            {
                if (item < min_limit.Position || item > max_limit.Position)
                {
#if false
                    bar.Height += 1;

                    //GdkWindow.DrawRectangle (Style.ForegroundGC (StateType.Normal), false, box);
                    Style.PaintShadow(this.Style, GdkWindow, State, ShadowType.In, area,
                                      this, null, bar.X, bar.Y,
                                      bar.Width, bar.Height);
#else
                    GdkWindow.DrawRectangle(Style.BackgroundGC(StateType.Active), true, area);
#endif
                }
                else
                {
                    GdkWindow.DrawRectangle(Style.BaseGC(StateType.Selected), true, area);
                }
            }
        }
Esempio n. 2
0
        protected override bool OnExposeEvent(Gdk.EventExpose evt)
        {
            Rectangle headerRect, bgRect;
            int       headerHeight = header.Allocation.Height;

            Gdk.Color white, bg, mid;

            headerRect        = bgRect = Allocation;
            headerRect.Height = headerHeight;
            bgRect.Y         += headerHeight;
            bgRect.Height    -= headerHeight;

            GdkWindow.DrawRectangle(Style.BaseGC(State), true, bgRect);

            white = Style.Base(State);
            bg    = Style.Background(State);

            mid       = new Gdk.Color();
            mid.Red   = (ushort)((white.Red + bg.Red) / 2);
            mid.Green = (ushort)((white.Green + bg.Green) / 2);
            mid.Blue  = (ushort)((white.Blue + bg.Blue) / 2);
            Style.BaseGC(State).RgbFgColor = mid;
            GdkWindow.DrawRectangle(Style.BaseGC(State), true, headerRect);
            Style.BaseGC(State).Foreground = white;

            return(base.OnExposeEvent(evt));
        }
Esempio n. 3
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
//			var alloc = Allocation;
            double border = 1.0;

//			var halfBorder = border / 2.0;

            using (var cr = Gdk.CairoHelper.Create(evnt.Window)) {
                cr.LineWidth = border;
                cr.Rectangle(0, 0, Allocation.Width, Allocation.Height);
                cr.Color = document.Editor.ColorStyle.Default.CairoBackgroundColor;
                cr.Fill();

                FoldingScreenbackgroundRenderer.DrawRoundRectangle(cr,
                                                                   true, true,
                                                                   0, 0, Allocation.Width / 2,
                                                                   Allocation.Width, Allocation.Height);
                cr.Color = isMouseInside || menuPushed ? document.Editor.ColorStyle.Default.CairoColor : document.Editor.ColorStyle.FoldLine.CairoColor;
                cr.Stroke();

                evnt.Window.DrawPixbuf(Style.BaseGC(State), icon,
                                       0, 0,
                                       (Allocation.Width - icon.Width) / 2, (Allocation.Height - icon.Height) / 2,
                                       icon.Width, icon.Height,
                                       Gdk.RgbDither.None, 0, 0);
            }

            return(true);
        }
Esempio n. 4
0
        void ExposeHandler(object obj, ExposeEventArgs args)
        {
            int max_steps = 25;
            int displ;

            Gdk.Window    win  = args.Event.Window;
            Gdk.Rectangle area = args.Event.Area;

            win.DrawRectangle(Style.BaseGC(StateType.Normal), true, area);

            for (int y = 0, row = top_displayed; y < area.Y + area.Height; y += line_height, row++)
            {
                Gdk.GC        gc;
                Gdk.Rectangle region_area = new Gdk.Rectangle(0, y, Allocation.Width, line_height);
                StateType     state       = StateType.Normal;

                if (sel_rows.Contains(row))
                {
                    if (HasFocus)
                    {
                        state = StateType.Selected;
                    }
                    else
                    {
                        state = StateType.Active;
                    }

                    win.DrawRectangle(Style.BaseGC(state), true, region_area);
                }

                //FIXME: we have a ghost row at the end of the list!

                if (row >= provider.Rows)
                {
                    return;
                }

                string text = "";

                if (ellipses[row] == null)
                {
                    text = provider.GetValue(row);
                }
                else
                {
                    text = (string)ellipses[row];
                }
                displ = (int)((max_steps / HAdjustment.Upper) * HAdjustment.Value);
                text  = ELabel.Ellipsize(layout, text, Allocation.Width - 2 * 2, ellipsis_width, en_width, displ);

                layout.SetText(text);

                gc = Style.TextGC(state);
                win.DrawLayout(gc, 2, y, layout);
            }

            args.RetVal = true;
        }
Esempio n. 5
0
        // Methods :: Public :: ForwardKeyPress
        //  Hack to forward key press events to the treeview
        public bool ForwardKeyPress(Widget orig_widget, Gdk.EventKey e)
        {
            bool go = false;

            Gdk.ModifierType mod = 0;

            bool has_state = (e.State != 0);
            bool has_ctrl  = ((e.State & Gdk.ModifierType.ControlMask) != 0);
            bool has_alt   = ((e.State & Gdk.ModifierType.Mod1Mask) != 0);
            bool has_shift = ((e.State & Gdk.ModifierType.ShiftMask) != 0);

            bool has_mod = KeyUtils.HaveModifier(e);
            bool is_mod  = KeyUtils.IsModifier(e);

            if (has_state && has_ctrl)
            {
                go  = true;
                mod = Gdk.ModifierType.ControlMask;
            }
            else if (has_state && has_alt)
            {
                go  = true;
                mod = Gdk.ModifierType.Mod1Mask;
            }
            else if (has_state && has_shift)
            {
                go  = true;
                mod = Gdk.ModifierType.ShiftMask;
            }
            else if (!has_mod && !is_mod)
            {
                go  = true;
                mod = 0;
            }

            if (!go)
            {
                return(false);
            }

            Gdk.GC saved_gc = Style.BaseGC(StateType.Selected);

            Gdk.GC active_gc = Style.BaseGC(StateType.Active);
            Style.SetBaseGC(StateType.Selected, active_gc);

            GrabFocus();

            bool ret = Gtk.Global.BindingsActivate(this, (uint)e.Key, mod);

            Style.SetBaseGC(StateType.Selected, saved_gc);
            orig_widget.GrabFocus();

            return(ret);
        }
        void StyleHandler(object obj, StyleSetArgs args)
        {
            if (Style == my_style)
            {
                return;
            }

            my_style = style_widget.Style.Copy();
            Style    = my_style;
            my_style.SetBackgroundGC(StateType.Normal, Style.BaseGC(StateType.Normal));
            Refresh();
        }
Esempio n. 7
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            int winWidth, winHeight;

            this.GetSize(out winWidth, out winHeight);
            evnt.Window.DrawRectangle(Style.BaseGC(StateType.Normal), true, 0, 0, winWidth - 1, winHeight - 1);
            evnt.Window.DrawRectangle(Style.MidGC(StateType.Normal), false, 0, 0, winWidth - 1, winHeight - 1);
            foreach (var child in this.Children)
            {
                this.PropagateExpose(child, evnt);
            }
            return(false);
        }
Esempio n. 8
0
        private void DrawBox(Rectangle area, int item)
        {
            Box       box = new Box(this, item);
            Rectangle bar = box.Bar;

            if (bar.Intersect(area, out area))
            {
                if (item < min_limit.Position || item > max_limit.Position)
                {
                    GdkWindow.DrawRectangle(Style.BackgroundGC(StateType.Active), true, area);
                }
                else
                {
                    GdkWindow.DrawRectangle(Style.BaseGC(StateType.Selected), true, area);
                }
            }
        }
Esempio n. 9
0
            protected override bool OnExposeEvent(Gdk.EventExpose evt)
            {
                if (!IsDrawable)
                {
                    return(false);
                }

                if (evt.Window == GdkWindow)
                {
                    GdkWindow.DrawRectangle(Style.BaseGC(State), true,
                                            evt.Area.X, evt.Area.Y,
                                            evt.Area.Width, evt.Area.Height);
                }

                if (Child != null)
                {
                    PropagateExpose(Child, evt);
                }

                return(false);
            }
Esempio n. 10
0
        // From Mono.TextEditor.FoldMarkerMargin
        void DrawFoldSegment(Gdk.Drawable win, int x, int y, int w, int h, bool isOpen, bool selected)
        {
            Gdk.Rectangle drawArea = new Gdk.Rectangle(x, y, w, h);

            win.DrawRectangle(selected ? Style.ForegroundGC(StateType.Normal) : Style.BaseGC(StateType.Normal), true, drawArea);
            win.DrawRectangle(selected ? Style.ForegroundGC(StateType.Normal) : Style.DarkGC(StateType.Normal), false, drawArea);

            win.DrawLine(selected ? Style.BaseGC(StateType.Normal) : Style.ForegroundGC(StateType.Normal),
                         drawArea.Left + drawArea.Width * 3 / 10,
                         drawArea.Top + drawArea.Height / 2,
                         drawArea.Right - drawArea.Width * 3 / 10,
                         drawArea.Top + drawArea.Height / 2);

            if (!isOpen)
            {
                win.DrawLine(selected ? Style.BaseGC(StateType.Normal) : Style.ForegroundGC(StateType.Normal),
                             drawArea.Left + drawArea.Width / 2,
                             drawArea.Top + drawArea.Height * 3 / 10,
                             drawArea.Left + drawArea.Width / 2,
                             drawArea.Bottom - drawArea.Height * 3 / 10);
            }
        }
Esempio n. 11
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            Gdk.Window win = evnt.Window;
            win.DrawRectangle(Style.BaseGC(string.IsNullOrEmpty(Markup) ? StateType.Insensitive : StateType.Normal), true, evnt.Area);
            int x = 0;
            int y = 0;

            if (string.IsNullOrEmpty(Markup))
            {
                layout.SetMarkup(GettextCatalog.GetString("No documentation available."));
                int width, height;
                layout.GetPixelSize(out width, out height);
                x = (Allocation.Width - width) / 2;
                y = (Allocation.Height - height) / 2;
            }
            else
            {
                layout.SetMarkup(Markup);
            }
            layout.Width = Allocation.Width * (int)Pango.Scale.PangoScale;
            win.DrawLayout(Style.TextGC(StateType.Normal), x, y, layout);
            return(true);
        }
Esempio n. 12
0
        protected override bool OnExposeEvent(Gdk.EventExpose e)
        {
            using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) {
                cr.LineWidth = 1;
                cr.Rectangle(0, 0, Allocation.Width, 16);
                var pattern = new Cairo.LinearGradient(0, 0, 0, 16);
                pattern.AddColorStop(0, new Cairo.Color(0.6, 0.8, 0.6));
                pattern.AddColorStop(1, new Cairo.Color(0.8, 1.0, 0.8));
                cr.Pattern = pattern;
                cr.Fill();
                cr.Rectangle(0, 16, Allocation.Width, Allocation.Height - 16);
                pattern = new Cairo.LinearGradient(0, 16, 0, Allocation.Height);
                pattern.AddColorStop(0, new Cairo.Color(0.8, 1.0, 0.8));
                pattern.AddColorStop(1, new Cairo.Color(0.6, 0.8, 0.6));
                cr.Pattern = pattern;
                cr.Fill();

                cr.Line(0, 0, Allocation.Width, 0);
                cr.Color = new Cairo.Color(0.4, 0.6, 0.4);
                cr.Stroke();

                double xPos = padding, yPos = padding;
                var    layout = PangoUtil.CreateLayout(this);
                int    w, h;
                layout.SetText(new string ('X', maxLength));
                layout.GetPixelSize(out w, out h);

                foreach (Category cat in categories)
                {
                    yPos = padding;
                    cr.MoveTo(xPos, yPos);
                    layout.SetMarkup("<b>" + cat.Title + "</b>");
                    cr.Color = (HslColor)Style.Text(StateType.Normal);
                    cr.ShowLayout(layout);
                    layout.SetMarkup("");
                    int w2, h2;
                    layout.GetPixelSize(out w2, out h2);
                    yPos += h2;
                    yPos += headerDistance;
                    var startY     = yPos;
                    int curItem    = 0;
                    int row        = 0;
                    var iconHeight = Math.Max(h, cat.Items[0].Icon.Height + 2);
                    if (cat.FirstVisibleItem > 0)
                    {
                        Gtk.Style.PaintArrow(Style, e.Window, State, ShadowType.None,
                                             new Rectangle((int)xPos, (int)yPos, w, h),
                                             this,
                                             "",
                                             ArrowType.Up,
                                             true,
                                             (int)xPos,
                                             (int)yPos,
                                             w,
                                             h);
                        yPos += iconHeight;
                        curItem++;
                    }

                    for (int i = cat.FirstVisibleItem; i < cat.Items.Count; i++)
                    {
                        var item = cat.Items[i];

                        if (curItem + 1 >= maxItems && row + 1 >= maxRows && i + 1 < cat.Items.Count)
                        {
                            Gtk.Style.PaintArrow(Style, e.Window, State, ShadowType.None,
                                                 new Rectangle((int)xPos, (int)yPos, w, h),
                                                 this,
                                                 "",
                                                 ArrowType.Down,
                                                 true,
                                                 (int)xPos,
                                                 (int)yPos,
                                                 w,
                                                 h);
                            break;
                        }

                        if (item == ActiveItem)
                        {
                            cr.Rectangle(xPos + 0.5, yPos + 0.5, w + item.Icon.Width + 2, iconHeight);

                            pattern = new Cairo.LinearGradient(xPos, yPos, xPos, yPos + iconHeight * 2);
                            pattern.AddColorStop(0, (HslColor)Style.Base(StateType.Selected));
                            pattern.AddColorStop(1, new Cairo.Color(0.8, 1.0, 0.8));
                            cr.Pattern = pattern;
                            cr.FillPreserve();

                            cr.Color = (HslColor)Style.Base(StateType.Selected);
                            cr.Stroke();
                            cr.Color = (HslColor)Style.Text(StateType.Selected);
                        }
                        else if (item == hoverItem)
                        {
                            cr.Rectangle(xPos + 0.5, yPos + 0.5, w + item.Icon.Width + 2, iconHeight);
                            pattern = new Cairo.LinearGradient(xPos, yPos, xPos, yPos + iconHeight);
                            pattern.AddColorStop(0, new Cairo.Color(0.6, 0.8, 0.6));
                            pattern.AddColorStop(1, new Cairo.Color(0.8, 1.0, 0.8));
                            cr.Pattern = pattern;
                            cr.Fill();
                            cr.Color = (HslColor)Style.Text(StateType.Normal);
                        }
                        else
                        {
                            cr.Color = (HslColor)Style.Text(StateType.Normal);
                        }
                        cr.MoveTo(xPos + item.Icon.Width + 2, yPos + (iconHeight - h) / 2);
                        layout.SetText(Ellipsize(item.ListTitle ?? item.Title, maxLength));
                        cr.ShowLayout(layout);
                        e.Window.DrawPixbuf(Style.BaseGC(StateType.Normal), item.Icon, 0, 0, (int)xPos, (int)(yPos + (iconHeight - item.Icon.Height) / 2), item.Icon.Width, item.Icon.Height, RgbDither.None, 0, 0);

                        yPos += iconHeight;
                        if (++curItem >= maxItems)
                        {
                            curItem = 0;
                            yPos    = startY;
                            xPos   += w + cat.Items[0].Icon.Width + 2 + padding;
                            row++;
                        }
                    }


                    xPos += w + cat.Items[0].Icon.Width + 2 + padding;
                }
                layout.Dispose();
            }
            return(true);
        }
Esempio n. 13
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            Rectangle area;

            //Console.WriteLine ("expose {0}", args.Area);
            foreach (Rectangle sub in args.Region.GetRectangles())
            {
                if (sub.Intersect(background, out area))
                {
                    Rectangle active = background;
                    int       min_x  = BoxX(min_limit.Position);
                    int       max_x  = BoxX(max_limit.Position + 1);
                    active.X     = min_x;
                    active.Width = max_x - min_x;

                    if (active.Intersect(area, out active))
                    {
                        GdkWindow.DrawRectangle(Style.BaseGC(State), true, active);
                    }

                    int i;
                    BoxXHit(area.X, out i);
                    int end;
                    BoxXHit(area.X + area.Width, out end);
                    while (i <= end)
                    {
                        DrawBox(area, i++);
                    }
                }

                Style.PaintShadow(this.Style, GdkWindow, State, ShadowType.In, area,
                                  this, null, background.X, background.Y,
                                  background.Width, background.Height);

                if (sub.Intersect(legend, out area))
                {
                    int i = 0;

                    while (i < box_counts.Length)
                    {
                        DrawTick(area, i++);
                    }
                }

                if (has_limits)
                {
                    if (min_limit != null)
                    {
                        min_limit.Draw(sub);
                    }

                    if (max_limit != null)
                    {
                        max_limit.Draw(sub);
                    }
                }

                if (glass != null)
                {
                    glass.Draw(sub);
                }
            }
            return(base.OnExposeEvent(args));
        }
            void DrawList()
            {
                int winWidth, winHeight;

                GdkWindow.GetSize(out winWidth, out winHeight);

                int       lineWidth = winWidth - leftXAlignment * 2;
                const int xpos      = leftXAlignment + padding;

                int n    = (int)(vAdjustment.Value / rowHeight);
                int ypos = (int)(leftXAlignment + n * rowHeight - vAdjustment.Value);

                while (ypos < winHeight - leftXAlignment && n < win.DataProvider.IconCount)
                {
                    string text = win.DataProvider.GetMarkup(n) ?? "&lt;null&gt;";

                    var icon       = win.DataProvider.GetIcon(n);
                    int iconHeight = icon != null ? (int)icon.Height : 24;
                    int iconWidth  = icon != null ? (int)icon.Width : 0;

                    layout.Ellipsize = Pango.EllipsizeMode.End;
                    layout.Width     = (Allocation.Width - xpos - iconWidth - iconTextDistance) * (int)Pango.Scale.PangoScale;
                    layout.SetMarkup(PathBar.GetFirstLineFromMarkup(text));

                    int wi, he, typos, iypos;
                    layout.GetPixelSize(out wi, out he);
                    typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos;
                    iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos;

                    if (n == selection)
                    {
                        if (!disableSelection)
                        {
                            GdkWindow.DrawRectangle(Style.BaseGC(StateType.Selected),
                                                    true, leftXAlignment, ypos, lineWidth, rowHeight);
                            GdkWindow.DrawLayout(Style.TextGC(StateType.Selected),
                                                 xpos + iconWidth + iconTextDistance, typos, layout);
                        }
                        else
                        {
                            GdkWindow.DrawRectangle(Style.BaseGC(StateType.Selected),
                                                    false, leftXAlignment, ypos, lineWidth, rowHeight);
                            GdkWindow.DrawLayout(Style.TextGC(StateType.Normal),
                                                 xpos + iconWidth + iconTextDistance, typos, layout);
                        }
                    }
                    else
                    {
                        GdkWindow.DrawLayout(Style.TextGC(StateType.Normal),
                                             xpos + iconWidth + iconTextDistance, typos, layout);
                    }

                    if (icon != null)
                    {
                        using (var ctx = Gdk.CairoHelper.Create(this.GdkWindow))
                            ctx.DrawImage(this, icon, xpos, iypos);
                    }

                    ypos += rowHeight;
                    n++;

//reset the markup or it carries over to the next SetText
                    layout.SetMarkup(string.Empty);
                }
            }
Esempio n. 15
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            bool usePaintBox = !Gtk.Settings.Default.ThemeName.Contains("Equinox");

            if (usePaintBox)
            {
                //HACK: paint the button background as if it were bigger, but it stays clipped to the real area,
                // so we get the content but not the border. This might break with crazy themes.
                // Themes that don't work need to be filtered out.
                //FIXME: we can't use the style's actual internal padding because GTK# hasn't wrapped GtkBorder AFAICT
                // (default-border, inner-border, default-outside-border, etc - see http://git.gnome.org/browse/gtk+/tree/gtk/gtkbutton.c)
                const int boxpadding = 4;
                Style.PaintBox(Style, evnt.Window, StateType.Normal, ShadowType.None, evnt.Area, styleButton, "button",
                               -boxpadding, -padding, Allocation.Width + boxpadding * 2, Allocation.Height + boxpadding * 2);
            }

            if (leftWidths == null || rightWidths == null)
            {
                return(true);
            }

            int xpos = padding, ypos = padding;

            for (int i = 0; i < leftPath.Length; i++)
            {
                bool last = i == leftPath.Length - 1;

                int x = xpos;
                xpos += leftWidths [i];
                xpos += spacing;

                if (hoverIndex >= 0 && hoverIndex < Path.Length && leftPath [i] == Path [hoverIndex] && (menuVisible || pressed || hovering))
                {
                    if (usePaintBox)
                    {
                        Style.PaintBox(Style, GdkWindow,
                                       (pressed || menuVisible) ? StateType.Active : StateType.Prelight,
                                       (pressed || menuVisible) ? ShadowType.In : ShadowType.Out,
                                       evnt.Area, styleButton, "button",
                                       x - padding, ypos - padding, leftWidths [i] + padding + padding /*+ (last ? padding : spacing)*/,
                                       height + padding * 2);
                    }
                    else
                    {
                        evnt.Window.DrawRectangle(Style.DarkGC(StateType.Normal), false, x - padding, ypos - padding, leftWidths [i] + padding + padding, height + padding);
                    }
                }

                int textOffset = 0;
                if (leftPath [i].Icon != null)
                {
                    GdkWindow.DrawPixbuf(Style.BaseGC(State), leftPath [i].Icon, 0, 0, x, ypos, -1, -1, RgbDither.None, 0, 0);
                    textOffset += leftPath [i].Icon.Width + padding;
                }

                layout.Attributes = (i == activeIndex) ? boldAtts : null;
                layout.SetText(leftPath [i].Text);
                Style.PaintLayout(Style, GdkWindow, State, false, evnt.Area, this, "", x + textOffset, ypos, layout);
                if (!last)
                {
                    if (leftPath [i].IsPathEnd)
                    {
                        Style.PaintVline(Style, GdkWindow, State, evnt.Area, this, "", ypos, ypos + height, xpos - spacing / 2);
                    }
                    else
                    {
                        int arrowH = Math.Min(height, spacing);
                        int arrowY = ypos + (height - arrowH) / 2;
                        Style.PaintArrow(Style, GdkWindow, State, ShadowType.None, evnt.Area, this, "", ArrowType.Right,
                                         true, xpos - spacing, arrowY, spacing, arrowH);
                    }
                }
            }

            int xposRight = Allocation.Width - padding;

            for (int i = 0; i < rightPath.Length; i++)
            {
//				bool last = i == rightPath.Length - 1;

                xposRight -= rightWidths [i];
                xposRight -= spacing;

                int x = xposRight;

                if (hoverIndex >= 0 && hoverIndex < Path.Length && rightPath [i] == Path [hoverIndex] && (menuVisible || pressed || hovering))
                {
                    if (usePaintBox)
                    {
                        Style.PaintBox(Style, GdkWindow,
                                       (pressed || menuVisible) ? StateType.Active : StateType.Prelight,
                                       (pressed || menuVisible) ? ShadowType.In : ShadowType.Out,
                                       evnt.Area, this, "button",
                                       x - padding, ypos - padding, rightWidths [i] + padding + padding /*+ (last ? padding : spacing)*/,
                                       height + padding * 2);
                    }
                    else
                    {
                        evnt.Window.DrawRectangle(Style.DarkGC(StateType.Normal), false, x - padding, ypos - padding, rightWidths [i] + padding + padding, height + padding);
                    }
                }

                int textOffset = 0;
                if (rightPath [i].Icon != null)
                {
                    GdkWindow.DrawPixbuf(Style.BaseGC(State), rightPath [i].Icon, 0, 0, x, ypos, -1, -1, RgbDither.None, 0, 0);
                    textOffset += rightPath [i].Icon.Width + padding;
                }

                layout.Attributes = (i == activeIndex) ? boldAtts : null;
                layout.SetText(rightPath [i].Text);
                Style.PaintLayout(Style, GdkWindow, State, false, evnt.Area, this, "", x + textOffset, ypos, layout);
            }

            return(true);
        }
            void DrawList()
            {
                int winWidth, winHeight;

                GdkWindow.GetSize(out winWidth, out winHeight);

                int       lineWidth = winWidth - margin * 2;
                const int xpos      = margin + padding;

                int n    = (int)(vAdjustment.Value / rowHeight);
                int ypos = (int)(margin + n * rowHeight - vAdjustment.Value);

                while (ypos < winHeight - margin && n < win.DataProvider.IconCount)
                {
                    string text = win.DataProvider.GetMarkup(n) ?? "&lt;null&gt;";

                    Gdk.Pixbuf icon       = win.DataProvider.GetIcon(n);
                    int        iconHeight = icon != null ? icon.Height : 24;
                    int        iconWidth  = icon != null ? icon.Width : 0;

                    layout.Ellipsize = Pango.EllipsizeMode.End;
                    layout.Width     = (Allocation.Width - xpos - iconWidth - 2) * (int)Pango.Scale.PangoScale;
                    layout.SetMarkup(text);

                    int wi, he, typos, iypos;
                    layout.GetPixelSize(out wi, out he);
                    typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos;
                    iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos;

                    if (n == selection)
                    {
                        if (!disableSelection)
                        {
                            GdkWindow.DrawRectangle(Style.BaseGC(StateType.Selected),
                                                    true, margin, ypos, lineWidth, rowHeight);
                            GdkWindow.DrawLayout(Style.TextGC(StateType.Selected),
                                                 xpos + iconWidth + 2, typos, layout);
                        }
                        else
                        {
                            GdkWindow.DrawRectangle(Style.BaseGC(StateType.Selected),
                                                    false, margin, ypos, lineWidth, rowHeight);
                            GdkWindow.DrawLayout(Style.TextGC(StateType.Normal),
                                                 xpos + iconWidth + 2, typos, layout);
                        }
                    }
                    else
                    {
                        GdkWindow.DrawLayout(Style.TextGC(StateType.Normal),
                                             xpos + iconWidth + 2, typos, layout);
                    }

                    if (icon != null)
                    {
                        GdkWindow.DrawPixbuf(Style.ForegroundGC(StateType.Normal), icon, 0, 0,
                                             xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0);
                    }

                    ypos += rowHeight;
                    n++;

//reset the markup or it carries over to the next SetText
                    layout.SetMarkup(string.Empty);
                }
            }
Esempio n. 17
0
        protected override bool OnExposeEvent(Gdk.EventExpose e)
        {
            Gdk.Drawable  draw = e.Window;
            Gdk.Rectangle area = e.Area;
            if (this.categories.Count == 0 || !string.IsNullOrEmpty(CustomMessage))
            {
                Pango.Layout messageLayout = new Pango.Layout(this.PangoContext);
                messageLayout.Alignment = Pango.Alignment.Center;
                messageLayout.Width     = (int)(Allocation.Width * 2 / 3 * Pango.Scale.PangoScale);
                if (!string.IsNullOrEmpty(CustomMessage))
                {
                    messageLayout.SetText(CustomMessage);
                }
                else
                {
                    messageLayout.SetText(MonoDevelop.Core.GettextCatalog.GetString("There are no tools available for the current document."));
                }
                draw.DrawLayout(Style.TextGC(StateType.Normal), Allocation.Width * 1 / 6, 12, messageLayout);
                messageLayout.Dispose();
                return(true);
            }

            Cairo.Context cr = Gdk.CairoHelper.Create(e.Window);
            draw.DrawRectangle(Style.BaseGC(StateType.Normal), true, area);
            int xpos        = (this.hAdjustement != null ? (int)this.hAdjustement.Value : 0);
            int vadjustment = (this.vAdjustement != null ? (int)this.vAdjustement.Value : 0);
            int ypos        = -vadjustment;

            Iterate(ref xpos, ref ypos, delegate(Category category, Gdk.Size itemDimension) {
                const int foldSegmentHeight = 8;

                if (category == SelectedItem)
                {
                    draw.DrawRectangle(Style.BaseGC(StateType.Selected),
                                       true,
                                       new Gdk.Rectangle(xpos,
                                                         ypos,
                                                         itemDimension.Width,
                                                         itemDimension.Height));
                }
                else
                {
                    cr.NewPath();
                    cr.MoveTo(xpos, ypos);
                    cr.RelLineTo(itemDimension.Width, 0);
                    cr.RelLineTo(0, itemDimension.Height);
                    cr.RelLineTo(-itemDimension.Width, 0);
                    cr.RelLineTo(0, -itemDimension.Height);
                    cr.ClosePath();
                    using (var pat = new Cairo.LinearGradient(xpos, ypos, xpos, ypos + itemDimension.Height)) {
                        Cairo.Color ccol = Convert(Style.Mid(StateType.Normal));
                        ccol.A           = 0.2;
                        pat.AddColorStop(0, ccol);
                        ccol.A = 1;
                        pat.AddColorStop(1, ccol);
                        cr.Pattern = pat;
                        cr.FillPreserve();
                    }
                }
                DrawFoldSegment(draw, xpos + 2, ypos + (itemDimension.Height - foldSegmentHeight) / 2, foldSegmentHeight, foldSegmentHeight, category.IsExpanded, category == mouseOverItem && mouseX < xpos + 2 + 12);
                headerLayout.SetText(category.Text);
                int width, height;
                layout.GetPixelSize(out width, out height);
                draw.DrawLayout(Style.TextGC(category != this.SelectedItem ? StateType.Normal : StateType.Selected), xpos + 2 + 12, ypos + (itemDimension.Height - height) / 2, headerLayout);
                if (category == mouseOverItem)
                {
                    draw.DrawRectangle(Style.DarkGC(StateType.Prelight),
                                       false,
                                       new Gdk.Rectangle(xpos,
                                                         ypos,
                                                         itemDimension.Width - 1,
                                                         itemDimension.Height - 1));
                }
            }, delegate(Category curCategory, Item item, Gdk.Size itemDimension) {
                if (item == SelectedItem)
                {
                    draw.DrawRectangle(Style.BaseGC(StateType.Selected),
                                       true,
                                       new Gdk.Rectangle(xpos,
                                                         ypos,
                                                         itemDimension.Width,
                                                         itemDimension.Height));
                }
                if (listMode || !curCategory.CanIconizeItems)
                {
                    draw.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal),
                                    item.Icon, 0, 0,
                                    xpos + 4,
                                    ypos + 1 + (itemDimension.Height - item.Icon.Height) / 2,
                                    item.Icon.Width, item.Icon.Height, Gdk.RgbDither.None, 0, 0);
                    layout.SetText(item.Text);
                    int width, height;
                    layout.GetPixelSize(out width, out height);
                    draw.DrawLayout(Style.TextGC(item != this.SelectedItem ? StateType.Normal : StateType.Selected), xpos + IconSize.Width + 4, ypos + (itemDimension.Height - height) / 2, layout);
                }
                else
                {
                    draw.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal),
                                    item.Icon, 0, 0,
                                    xpos + (itemDimension.Width - item.Icon.Width) / 2,
                                    ypos + (itemDimension.Height - item.Icon.Height) / 2,
                                    item.Icon.Width, item.Icon.Height, Gdk.RgbDither.None, 0, 0);
                }

                if (item == mouseOverItem)
                {
                    draw.DrawRectangle(Style.DarkGC(StateType.Prelight),
                                       false,
                                       new Gdk.Rectangle(xpos,
                                                         ypos,
                                                         itemDimension.Width,
                                                         itemDimension.Height));
                }
            });
            ((IDisposable)cr).Dispose();
            return(true);
        }
Esempio n. 18
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            Rectangle area;

            //Console.WriteLine ("expose {0}", args.Area);
            foreach (Rectangle sub in args.Region.GetRectangles())
            {
                if (sub.Intersect(background, out area))
                {
                    Rectangle active = background;
                    int       min_x  = BoxX(min_limit.Position);
                    int       max_x  = BoxX(max_limit.Position + 1);
                    active.X     = min_x;
                    active.Width = max_x - min_x;

                    // white background for entire widget
                    if (active.Intersect(area, out active))
                    {
                        GdkWindow.DrawRectangle(Style.BaseGC(State), true, active);
                    }

                    // draw bars indicating photo counts
                    int i;
                    BoxXHit(area.X, out i);
                    int end;
                    BoxXHit(area.X + area.Width, out end);
                    while (i <= end)
                    {
                        DrawBox(area, i++);
                    }
                }

                Style.PaintShadow(this.Style, GdkWindow, State, ShadowType.In, area,
                                  this, null, background.X, background.Y,
                                  background.Width, background.Height);

                //	draw ticks and legend
                if (sub.Intersect(legend, out area))
                {
                    int i = 0;
                    while (i < box_counts.Length)
                    {
                        DrawTick(area, i++);
                    }
                }

                //  draw limit markers and glass if needed (drawing done inside confines of action_area)
                if (sub.Intersect(action_area, out area))
                {
                    //	draw limits markers
                    if (has_limits)
                    {
                        if (min_limit != null)
                        {
                            min_limit.Draw(area);
                        }

                        if (max_limit != null)
                        {
                            max_limit.Draw(area);
                        }
                    }

                    //	draw glass
                    if (glass != null)
                    {
                        glass.Draw(area);
                    }
                }
            }
            return(base.OnExposeEvent(args));
        }