Example #1
0
 //public Camera cameraWindow = new Camera();
 //public ColorPicker colorWindow = new ColorPicker();
 public MainWindow()
     : base(Gtk.WindowType.Toplevel)
 {
     this.DefaultSize = new Size(640,480);
     Build ();
     bkg = drawingarea1.GdkWindow;
 }
Example #2
0
        private void RenderSelection (Gdk.Drawable drawable, Gdk.Rectangle background_area,
            bool path_selected, StateType state)
        {
            if (view == null) {
                return;
            }

            if (path_selected && view.Cr != null) {
                Gdk.Rectangle rect = background_area;
                rect.X -= 2;
                rect.Width += 4;

                // clear the standard GTK selection and focus
                drawable.DrawRectangle (view.Style.BaseGC (StateType.Normal), true, rect);

                // draw the hot cairo selection
                if (!view.EditingRow) {
                    view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
                        background_area.Width - 2, background_area.Height - 2);
                }
            } else if (path != null && path.Equals (view.HighlightedPath) && view.Cr != null) {
                view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
                    background_area.Width - 2, background_area.Height - 2, false);
            } else if (view.NotifyStage.ActorCount > 0 && view.Cr != null) {
                TreeIter iter;
                if (view.Model.GetIter (out iter, path) && view.NotifyStage.Contains (iter)) {
                    Actor<TreeIter> actor = view.NotifyStage[iter];
                    Cairo.Color color = view.Theme.Colors.GetWidgetColor (GtkColorClass.Background, StateType.Active);
                    color.A = Math.Sin (actor.Percent * Math.PI);

                    view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
                        background_area.Width - 2, background_area.Height - 2, true, true, color);
                }
            }
        }
        protected override void OnStyleSet(Style old_style)
        {
            if (changing_style)
            {
                return;
            }

            changing_style = true;
            GtkUtilities.AdaptGtkRcStyle(this, typeof(TreeView));
            changing_style = false;

            base.OnStyleSet(old_style);
            RecomputeRowHeight = true;
            theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme(this);

            // Save the drawable so we can reuse it
            Gdk.Drawable drawable = cell_context != null ? cell_context.Drawable : null;

            if (pango_layout != null)
            {
                pango_layout.Dispose();
                pango_layout = null;
            }

            cell_context          = new CellContext();
            cell_context.Theme    = theme;
            cell_context.Widget   = this;
            cell_context.Drawable = drawable;
        }
Example #4
0
        public override void Draw(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            Screen.Draw(d, g, width, height, screenChanged, !_holdingSquare);

            foreach (Combatant a in Allies)
            {
                if (a != null)
                {
                    a.Draw(d, g, width, height);
                }
            }

            foreach (Combatant e in EnemyList)
            {
                e.Draw(d, g, width, height);
            }

            if (Commanding != null)
            {
                Shapes.RenderInvertedTriangle(g, Colors.YELLOW, Commanding.X, Commanding.Y - 20, 20);
            }

            foreach (BattleIcon icon in _battleIcons)
            {
                icon.Draw(d, g, width, height, screenChanged);
            }
        }
        protected override void Render(Gdk.Drawable drawable, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
        {
            if (_ImageRow && _pixbuf == null)
            {
                return;
            }

            Gdk.Rectangle pix_rect = Gdk.Rectangle.Zero;

            this.GetSize(widget, ref cell_area, out pix_rect.X, out pix_rect.Y, out pix_rect.Width, out pix_rect.Height);

            // Take care of padding
            pix_rect.X += cell_area.X + (int)this.Xpad;
            pix_rect.Y += cell_area.Y + (int)this.Ypad;
            // Remove left, right, top and buttom borders which were added to the returned width
            pix_rect.Width  -= (int)this.Xpad * 2;
            pix_rect.Height -= (int)this.Ypad * 2;

            Cairo.Context context = Gdk.CairoHelper.Create(drawable);
            context.Translate(pix_rect.X, pix_rect.Y);

            if (_ImageRow)
            {
                RenderImage(context, pix_rect.Height);
            }
            else
            {
                RenderDoc(context, widget, pix_rect.Height);
            }

            (context as System.IDisposable).Dispose();
        }
Example #6
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            Text.ShadowedText(g, PAUSED, X + x_text, Y + y_text);
        }
