Пример #1
0
        private void OnExposed(object o, ExposeEventArgs args)
        {
            Rectangle area = args.Event.Region.Clipbox;

            GdkWindow.DrawRectangle(Style.BackgroundGC(StateType.Normal), true,
                                    area.X, area.Y, area.Width, area.Height);
            if (field != null)
            {
                if (pixmap == null)
                {
                    FieldRegion region;

                    pixmap = new Pixmap(GdkWindow,
                                        (int)(field.Width * zoomLevel),
                                        (int)(field.Height * zoomLevel),
                                        -1);
                    region       = new FieldRegion();
                    region.Left  = region.Bottom = 0;
                    region.Right = field.Width - 1;
                    region.Top   = field.Height - 1;
                    renderer.RenderToDrawable(pixmap, Style.BlackGC, region, null);
                }

                GdkWindow.DrawDrawable(Style.BlackGC, pixmap,
                                       area.X, area.Y, area.X, area.Y,
                                       area.Width, area.Height);

                if (selection != null)
                {
                    renderer.RenderToDrawable(GdkWindow, Style.BlackGC,
                                              selection, selection);
                }
            }
        }
Пример #2
0
    protected override bool OnExposeEvent(Gdk.EventExpose args)
    {
        Gdk.Rectangle exposeArea;
        Gdk.Rectangle titleArea = TitleArea;

        if (args.Area.Intersect(titleArea, out exposeArea))
        {
            GdkWindow.DrawPixbuf(Style.BackgroundGC(State), Icon, 0, 0,
                                 titleArea.X, titleArea.Y, Icon.Width,
                                 Icon.Height, Gdk.RgbDither.None, 0, 0);
        }

        titleArea.X     += icon.Width + 1;
        titleArea.Width -= icon.Width - 1;

        if (args.Area.Intersect(titleArea, out exposeArea))
        {
            int layoutWidth, layoutHeight;
            Layout.GetPixelSize(out layoutWidth, out layoutHeight);

            titleArea.Y += (titleArea.Height - layoutHeight) / 2;

            Style.PaintLayout(Style, GdkWindow, State,
                              true, exposeArea, this, null,
                              titleArea.X, titleArea.Y, Layout);
        }

        return(base.OnExposeEvent(args));
    }
        private void Refresh(bool Draw)
        {
            Graphics offScreenGraphics;
            Bitmap   offscreenBitmap;

            offscreenBitmap   = new Bitmap(BackgroundBitmap.Width, BackgroundBitmap.Height);
            offScreenGraphics = Graphics.FromImage(offscreenBitmap);

            if (BackgroundBitmap != null)
            {
                offScreenGraphics.DrawImage(BackgroundBitmap, 0, 0, BackgroundBitmap.Width, BackgroundBitmap.Height);
            }

            DrawCloseButton(ref offScreenGraphics);
            DrawText(ref offScreenGraphics);


            if (Gdk.Display.Default.SupportsShapes)
            {
                background = modFunctions.ImageToPixbuf(offscreenBitmap).AddAlpha(true, transparencyKey.R, transparencyKey.G, transparencyKey.B);
                Gdk.Pixmap pixmap = null;
                Gdk.Pixmap mask   = null;
                this.WidthRequest  = background.Width;
                this.HeightRequest = background.Height;
                background.RenderPixmapAndMask(out pixmap, out mask, 2);
                this.ShapeCombineMask(mask, 0, 0);
            }
            else
            {
                if (this.GdkWindow == null)
                {
                    background = modFunctions.ImageToPixbuf(modFunctions.SwapColors(offscreenBitmap, transparencyKey, Color.Black));
                }
                else if (this.GdkWindow.FrameExtents.Location.X <= 0 | this.GdkWindow.FrameExtents.Location.Y <= 0)
                {
                    background = modFunctions.ImageToPixbuf(modFunctions.SwapColors(offscreenBitmap, transparencyKey, Color.Black));
                }
                else
                {
                    if (ScreenTransBitmap == null)
                    {
                        ScreenTransBitmap = modFunctions.GetScreenRect(new Rectangle(this.GdkWindow.FrameExtents.Location.X, this.GdkWindow.FrameExtents.Location.Y, offscreenBitmap.Size.Width, offscreenBitmap.Size.Height));
                    }
                    if (ScreenTransBitmap == null)
                    {
                        background = modFunctions.ImageToPixbuf(modFunctions.SwapColors(offscreenBitmap, transparencyKey, Color.Black));
                    }
                    else
                    {
                        background = modFunctions.ImageToPixbuf(modFunctions.ReplaceColors(offscreenBitmap, transparencyKey, ScreenTransBitmap));
                    }
                }
                this.WidthRequest  = background.Width;
                this.HeightRequest = background.Height;
            }
            if (Draw & titleText != null)
            {
                GdkWindow.DrawPixbuf(Style.BackgroundGC(State), background, 0, 0, 0, 0, background.Width, background.Height, Gdk.RgbDither.None, 0, 0);
            }
        }
