Esempio n. 1
0
 private void HandleExposeEvent(object o, Gtk.ExposeEventArgs args)
 {
     using (Context g = Gdk.CairoHelper.Create(this.GdkWindow)) {
         DrawGradient(g);
         DrawTriangles(g);
     }
 }
Esempio n. 2
0
    private void TransparentExposeEvent(object obj, Gtk.ExposeEventArgs args)
    {
        Gtk.Widget    widget = (Gtk.Widget)obj;
        Gdk.Rectangle area   = args.Event.Area;

        widget.GdkWindow.ClearArea(area.X, area.Y, area.Width, area.Height);
    }
Esempio n. 3
0
        void OnGripExpose(object ob, Gtk.ExposeEventArgs args)
        {
            EventBox w = (EventBox)ob;

            Gdk.Rectangle handleRect = w.Allocation;
//			w.GdkWindow.DrawRectangle (w.Style.DarkGC (StateType.Normal), true, handleRect);
            handleRect.X = handleRect.Y = 0;

/*			switch (position) {
 *                      case PositionType.Top:
 *                              handleRect.Height -= 4; handleRect.Y += 1;
 *                              Gtk.Style.PaintHline (w.Style, w.GdkWindow, StateType.Normal, args.Event.Area, w, "", 0, w.Allocation.Width, gripSize - 2);
 *                              break;
 *                      case PositionType.Bottom:
 *                              handleRect.Height -= 4; handleRect.Y += 3;
 *                              Gtk.Style.PaintHline (w.Style, w.GdkWindow, StateType.Normal, args.Event.Area, w, "", 0, w.Allocation.Width, 0);
 *                              break;
 *                      case PositionType.Left:
 *                              handleRect.Width -= 4; handleRect.X += 1;
 *                              Gtk.Style.PaintVline (w.Style, w.GdkWindow, StateType.Normal, args.Event.Area, w, "", 0, w.Allocation.Height, gripSize - 2);
 *                              break;
 *                      case PositionType.Right:
 *                              handleRect.Width -= 4; handleRect.X += 3;
 *                              Gtk.Style.PaintVline (w.Style, w.GdkWindow, StateType.Normal, args.Event.Area, w, "", 0, w.Allocation.Height, 0);
 *                              break;
 *                      }*/

            Orientation or = horiz ? Orientation.Vertical : Orientation.Horizontal;
            StateType   s  = insideGrip ? StateType.Prelight : StateType.Normal;

            Gtk.Style.PaintHandle(w.Style, w.GdkWindow, s, ShadowType.None, args.Event.Area, w, "paned", handleRect.Left, handleRect.Top, handleRect.Width, handleRect.Height, or);
        }
Esempio n. 4
0
    /**
     * Configure the drawing area when the application launches
     */
    protected void OnMainDrawingAreaExposeEvent(object o, Gtk.ExposeEventArgs args)
    {
        int x, y, w, h;

        Gdk.Rectangle[] rects = args.Event.Region.GetRectangles();

        foreach (Gdk.Rectangle rect in rects)
        {
            x = rect.X;
            y = rect.Y;
            w = rect.Width;
            h = rect.Height;

            if (x + w > width)
            {
                w = width - x;
            }

            if (y + h > height)
            {
                h = height - y;
            }

            //Console.WriteLine("DrawPixbuf x:{0} y:{1} w:{2} h:{3}", x, y, w, h);

            drawable.DrawPixbuf(gc, surface, x, y, x, y, w, h, Gdk.RgbDither.None, 0, 0);
        }
    }
