Beispiel #1
0
        /// <summary>The drawing canvas is being exposed to user.</summary>
        private void OnDrawingAreaExpose(object sender, ExposeEventArgs args)
        {
            try
            {
                DrawingArea area = (DrawingArea)sender;

#if NETFRAMEWORK
                Cairo.Context context = Gdk.CairoHelper.Create(area.GdkWindow);
#else
                Cairo.Context context = args.Cr;
#endif
                foreach (DGArc tmpArc in arcs)
                {
                    tmpArc.Paint(context);
                }
                foreach (DGNode tmpNode in nodes)
                {
                    tmpNode.Paint(context);
                }

                ((IDisposable)context.GetTarget()).Dispose();
                ((IDisposable)context).Dispose();
            }
            catch (Exception err)
            {
                ShowError(err);
            }
        }
Beispiel #2
0
		// Expose callback for the drawing area
		void DrawnCallback (object o, DrawnArgs args)
		{
			Cairo.Context cr = args.Cr;
			
			Gdk.CairoHelper.SetSourcePixbuf (cr, frame, 0, 0);
			cr.Paint ();

			args.RetVal = true;
		}
Beispiel #3
0
        private void HandleDrawingDrawnEvent(object o, Gtk.DrawnArgs args)
        {
            Context g = args.Cr;

            DrawBorder(g);
            DrawPointerCross(g);
            DrawSpline(g);
            DrawGrid(g);
            DrawControlPoints(g);
        }