Пример #4
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)
                {
#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);
                }
            }
        }
Пример #5
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            //draw the background
            if (logoPixbuf != null)
            {
                var gc    = Style.BackgroundGC(State);
                var lRect = new Rectangle(Allocation.X, Allocation.Y, logoPixbuf.Width, logoPixbuf.Height);
                if (evnt.Region.RectIn(lRect) != OverlapType.Out)
                {
                    evnt.Window.DrawPixbuf(gc, logoPixbuf, 0, 0, lRect.X, lRect.Y, lRect.Width, lRect.Height, RgbDither.None, 0, 0);
                }

                var bgRect = new Rectangle(Allocation.X + logoPixbuf.Width, Allocation.Y, Allocation.Width - logoPixbuf.Width, bgPixbuf.Height);
                if (evnt.Region.RectIn(bgRect) != OverlapType.Out)
                {
                    for (int x = bgRect.X; x < bgRect.Right; x += bgPixbuf.Width)
                    {
                        evnt.Window.DrawPixbuf(gc, bgPixbuf, 0, 0, x, bgRect.Y, bgPixbuf.Width, bgRect.Height, RgbDither.None, 0, 0);
                    }
                }
            }

            foreach (Widget widget in Children)
            {
                PropagateExpose(widget, evnt);
            }

            return(true);
        }
 protected override bool OnExposeEvent(Gdk.EventExpose args)
 {
     if (background != null)
     {
         GdkWindow.DrawPixbuf(Style.BackgroundGC(State), background, 0, 0, 0, 0, background.Width, background.Height, Gdk.RgbDither.None, 0, 0);
     }
     return(base.OnExposeEvent(args));
 }
Пример #7
0
 void RenderPendingUpdates(Gdk.Window window)
 {
     foreach (RedrawRequest request in redrawList)
     {
         Rectangle updateRect = request.Area;
         RenderMargins(this.buffer, updateRect, request.Margin);
         window.DrawDrawable(Style.BackgroundGC(StateType.Normal), buffer, updateRect.X, updateRect.Y, updateRect.X, updateRect.Y, updateRect.Width, updateRect.Height);
     }
     redrawList.Clear();
 }
Пример #8
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            if (canvas != null)
            {
                GdkWindow.DrawDrawable(Style.BackgroundGC(State), canvas, 0, 0, widget_alloc.X, widget_alloc.Y, widget_alloc.Width, widget_alloc.Height);
                return(true);
            }

            return(base.OnExposeEvent(evnt));
        }
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            GdkWindow.DrawRectangle(Style.BackgroundGC(State), true, Allocation);

            foreach (Widget child in Children)
            {
                PropagateExpose(child, evnt);
            }

            return(true);
        }