Esempio n. 5
0
        private void HeaderExpose(object ob, Gtk.ExposeEventArgs a)
        {
            Gdk.Rectangle rect = new Gdk.Rectangle(0, 0, header.Allocation.Width - 1, header.Allocation.Height);
            HslColor      gcol = frame.Style.Background(Gtk.StateType.Normal);

            if (pointerHover)
            {
                gcol.L *= 1.05;
            }
            gcol.L = Math.Min(1, gcol.L);

            using (Cairo.Context cr = Gdk.CairoHelper.Create(a.Event.Window)) {
                cr.NewPath();
                cr.MoveTo(0, 0);
                cr.RelLineTo(rect.Width, 0);
                cr.RelLineTo(0, rect.Height);
                cr.RelLineTo(-rect.Width, 0);
                cr.RelLineTo(0, -rect.Height);
                cr.ClosePath();
                Cairo.SolidPattern solidPattern = new Cairo.SolidPattern(gcol);
                cr.Pattern = solidPattern;
                cr.FillPreserve();
                solidPattern.Destroy();
            }

            header.GdkWindow.DrawRectangle(frame.Style.DarkGC(Gtk.StateType.Normal), false, rect);

            foreach (Widget child in header.Children)
            {
                header.PropagateExpose(child, a.Event);
            }
        }
Esempio n. 6
0
        void HandleExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.GC     button = new Gdk.GC(this.eventbox1.GdkWindow);
            Gdk.Pixmap pixmap_mask;
            Pixmap     pixmap;

            Gdk.Pixbuf pixbuf;

            if (!this.IsActive)
            {
                pixbuf = this.RoundLeft ? Images.iButtonLeft : Images.iButtonRight;
            }
            else
            {
                pixbuf = this.RoundLeft ? Images.iButtonLeftPushed : Images.iButtonRightPushed;
            }
            pixbuf.RenderPixmapAndMask(out pixmap, out pixmap_mask, 255);
            button.Fill = Gdk.Fill.Tiled;
            button.Tile = pixmap;
            this.eventbox1.GdkWindow.DrawRectangle(button, true, 0, 0, this.WidthRequest, this.HeightRequest);

            Pango.Layout layout = new Pango.Layout(this.PangoContext);
            layout.SetMarkup("<span color=\"{1}\" font=\"10.5\">{0}</span>".FormatStr(this.Text.HtmlEncode(), this.IsActive ? "white" : "black"));
            this.eventbox1.GdkWindow.DrawLayout(this.IsActive ? Style.WhiteGC : Style.BlackGC, this.RoundLeft ? 10 : 5, yOffset, layout);
        }
Esempio n. 7
0
        private void HandleExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            using (Context g = Gdk.CairoHelper.Create(this.GdkWindow)) {
                int       rad  = 4;
                Rectangle rect = Allocation.ToCairoRectangle();

                g.FillRoundedRectangle(rect, rad, CairoColor);
            }
        }
Esempio n. 8
0
 private void OnExposed(object sender, Gtk.ExposeEventArgs e)
 {
     using (Context context = Gdk.CairoHelper.Create(e.Event.Window))
     {
         Gdk.CairoHelper.SetSourcePixmap(context, _pixmap, e.Event.Area.X, e.Event.Area.Y);
         context.Rectangle(e.Event.Area.X, e.Event.Area.Y, e.Event.Area.Width, e.Event.Area.Height);
         context.Fill();
     }
 }
        protected virtual void OnDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            EventExpose evnt = args.Event;

            drawingarea.GdkWindow.DrawDrawable(drawingarea.Style.ForegroundGCs[(int)drawingarea.State],
                                               pixmap,
                                               evnt.Area.X, evnt.Area.Y,
                                               evnt.Area.X, evnt.Area.Y,
                                               evnt.Area.Width, evnt.Area.Height);
        }
Esempio n. 10
0
 private void HandleDrawingExposeEvent(object o, Gtk.ExposeEventArgs args)
 {
     using (Context g = Gdk.CairoHelper.Create(drawing.GdkWindow)) {
         DrawBorder(g);
         DrawPointerCross(g);
         DrawSpline(g);
         DrawGrid(g);
         DrawControlPoints(g);
     }
 }
Esempio n. 11
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;
            }
        }
