public void HandleDrawn(object o, Gtk.DrawnArgs args)
            {
                var h = Handler;

                var allocation = h.Control.Allocation.Size;

                args.Cr.Rectangle(new Cairo.Rectangle(0, 0, allocation.Width, allocation.Height));
                args.Cr.Clip();
                Gdk.Rectangle rect = new Gdk.Rectangle();
                if (!GraphicsHandler.GetClipRectangle(args.Cr, ref rect))
                {
                    rect = new Gdk.Rectangle(Gdk.Point.Zero, allocation);
                }

#if old
                using (var graphics = new Graphics(new GraphicsHandler(args.Cr, h.Control.CreatePangoContext(), false)))
                {
                    if (h.SelectedBackgroundColor != null)
                    {
                        graphics.Clear(h.SelectedBackgroundColor.Value);
                    }

                    h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect.ToEto()));
                }
#else
                //CreatePangoContext  - creates a new one each time. local owned
                //GetPangoContext - gets a context owned by the control
                // only get the pango context once, using a context owned by the widget
                if (Pcontext == null)
                {
                    Pcontext = h.Control.GetPangoContext();
                }

                using (var graphics = new Graphics(new GraphicsHandler(args.Cr, Pcontext, false)))
                {
                    if (h.SelectedBackgroundColor != null)
                    {
                        graphics.Clear(h.SelectedBackgroundColor.Value);
                    }

                    h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect.ToEto()));
                }
#endif
            }
예제 #2
0
            public void HandleDrawn(object o, Gtk.DrawnArgs args)
            {
                var h = Handler;

                var allocation = h.Control.Allocation.Size;

                args.Cr.Rectangle(new Cairo.Rectangle(0, 0, allocation.Width, allocation.Height));
                args.Cr.Clip();
                Gdk.Rectangle rect = new Gdk.Rectangle();
                if (!GraphicsHandler.GetClipRectangle(args.Cr, ref rect))
                {
                    rect = new Gdk.Rectangle(Gdk.Point.Zero, allocation);
                }

                using (var graphics = new Graphics(new GraphicsHandler(args.Cr, h.Control.PangoContext, false)))
                {
                    if (h.SelectedBackgroundColor != null)
                    {
                        graphics.Clear(h.SelectedBackgroundColor.Value);
                    }

                    h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect.ToEto()));
                }
            }