Пример #10
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle titleArea = TitleArea;
            Gdk.Rectangle exposeArea;

            if (Icon != null)
            {
                Gdk.Rectangle pixbufRect;
                pixbufRect.Width  = icon.Width;
                pixbufRect.Height = icon.Height;

                if (Direction == TextDirection.Rtl)
                {
                    pixbufRect.X = titleArea.X + titleArea.Width - pixbufRect.Width;
                }
                else
                {
                    pixbufRect.X = titleArea.X;
                    titleArea.X += pixbufRect.Width + 4;
                }

                titleArea.Width -= pixbufRect.Width - 4;
                pixbufRect.Y     = titleArea.Y + (titleArea.Height - pixbufRect.Height) / 2;

                if (evnt.Area.Intersect(pixbufRect, out exposeArea))
                {
                    Gdk.GC gc = Style.BackgroundGC(State);
                    GdkWindow.DrawPixbuf(gc, icon, 0, 0, pixbufRect.X,
                                         pixbufRect.Y, pixbufRect.Width,
                                         pixbufRect.Height, Gdk.RgbDither.None,
                                         0, 0);
                }
            }

            /* TODO this crashes win32 at the moment...
             * if (titleArea.Intersect (evnt.Area, out exposeArea)) {
             *      int width, height, textX, textY;
             *      Layout.GetPixelSize (out width, out height);
             *
             *      if (Direction == TextDirection.Rtl)
             *              textX = titleArea.X + titleArea.Width - width;
             *      else
             *              textX = titleArea.X;
             *
             *      textY = titleArea.Y + (titleArea.Height - height) / 2;
             *
             *      Style.PaintLayout (Style, GdkWindow, State, true,
             *                         exposeArea, this, null, textX,
             *                         textY, layout);
             * }
             */

            return(base.OnExposeEvent(evnt));
        }
Пример #11
0
    void RealizeHanlder(object o, EventArgs sender)
    {
        white_gc = Style.WhiteGC;

        bkgr_gc = Style.BackgroundGC(StateType.Normal);

        selection_gc = new Gdk.GC(GdkWindow);
        selection_gc.Copy(Style.BackgroundGC(StateType.Normal));
        Gdk.Color fgcol = new Gdk.Color();
        fgcol.Pixel             = 0x000077ee;
        selection_gc.Foreground = fgcol;
        selection_gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.NotLast, JoinStyle.Round);
    }
Пример #12
0
 protected override bool OnExposeEvent(Gdk.EventExpose e)
 {
     RenderPendingUpdates(e.Window);
     e.Window.DrawDrawable(Style.BackgroundGC(StateType.Normal),
                           buffer,
                           e.Area.X, e.Area.Y, e.Area.X, e.Area.Y,
                           e.Area.Width, e.Area.Height + 1);
     if (requestResetCaretBlink)
     {
         ResetCaretBlink();
         requestResetCaretBlink = false;
     }
     DrawCaret(e.Window, e.Area);
     return(true);
 }
        private void OnWidgetDestroyed(object sender, EventArgs args)
        {
            if (!IsRealized)
            {
                return;
            }

            canvas = new Pixmap(GdkWindow, widget_alloc.Width, widget_alloc.Height);
            canvas.DrawDrawable(Style.BackgroundGC(State), GdkWindow,
                                widget_alloc.X, widget_alloc.Y, 0, 0, widget_alloc.Width, widget_alloc.Height);

            if (AnimationState != AnimationState.Going)
            {
                WidgetDestroyed(this, args);
            }
        }