Esempio n. 12
0
        void OnGripExpose(object sender, Gtk.ExposeEventArgs args)
        {
            var       w = (EventBox)sender;
            StateType s = insideGrip ? StateType.Prelight : StateType.Normal;

            using (var ctx = CairoHelper.Create(args.Event.Window)) {
                ctx.Color = (HslColor)(w.Style.Background(s));
                ctx.Paint();
            }
        }
Esempio n. 13
0
    protected void OnStageVboxExposeEvent(object o, Gtk.ExposeEventArgs args)
    {
        int l, t, w, h;

        w = stage_vbox.Allocation.Width; h = stage_vbox.Allocation.Height;
        l = stage_vbox.Allocation.Left; t = stage_vbox.Allocation.Top;

        Gtk.Style.PaintBox(stage_vbox.Style, stage_vbox.GdkWindow, Gtk.StateType.Normal,
                           Gtk.ShadowType.In, new Gdk.Rectangle(l, t, w, h), this, null,
                           l + 1, t + 1, w - 2, h - 2);
    }
        void HPaneExpose(object sender, Gtk.ExposeEventArgs args)
        {
            int size = this.Allocation.Width;

            if (size == oldSize2)
            {
                return;
            }
            oldSize2 = size;
            this.hpaned1.Position = Math.Min(350, this.Allocation.Width * 2 / 3);
        }
Esempio n. 15
0
 // Draw the robot's default icon
 protected void OnIconboxExposeEvent(object o, Gtk.ExposeEventArgs args)
 {
     args.Event.Window.Clear();
     if (robot_ != null)
     {
         int w, h;
         args.Event.Window.GetSize(out w, out h);
         Graphics g = Gtk.DotNet.Graphics.FromDrawable(args.Event.Window);
         robot_.file.draw(g, w / 2, h / 2, robot_.number, 0, null);
     }
     args.RetVal = true;
 }
Esempio n. 16
0
 protected virtual void OnDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
 {
     if (designService != null)
     {
         DrawingArea   area = (DrawingArea)o;
         Cairo.Context cr   = Gdk.CairoHelper.Create(area.GdkWindow);
         cr.Antialias = Cairo.Antialias.None;
         designService.RedrawReport(cr);
         area.SetSizeRequest((int)designService.Width, (int)designService.Height);
         (cr as IDisposable).Dispose();
     }
 }
Esempio n. 17
0
        void HandleEventbox1handleExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.GC     gc = new Gdk.GC(this.eventbox1.GdkWindow);
            Gdk.Pixmap pixmap_mask;
            Pixmap     pixmap;

            Gdk.Pixbuf pbBackground = Images.StatusWidget_Background;
            Gdk.Pixbuf pbLeft       = Images.StatusWidget_Left;
            Gdk.Pixbuf pbRight      = Images.StatusWidget_Right;

            int w, h;

            this.eventbox1.GdkWindow.GetSize(out w, out h);

            pbBackground.RenderPixmapAndMask(out pixmap, out pixmap_mask, 255);
            gc.Fill = Gdk.Fill.Tiled;
            gc.Tile = pixmap;
            this.eventbox1.GdkWindow.DrawRectangle(gc, true, pbLeft.Width, 0, this.WidthRequest - (pbLeft.Width + pbRight.Width), this.HeightRequest);

            this.eventbox1.GdkWindow.DrawPixbuf(gc, pbLeft, 0, 0, 0, 0, pbLeft.Width, h, RgbDither.Normal, 0, 0);
            this.eventbox1.GdkWindow.DrawPixbuf(gc, pbRight, 0, 0, w - pbRight.Width, 0, pbRight.Width, h, RgbDither.Normal, 0, 0);

            Pango.Layout layout = new Pango.Layout(this.PangoContext);
            //layout.Width = w - 40;
            layout.Width     = Pango.Units.FromPixels(w - 40);
            layout.Alignment = Pango.Alignment.Center;
            layout.Ellipsize = Pango.EllipsizeMode.Middle;
            // draw pulsar
            if (IsPulsing)
            {
                layout.SetMarkup("<span color=\"white\" font=\"{1}\">{0}</span>".FormatStr(this.Text.HtmlEncode(), fontsmallsize));
                this.eventbox1.GdkWindow.DrawLayout(Style.WhiteGC, 20, 27, layout);

                int xoffset     = 50;
                int yoffset     = 10;
                int pheight     = 10;
                int pulsarwidth = w - xoffset * 2;
                this.eventbox1.GdkWindow.DrawRectangle(Style.WhiteGC, false, xoffset, yoffset, pulsarwidth, pheight);
                this.eventbox1.GdkWindow.DrawRectangle(Style.WhiteGC, false, xoffset, yoffset, pulsarwidth, pheight);

                int barwidth = (w - xoffset * 2) / 10 + 2;
                this.eventbox1.GdkWindow.DrawRectangle(Style.WhiteGC, true, (int)(PulsarLevel * (pulsarwidth - barwidth)) + xoffset, yoffset, barwidth, pheight);
            }
            else
            {
                // draw text in center
                layout.SetMarkup("<span color=\"white\" font=\"{1}\">{0}</span>".FormatStr(this.Text.HtmlEncode(), fontlargesize));
                this.eventbox1.GdkWindow.DrawLayout(Style.WhiteGC, 20, 14, layout);
            }
        }
