public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz)
 {
     Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
     if ((res != null))
     {
         return(res);
     }
     else
     {
         try {
             return(Gtk.IconTheme.Default.LoadIcon(name, sz, 0));
         }
         catch (System.Exception) {
             if ((name != "gtk-missing-image"))
             {
                 return(Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz));
             }
             else
             {
                 Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
                 Gdk.GC     gc   = new Gdk.GC(pmap);
                 gc.RgbFgColor = new Gdk.Color(255, 255, 255);
                 pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
                 gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                 pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
                 gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
                 gc.RgbFgColor = new Gdk.Color(255, 0, 0);
                 pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
                 pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
                 return(Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz));
             }
         }
     }
 }
示例#2
0
        /// <summary>Limpia la superficie de dibujo.</summary>

        public void Clean()
        {
            lock (this)
            {
                if (pixmap != null)
                {
                    pixmap.DrawRectangle(
                        GetGC(COLOR_FONDO), true, 0, 0, Ancho, Alto);
                }
            }
        }
示例#3
0
        private static void Draw()
        {
            _drawing = true;

            Gdk.GC gc = new Gdk.GC(_pixmap);
            _pixmap.DrawRectangle(gc, true, 0, 0, Globals.WIDTH, Globals.HEIGHT);



            #region Draw Grid
            Cairo.Context g = Gdk.CairoHelper.Create(_pixmap);
            g.Color = new Cairo.Color(.8, .8, .8);
            for (int i = 1; i < 8; i++)
            {
                g.MoveTo(i * Globals.WIDTH / 8, 0);
                g.LineTo(i * Globals.WIDTH / 8, Globals.HEIGHT);
                g.Stroke();
            }
            for (int j = 1; j < 7; j++)
            {
                g.MoveTo(0, j * Globals.HEIGHT / 7);
                g.LineTo(Globals.WIDTH, j * Globals.HEIGHT / 7);
                g.Stroke();
            }
            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
            #endregion Draw Grid



            Game.State.Draw(_pixmap);

            _drawing = false;
        }
        static void DrawBrush(Widget widget, InputSource source,
                              double x, double y, double pressure)
        {
            Gdk.GC gc;
            switch (source)
            {
            case InputSource.Mouse:
                gc = widget.Style.BlackGC;
                break;

            case InputSource.Pen:
                gc = widget.Style.BlackGC;
                break;

            case InputSource.Eraser:
                gc = widget.Style.WhiteGC;
                break;

            default:
                gc = widget.Style.BlackGC;
                break;
            }

            Gdk.Rectangle update_rect = new Gdk.Rectangle();
            update_rect.X      = (int)(x - 10.0d * pressure);
            update_rect.Y      = (int)(y - 10.0d * pressure);
            update_rect.Width  = (int)(20.0d * pressure);
            update_rect.Height = (int)(20.0d * pressure);

            pixmap.DrawRectangle(gc, true,
                                 update_rect.X, update_rect.Y,
                                 update_rect.Width, update_rect.Height);
            darea.QueueDrawArea(update_rect.X, update_rect.Y,
                                update_rect.Width, update_rect.Height);
        }
示例#5
0
        // From MonoDevelop:
        // https://github.com/mono/monodevelop/blob/master/main/src/core/MonoDevelop.Ide/gtk-gui/generated.cs
        private static Pixbuf CreateMissingImage(int size)
        {
            var pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, size, size);
            var gc = new Gdk.GC (pmap);

            gc.RgbFgColor = new Gdk.Color (255, 255, 255);
            pmap.DrawRectangle (gc, true, 0, 0, size, size);
            gc.RgbFgColor = new Gdk.Color (0, 0, 0);
            pmap.DrawRectangle (gc, false, 0, 0, (size - 1), (size - 1));

            gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
            gc.RgbFgColor = new Gdk.Color (255, 0, 0);
            pmap.DrawLine (gc, (size / 4), (size / 4), ((size - 1) - (size / 4)), ((size - 1) - (size / 4)));
            pmap.DrawLine (gc, ((size - 1) - (size / 4)), (size / 4), (size / 4), ((size - 1) - (size / 4)));

            return Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, size, size);
        }
示例#6
0
        // From MonoDevelop:
        // https://github.com/mono/monodevelop/blob/master/main/src/core/MonoDevelop.Ide/gtk-gui/generated.cs
        private static Pixbuf CreateMissingImage(int size)
        {
            var pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, size, size);
            var gc   = new Gdk.GC(pmap);

            gc.RgbFgColor = new Gdk.Color(255, 255, 255);
            pmap.DrawRectangle(gc, true, 0, 0, size, size);
            gc.RgbFgColor = new Gdk.Color(0, 0, 0);
            pmap.DrawRectangle(gc, false, 0, 0, (size - 1), (size - 1));

            gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
            gc.RgbFgColor = new Gdk.Color(255, 0, 0);
            pmap.DrawLine(gc, (size / 4), (size / 4), ((size - 1) - (size / 4)), ((size - 1) - (size / 4)));
            pmap.DrawLine(gc, ((size - 1) - (size / 4)), (size / 4), (size / 4), ((size - 1) - (size / 4)));

            return(Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, size, size));
        }