Пример #14
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            if (calendarItem != null)
            {
                int           triangleSize    = 25;
                Gdk.Rectangle targetRectangle = this.Allocation;
                evnt.Window.DrawRectangle(Style.BackgroundGC(State), true, targetRectangle);
                Style.PaintLayout(Style, evnt.Window, State, true, targetRectangle, this, null, targetRectangle.X, targetRectangle.Y, PangoText);

                //Верхний правый треугольник
                if (calendarItem.TagColor != "" && calendarItem.id > 0)
                {
                    Gdk.Color col = new Gdk.Color();
                    Gdk.Color.Parse(calendarItem.TagColor, ref col);
                    Gdk.GC TagGC = new Gdk.GC(evnt.Window);
                    TagGC.RgbFgColor = col;

                    Gdk.Point[] triangle = new Gdk.Point[]
                    {
                        new Gdk.Point(targetRectangle.X + targetRectangle.Width, targetRectangle.Top),
                        new Gdk.Point(targetRectangle.X + targetRectangle.Width - triangleSize, targetRectangle.Top),
                        new Gdk.Point(targetRectangle.X + targetRectangle.Width, targetRectangle.Top + triangleSize)
                    };
                    evnt.Window.DrawPolygon(TagGC, true, triangle);

                    if (calendarItem.Tag != "")
                    {
                        Pango.Rectangle logicExt, inkExt;
                        PangoTag.GetPixelExtents(out inkExt, out logicExt);
                        evnt.Window.DrawLayout(Style.WhiteGC, targetRectangle.Right - triangleSize * 5 / 16 - logicExt.Width / 2, targetRectangle.Top + triangleSize * 5 / 16 - logicExt.Height / 2, PangoTag);
                    }
                }

                if (calendarItem.MessageCount > 0)
                {
                    Pango.Rectangle logicExt, inkExt;
                    PangoMessages.GetPixelExtents(out inkExt, out logicExt);
                    var messagebox = new Gdk.Rectangle(targetRectangle.Right - logicExt.Width, targetRectangle.Bottom - logicExt.Height, logicExt.Height, logicExt.Width);
                    evnt.Window.DrawLayoutWithColors(Style.BlackGC, targetRectangle.Right - logicExt.Width + 1, targetRectangle.Bottom - logicExt.Height + 1, PangoMessages, ColorUtil.Create("Cornsilk"), ColorUtil.Create("Gray"));
                }

                return(true);
            }

            return(base.OnExposeEvent(evnt));
        }
Пример #15
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);
                }
            }
        }
Пример #16
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            if (isSelected)
            {
                background = activebackground;
            }
            else
            {
                background = inactivebackground;
            }

            GdkWindow.DrawPixbuf(Style.BackgroundGC(State), background, 0, 0,
                                 0, 0, background.Width, background.Height,
                                 Gdk.RgbDither.None, 0, 0);

            return(base.OnExposeEvent(args));
        }
            protected override bool OnExposeEvent(EventExpose evnt)
            {
                using (var context = Gdk.CairoHelper.Create(evnt.Window)) {
                    context.Color    = new Cairo.Color(1, 1, 1);
                    context.Operator = Cairo.Operator.Source;
                    context.Paint();
                    context.Operator = Cairo.Operator.Over;
                    DrawBackground(context, evnt.Area);
                }

                if (Owner.LogoImage != null)
                {
                    var gc    = Style.BackgroundGC(State);
                    var lRect = new Rectangle(Allocation.X, Allocation.Y, Owner.LogoImage.Width, Owner.LogoImage.Height);
                    if (evnt.Region.RectIn(lRect) != OverlapType.Out)
                    {
                        evnt.Window.DrawPixbuf(gc, Owner.LogoImage, 0, 0, lRect.X, lRect.Y, lRect.Width, lRect.Height, RgbDither.None, 0, 0);
                    }

                    var bgRect = new Rectangle(Allocation.X + Owner.LogoImage.Width, Allocation.Y, Allocation.Width - Owner.LogoImage.Width, Owner.TopBorderImage.Height);
                    if (evnt.Region.RectIn(bgRect) != OverlapType.Out)
                    {
                        for (int x = bgRect.X; x < bgRect.Right; x += Owner.TopBorderImage.Width)
                        {
                            evnt.Window.DrawPixbuf(gc, Owner.TopBorderImage, 0, 0, x, bgRect.Y, Owner.TopBorderImage.Width, bgRect.Height, RgbDither.None, 0, 0);
                        }
                    }
                }

                foreach (Widget widget in Children)
                {
                    PropagateExpose(widget, evnt);
                }

                if (OverdrawOpacity > 0)
                {
                    using (var context = Gdk.CairoHelper.Create(evnt.Window)) {
                        DrawOverdraw(context, OverdrawOpacity);
                    }
                }

                return(true);
            }
Пример #18
0
        private void OnWidgetDestroyed(object sender, EventArgs args)
        {
            if (!IsRealized)
            {
                return;
            }

            canvas = new Pixmap(GdkWindow, widget_alloc.Width, widget_alloc.Height);
            if (Platform.IsMac)
            {
                //FIXME: quick hack to make less ugly on Mac, because Mac GTK doesn't yet support offscreen drawing
                canvas.DrawRectangle(Style.BackgroundGC(State), true, 0, 0, widget_alloc.Width, widget_alloc.Height);
            }
            else
            {
                canvas.DrawDrawable(Style.BackgroundGC(State), GdkWindow, widget_alloc.X, widget_alloc.Y, 0, 0, widget_alloc.Width, widget_alloc.Height);
            }

            if (AnimationState != AnimationState.Going)
            {
                WidgetDestroyed(this, args);
            }
        }