Esempio n. 18
0
        protected virtual void OnDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            double dar;
            int    w, h, destH, destW;

            if (source == null)
            {
                return;
            }
            drawingarea.GdkWindow.Clear();

            using (Context c = CairoHelper.Create(drawingarea.GdkWindow)) {
                w   = drawingarea.Allocation.Width;
                h   = drawingarea.Allocation.Height;
                dar = (double)w / h;

                if (sourceDAR > dar)
                {
                    destW   = w;
                    destH   = (int)(w / sourceDAR);
                    xOffset = 0;
                    yOffset = (h - destH) / 2;
                }
                else
                {
                    destH   = h;
                    destW   = (int)(h * sourceDAR);
                    xOffset = (w - destW) / 2;
                    yOffset = 0;
                }
                c.Translate(xOffset, yOffset);
                xScale = (double)destW / sourceWidth;
                yScale = (double)destH / sourceHeight;

                c.Save();
                c.Scale(xScale, yScale);
                c.SetSourceSurface(source, 0, 0);
                c.Paint();
                c.Restore();
                RedrawAllCoordinates(c);
                if (selectedCoords != null)
                {
                    DrawCoordinates(c, selectedCoords);
                }
            }
        }
Esempio n. 19
0
        protected virtual void OnLogodrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.Window win;
            Gdk.Pixbuf logo, frame;
            int        width, height, allocWidth, allocHeight, logoX, logoY;
            float      ratio;

            if (logopix == null)
            {
                return;
            }

            logo = logopix.Value;

            win         = logodrawingarea.GdkWindow;
            width       = logo.Width;
            height      = logo.Height;
            allocWidth  = logodrawingarea.Allocation.Width;
            allocHeight = logodrawingarea.Allocation.Height;

            /* Checking if allocated space is smaller than our logo */
            if ((float)allocWidth / width > (float)allocHeight / height)
            {
                ratio = (float)allocHeight / height;
            }
            else
            {
                ratio = (float)allocWidth / width;
            }
            width  = (int)(width * ratio);
            height = (int)(height * ratio);

            logoX = (allocWidth / 2) - (width / 2);
            logoY = (allocHeight / 2) - (height / 2);

            /* Drawing our frame */
            frame = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, allocWidth, allocHeight);
            logo.Composite(frame, 0, 0, allocWidth, allocHeight, logoX, logoY,
                           ratio, ratio, Gdk.InterpType.Bilinear, 255);

            win.DrawPixbuf(this.Style.BlackGC, frame, 0, 0,
                           0, 0, allocWidth, allocHeight,
                           Gdk.RgbDither.Normal, 0, 0);
            frame.Dispose();
            return;
        }