Example #7
0
 internal Gdk.GC CreateGC(Gdk.Drawable drawable)
 {
     return(new Gdk.GC(drawable)
     {
         RgbBgColor = this, RgbFgColor = this
     });
 }
Example #8
0
        public override void Draw(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);


            Screen.Draw(d, !_holdingSquare);

            foreach (ICombatant a in _allies)
            {
                if (a != null)
                {
                    a.Draw(g);
                }
            }
            foreach (ICombatant e in _enemies)
            {
                e.Draw(g);
            }

            if (_control != null)
            {
                Graphics.RenderCursor(g, new Cairo.Color(.8, .8, 0), _control.X, _control.Y - 15);
            }

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Example #9
0
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            Gdk.GC gc = new Gdk.GC(window);

            int width = cell_area.Width / blockEvent.BlockCount;

            for (int i = 0; i < blockEvent.BlockCount; i++)
            {
                if (blockEvent.AllBlocksReceived)
                {
                    gc.RgbFgColor = new Gdk.Color(179, 139, 83);                     // Brown
                }
                else if (blockEvent[i].Written)
                {
                    gc.RgbFgColor = new Gdk.Color(145, 246, 145);                     // Green
                }
                else if (blockEvent[i].Received)
                {
                    gc.RgbFgColor = new Gdk.Color(232, 176, 6);                     // Gold
                }
                else if (blockEvent[i].Requested)
                {
                    gc.RgbFgColor = new Gdk.Color(112, 180, 224);                     // Blue
                }
                else
                {
                    gc.RgbFgColor = new Gdk.Color(248, 227, 212);                     // Pink
                }
                Gdk.Rectangle rect = new Gdk.Rectangle(background_area.X + (width * i), background_area.Y + 1, width, background_area.Height - 2 * 1);
                window.DrawRectangle(gc, true, rect);
            }
        }
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            base.Render(window, widget, background_area, cell_area, expose_area, flags);

            if (PackageSourceViewModel == null)
            {
                return;
            }

            using (var layout = new Pango.Layout(widget.PangoContext)) {
                layout.Alignment = Pango.Alignment.Left;
                layout.SetMarkup(GetPackageSourceNameMarkup());
                int       packageSourceNameWidth = GetLayoutWidth(layout);
                StateType state = GetState(widget, flags);

                layout.SetMarkup(GetPackageSourceDescriptionMarkup(flags));

                window.DrawLayout(widget.Style.TextGC(state), cell_area.X + textSpacing, cell_area.Y + textTopSpacing, layout);

                if (!PackageSourceViewModel.IsValid)
                {
                    using (var ctx = Gdk.CairoHelper.Create(window)) {
                        ctx.DrawImage(widget, warningImage, cell_area.X + textSpacing + packageSourceNameWidth + imageSpacing, cell_area.Y + textTopSpacing);
                    }

                    layout.SetMarkup(GetPackageSourceErrorMarkup(flags));
                    int packageSourceErrorTextX = cell_area.X + textSpacing + packageSourceNameWidth + (int)warningImage.Width + (2 * imageSpacing);
                    window.DrawLayout(widget.Style.TextGC(state), packageSourceErrorTextX, cell_area.Y + textTopSpacing, layout);
                }
            }
        }