Пример #19
0
        protected override bool OnExposeEvent(Gdk.EventExpose ev)
        {
            int width  = Allocation.Width;
            int height = Allocation.Height;

#if FAMISTUDIO_MACOS
            var bgColor = Style.Backgrounds[(int)State];
            var fgColor = Style.Foregrounds[(int)State];

            int imgWidth  = (int)(pixbuf.Width / GLTheme.DialogScaling);
            int imgHeight = (int)(pixbuf.Height / GLTheme.DialogScaling);

            int x  = buttonText == null ? (width - imgWidth) / 2 : 5;
            int y  = (height - imgHeight) / 2;
            int yp = State == Gtk.StateType.Active ? 1 : 0;

            // Have to use Cairo here since i am unable to draw unpixelated bitmaps with Gdk.
            var ctx = CairoHelper.Create(ev.Window);

            CairoHelper.SetSourceColor(ctx, bgColor);
            ctx.Paint();
            ctx.Translate(x, y + yp);
            ctx.Scale(1.0f / GLTheme.DialogScaling, 1.0f / GLTheme.DialogScaling);
            CairoHelper.SetSourcePixbuf(ctx, pixbuf, 0, 0);
            ctx.Paint();

            if (buttonText != null)
            {
                CairoHelper.SetSourceColor(ctx, fgColor);
                ctx.Scale(1.0f, 1.0f);
                ctx.SelectFontFace("Quicksand", FontSlant.Normal, bold ? FontWeight.Bold : FontWeight.Normal);
                ctx.SetFontSize(14 * GLTheme.DialogScaling);
                ctx.MoveTo(20 * GLTheme.DialogScaling, 13 * GLTheme.DialogScaling);
                ctx.ShowText(buttonText);
            }

            ctx.Target.Dispose();
            ctx.Dispose();
#else
            using (Gdk.GC gc = new Gdk.GC((Drawable)base.GdkWindow))
            {
                int x  = layoutNormal == null ? (width - pixbuf.Width) / 2 : 5;
                int y  = (height - pixbuf.Height) / 2;
                int yp = State == Gtk.StateType.Active ? 1 : 0;

                GdkWindow.DrawRectangle(Style.BackgroundGC(State), true, 0, 0, width, height);

                if (layoutNormal != null)
                {
                    var layout = bold ? layoutBold : layoutNormal;

                    layout.Width = -1;
                    layout.GetSize(out _, out int layoutHeight);
                    layoutHeight = Pango.Units.ToPixels(layoutHeight);

                    GdkWindow.DrawPixbuf(gc, pixbuf, 0, 0, x, y + yp, pixbuf.Width, pixbuf.Height, RgbDither.None, 0, 0);
                    GdkWindow.DrawLayout(Style.ForegroundGC(State), 10 + pixbuf.Width, (height - layoutHeight) / 2 + yp, layout);
                }
                else
                {
                    GdkWindow.DrawPixbuf(gc, pixbuf, 0, 0, x, y + yp, pixbuf.Width, pixbuf.Height, RgbDither.None, 0, 0);
                }
            }
#endif
            return(true);
        }