Esempio n. 20
0
        protected virtual void OnViewExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.Window win = args.Event.Window;

            // Draw the window border
            win.DrawRectangle(darkgc, false, 0, 0, dimensions + 1, dimensions + 1);

            if (arena != null)
            {
                const int d = Constants.ARENA_SIZE;

                // Clear the pixmap
                view_pixmap.DrawRectangle(whitegc, true, 0, 0, d, d);
                arena.draw(view_graphics);

                if (scaling_ == ScalingMode.None)
                {
                    win.DrawDrawable(whitegc, view_pixmap, 0, 0, 1, 1, d, d);
                }
                else
                {
                    Gdk.Pixbuf pb = Gdk.Pixbuf.FromDrawable(view_pixmap, win.Screen.DefaultColormap,
                                                            0, 0, 0, 0, d, d);

                    Gdk.Pixbuf spb = null;
                    switch (scaling_)
                    {
                    case ScalingMode.Nearest2x:
                    case ScalingMode.Nearest3x:
                        spb = pb.ScaleSimple(dimensions, dimensions, Gdk.InterpType.Nearest);
                        break;

                    case ScalingMode.Bilinear2x:
                    case ScalingMode.Bilinear3x:
                        spb = pb.ScaleSimple(dimensions, dimensions, Gdk.InterpType.Bilinear);
                        break;
                    }

                    win.DrawPixbuf(whitegc, spb, 0, 0, 1, 1, dimensions, dimensions,
                                   Gdk.RgbDither.None, 0, 0);
                }
            }

            args.RetVal = true;
        }
Esempio n. 21
0
        protected virtual void OnPreviewDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            DrawingArea area = (DrawingArea)o;

            if (designService.Report.Pages.Count > 0)
            {
                Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
                cr.Antialias           = Cairo.Antialias.None;
                reportRenderer.Context = cr;
                Cairo.Rectangle r = new Cairo.Rectangle(0, 0, designService.Report.WidthWithMargins, designService.Report.HeightWithMargins);
                cr.FillRectangle(r, backgroundPageColor);
                cr.Translate(designService.Report.Margin.Left, designService.Report.Margin.Top);
                reportRenderer.RenderPage(designService.Report.Pages [pageNumber]);
                area.SetSizeRequest((int)designService.Report.HeightWithMargins, (int)designService.Report.HeightWithMargins + 5);

                (cr as IDisposable).Dispose();
            }
        }
Esempio n. 22
0
        void GmapWidget_ExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            if (tracksDistance.Count == 0)
            {
                return;
            }
            var g = args.Event.Window;
            var aria = args.Event.Area;
            int layoutWidth, layoutHeight, voffset = 0;
            var gc = gmapWidget.Style.TextGC(Gtk.StateType.Normal);

            foreach (var distance in tracksDistance)
            {
                distance.PangoLayout.GetPixelSize(out layoutWidth, out layoutHeight);
                g.DrawLayout(gc, aria.Right - 6 - layoutWidth, aria.Top + 6 + voffset, distance.PangoLayout);
                voffset += 3 + layoutHeight;
            }
        }
Esempio n. 23
0
            /// <summary> Draw the image to the image menu item. Taken from: http://mono.1490590.n4.nabble.com/ImageMenuItem-does-not-display-the-image-Linux-platform-tp3510861p3511376.html </summary>
            ///  The event source. <see cref="System.Object"/>
            ///  The event args. <see cref="Gtk.ExposeEventArgs"/>
            private void DrawImageMenuItemImage(object o, Gtk.ExposeEventArgs args)
            {
                if (o as Gtk.ImageMenuItem == null)
                {
                    return;
                }

                Gtk.Image image = (o as Gtk.ImageMenuItem).Image as Gtk.Image;
                if (image == null || image.Pixbuf == null)
                {
                    return;
                }

                Gdk.GC        mainGC = ((Gtk.Widget)o).Style.ForegroundGCs[(int)Gtk.StateType.Normal];
                Gdk.Rectangle r      = args.Event.Area;

                args.Event.Window.DrawPixbuf(mainGC, image.Pixbuf, 0, 0, r.Left + 2,
                                             r.Top + (r.Height - image.Pixbuf.Height) / 2, -1, -1, Gdk.RgbDither.None, 0, 0);
            }
