Beispiel #1
0
 public override void Render(Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
 {
     Gdk.GC gc = new Gdk.GC(window);
     gc.RgbFgColor = (Gdk.Color)Value;
     window.DrawRectangle(gc, true, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
     window.DrawRectangle(Container.Style.BlackGC, false, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
 }
Beispiel #2
0
        public override void Render(Gdk.Drawable window, Cairo.Context ctx, Gdk.Rectangle bounds, Gtk.StateType state)
        {
            Gdk.GC gc = new Gdk.GC(window);
            gc.RgbFgColor = GetColor();
            int yd = (bounds.Height - ColorBoxSize) / 2;

            window.DrawRectangle(gc, true, bounds.X, bounds.Y + yd, ColorBoxSize - 1, ColorBoxSize - 1);
            window.DrawRectangle(Container.GetNativeWidget <Gtk.Widget> ().Style.BlackGC, false, bounds.X, bounds.Y + yd, ColorBoxSize - 1, ColorBoxSize - 1);
            bounds.X     += ColorBoxSize + ColorBoxSpacing;
            bounds.Width -= ColorBoxSize + ColorBoxSpacing;
            base.Render(window, ctx, bounds, state);
        }
        internal protected override void Draw(Gdk.Drawable drawable, Gdk.Rectangle area, long line, int x, int y)
        {
            drawable.DrawRectangle(bgGC, true, x, y, Width, Editor.LineHeight);
            LayoutWrapper layout = GetLayout(line);

            if (!Data.IsSomethingSelected && Caret.InTextEditor && line == Data.Caret.Line)
            {
                drawable.DrawRectangle(GetGC(Style.HighlightOffset), true, CalculateCaretXPos(false), y, byteWidth, Editor.LineHeight);
            }

            drawable.DrawLayout(fgGC, x, y, layout.Layout);
            if (layout.IsUncached)
            {
                layout.Dispose();
            }
        }
        internal protected override void Draw(Gdk.Drawable drawable, Gdk.Rectangle area, long line, int x, int y)
        {
            drawable.DrawRectangle(bgGC, true, x, y, Width, Editor.LineHeight);
            LayoutWrapper layout = GetLayout(line);

            if (!Data.IsSomethingSelected && !Caret.InTextEditor && line == Data.Caret.Line)
            {
                int column  = (int)(Caret.Offset % BytesInRow);
                int xOffset = charWidth * column;
                drawable.DrawRectangle(GetGC(Style.HighlightOffset), true, x + xOffset, y, charWidth, Editor.LineHeight);
            }
            drawable.DrawLayout(fgGC, x, y, layout.Layout);
            if (layout.IsUncached)
            {
                layout.Dispose();
            }
        }
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle backgroundArea, Gdk.Rectangle cellArea, Gdk.Rectangle exposeArea, CellRendererState flags)
        {
            base.Render(window, widget, backgroundArea, cellArea, exposeArea, flags);

            var buttonRect = GetButtonRectangle(backgroundArea);
            var highlight  = buttonRect.Contains(LastMouseX, LastMouseY); // flags.HasFlag(CellRendererState.Prelit)

            Gdk.GC gcBlack = widget.Style.BlackGC;
            Gdk.GC gcBack  = widget.Style.BackgroundGC(highlight ? StateType.Selected : StateType.Normal);
            Gdk.GC gcText  = widget.Style.TextGC(highlight ? StateType.Selected : StateType.Normal);

            window.DrawRectangle(gcBack, true, buttonRect);
            window.DrawRectangle(gcBlack, false, buttonRect);

            Pango.Layout layout = new Pango.Layout(widget.PangoContext);
            layout.SetText("...");
            layout.Alignment = Pango.Alignment.Center;
            layout.Width     = buttonRect.Width;
            window.DrawLayout(gcText, buttonRect.Left + buttonRect.Width / 2, buttonRect.Top, layout);
        }
        void DrawFoldSegment(Gdk.Drawable win, int x, int y, bool isOpen, bool isSelected)
        {
            Gdk.Rectangle drawArea = new Gdk.Rectangle(x + (Width - foldSegmentSize) / 2, y + (editor.LineHeight - foldSegmentSize) / 2, foldSegmentSize, foldSegmentSize);
            win.DrawRectangle(foldBgGC, true, drawArea);
            win.DrawRectangle(isSelected ? foldLineHighlightedGC  : foldLineGC, false, drawArea);

            win.DrawLine(foldToggleMarkerGC,
                         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(foldToggleMarkerGC,
                             drawArea.Left + drawArea.Width / 2,
                             drawArea.Top + drawArea.Height * 3 / 10,
                             drawArea.Left + drawArea.Width / 2,
                             drawArea.Bottom - drawArea.Height * 3 / 10);
            }
        }
Beispiel #7
0
        internal protected override void Draw(Gdk.Drawable drawable, Gdk.Rectangle area, long line, int x, int y)
        {
            drawable.DrawRectangle(GetGC(Style.HexOffsetBg), true, x, y, Width, Editor.LineHeight);
            LayoutWrapper layout = GetLayout(line);
            int           w, h;

            layout.Layout.GetPixelSize(out w, out h);
            drawable.DrawLayout(GetGC(line != Caret.Line ? Style.HexOffset : Style.HexOffsetHighlighted), x + Width - w - 4, y, layout.Layout);
            if (layout.IsUncached)
            {
                layout.Dispose();
            }
        }
Beispiel #8
0
        public override void Render(Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
        {
            int iy = bounds.Y + (bounds.Height - imgSize) / 2;

            if (image != null)
            {
                int dy = (imgSize - image.Height) / 2;
                int dx = (imgSize - image.Width) / 2;
                window.DrawPixbuf(Container.Style.BackgroundGC(state), image, 0, 0, bounds.X + dx, iy + dy, -1, -1, Gdk.RgbDither.None, 0, 0);
            }

            window.DrawRectangle(Container.Style.DarkGC(state), false, bounds.X, iy, imgSize - 1, imgSize - 1);

            bounds.X += imgSize + spacing;
            base.Render(window, bounds, state);
        }
Beispiel #9
0
        internal protected override void Draw(Gdk.Drawable win, Gdk.Rectangle area, long line, int x, int y)
        {
            if (backgroundGC == null)
            {
                OptionsChanged();
            }

            win.DrawRectangle(backgroundGC, true, x, y, Width, Editor.LineHeight);
            win.DrawLine(separatorGC, x + Width - 1, y, x + Width - 1, y + Editor.LineHeight);

            foreach (long bookmark in Data.Bookmarks)
            {
                if (line * Editor.BytesInRow <= bookmark && bookmark < line * Editor.BytesInRow + Editor.BytesInRow)
                {
                    DrawBookmark(win, x, y);
                    return;
                }
            }
        }
        public void DrawWindowFrame(Gtk.Widget w, string caption, int x, int y, int width, int height)
        {
            Gdk.Drawable drawable = w.GdkWindow;
            Gdk.Pixmap   pix      = new Gdk.Pixmap(drawable, width, height, drawable.Depth);

            Gdk.GC gcc = new Gdk.GC(pix);
            gcc.Foreground = w.Style.Backgrounds [(int)Gtk.StateType.Normal];
            pix.DrawRectangle(gcc, true, 0, 0, width, height);

            IntPtr hdc = gdk_win32_hdc_get(pix.Handle, gcc.Handle, 0);

            RECT r = new RECT(0, 0, width, height);
            SIZE size;

            GetThemePartSize(hTheme, hdc, WP_CAPTION, CS_ACTIVE, ref r, 1, out size);

            r.Bottom = size.cy;
            DrawThemeBackground(hTheme, hdc, WP_CAPTION, CS_ACTIVE, ref r, ref r);

            RECT    rf = new RECT(FrameBorder, FrameBorder, width - FrameBorder * 2, size.cy);
            LOGFONT lf = new LOGFONT();

            GetThemeSysFont(hTheme, TMT_CAPTIONFONT, ref lf);
            IntPtr titleFont = CreateFontIndirect(ref lf);
            IntPtr oldFont   = SelectObject(hdc, titleFont);

            SetBkMode(hdc, 1 /*TRANSPARENT*/);
            DrawThemeText(hTheme, hdc, WP_CAPTION, CS_ACTIVE, caption, -1, DT_LEFT | DT_SINGLELINE | DT_WORD_ELLIPSIS, 0, ref rf);
            SelectObject(hdc, oldFont);
            DeleteObject(titleFont);

            int ny = r.Bottom;

            r = new RECT(0, ny, width, height);
            DrawThemeBackground(hTheme, hdc, WP_FRAMEBOTTOM, 0, ref r, ref r);

            gdk_win32_hdc_release(pix.Handle, gcc.Handle, 0);

            Gdk.Pixbuf img = Gdk.Pixbuf.FromDrawable(pix, pix.Colormap, 0, 0, 0, 0, width, height);
            drawable.DrawPixbuf(new Gdk.GC(drawable), img, 0, 0, x, y, width, height, Gdk.RgbDither.None, 0, 0);
            drawable.DrawRectangle(w.Style.BackgroundGC(Gtk.StateType.Normal), true, x + FrameBorder, y + size.cy, width - FrameBorder * 2, height - FrameBorder - size.cy);
        }
Beispiel #11
0
 protected internal override void Draw(Gdk.Drawable drawable, Gdk.Rectangle area, long line, int x, int y)
 {
     drawable.DrawRectangle(bgGC, true, x, y, Width, Editor.LineHeight);
 }
        /*
         * void InternalDrawBackground (TextEditor Editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, ref int startXPos, int endXPos, ref bool drawBg)
         * {
         *      Gdk.Rectangle clipRectangle = new Gdk.Rectangle (mode.Editor.TextViewMargin.XOffset, 0,
         *                                                       Editor.Allocation.Width - mode.Editor.TextViewMargin.XOffset, Editor.Allocation.Height);
         *
         *      // draw default background
         *      using (Gdk.GC fillGc = new Gdk.GC (win)) {
         *              fillGc.ClipRectangle = clipRectangle;
         *              fillGc.RgbFgColor = selected ? Editor.ColorStyle.Selection.BackgroundColor : Editor.ColorStyle.Default.BackgroundColor;
         *              win.DrawRectangle (fillGc, true, startXPos, y, endXPos, Editor.LineHeight);
         *      }
         *
         *      if (startOffset >= endOffset)
         *              return;
         *
         *      int caretOffset = Editor.Caret.Offset - BaseOffset;
         *      foreach (TextLink link in mode.Links) {
         *              if (!link.IsEditable)
         *                      continue;
         *              bool isPrimaryHighlighted = link.PrimaryLink.Offset <= caretOffset && caretOffset <= link.PrimaryLink.EndOffset;
         *
         *              foreach (ISegment segment in link.Links) {
         *
         *                      if ((BaseOffset + segment.Offset <= startOffset && startOffset < BaseOffset + segment.EndOffset) ||
         *                          (startOffset <= BaseOffset + segment.Offset && BaseOffset + segment.Offset < endOffset)) {
         *                              int strOffset    = BaseOffset + segment.Offset - startOffset;
         *                              int strEndOffset = BaseOffset + segment.EndOffset - startOffset;
         *
         *                              int lineNr, x_pos, x_pos2;
         *                              layout.IndexToLineX (strOffset, false, out lineNr, out x_pos);
         *                              layout.IndexToLineX (strEndOffset, false, out lineNr, out x_pos2);
         *                              x_pos  = (int)(x_pos / Pango.Scale.PangoScale);
         *                              x_pos2 = (int)(x_pos2 / Pango.Scale.PangoScale);
         *                              using (Gdk.GC rectangleGc = new Gdk.GC (win)) {
         *                                      rectangleGc.ClipRectangle = clipRectangle;
         *                                      using (Gdk.GC fillGc = new Gdk.GC (win)) {
         *                                              fillGc.ClipRectangle = clipRectangle;
         *                                              drawBg = false;
         *
         *                                              if (segment == link.PrimaryLink) {
         *                                                      fillGc.RgbFgColor      = isPrimaryHighlighted ? Editor.ColorStyle.PrimaryTemplateHighlighted.BackgroundColor : Editor.ColorStyle.PrimaryTemplate.BackgroundColor;
         *                                                      rectangleGc.RgbFgColor = isPrimaryHighlighted ? Editor.ColorStyle.PrimaryTemplateHighlighted.Color           : Editor.ColorStyle.PrimaryTemplate.Color;
         *                                              } else {
         *                                                      fillGc.RgbFgColor      = isPrimaryHighlighted ? Editor.ColorStyle.SecondaryTemplateHighlighted.BackgroundColor : Editor.ColorStyle.SecondaryTemplate.BackgroundColor;
         *                                                      rectangleGc.RgbFgColor = isPrimaryHighlighted ? Editor.ColorStyle.SecondaryTemplateHighlighted.Color           : Editor.ColorStyle.SecondaryTemplate.Color;
         *                                              }
         *                                              // Draw segment
         *                                              if (!selected)
         *                                                      win.DrawRectangle (fillGc, true, startXPos, y, x_pos2 - x_pos, Editor.LineHeight);
         *
         *                                              int x1 = startXPos + x_pos - 1;
         *                                              int x2 = startXPos + x_pos2 - 1;
         *                                              int y2 = y + Editor.LineHeight - 1;
         *
         *                                              win.DrawLine (rectangleGc, x1, y, x2, y);
         *                                              win.DrawLine (rectangleGc, x1, y2, x2, y2);
         *                                              win.DrawLine (rectangleGc, x1, y, x1, y2);
         *                                              win.DrawLine (rectangleGc, x2, y, x2, y2);
         *                                      }
         *                              }
         *                      }
         *              }
         *      }
         *      startXPos += Editor.GetWidth (Editor.Document.GetTextBetween (startOffset, endOffset));
         * }
         */
        /*	bool Overlaps (ISegment segment, int start, int end)
         *      {
         *              return segment.Offset <= start && start < segment.EndOffset ||
         *                          segment.Offset <= end && end < segment.EndOffset ||
         *                              start <= segment.Offset && segment.Offset < end ||
         *                              start < segment.EndOffset && segment.EndOffset < end;
         *      }*/

        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)
        {
            int caretOffset = Editor.Caret.Offset - BaseOffset;

            foreach (TextLink link in mode.Links)
            {
                if (!link.IsEditable)
                {
                    continue;
                }
                bool isPrimaryHighlighted = link.PrimaryLink.Offset <= caretOffset && caretOffset <= link.PrimaryLink.EndOffset;

                foreach (ISegment segment in link.Links)
                {
                    if ((BaseOffset + segment.Offset <= startOffset && startOffset < BaseOffset + segment.EndOffset) || (startOffset <= BaseOffset + segment.Offset && BaseOffset + segment.Offset < endOffset))
                    {
                        int strOffset    = BaseOffset + segment.Offset - startOffset;
                        int strEndOffset = BaseOffset + segment.EndOffset - startOffset;

                        int x_pos  = layout.Layout.IndexToPos(strOffset).X;
                        int x_pos2 = layout.Layout.IndexToPos(strEndOffset).X;

                        x_pos  = (int)(x_pos / Pango.Scale.PangoScale);
                        x_pos2 = (int)(x_pos2 / Pango.Scale.PangoScale);
                        using (Gdk.GC rectangleGc = new Gdk.GC(win)) {
                            //	rectangleGc.ClipRectangle = clipRectangle;
                            using (Gdk.GC fillGc = new Gdk.GC(win)) {
                                //		fillGc.ClipRectangle = clipRectangle;
                                drawBg = false;

                                if (segment == link.PrimaryLink)
                                {
                                    fillGc.RgbFgColor      = isPrimaryHighlighted ? Editor.ColorStyle.PrimaryTemplateHighlighted.BackgroundColor : Editor.ColorStyle.PrimaryTemplate.BackgroundColor;
                                    rectangleGc.RgbFgColor = isPrimaryHighlighted ? Editor.ColorStyle.PrimaryTemplateHighlighted.Color : Editor.ColorStyle.PrimaryTemplate.Color;
                                }
                                else
                                {
                                    fillGc.RgbFgColor      = isPrimaryHighlighted ? Editor.ColorStyle.SecondaryTemplateHighlighted.BackgroundColor : Editor.ColorStyle.SecondaryTemplate.BackgroundColor;
                                    rectangleGc.RgbFgColor = isPrimaryHighlighted ? Editor.ColorStyle.SecondaryTemplateHighlighted.Color : Editor.ColorStyle.SecondaryTemplate.Color;
                                }
                                // Draw segment

                                int x1 = startXPos + x_pos - 1;
                                int x2 = startXPos + x_pos2 - 1;
                                int y2 = y + Editor.LineHeight - 1;

                                if (selectionStart < 0)
                                {
                                    //		Console.WriteLine ("Draw BG at " + y + "//" + Editor.GetTextEditorData ().VAdjustment.Value);
                                    //		Console.WriteLine (Environment.StackTrace);
                                    win.DrawRectangle(fillGc, true, x1, y, x2 - x1, Editor.LineHeight);
                                }

                                win.DrawLine(rectangleGc, x1, y, x2, y);
                                win.DrawLine(rectangleGc, x1, y2, x2, y2);
                                win.DrawLine(rectangleGc, x1, y, x1, y2);
                                win.DrawLine(rectangleGc, x2, y, x2, y2);
                            }
                        }
                    }
                }
            }

            /*
             *      int curOffset = startOffset;
             *      foreach (TextLink link in mode.Links) {
             *              if (!link.IsEditable)
             *                      continue;
             *              ISegment segment = link.Links.Where (s => Overlaps (s, curOffset - BaseOffset, endOffset - BaseOffset)).FirstOrDefault ();
             *              if (segment == null) {
             *                      break;
             *              }
             *              InternalDrawBackground (Editor, win, layout, selected, curOffset, segment.Offset + BaseOffset, y, ref startXPos, endXPos, ref drawBg);
             *              curOffset = segment.EndOffset + BaseOffset;
             *              InternalDrawBackground (Editor, win, layout, selected, segment.Offset + BaseOffset, curOffset, y, ref startXPos, endXPos, ref drawBg);
             *      }
             *      InternalDrawBackground (Editor, win, layout, selected, curOffset, endOffset, y, ref startXPos, endXPos, ref drawBg);
             */
            return(true);
        }
Beispiel #13
0
        /// <summary>
        /// Render the bytes in the highlight range.
        /// </summary>
        /// <param name="h">
        /// A <see cref="Highlight"/>
        /// </param>
        /// <param name="merge">
        /// Whether to visually merge the highlight with adjacent ones left and/or right.
        /// </param>
        /// <remarks>
        /// This method doesn't check whether the merge flags are correct (eg there is indeed
        /// a similar adjacent highlight). It just draws the highlight in such a way as
        /// to appear merged to any similar highlights if they exist.
        ///</remarks>
        internal protected virtual void RenderHighlight(Highlight h, Drawer.HighlightType left, Drawer.HighlightType right)
        {
            if (isAreaRealized == false)
            {
                return;
            }

            int  rstart, bstart, xstart, ystart;
            int  rend, bend, xend, yend;
            bool odd;

            Gdk.GC gc;
            Gdk.GC oddGC;
            Gdk.GC evenGC;
            Gdk.GC leftGC;
            Gdk.GC rightGC;

            oddGC  = drawer.GetBackgroundGC(Drawer.RowType.Odd, h.Type);
            evenGC = drawer.GetBackgroundGC(Drawer.RowType.Even, h.Type);


            GetDisplayInfoByOffset(h.Start, out rstart, out bstart, out xstart, out ystart);
            GetDisplayInfoByOffset(h.End, out rend, out bend, out xend, out yend);

            //System.Console.WriteLine("Start {0:x} {1} {2} x:{3} y:{4}", h.Start, rstart, bstart, xstart, ystart);
            //System.Console.WriteLine("End {0:x} {1} {2} x:{3} y:{4}", h.End, rend, bend, xend, yend);
            bool drawLeft = false;
            int  dxstart  = xstart;

            if (bstart > 0)
            {
                int            digit;
                GetOffsetFlags gof;
                GetOffsetByDisplayInfo(xstart - 1, ystart, out digit, out gof);
                if ((gof & GetOffsetFlags.Abyss) != 0)
                {
                    dxstart -= drawer.Width;
                    drawLeft = true;
                }
            }

            bool drawRight = false;
            int  dxend     = xend;

            if (bend < bpr - 1)
            {
                int            digit;
                GetOffsetFlags gof;
                GetOffsetByDisplayInfo(xend + dpb * drawer.Width, yend, out digit, out gof);
                if ((gof & GetOffsetFlags.Abyss) != 0)
                {
                    dxend    += drawer.Width;
                    drawRight = true;
                }
            }

            // if the whole range is on one row
            if (rstart == rend)
            {
                if (areaGroup.ManualDoubleBuffer)
                {
                    BeginPaint(x + dxstart, y + ystart, dxend - dxstart + dpb * drawer.Width, drawer.Height);
                }
                // odd row?
                odd = (((h.Start / bpr) % 2) == 1);
                if (odd)
                {
                    gc      = oddGC;
                    leftGC  = drawer.GetBackgroundGC(Drawer.RowType.Odd, left);
                    rightGC = drawer.GetBackgroundGC(Drawer.RowType.Odd, right);
                }
                else
                {
                    gc      = evenGC;
                    leftGC  = drawer.GetBackgroundGC(Drawer.RowType.Even, left);
                    rightGC = drawer.GetBackgroundGC(Drawer.RowType.Even, right);
                }

                //render
                if (drawLeft)
                {
                    backPixmap.DrawRectangle(leftGC, true, x + dxstart, y + ystart, drawer.Width, drawer.Height);
                }
                if (drawRight)
                {
                    backPixmap.DrawRectangle(rightGC, true, x + xend + dpb * drawer.Width, y + yend, drawer.Width, drawer.Height);
                }

                backPixmap.DrawRectangle(gc, true, x + xstart, y + ystart, xend - xstart + dpb * drawer.Width, drawer.Height);

                RenderRangeHelper(h.Type, rstart, bstart, bend - bstart + 1);
            }
            else       // multi-row range

            {
                if (areaGroup.ManualDoubleBuffer)
                {
                    // handle double-buffering
                    Gdk.Region paintRegion = new Gdk.Region();

                    Gdk.Rectangle rectStart = new Gdk.Rectangle(x + dxstart, y + ystart, width - dxstart, drawer.Height);

                    Gdk.Rectangle rectMiddle;
                    if (rend > rstart + 1)
                    {
                        rectMiddle = new Gdk.Rectangle(x, y + ystart + drawer.Height, width, yend - ystart - drawer.Height);
                    }
                    else
                    {
                        rectMiddle = Gdk.Rectangle.Zero;
                    }

                    Gdk.Rectangle rectEnd = new Gdk.Rectangle(x, y + yend, dxend + dpb * drawer.Width, drawer.Height);

                    paintRegion.UnionWithRect(rectStart);
                    paintRegion.UnionWithRect(rectMiddle);
                    paintRegion.UnionWithRect(rectEnd);

                    BeginPaintRegion(paintRegion);
                }

                // render first row
                odd = (((h.Start / bpr) % 2) == 1);
                if (odd)
                {
                    gc      = oddGC;
                    leftGC  = drawer.GetBackgroundGC(Drawer.RowType.Odd, left);
                    rightGC = drawer.GetBackgroundGC(Drawer.RowType.Odd, right);
                }
                else
                {
                    gc      = evenGC;
                    leftGC  = drawer.GetBackgroundGC(Drawer.RowType.Even, left);
                    rightGC = drawer.GetBackgroundGC(Drawer.RowType.Even, right);
                }

                if (drawLeft)
                {
                    backPixmap.DrawRectangle(leftGC, true, x + dxstart, y + ystart, drawer.Width, drawer.Height);
                }
                backPixmap.DrawRectangle(gc, true, x + xstart, y + ystart, width - xstart, drawer.Height);

                RenderRangeHelper(h.Type, rstart, bstart, bpr - bstart);

                long curOffset = h.Start + bpr - bstart;

                // render middle rows
                for (int i = rstart + 1; i < rend; i++)
                {
                    odd = (((curOffset / bpr) % 2) == 1);
                    if (odd)
                    {
                        gc = oddGC;
                    }
                    else
                    {
                        gc = evenGC;
                    }
                    backPixmap.DrawRectangle(gc, true, x, y + i * drawer.Height, width, drawer.Height);
                    RenderRangeHelper(h.Type, i, 0, bpr);
                    curOffset += bpr;
                }

                // render last row
                odd = (((h.End / bpr) % 2) == 1);
                if (odd)
                {
                    gc      = oddGC;
                    leftGC  = drawer.GetBackgroundGC(Drawer.RowType.Odd, left);
                    rightGC = drawer.GetBackgroundGC(Drawer.RowType.Odd, right);
                }
                else
                {
                    gc      = evenGC;
                    leftGC  = drawer.GetBackgroundGC(Drawer.RowType.Even, left);
                    rightGC = drawer.GetBackgroundGC(Drawer.RowType.Even, right);
                }

                if (drawRight)
                {
                    backPixmap.DrawRectangle(rightGC, true, x + xend + dpb * drawer.Width, y + yend, drawer.Width, drawer.Height);
                }
                backPixmap.DrawRectangle(gc, true, x, y + yend, xend + dpb * drawer.Width, drawer.Height);
                RenderRangeHelper(h.Type, rend, 0, bend + 1);
            }

            if (areaGroup.ManualDoubleBuffer)
            {
                EndPaint();
            }
        }
        internal protected override void Draw(Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y, int lineHeight)
        {
            foldSegmentSize  = Width * 4 / 6;
            foldSegmentSize -= (foldSegmentSize) % 2;

            Gdk.Rectangle      drawArea = new Gdk.Rectangle(x, y, Width, lineHeight);
            Document.LineState state    = editor.Document.GetLineState(line);

            bool isFoldStart  = false;
            bool isContaining = false;
            bool isFoldEnd    = false;

            bool isStartSelected      = false;
            bool isContainingSelected = false;
            bool isEndSelected        = false;

            if (line < editor.Document.LineCount)
            {
                LineSegment lineSegment = editor.Document.GetLine(line);
                startFoldings.Clear();
                containingFoldings.Clear();
                endFoldings.Clear();
                foreach (FoldSegment segment in editor.Document.GetFoldingContaining(lineSegment))
                {
                    if (segment.StartLine.Offset == lineSegment.Offset)
                    {
                        startFoldings.Add(segment);
                    }
                    else if (segment.EndLine.Offset == lineSegment.Offset)
                    {
                        endFoldings.Add(segment);
                    }
                    else
                    {
                        containingFoldings.Add(segment);
                    }
                }

                isFoldStart  = startFoldings.Count > 0;
                isContaining = containingFoldings.Count > 0;
                isFoldEnd    = endFoldings.Count > 0;

                isStartSelected      = this.lineHover != null && IsMouseHover(startFoldings);
                isContainingSelected = this.lineHover != null && IsMouseHover(containingFoldings);
                isEndSelected        = this.lineHover != null && IsMouseHover(endFoldings);
            }

            Gdk.GC bgGC = foldBgGC;
            if (editor.TextViewMargin.BackgroundRenderer != null)
            {
                if (isContainingSelected || isStartSelected || isEndSelected)
                {
                    bgGC = foldBgGC;
                }
                else
                {
                    bgGC = foldLineHighlightedGCBg;
                }
            }

            win.DrawRectangle(bgGC, true, drawArea);
            if (state == Document.LineState.Changed)
            {
                win.DrawRectangle(lineStateChangedGC, true, x + 1, y, Width / 3, lineHeight);
                //		win.DrawRectangle (bgGC, true, x + 3 , y, Width  - 3, lineHeight);
            }
            else if (state == Document.LineState.Dirty)
            {
                win.DrawRectangle(lineStateDirtyGC, true, x + 1, y, Width / 3, lineHeight);
                //		win.DrawRectangle (bgGC, true, x + 3 , y, Width - 3, lineHeight);
            }            /* else {
                          *     win.DrawRectangle (bgGC, true, drawArea);
                          * }*/

            if (line < editor.Document.LineCount)
            {
                int foldSegmentYPos = y + (editor.LineHeight - foldSegmentSize) / 2;
                int xPos            = x + Width / 2;

                if (isFoldStart)
                {
                    bool isVisible         = true;
                    bool moreLinedOpenFold = false;
                    foreach (FoldSegment foldSegment in startFoldings)
                    {
                        if (foldSegment.IsFolded)
                        {
                            isVisible = false;
                        }
                        else
                        {
                            moreLinedOpenFold = foldSegment.EndLine.Offset > foldSegment.StartLine.Offset;
                        }
                    }
                    bool isFoldEndFromUpperFold = false;
                    foreach (FoldSegment foldSegment in endFoldings)
                    {
                        if (foldSegment.EndLine.Offset > foldSegment.StartLine.Offset && !foldSegment.IsFolded)
                        {
                            isFoldEndFromUpperFold = true;
                        }
                    }
                    DrawFoldSegment(win, x, y, isVisible, isStartSelected);
                    if (isContaining || isFoldEndFromUpperFold)
                    {
                        win.DrawLine(isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, foldSegmentYPos - 2);
                    }
                    if (isContaining || moreLinedOpenFold)
                    {
                        win.DrawLine(isEndSelected || (isStartSelected && isVisible) || isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, foldSegmentYPos + foldSegmentSize + 2, xPos, drawArea.Bottom);
                    }
                }
                else
                {
                    if (isFoldEnd)
                    {
                        int yMid = drawArea.Top + drawArea.Height / 2;
                        win.DrawLine(isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid, x + Width - 2, yMid);
                        win.DrawLine(isContainingSelected || isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, yMid);
                        if (isContaining)
                        {
                            win.DrawLine(isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid + 1, xPos, drawArea.Bottom);
                        }
                    }
                    else if (isContaining)
                    {
                        win.DrawLine(isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, drawArea.Bottom);
                    }
                }
            }
        }