Пример #20
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect;

            if (DrawBackground)
            {
                GdkWindow.DrawRectangle(Style.BackgroundGC(Gtk.StateType.Normal), true, Allocation.X, Allocation.Y, Allocation.Width - 1, Allocation.Height - 1);
            }

            if (GradientBackround)
            {
                rect = new Gdk.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                Color gcol = Util.ToXwtColor(Style.Background(Gtk.StateType.Normal));

                using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) {
                    cr.NewPath();
                    cr.MoveTo(rect.X, rect.Y);
                    cr.RelLineTo(rect.Width, 0);
                    cr.RelLineTo(0, rect.Height);
                    cr.RelLineTo(-rect.Width, 0);
                    cr.RelLineTo(0, -rect.Height);
                    cr.ClosePath();
                    Cairo.Gradient pat    = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom);
                    Cairo.Color    color1 = gcol.ToCairoColor();
                    pat.AddColorStop(0, color1);
                    gcol.Light -= 0.1;
                    pat.AddColorStop(1, gcol.ToCairoColor());
                    cr.Pattern = pat;
                    cr.FillPreserve();
                }
            }

            bool res = base.OnExposeEvent(evnt);

            Gdk.GC borderColor;
            if (color != null)
            {
                borderColor            = new Gdk.GC(GdkWindow);
                borderColor.RgbFgColor = Util.ToGdkColor(color.Value);
            }
            else
            {
                borderColor = Style.DarkGC(Gtk.StateType.Normal);
            }

            rect = Allocation;
            for (int n = 0; n < topMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X, rect.Y + n, rect.Right, rect.Y + n);
            }

            for (int n = 0; n < bottomMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X, rect.Bottom - n, rect.Right, rect.Bottom - n);
            }

            for (int n = 0; n < leftMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom);
            }

            for (int n = 0; n < rightMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.Right - n, rect.Y, rect.Right - n, rect.Bottom);
            }

            if (color != null)
            {
                borderColor.Dispose();
            }

            return(res);
        }
Пример #21
0
 protected override bool OnExposeEvent(Gdk.EventExpose evnt)
 {
     GdkWindow.DrawRectangle(Style.BackgroundGC(StateType.Active), true, header_box.Allocation);
     return(base.OnExposeEvent(evnt));
 }