Esempio n. 24
0
    private void TransparentExposeEvent(object obj, Gtk.ExposeEventArgs args)
    {
        Gtk.Widget    widget = (Gtk.Widget)obj;
        Gdk.Rectangle area   = args.Event.Area;

        if (visual_is_rgba)
        {
            Cairo.Context cr = Gdk.CairoHelper.Create(widget.GdkWindow);
            cr.SetSourceRGBA(0, 0, 0, 0);
            cr.Operator = Cairo.Operator.Source;
            Gdk.CairoHelper.Region(cr, args.Event.Region);
            cr.Fill();

            ((IDisposable)cr.Target).Dispose();
            ((IDisposable)cr).Dispose();
        }
        else
        {
            widget.GdkWindow.ClearArea(area.X, area.Y, area.Width, area.Height);
        }
    }
Esempio n. 25
0
        void HandleEventbox2ExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.GC     button = new Gdk.GC(this.eventbox2.GdkWindow);
            Gdk.Pixmap pixmap_mask;
            Pixmap     pixmap;

            Gdk.Pixbuf pixbuf = null;
            if (this.IsActive)
            {
                pixbuf = ActivePixbuf;
            }
            else
            {
                pixbuf = NormalPixbuf;
            }
            pixbuf.RenderPixmapAndMask(out pixmap, out pixmap_mask, 255);

            button.Fill = Gdk.Fill.Tiled;
            button.Tile = pixmap;

            this.eventbox2.GdkWindow.DrawRectangle(button, true, 0, 0, eventbox2.WidthRequest, eventbox2.HeightRequest);
        }
Esempio n. 26
0
        void tableAccsessMatrix_ExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            int x, y, w, h, x0, y0;

            h  = tableAccsessMatrix.Allocation.Height;
            w  = tableAccsessMatrix.Allocation.Width;
            x0 = tableAccsessMatrix.Allocation.X;
            y0 = tableAccsessMatrix.Allocation.Y;

            for (int col = 0; col < checkButtons.GetLength(1); col++)
            {
                if (checkButtons[1, col] == null)
                {
                    continue;
                }

                var gc = this.Style.ForegroundGC(this.State);
                gc.SetLineAttributes(col != 0 ? 1 : 2, Gdk.LineStyle.Solid, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);
                x = cells[1, col].Allocation.X - 3;
                //checkButtons[1, col].TranslateCoordinates(tableAccsessMatrix, -1, 0, out x, out y);
                tableAccsessMatrix.GdkWindow.DrawLine(gc, x, y0, x, y0 + h);
            }
            for (int row = 0; row < checkButtons.GetLength(0); row++)
            {
                if (checkButtons[row, 1] == null)
                {
                    continue;
                }
                checkButtons[row, 1].TranslateCoordinates(tableAccsessMatrix, 0, -3, out x, out y);

                var gc = this.Style.ForegroundGC(this.State);
                gc.SetLineAttributes(row != 0 ? 1 : 2, Gdk.LineStyle.Solid, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);

                tableAccsessMatrix.GdkWindow.DrawLine(gc, x0, y0 + y, x0 + w, y0 + y);
            }
        }
Esempio n. 27
0
        protected virtual void OnDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            if (!loaded)
            {
                return;
            }
            drawingarea.GdkWindow.Clear();

            using (Context c = CairoHelper.Create(drawingarea.GdkWindow)) {
                c.SetSourceSurface(source, xOffset, yOffset);
                c.Paint();
                if (visible)
                {
                    c.SetSourceSurface(drawings, xOffset, yOffset);
                    c.PaintWithAlpha(transparency);
                }
                //Preview
                if (preview)
                {
                    Paint(c, initialPoint.X + xOffset, initialPoint.Y + yOffset,
                          finalPoint.X + xOffset, finalPoint.Y + yOffset);
                }
            }
        }