示例#7
0
 /// <summary>
 /// Loads the missing icon for a given size in pixels.
 /// </summary>
 /// <returns>The missing icon. This function uses a cache internally.</returns>
 /// <param name="sz">Size in pixels.</param>
 public static Gdk.Pixbuf LoadMissingIcon(int sz)
 {
     if (!missingIcons.ContainsKey(sz))
     {
         Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
         Gdk.GC     gc   = new Gdk.GC(pmap);
         gc.RgbFgColor = new Gdk.Color(255, 255, 255);
         pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
         gc.RgbFgColor = new Gdk.Color(0, 0, 0);
         pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
         gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
         gc.RgbFgColor = new Gdk.Color(255, 0, 0);
         pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
         pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
         missingIcons [sz] = Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
     }
     return((Gdk.Pixbuf)missingIcons [sz]);
 }
示例#8
0
		static void ConfigureEvent (object obj, ConfigureEventArgs args)
		{
			Gdk.EventConfigure ev = args.Event;
			Gdk.Window window = ev.Window;
			Gdk.Rectangle allocation = darea.Allocation;

			pixmap = new Gdk.Pixmap (window, allocation.Width, allocation.Height, -1);
			pixmap.DrawRectangle (darea.Style.WhiteGC, true, 0, 0,
					      allocation.Width, allocation.Height);

			args.RetVal = true;
		}
示例#9
0
        static void ConfigureEvent(object obj, ConfigureEventArgs args)
        {
            Gdk.EventConfigure ev         = args.Event;
            Gdk.Window         window     = ev.Window;
            Gdk.Rectangle      allocation = darea.Allocation;

            pixmap = new Gdk.Pixmap(window, allocation.Width, allocation.Height, -1);
            pixmap.DrawRectangle(darea.Style.WhiteGC, true, 0, 0,
                                 allocation.Width, allocation.Height);

            args.RetVal = true;
        }
示例#10
0
        static void DrawBrush(double x, double y, bool black)
        {
            Gdk.Rectangle update_rect = new Gdk.Rectangle();
            update_rect.X      = (int)x - 5;
            update_rect.Y      = (int)y - 5;
            update_rect.Width  = 10;
            update_rect.Height = 10;

            pixmap.DrawRectangle(black ? darea.Style.BlackGC : darea.Style.WhiteGC, true,
                                 update_rect.X, update_rect.Y,
                                 update_rect.Width, update_rect.Height);
            darea.QueueDrawArea(update_rect.X, update_rect.Y,
                                update_rect.Width, update_rect.Height);
        }
示例#11
0
    /*
     *
     * DRAWINGAREA
     *
     */


    public static void ErasePaint(Gtk.DrawingArea da, Gdk.Pixmap px)
    {
        px.DrawRectangle(da.Style.WhiteGC, true, 0, 0, da.Allocation.Width, da.Allocation.Height);
        da.QueueDraw();         // -- refresh
    }
示例#12
0
文件: Misc.cs 项目: GNOME/longomatch
 /// <summary>
 /// Loads the missing icon for a given size in pixels.
 /// </summary>
 /// <returns>The missing icon. This function uses a cache internally.</returns>
 /// <param name="sz">Size in pixels.</param>
 public static Gdk.Pixbuf LoadMissingIcon(int sz)
 {
     if (!missingIcons.ContainsKey (sz)) {
         Gdk.Pixmap pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, sz, sz);
         Gdk.GC gc = new Gdk.GC (pmap);
         gc.RgbFgColor = new Gdk.Color (255, 255, 255);
         pmap.DrawRectangle (gc, true, 0, 0, sz, sz);
         gc.RgbFgColor = new Gdk.Color (0, 0, 0);
         pmap.DrawRectangle (gc, false, 0, 0, (sz - 1), (sz - 1));
         gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
         gc.RgbFgColor = new Gdk.Color (255, 0, 0);
         pmap.DrawLine (gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
         pmap.DrawLine (gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
         missingIcons [sz] = Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
     }
     return (Gdk.Pixbuf)missingIcons [sz];
 }
 public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz) {
     Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
     if ((res != null)) {
         return res;
     }
     else {
         try {
             return Gtk.IconTheme.Default.LoadIcon(name, sz, 0);
         }
         catch (System.Exception ) {
             if ((name != "gtk-missing-image")) {
                 return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz);
             }
             else {
                 Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
                 Gdk.GC gc = new Gdk.GC(pmap);
                 gc.RgbFgColor = new Gdk.Color(255, 255, 255);
                 pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
                 gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                 pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
                 gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
                 gc.RgbFgColor = new Gdk.Color(255, 0, 0);
                 pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
                 pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
                 return Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
             }
         }
     }
 }
示例#14
0
        // This events is executed when the window is resized, minimized, overlapped etc..
        protected override bool OnConfigureEvent( Gdk.EventConfigure args )
        {
            pmNote = new Gdk.Pixmap( args.Window, this.Allocation.Width, this.Allocation.Height, -1 );
            pmNote.DrawRectangle( this.Style.WhiteGC, true, 0, 0,
                  	      			      this.Allocation.Width, this.Allocation.Height );

            return true;
        }