Example #11
0
        public override void Draw(TextEditor editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos)
        {
            int markerStart = LineSegment.Offset + System.Math.Max(StartCol, 0);
            int markerEnd   = LineSegment.Offset + (EndCol < 0 ? LineSegment.Length : EndCol);

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            int @from;
            int to;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int             start = startOffset < markerStart ? markerStart : startOffset;
                int             end   = endOffset < markerEnd ? endOffset : markerEnd;
                int /*lineNr,*/ x_pos;

                x_pos = layout.IndexToPos(start - startOffset).X;
                @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                x_pos = layout.IndexToPos(end - startOffset).X;

                to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }
            @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from >= to)
            {
                return;
            }
            using (Cairo.Context cr = Gdk.CairoHelper.Create(win)) {
                int height = editor.LineHeight / 5;
                cr.Color = Mono.TextEditor.Highlighting.Style.ToCairoColor(ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition(ColorName));
                Pango.CairoHelper.ShowErrorUnderline(cr, @from, y + editor.LineHeight - height, to - @from, height);
            }

            /*
             *              using (Gdk.GC gc = new Gdk.GC(win)) {
             *                      gc.RgbFgColor = ;
             *                      const int length = 6;
             *                      const int height = 2;
             *                      if (Wave) {
             *                              startXPos = System.Math.Max (startXPos, editor.TextViewMargin.XOffset);
             *                              for (int height = @from; height < to; height += length) {
             *                                      win.DrawLine (gc, height, drawY, height + length / 2, drawY - height);
             *                                      win.DrawLine (gc, height + length / 2, drawY - height, height + length, drawY);
             *                              }
             *                      } else {
             *                              win.DrawLine (gc, @from, drawY, to, drawY);
             *                      }
             *              }	*/
        }
Example #12
0
            public bool DrawBackground(TextEditor editor, Gdk.Drawable win, TextViewMargin.LayoutWrapper layout, int selectionStart, int selectionEnd, int startOffset, int endOffset, int y, int startXPos, int endXPos, ref bool drawBg)
            {
                drawBg = false;
                if (selectionStart >= 0 || editor.CurrentMode is TextLinkEditMode)
                {
                    return(true);
                }
                foreach (ISegment usage in Usages)
                {
                    int markerStart = usage.Offset;
                    int markerEnd   = usage.EndOffset;

                    if (markerEnd < startOffset || markerStart > endOffset)
                    {
                        return(true);
                    }

                    int @from;
                    int to;

                    if (markerStart < startOffset && endOffset < markerEnd)
                    {
                        @from = startXPos;
                        to    = endXPos;
                    }
                    else
                    {
                        int start = startOffset < markerStart ? markerStart : startOffset;
                        int end   = endOffset < markerEnd ? endOffset : markerEnd;

                        uint curIndex = 0, byteIndex = 0;
                        TextViewMargin.TranslateToUTF8Index(layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);

                        int x_pos = layout.Layout.IndexToPos((int)byteIndex).X;

                        @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                        TextViewMargin.TranslateToUTF8Index(layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
                        x_pos = layout.Layout.IndexToPos((int)byteIndex).X;

                        to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
                    }

                    @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
                    to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
                    if (@from < to)
                    {
                        using (Gdk.GC gc = new Gdk.GC(win)) {
                            gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.BackgroundColor;
                            win.DrawRectangle(gc, true, @from + 1, y + 1, to - @from - 1, editor.LineHeight - 2);
                            gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.Color;
                            win.DrawRectangle(gc, false, @from, y, to - @from, editor.LineHeight - 1);
                        }
                    }
                }
                return(true);
            }
Example #13
0
 public BookmarkMarginDrawEventArgs(TextEditor editor, Gdk.Drawable win, LineSegment line, int lineNumber, int xPos, int yPos)
 {
     this.Editor      = editor;
     this.Win         = win;
     this.LineSegment = line;
     this.Line        = lineNumber;
     this.X           = xPos;
     this.Y           = yPos;
 }
Example #14
0
        void RenderMargins(Gdk.Drawable win, Gdk.Rectangle area, Margin marginToRender)
        {
            int  reminder  = (int)HexEditorData.VAdjustment.Value % LineHeight;
            long firstLine = (long)(HexEditorData.VAdjustment.Value / (long)LineHeight);
            long startLine = (area.Top + reminder) / this.LineHeight;
            long endLine   = (area.Bottom + reminder) / this.LineHeight - 1;

            if ((area.Bottom + reminder) % this.LineHeight != 0)
            {
                endLine++;
            }
            // Initialize the rendering of the margins. Determine wether each margin has to be
            // rendered or not and calculate the X offset.
            List <Margin> marginsToRender = new List <Margin> ();

            if (marginToRender != null)
            {
                marginsToRender.Add(marginToRender);
            }
            else
            {
                int curX = 0;
                foreach (Margin margin in this.margins)
                {
                    if (margin.IsVisible)
                    {
                        margin.XOffset = curX;
                        if (curX >= area.X || margin.Width < 0)
                        {
                            marginsToRender.Add(margin);
                        }
                        curX += margin.Width;
                    }
                }
            }

            int curY = (int)(startLine * this.LineHeight - reminder);

            for (long visualLineNumber = startLine; visualLineNumber <= endLine; visualLineNumber++)
            {
                long logicalLineNumber = visualLineNumber + firstLine;
                foreach (Margin margin in marginsToRender)
                {
                    try {
                        margin.Draw(win, area, logicalLineNumber, margin.XOffset, curY);
                    } catch (Exception e) {
                        System.Console.WriteLine(e);
                    }
                }
                curY += LineHeight;
                if (curY > area.Bottom)
                {
                    break;
                }
            }
        }
 public DrawItemEventArgs( int ItemIndex, Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags )
 {
     this.itemIndex  = ItemIndex;
     this.drawable   = window;
     this.widget     = widget;
     this.backgroundArea = background_area;
     this.cellArea   = cell_area;
     this.exposeArea = expose_area;
     this.cellFlags  = flags;
 }
Example #16
0
        /// <summary>Función que se llama cuando el objeto es "expuesto" (se
        /// muestra después de estar oculto) para que se redibuje.</summary>
        /// <param name="o"></param>
        /// <param name="args"></param>

        public void OnExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            lock (this)
            {
                this.window = args.Event.Window;
                Refresh();
                SignalArgs sa = (SignalArgs)args;
                sa.RetVal = false;
            }
        }