Esempio n. 28
0
        void HandleExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            if (display == null)
            {
                return;
            }

            DrawingArea area = (DrawingArea)o;

            Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);

            int border = Math.Min((int)(Allocation.Width * 0.1), (int)(Allocation.Height * 0.1));

            scale = Math.Max(1.0 * display.Width / (Allocation.Width - border * 2), 1.0 * display.Height / (Allocation.Height - border * 2));

            Gdk.Pixbuf image = display.ScaleSimple((int)(display.Width / scale), (int)(display.Height / scale), InterpType.Bilinear);

            imageX = (Allocation.Width - image.Width) / 2;
            imageY = (Allocation.Height - image.Height) / 2;

            Gdk.CairoHelper.SetSourcePixbuf(cr, image, imageX, imageY);
            cr.Paint();

            for (int i = 0; i < CurrentDefinition.Leds.Count; i++)
            {
                DrawLed(i, cr);
            }

            if (FocussedLed != -1)
            {
                cr.LineWidth = 5 / scale;
                cr.Save();
                cr.SetSourceRGB(0, 0, 1);
                cr.Arc(
                    imageX + CurrentDefinition.Leds[FocussedLed].X / scale,
                    imageY + CurrentDefinition.Leds[FocussedLed].Y / scale,
                    (LedSize + 5) / scale / 2,
                    0,
                    2 * Math.PI);
                cr.Stroke();
                cr.Restore();
            }

            if (SelectedLed != -1)
            {
                cr.LineWidth = 5 / scale;
                cr.Save();
                cr.SetSourceRGB(1, 0, 0);
                cr.Arc(
                    imageX + CurrentDefinition.Leds[SelectedLed].X / scale,
                    imageY + CurrentDefinition.Leds[SelectedLed].Y / scale,
                    LedSize / scale / 2,
                    0,
                    2 * Math.PI);
                cr.Stroke();
                cr.Restore();
            }

            image.Dispose();

            ((IDisposable)cr).Dispose();
        }
        protected void OnDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.EventExpose expose = args.Args[0] as Gdk.EventExpose;
            Gdk.Window      win = expose.Window;
            int             width, height;

            win.GetSize(out width, out height);
            Gdk.Rectangle exposeRect = expose.Area;
            bool          fulldraw   = width == exposeRect.Width && height == exposeRect.Height;

            win.DrawRectangle(Style.LightGC(StateType.Normal), true, exposeRect);
            if (GetContentDelegate == null)
            {
                return; // todo: an error message could be displayed
            }
            int offset = (int)vscrollbar1.Value;

            if (fulldraw)
            {
                TopVisibleRow    = offset;
                BottomVisibleRow = offset;
            }
            int hscrollRange = 0;
            int dy           = exposeRect.Top;

            offset += dy / ConstantHeight;
            dy     -= dy % ConstantHeight;

            Gdk.GC backgound = new Gdk.GC((Gdk.Drawable)base.GdkWindow);
            Gdk.GC text      = new Gdk.GC((Gdk.Drawable)base.GdkWindow);

            ColumnControl.Column[] columns = mColumnControl.GetVisibleColumnsInDrawOrder();

            for (int row = offset; row < RowCount; row++)
            {
                int           dx   = -(int)hscrollbar1.Value;
                Gdk.Rectangle rect = new Gdk.Rectangle(dx, dy, 0, ConstantHeight);

                System.Drawing.Color backColor = System.Drawing.Color.WhiteSmoke;
                System.Drawing.Color textColor = System.Drawing.Color.Black;

                if (isRowSelected(row))
                {
                    if (HasFocus)
                    {
                        backColor = System.Drawing.Color.DarkGray;
                    }
                    else
                    {
                        backColor = System.Drawing.Color.LightGray;
                    }
                }
                else
                {
                    if (GetColorDelegate != null)
                    {
                        GetColorDelegate(row, ref backColor, ref textColor);
                    }
                }

                backgound.RgbFgColor = new Gdk.Color(backColor.R, backColor.G, backColor.B);
                text.RgbFgColor      = new Gdk.Color(textColor.R, textColor.G, textColor.B);

                for (int c = 0; c < columns.Length; c++)
                {
                    ColumnControl.Column column = columns[c];
                    int columnIndex             = column.SortOrder;
                    int xwidth = column.Width;
                    if (dx > exposeRect.Right)
                    {
                        break;
                    }
                    rect = new Gdk.Rectangle(rect.Left, rect.Top, xwidth + mColumnControl.GripperWidth, ConstantHeight);
                    if (c == columns.Length - 1)
                    {
                        rect.Width = Math.Max(rect.Width, exposeRect.Right - rect.Left + 1);
                    }
                    object content = GetContentDelegate(row, columnIndex);
                    if (content is Gdk.Pixbuf)
                    {
                        Gdk.Pixbuf image = (Gdk.Pixbuf)content;
                        win.DrawRectangle(backgound, true, rect);
                        dx += 2;
                        image.RenderToDrawable(win, text, 0, 0, dx, dy, image.Width, image.Height, Gdk.RgbDither.Normal, 0, 0);
                        dx += xwidth + mColumnControl.GripperWidth - 2;
                        rect.Offset(xwidth + mColumnControl.GripperWidth, 0);
                    }
                    else
                    {
                        LineLayout.SetText(content.ToString());
                        win.DrawRectangle(backgound, true, rect);
                        dx += 2;
                        win.DrawLayout(text, dx, dy, LineLayout);
                        dx += xwidth + mColumnControl.GripperWidth - 2;
                        rect.Offset(xwidth + mColumnControl.GripperWidth, 0);
                    }
                }
                hscrollRange = Math.Max(hscrollRange, dx + rect.Width);
                dy          += ConstantHeight;
                if (dy > exposeRect.Bottom)
                {
                    break;
                }
                if (fulldraw && exposeRect.Height - dy >= ConstantHeight)
                {
                    BottomVisibleRow++;
                }
            }

            if (fulldraw)
            {
                int pageSize = BottomVisibleRow - TopVisibleRow;
                if (vscrollbar1.Adjustment.PageSize != pageSize)
                {
                    vscrollbar1.Adjustment.PageSize      = pageSize;
                    vscrollbar1.Adjustment.PageIncrement = pageSize;
                }
                hscrollRange += (int)hscrollbar1.Value;
                if (hscrollRange > 0)
                {
                    hscrollbar1.SetRange(0, hscrollRange);
                }

                // position current row inside visible area
                // TODO: please think about, because of double redraw a more sophisticated solution could be possible
                if (CurrentRow >= 0 && CurrentRow < RowCount)
                {
                    if (CurrentRow < TopVisibleRow)
                    {
                        OffsetCursor(TopVisibleRow - CurrentRow);
                    }
                    else if (CurrentRow > BottomVisibleRow)
                    {
                        OffsetCursor(BottomVisibleRow - CurrentRow);
                    }
                }
            }

#if DEBUG2
            if (ComponentManager != null)
            {
                String t1 = String.Format("Expose.Area={0}, size={1}.{2}",
                                          expose.Area.ToString(), width, height);
                String t2 = String.Format("{0} T={1} B={2}", fulldraw ? "FULL" : "PART", TopVisibleRow, BottomVisibleRow);
                ComponentManager.MessageWriteLineInvoke(String.Format("{0} {1}", t1, t2));
            }
#endif
        }
Esempio n. 30
0
 public static void Draw(object o, Gtk.ExposeEventArgs a)
 {
     DrawStar(numberCorner, numberSkip, new Rectangle(0, 0, 400, 400));
 }