Пример #22
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            if (evnt.Window != GdkWindow)
            {
                return(true);
            }

            if (selection.Collection.Count == 0)
            {
                return(true);
            }

            if (Orientation == Orientation.Horizontal && (Extendable && Allocation.Width >= BackgroundPixbuf.Width + (2 * x_offset) + BackgroundTile.Width) ||
                Orientation == Orientation.Vertical && (Extendable && Allocation.Height >= BackgroundPixbuf.Height + (2 * y_offset) + BackgroundTile.Height))
            {
                BackgroundPixbuf = null;
            }

            if (Orientation == Orientation.Horizontal && (Extendable && Allocation.Width < BackgroundPixbuf.Width + (2 * x_offset)) ||
                Orientation == Orientation.Vertical && (Extendable && Allocation.Height < BackgroundPixbuf.Height + (2 * y_offset)))
            {
                BackgroundPixbuf = null;
            }

            int xpad = 0, ypad = 0;

            if (Allocation.Width > BackgroundPixbuf.Width + (2 * x_offset))
            {
                xpad = (int)(x_align * (Allocation.Width - (BackgroundPixbuf.Width + (2 * x_offset))));
            }

            if (Allocation.Height > BackgroundPixbuf.Height + (2 * y_offset))
            {
                ypad = (int)(y_align * (Allocation.Height - (BackgroundPixbuf.Height + (2 * y_offset))));
            }

            GdkWindow.DrawPixbuf(Style.BackgroundGC(StateType.Normal), BackgroundPixbuf,
                                 0, 0, x_offset + xpad, y_offset + ypad,
                                 BackgroundPixbuf.Width, BackgroundPixbuf.Height, RgbDither.None, 0, 0);

            //drawing the icons...
            start_indexes = new Dictionary <int, int> ();

            Pixbuf icon_pixbuf = null;

            if (Orientation == Orientation.Horizontal)
            {
                icon_pixbuf = new Pixbuf(Colorspace.Rgb, true, 8, BackgroundPixbuf.Width, thumb_size);
            }
            else if (Orientation == Orientation.Vertical)
            {
                icon_pixbuf = new Pixbuf(Colorspace.Rgb, true, 8, thumb_size, BackgroundPixbuf.Height);
            }
            icon_pixbuf.Fill(0x00000000);

            var current = GetPixbuf((int)Math.Round(Position));
            int ref_x   = (int)(icon_pixbuf.Width / 2.0 - current.Width * (Position + 0.5f - Math.Round(Position)));            //xpos of the reference icon
            int ref_y   = (int)(icon_pixbuf.Height / 2.0 - current.Height * (Position + 0.5f - Math.Round(Position)));

            int start_x = Orientation == Orientation.Horizontal ? ref_x : 0;
            int start_y = Orientation == Orientation.Vertical ? ref_y : 0;

            for (int i = (int)Math.Round(Position); i < selection.Collection.Count; i++)
            {
                current = GetPixbuf(i, ActiveItem == i);
                if (Orientation == Orientation.Horizontal)
                {
                    current.CopyArea(0, 0, Math.Min(current.Width, icon_pixbuf.Width - start_x), current.Height, icon_pixbuf, start_x, start_y);
                    start_indexes [start_x] = i;
                    start_x += current.Width + spacing;
                    if (start_x > icon_pixbuf.Width)
                    {
                        break;
                    }
                }
                else if (Orientation == Orientation.Vertical)
                {
                    current.CopyArea(0, 0, current.Width, Math.Min(current.Height, icon_pixbuf.Height - start_y), icon_pixbuf, start_x, start_y);
                    start_indexes [start_y] = i;
                    start_y += current.Height + spacing;
                    if (start_y > icon_pixbuf.Height)
                    {
                        break;
                    }
                }
            }
            filmstrip_end_pos = (Orientation == Orientation.Horizontal ? start_x : start_y);

            start_x = Orientation == Orientation.Horizontal ? ref_x : 0;
            start_y = Orientation == Orientation.Vertical ? ref_y : 0;
            for (int i = (int)Math.Round(Position) - 1; i >= 0; i--)
            {
                current = GetPixbuf(i, ActiveItem == i);
                if (Orientation == Orientation.Horizontal)
                {
                    start_x -= (current.Width + spacing);
                    current.CopyArea(Math.Max(0, -start_x), 0, Math.Min(current.Width, current.Width + start_x), current.Height, icon_pixbuf, Math.Max(start_x, 0), 0);
                    start_indexes [Math.Max(0, start_x)] = i;
                    if (start_x < 0)
                    {
                        break;
                    }
                }
                else if (Orientation == Orientation.Vertical)
                {
                    start_y -= (current.Height + spacing);
                    current.CopyArea(0, Math.Max(0, -start_y), current.Width, Math.Min(current.Height, current.Height + start_y), icon_pixbuf, 0, Math.Max(start_y, 0));
                    start_indexes [Math.Max(0, start_y)] = i;
                    if (start_y < 0)
                    {
                        break;
                    }
                }
            }
            filmstrip_start_pos = Orientation == Orientation.Horizontal ? start_x : start_y;

            GdkWindow.DrawPixbuf(Style.BackgroundGC(StateType.Normal), icon_pixbuf,
                                 0, 0, x_offset + xpad, y_offset + ypad + thumb_offset,
                                 icon_pixbuf.Width, icon_pixbuf.Height, RgbDither.None, 0, 0);

            icon_pixbuf.Dispose();

            return(true);
        }