Example #17
0
    public static Cairo.Context Create(Gdk.Drawable drawable)
    {
        Cairo.Context ctx = new Cairo.Context(gdk_cairo_create(drawable.Handle));
        if (ctx == null)
        {
            throw new Exception("Couldn't create Cairo Graphics!");
        }

        return(ctx);
    }
Example #18
0
        public static Surface CreateSurface(Gdk.Drawable d)
        {
            d.GetSize(out var width, out var height);
            var surface = new XlibSurface(GdkUtils.GetXDisplay(d.Display),
                                          GdkUtils.GetXid(d),
                                          GdkUtils.GetXVisual(d.Visual),
                                          width, height);

            return(surface);
        }
 public DrawItemEventArgs(int ItemIndex, Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
 {
     this.itemIndex      = ItemIndex;
     this.drawable       = window;
     this.widget         = widget;
     this.backgroundArea = background_area;
     this.cellArea       = cell_area;
     this.exposeArea     = expose_area;
     this.cellFlags      = flags;
 }
Example #20
0
            //-------------------------------------------------------------
            public void draw(Gdk.Drawable da, bool autoscale = false, double tMin = 0, bool manualscaleMin = false, double manualMin = -999999, bool manualscaleMax = false, double manualMax = 99999999)
            {
                if (data == null)
                {
                    return;
                }

                string datasubtype = this.probe.ChannelMap[0].datasubtype;

                draw(da, datasubtype, autoscale, tMin, manualscaleMin, manualMin, manualscaleMax, manualMax);
            }
Example #21
0
            protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
            {
                int w           = 10;
                var newCellArea = new Gdk.Rectangle(cell_area.X + w, cell_area.Y, cell_area.Width - w, cell_area.Height);

                using (var ctx = CairoHelper.Create(window)) {
                    ctx.DrawImage(widget, Icon, cell_area.X - 4, cell_area.Y + Math.Round((cell_area.Height - Icon.Height) / 2));
                }

                base.Render(window, widget, background_area, newCellArea, expose_area, flags);
            }
Example #22
0
        public Gdk(GGdk.Drawable drawable)
        {
            d_drawable = drawable;

            int width;
            int height;

            d_drawable.GetSize(out width, out height);

            Width  = width;
            Height = height;
        }
Example #23
0
        public static Surface CreateSurface(Gdk.Drawable d)
        {
            int width, height;

            d.GetSize(out width, out height);
            XlibSurface surface = new XlibSurface(GdkUtils.GetXDisplay(d.Display),
                                                  (IntPtr)GdkUtils.GetXid(d),
                                                  GdkUtils.GetXVisual(d.Visual),
                                                  width, height);

            return(surface);
        }
        public virtual void Render(Gdk.Drawable window, Cairo.Context ctx, Gdk.Rectangle bounds, StateType state)
        {
            int w, h;

            layout.GetPixelSize(out w, out h);
            int dy = (bounds.Height - h) / 2;

            ctx.Save();
            ctx.SetSourceColor(container.Style.Text(state).ToCairoColor());
            ctx.MoveTo(bounds.X, dy + bounds.Y);
            Pango.CairoHelper.ShowLayout(ctx, layout);
            ctx.Restore();
        }
        internal protected override void Draw(Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y, int lineHeight)
        {
            Gdk.Rectangle drawArea = new Rectangle(x, y, Width, lineHeight);
            win.DrawRectangle(lineNumberBgGC, true, drawArea);
            layout.Alignment = Pango.Alignment.Right;
            layout.Width     = Width;

            if (line < editor.Document.LineCount)
            {
                layout.SetText((line + 1).ToString());
                win.DrawLayout(editor.Caret.Line == line ? lineNumberHighlightGC : lineNumberGC, x + Width, y, layout);
            }
        }
Example #26
0
        public PreviewRenderer(Preview preview, Gdk.GC gc, Dimensions dimensions)
        {
            _window = preview.GdkWindow;
              _gc = gc;
              _width = dimensions.Width - 1;
              _height = dimensions.Height - 1;

              var colormap = Colormap.System;
              _inactive = new Gdk.Color(0xff, 0, 0);
              _active = new Gdk.Color(0, 0xff, 0);
              colormap.AllocColor(ref _inactive, true, true);
              colormap.AllocColor(ref _active, true, true);
        }
Example #27
0
            static void Draw(Gdk.Drawable drawable, TextView view, TextIter start, TextIter end)
            {
                if (HighlightSpacesEnabled || HighlightTabsEnabled || HighlightNewlinesEnabled)
                {
                    Cairo.Context cntx = Gdk.CairoHelper.Create(drawable);

                    //shift to pixel grid to reduce antialiasing
                    cntx.Antialias = Cairo.Antialias.Default;
                    cntx.LineCap   = Cairo.LineCap.Square;
                    cntx.LineWidth = 1;
                    cntx.Translate(0.5, 0.5);

                    TextIter iter = start;
                    while (iter.Compare(end) <= 0)
                    {
                        switch (iter.Char)
                        {
                        case " ":
                            if (HighlightSpacesEnabled)
                            {
                                DrawSpaceAtIter(cntx, view, iter);
                            }
                            break;

                        case "\t":
                            if (HighlightTabsEnabled)
                            {
                                DrawTabAtIter(cntx, view, iter);
                            }
                            break;

                        case "\n":
                        case "\r":
                            if (HighlightNewlinesEnabled)
                            {
                                DrawLineEndAtIter(cntx, view, iter);
                            }
                            break;

                        default:
                            break;
                        }
                        if (!iter.ForwardChar())
                        {
                            break;
                        }
                    }
                    ((IDisposable)cntx).Dispose();
                }
            }
Example #28
0
        public PreviewRenderer(Preview preview, Gdk.GC gc, Dimensions dimensions)
        {
            _window = preview.GdkWindow;
            _gc     = gc;
            _width  = dimensions.Width - 1;
            _height = dimensions.Height - 1;

            var colormap = Colormap.System;

            _inactive = new Gdk.Color(0xff, 0, 0);
            _active   = new Gdk.Color(0, 0xff, 0);
            colormap.AllocColor(ref _inactive, true, true);
            colormap.AllocColor(ref _active, true, true);
        }
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            if (Template == null)
            {
                return;
            }

            if (!Template.AvailableLanguages.Any() || !IsTemplateRowSelected(widget, flags))
            {
                return;
            }

            using (var ctx = CairoHelper.Create(window)) {
                using (var layout = new Pango.Layout(widget.PangoContext)) {
                    int textHeight = 0;

                    SetMarkup(layout, GetSelectedLanguage());
                    layout.GetPixelSize(out textWidth, out textHeight);

                    languageRect = GetLanguageButtonRectangle(window, widget, cell_area, textHeight, textWidth);

                    StateType state = StateType.Normal;
                    if (!RenderRecentTemplate)
                    {
                        RoundBorder(ctx, languageRect.X, languageRect.Y, languageRect.Width, languageRect.Height);
                        SetSourceColor(ctx, Styles.NewProjectDialog.TemplateLanguageButtonBackground.ToCairoColor());
                        ctx.Fill();
                    }
                    else
                    {
                        state = GetState(widget, flags);
                    }

                    int tw            = TemplateHasMultipleLanguages() ? textWidth + dropdownTriangleWidth + 2 : textWidth;
                    int languageTextX = languageRect.X + ((languageRect.Width - tw) / 2);
                    int languageTextY = languageRect.Y + (languageRect.Height - textHeight) / 2;

                    window.DrawLayout(widget.Style.TextGC(state), languageTextX, languageTextY, layout);

                    if (TemplateHasMultipleLanguages())
                    {
                        int triangleX = languageTextX + textWidth + languageRightHandPadding;
                        int triangleY = languageRect.Y + (languageRect.Height - dropdownTriangleHeight) / 2;
                        DrawTriangle(ctx, triangleX, triangleY);
                    }
                }
            }
        }