Beispiel #4
0
 /// <summary>
 /// Invoked when the chart is rendered. Handles drawing of the
 /// lines of the triangle.
 /// </summary>
 /// <param name="o">Sender object.</param>
 /// <param name="args">Event arguments.</param>
 private void OnDrawChart(object o, ExposeEventArgs args)
 {
     try
     {
         Refresh(true);
     }
     catch (Exception err)
     {
         ShowError(err);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Traps the Exposed event for the image. This event fires after
        /// size/space allocation has occurred but before it is actually
        /// drawn on the screen. Because the size-allocated signal is emitted
        /// several times, we don't want to refresh the map each time.
        /// Therefore, we refresh the map once, during the expose event.
        ///
        /// We also disconnect the event handler after refreshing the map so
        /// that we don't refresh it multiple times unnecessarily.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="args">Event data.</param>
        private void OnImageExposed(object sender, ExposeEventArgs args)
        {
            try
            {
                RefreshMap();
#if NETFRAMEWORK
                image.ExposeEvent -= OnImageExposed;
#else
                image.Drawn -= OnImageExposed;
#endif
            }
            catch (Exception err)
            {
                ShowError(err);
            }
        }
Beispiel #6
0
        private void OnDrawn(object o, DrawnArgs args)
        {
            // NOTE: This is a little insane, but it allows packing of EventBox based widgets
            // into a GtkMenuItem without breaking the theme (leaving an unstyled void in the item).
            // This method is called before the EventBox child does its drawing and the background
            // is filled in with the proper style.

            int x, y, width, height;
            Widget widget = (Widget)o;

            if(IsSelected) {
                x = Allocation.X - widget.Allocation.X;
                y = Allocation.Y - widget.Allocation.Y;
                width = Allocation.Width;
                height = Allocation.Height;

                StyleContext.Save ();
                StyleContext.AddClass ("menuitem");
                StyleContext.State = StateFlags.Prelight | StateFlags.Selected;
                StyleContext.RenderFrame (args.Cr, x, y, width, height);
                StyleContext.RenderBackground (args.Cr, x, y, width, height);
                StyleContext.Restore ();
            } else {

                args.Cr.Save ();

                var color = Parent.StyleContext.GetBackgroundColor (StateFlags.Normal);
                // Fill only the visible area in solid color, to be most efficient
                args.Cr.SetSourceRGB (color.Red, color.Green, color.Blue);
                args.Cr.Rectangle (0, 0, widget.Allocation.Width, widget.Allocation.Height);
                args.Cr.Fill ();

                args.Cr.Restore ();

                // FIXME: The above should not be necessary, but Clearlooks-based themes apparently
                // don't provide any style for the menu background so we have to fill it first with
                // the correct theme color. Weak.
                //
                // Do a complete style paint based on the size of the entire menu to be compatible with
                // themes that provide a real style for "menu"
                x = Parent.Allocation.X - widget.Allocation.X;
                y = Parent.Allocation.Y - widget.Allocation.Y;
                width = Parent.Allocation.Width;
                height = Parent.Allocation.Height;

                StyleContext.Save ();
                StyleContext.AddClass ("menuitem");
                StyleContext.State = StateFlags.Normal;
                StyleContext.RenderFrame (args.Cr, x, y, width, height);
                StyleContext.RenderBackground (args.Cr, x, y, width, height);
                StyleContext.Restore ();
            }
        }
Beispiel #7
0
        void HandleHeaderDrawn(object o, DrawnArgs args)
        {
            Cairo.Context cr = args.Cr;
            cr.Save ();

            int wd = Allocation.Width - 48;
            Cairo.Color c1 = new Gdk.Color(65,65,65).ToCairoColor();
            Cairo.Color c2 = new Gdk.Color(255,255,255).ToCairoColor();

            Cairo.Gradient linpat = new LinearGradient(0,0,wd,Allocation.Height);
            linpat.AddColorStop(0.00, c1);
            linpat.AddColorStop(1.00, c2);

            cr.Rectangle (0, 0, wd, Allocation.Height);
            cr.Source = linpat;
            //cr.PaintWithAlpha(0.5);
            cr.Fill();

            cr.Color = new Color(1, 1, 1);
            cr.SelectFontFace("Arial", FontSlant.Normal, FontWeight.Bold);
            cr.SetFontSize(15.2);

            String txt = String.Empty;

            if (CurrentWidget != null)
            {
                if (CurrentWidget is  DockableWidget)
                {
                    txt = (CurrentWidget as DockableWidget).Title;
                }
            }

            //TextExtents te = cr.TextExtents(txt);

            cr.MoveTo(4,20);
            cr.ShowText(txt);

            cr.Restore ();

            cr=null;
        }
Beispiel #8
0
        private void ScribbleDrawn(object o, DrawnArgs args)
        {
            Cairo.Context cr = args.Cr;

            cr.SetSourceSurface (surface, 0, 0);
            cr.Paint ();
        }
Beispiel #9
0
        private void CheckerboardDrawn(object o, DrawnArgs args)
        {
            const int CheckSize = 10;
            const int Spacing = 2;

            Widget widget = o as Widget;
            Cairo.Context cr = args.Cr;

            int i, j, xcount, ycount;

            // At the start of a draw handler, a clip region has been set on
            // the Cairo context, and the contents have been cleared to the
            // widget's background color.

            Rectangle alloc = widget.Allocation;
            // Start redrawing the Checkerboard
            xcount = 0;
            i = Spacing;
            while (i < alloc.Width) {
                j = Spacing;
                ycount = xcount % 2; // start with even/odd depending on row
                while (j < alloc.Height) {
                    if (ycount % 2 != 0)
                        cr.SetSourceRGB (0.45777, 0, 0.45777);
                    else
                        cr.SetSourceRGB (1, 1, 1);
                    // If we're outside the clip, this will do nothing.
                    cr.Rectangle (i, j, CheckSize, CheckSize);
                    cr.Fill ();

                    j += CheckSize + Spacing;
                    ++ycount;
                }
                i += CheckSize + Spacing;
                ++xcount;
            }

            // return true because we've handled this event, so no
            // further processing is required.
            args.RetVal = true;
        }
Beispiel #10
0
        private void OnCubanoToolbarExposeEvent(object o, DrawnArgs args)
        {
            Toolbar toolbar = (Toolbar)o;

            // This forces the toolbar to look like it's just a regular part
            // of the window since the stock toolbar look makes Banshee look ugly.
            RenderBackground (args.Cr);

            // Manually expose all the toolbar's children
            foreach (Widget child in toolbar.Children) {
                toolbar.PropagateDraw (child, args.Cr);
            }
        }