Пример #23
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            if (evnt.Window != GdkWindow)
            {
                return(true);
            }

            if (extendable && Allocation.Width >= BackgroundPixbuf.Width + (2 * x_offset) + BackgroundTile.Width)
            {
                BackgroundPixbuf = null;
            }

            if (extendable && Allocation.Width < BackgroundPixbuf.Width + (2 * x_offset))
            {
                BackgroundPixbuf = null;
            }

            int xpad = 0, ypad = 0;

            if (Allocation.Width > BackgroundPixbuf.Width + (2 * x_offset))
            {
                xpad = (int)(x_align * (Allocation.Width - (BackgroundPixbuf.Width + (2 * x_offset))));
            }

            if (Allocation.Height > BackgroundPixbuf.Height + (2 * y_offset))
            {
                ypad = (int)(y_align * (Allocation.Height - (BackgroundPixbuf.Height + (2 * y_offset))));
            }

            GdkWindow.DrawPixbuf(Style.BackgroundGC(StateType.Normal), BackgroundPixbuf,
                                 0, 0, x_offset + xpad, y_offset + ypad,
                                 BackgroundPixbuf.Width, BackgroundPixbuf.Height, Gdk.RgbDither.None, 0, 0);

            //drawing the icons...
            start_indexes = new Hashtable();

            Pixbuf icon_pixbuf = new Pixbuf(Gdk.Colorspace.Rgb, true, 8, BackgroundPixbuf.Width, thumb_size);

            icon_pixbuf.Fill(0x00000000);

            Pixbuf current = GetPixbuf((int)Math.Round(Position));
            int    ref_x   = (int)(icon_pixbuf.Width / 2.0 - current.Width * (Position + 0.5f - Math.Round(Position)));         //xpos of the reference icon

            int start_x = ref_x;

            for (int i = (int)Math.Round(Position); i < selection.Collection.Count; i++)
            {
                current = GetPixbuf(i, ActiveItem == i);
                current.CopyArea(0, 0, Math.Min(current.Width, icon_pixbuf.Width - start_x), current.Height, icon_pixbuf, start_x, 0);
                start_indexes [start_x] = i;
                start_x += current.Width + spacing;
                if (start_x > icon_pixbuf.Width)
                {
                    break;
                }
            }
            filmstrip_end_pos = start_x;

            start_x = ref_x;
            for (int i = (int)Math.Round(Position) - 1; i >= 0; i--)
            {
                current  = GetPixbuf(i, ActiveItem == i);
                start_x -= (current.Width + spacing);
                current.CopyArea(Math.Max(0, -start_x), 0, Math.Min(current.Width, current.Width + start_x), current.Height, icon_pixbuf, Math.Max(start_x, 0), 0);
                start_indexes [Math.Max(0, start_x)] = i;
                if (start_x < 0)
                {
                    break;
                }
            }

            GdkWindow.DrawPixbuf(Style.BackgroundGC(StateType.Normal), icon_pixbuf,
                                 0, 0, x_offset + xpad, y_offset + ypad + thumb_offset,
                                 icon_pixbuf.Width, icon_pixbuf.Height, Gdk.RgbDither.None, 0, 0);

            icon_pixbuf.Dispose();

            return(true);
        }
Пример #24
0
        void VAdjustmentValueChanged(object sender, EventArgs args)
        {
            if (buffer == null)
            {
                AllocateWindowBuffer(this.Allocation);
            }

            if (HexEditorData.VAdjustment.Value != System.Math.Ceiling(HexEditorData.VAdjustment.Value))
            {
                HexEditorData.VAdjustment.Value = System.Math.Ceiling(HexEditorData.VAdjustment.Value);
                return;
            }
            long firstVisibleLine = (long)(HexEditorData.VAdjustment.Value / LineHeight);
            long lastVisibleLine  = (long)((HexEditorData.VAdjustment.Value + Allocation.Height) / LineHeight);

            margins.ForEach(margin => margin.SetVisibleWindow(firstVisibleLine, lastVisibleLine));

            int delta = (int)(HexEditorData.VAdjustment.Value - this.oldVadjustment);

            oldVadjustment = HexEditorData.VAdjustment.Value;

            // update pending redraws
            if (redrawList.Count > 0)
            {
                redrawList = new List <RedrawRequest> (redrawList.Select(request => {
                    Gdk.Rectangle area = request.Area;
                    area.Y            -= delta;
                    request.Area       = area;
                    return(request);
                }));
            }

            if (System.Math.Abs(delta) >= Allocation.Height - this.LineHeight * 2)
            {
                this.Repaint();
                return;
            }

            int from, to;

            if (delta > 0)
            {
                from = delta;
                to   = 0;
            }
            else
            {
                from = 0;
                to   = -delta;
            }

            DoFlipBuffer();
            this.buffer.DrawDrawable(Style.BackgroundGC(StateType.Normal),
                                     this.flipBuffer,
                                     0, from,
                                     0, to,
                                     Allocation.Width, Allocation.Height - from - to);

            if (delta > 0)
            {
                delta += LineHeight;
                RenderMargins(buffer, new Gdk.Rectangle(0, Allocation.Height - delta, Allocation.Width, delta), null);
            }
            else
            {
                delta -= LineHeight;
                RenderMargins(buffer, new Gdk.Rectangle(0, 0, Allocation.Width, -delta), null);
            }
            ResetCaretBlink();
            QueueDraw();
        }