Example #30
0
        public override void Draw(TextEditor editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos)
        {
            int markerStart = LineSegment.Offset + System.Math.Max(StartCol, 0);
            int markerEnd   = LineSegment.Offset + (EndCol < 0? LineSegment.Length : EndCol);

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            int from;
            int to;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                from = startXPos;
                to   = endXPos;
            }
            else
            {
                int start = startOffset < markerStart ? markerStart : startOffset;
                int end   = endOffset < markerEnd ? endOffset : markerEnd;
                from = startXPos + editor.GetWidth(editor.Document.GetTextAt(startOffset, start - startOffset));
                to   = startXPos + editor.GetWidth(editor.Document.GetTextAt(startOffset, end - startOffset));
            }
            from = System.Math.Max(from, editor.TextViewMargin.XOffset);
            to   = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (from >= to)
            {
                return;
            }

            using (Gdk.GC gc = new Gdk.GC(win)) {
                // gc.RgbFgColor = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition (ColorName);
                int drawY = y + editor.LineHeight - 1;

                win.DrawLine(gc, from, drawY, to, drawY);
                if (@from < to)
                {
                    //gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.BackgroundColor;
                    //win.DrawRectangle (gc, true, @from + 1, y + 1, to - @from - 1, editor.LineHeight - 2);
                    gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.Color;
                    win.DrawRectangle(gc, false, @from, y, to - @from, editor.LineHeight - 1);
                }
            }
        }
 protected override void Render(
     Gdk.Drawable window,                        // Note the type! --3vi1
     Widget widget,
     Rectangle background_area,
     Rectangle cell_area,
     Rectangle expose_area,
     CellRendererState flags)
 {
     // Cast window to correct type, or you won't call correct renderer! --3vi1
     Renderer.Render(
         (Gdk.Window)window,
         widget,
         background_area,
         cell_area,
         expose_area,
         flags
         );
 }
Example #32
0
        public void DrawIcon(Mono.TextEditor.TextEditor editor, Gdk.Drawable win, LineSegment line, int lineNumber, int x, int y, int width, int height)
        {
            int size;

            if (width > height)
            {
                x   += (width - height) / 2;
                size = height;
            }
            else
            {
                y   += (height - width) / 2;
                size = width;
            }

            using (Cairo.Context cr = Gdk.CairoHelper.Create(win))
                DrawIcon(cr, x, y, size);
        }
            protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
            {
                int w           = 10;
                var newCellArea = new Gdk.Rectangle(cell_area.X + w, cell_area.Y, cell_area.Width - w, cell_area.Height);

                using (var ctx = CairoHelper.Create(window)) {
                    var r = 4;
                    ctx.Arc(
                        cell_area.X + r,
                        cell_area.Y + cell_area.Height / 2 + 1,
                        r,
                        0,
                        Math.PI * 2);
                    ctx.SetSourceColor((Mono.TextEditor.HslColor)Color);
                    ctx.Fill();
                }

                base.Render(window, widget, background_area, newCellArea, expose_area, flags);
            }