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));
             }
         }
     }
 }
Example #2
0
        private void ShapeWindow()
        {
            Layout();
            Gdk.Pixmap bitmap = new Gdk.Pixmap(GdkWindow,
                                               Allocation.Width,
                                               Allocation.Height, 1);

            Context g = CairoHelper.Create(bitmap);

            DrawShape(g, Allocation.Width, Allocation.Height);

            ((IDisposable)g).Dispose();

            if (use_shape_ext)
            {
                ShapeCombineMask(bitmap, 0, 0);
            }
            else
            {
                Cairo.Context rgba = CairoHelper.Create(GdkWindow);
                DrawShape(rgba, Allocation.Width, Allocation.Height);
                ((IDisposable)rgba).Dispose();
                try {
                    CompositeUtils.InputShapeCombineMask(this, bitmap, 0, 0);
                } catch (EntryPointNotFoundException) {
                    Log.Warning("gtk+ version doesn't support input shapping");
                }
            }
            bitmap.Dispose();
        }
Example #3
0
    //called for cleaning the graph of a event done before than the current
    public static void ClearDrawingArea(Gtk.DrawingArea da, Gdk.Pixmap px)
    {
        if (px == null)
        {
            px = new Gdk.Pixmap(da.GdkWindow, da.Allocation.Width, da.Allocation.Height, -1);
        }

        UtilGtk.ErasePaint(da, px);
    }
Example #4
0
 void AllocateWindowBuffer(Rectangle allocation)
 {
     DisposeBgBuffer();
     if (this.IsRealized)
     {
         buffer     = new Gdk.Pixmap(this.GdkWindow, allocation.Width, allocation.Height);
         flipBuffer = new Gdk.Pixmap(this.GdkWindow, allocation.Width, allocation.Height);
     }
 }
Example #5
0
        ///<summary>
        /// Get the pixmap with the specified id.
        /// Returns null if the pixmap doesn't exist
        ///</summary>
        public Gdk.Pixmap GetPixmap(string id)
        {
            Gdk.Pixmap pix = null;
            if (pixmaps.ContainsKey(id))
            {
                pix = pixmaps[id];
            }

            return(pix);
        }
Example #6
0
        public static void Init()
        {
            // we initialize this here so that other classes can ask it questions immediately
            _drawThread = new Thread(new ThreadStart(Draw));
            _pixmap     = new Pixmap(Game.Window.GdkWindow, Globals.WIDTH, Globals.HEIGHT);


            _img_cloud     = new Pixbuf(typeof(Graphics).Assembly, "charfull.cloud.jpg");
            _img_tifa      = new Pixbuf(typeof(Graphics).Assembly, "charfull.tifa.jpg");
            _img_aeris     = new Pixbuf(typeof(Graphics).Assembly, "charfull.aeris.jpg");
            _img_barret    = new Pixbuf(typeof(Graphics).Assembly, "charfull.barret.jpg");
            _img_redxiii   = new Pixbuf(typeof(Graphics).Assembly, "charfull.redxiii.jpg");
            _img_yuffie    = new Pixbuf(typeof(Graphics).Assembly, "charfull.yuffie.jpg");
            _img_caitsith  = new Pixbuf(typeof(Graphics).Assembly, "charfull.caitsith.jpg");
            _img_vincent   = new Pixbuf(typeof(Graphics).Assembly, "charfull.vincent.jpg");
            _img_cid       = new Pixbuf(typeof(Graphics).Assembly, "charfull.cid.jpg");
            _img_sephiroth = new Pixbuf(typeof(Graphics).Assembly, "charfull.sephiroth.jpg");

            _img_cloud_small     = new Pixbuf(typeof(Graphics).Assembly, "charsmall.cloud.jpg");
            _img_tifa_small      = new Pixbuf(typeof(Graphics).Assembly, "charsmall.tifa.jpg");
            _img_aeris_small     = new Pixbuf(typeof(Graphics).Assembly, "charsmall.aeris.jpg");
            _img_barret_small    = new Pixbuf(typeof(Graphics).Assembly, "charsmall.barret.jpg");
            _img_redxiii_small   = new Pixbuf(typeof(Graphics).Assembly, "charsmall.redxiii.jpg");
            _img_yuffie_small    = new Pixbuf(typeof(Graphics).Assembly, "charsmall.yuffie.jpg");
            _img_caitsith_small  = new Pixbuf(typeof(Graphics).Assembly, "charsmall.caitsith.jpg");
            _img_vincent_small   = new Pixbuf(typeof(Graphics).Assembly, "charsmall.vincent.jpg");
            _img_cid_small       = new Pixbuf(typeof(Graphics).Assembly, "charsmall.cid.jpg");
            _img_sephiroth_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.sephiroth.jpg");

            _profileTable = new Dictionary <string, Pixbuf>();
            _profileTable.Add("Cloud", _img_cloud);
            _profileTable.Add("Tifa", _img_tifa);
            _profileTable.Add("Aeris", _img_aeris);
            _profileTable.Add("Barret", _img_barret);
            _profileTable.Add("RedXIII", _img_redxiii);
            _profileTable.Add("Yuffie", _img_yuffie);
            _profileTable.Add("CaitSith", _img_caitsith);
            _profileTable.Add("Vincent", _img_vincent);
            _profileTable.Add("Cid", _img_cid);
            _profileTable.Add("Sephiroth", _img_sephiroth);

            _phsTable = new Dictionary <string, Pixbuf>();
            _phsTable.Add("Cloud", _img_cloud_small);
            _phsTable.Add("Tifa", _img_tifa_small);
            _phsTable.Add("Aeris", _img_aeris_small);
            _phsTable.Add("Barret", _img_barret_small);
            _phsTable.Add("RedXIII", _img_redxiii_small);
            _phsTable.Add("Yuffie", _img_yuffie_small);
            _phsTable.Add("CaitSith", _img_caitsith_small);
            _phsTable.Add("Vincent", _img_vincent_small);
            _phsTable.Add("Cid", _img_cid_small);
            _phsTable.Add("Sephiroth", _img_sephiroth_small);
        }
Example #7
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;
		}
Example #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;
        }
Example #9
0
        public void RenderPixmapAndMask(Gdk.Pixbuf pixbuf,
                                        out Gdk.Pixmap pixmap_return, out Gdk.Pixmap mask_return,
                                        int alpha_threshold)
        {
            IntPtr pm_handle;
            IntPtr bm_handle;

            gdk_pixbuf_render_pixmap_and_mask(pixbuf.Handle, out pm_handle,
                                              out bm_handle, alpha_threshold);

            pixmap_return = new Gdk.Pixmap(pm_handle);
            mask_return   = new Gdk.Pixmap(bm_handle);
        }
Example #10
0
 void DisposeBgBuffer()
 {
     if (buffer != null)
     {
         buffer.Dispose();
         buffer = null;
     }
     if (flipBuffer != null)
     {
         flipBuffer.Dispose();
         flipBuffer = null;
     }
 }
Example #11
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));
        }
Example #12
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);
        }
Example #13
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]);
 }
Example #14
0
        /// <summary>Función encargada de responder a los cambios de
        /// tamaño del lienzo de dibujo.</summary>
        /// <param name="o"></param>
        /// <param name="args"></param>

        private void OnConfigureEvent(object o, ConfigureEventArgs args)
        {
            lock (this)
            {
                // TODO ver de donde sacamos window ahora
                Gdk.EventConfigure ev = args.Event;
                this.window = ev.Window;

                pixmap = new Pixmap(window, ev.Width, ev.Height, -1);
                _ancho = ev.Width;
                _alto  = ev.Height;
                this.Clean();
                if (rdd != null)
                {
                    rdd.ActualizarTodo();
                }
                SignalArgs sa = (SignalArgs)args;
                sa.RetVal = true;
            }
        }
Example #15
0
        /// <summary>
        /// Renders cell on provided space
        /// </summary>
        /// <param name="window">
        /// Drawable <see cref="Gdk.Drawable"/>
        /// </param>
        /// <param name="widget">
        /// Widget <see cref="Widget"/>
        /// </param>
        /// <param name="background_area">
        /// Area for background <see cref="Gdk.Rectangle"/>
        /// </param>
        /// <param name="cell_area">
        /// Cell area <see cref="Gdk.Rectangle"/>
        /// </param>
        /// <param name="expose_area">
        /// Expose area <see cref="Gdk.Rectangle"/>
        /// </param>
        /// <param name="aFlags">
        /// State flags <see cref="CellRendererState"/>
        /// </param>
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area,
                                       Gdk.Rectangle cell_area, Gdk.Rectangle expose_area,
                                       CellRendererState aFlags)
        {
            masterWidget = widget;

            CellRectangle r = new CellRectangle(cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);

            Gdk.Drawable  buffer  = null;
            Cairo.Context context = null;
            if (DoubleBuffered == true)
            {
                buffer  = new Gdk.Pixmap(window, cell_area.Width, cell_area.Height);
                context = Gdk.CairoHelper.Create(buffer);
            }
            else
            {
                context = Gdk.CairoHelper.Create(window);
            }

            Style style = Rc.GetStyle(widget);

            r.Set(expose_area.X, expose_area.Y, expose_area.Width, expose_area.Height);
            CalculateCellAreas(r);
            if (DoubleBuffered == true)
            {
                PaintCells(buffer, context, r, aFlags);
                widget.GdkWindow.DrawDrawable(style.BlackGC, buffer, cell_area.X, cell_area.Y, cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);
                buffer.Dispose();
            }
            else
            {
                PaintCells(window, context, r, aFlags);
            }

            style.Dispose();
            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
            context      = null;
            masterWidget = null;
        }
Example #16
0
        private void CheckScratchBuffers()
        {
            if (!this._ScratchBufferAllocated)
            {
                //Allocate a pixmap to be used for draw operations
                this._ScratchRenderBuffer    = new Gdk.Pixmap(null, this._Width, this._Height, Gdk.Visual.BestDepth);
                this._ScratchDisplayBuffer   = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, this._Width, this._Height);
                this._ScratchBufferAllocated = true;

                this._ScratchPenContext = new Gdk.GC(this._ScratchRenderBuffer);

                //Todo: This should be a property
                this._SelectionColor = new Gdk.Color(0xff, 0, 0);

                this._ScratchColorMap = Gdk.Colormap.System;

                this._ScratchColorMap.AllocColor(ref this._SelectionColor, true, true);

                this._ScratchPenContext.Foreground = this._SelectionColor;
            }
        }
            private void HandleSpinChanged(object sender, EventArgs args)
            {
                Console.WriteLine(m_list.Count);
                if ((int)m_spin.Value > m_list.Count || m_spin.Value < 1)
                {
                    return;
                }
                m_face = (Face)m_list[(int)m_spin.Value - 1];
                if (m_face.TagId > 0)
                {
                    tag_entry.Text = m_face.Tag.Name;
                }
                else
                {
                    tag_entry.Text = "";
                }
                Gdk.Pixmap bitmap = new Gdk.Pixmap(GdkWindow,
                                                   m_face.Rect.Width,
                                                   m_face.Rect.Height, 1);

                //Console.WriteLine(m_fac.X + " " + m_rect.Y + " " + m_rect.Width + " " + m_rect.Height);
            }
Example #18
0
        ///<summary>
        /// Wrapper around create to avoid creating pixmaps we already have
        ///</summary>
        private Gdk.Pixmap CreateWrapper(Drawer.Color fg, Drawer.Color bg)
        {
            string id = PixmapManager.Instance.GetPixmapId(this.GetType(), info, fg.GdkColor, bg.GdkColor);

            Gdk.Pixmap pix = PixmapManager.Instance.GetPixmap(id);
            if (pix == null)
            {
                pix = Create(fg.GdkColor, bg.GdkColor);         // can be null for DummyDrawer
                if (pix != null)
                {
                    PixmapManager.Instance.AddPixmap(id, pix);
                    PixmapManager.Instance.ReferencePixmap(id);
                    pixmapIds.Add(id);
                }
            }
            else
            {
                PixmapManager.Instance.ReferencePixmap(id);
                pixmapIds.Add(id);
            }

            return(pix);
        }
Example #19
0
        public static Gdk.Pixmap CreateFromXpm(Gdk.Drawable drawable,
                                               out Gdk.Pixmap mask, Gdk.Color transparent_color, string filename)
        {
            IntPtr mask_handle;
            IntPtr raw_ret = gdk_pixmap_create_from_xpm(drawable.Handle,
                                                        out mask_handle, ref transparent_color, filename);

            Gdk.Pixmap ret;
            if (raw_ret == IntPtr.Zero)
            {
                ret = null;
            }
            else
            {
                ret = new Gdk.Pixmap(raw_ret);
            }
//				ret = (Gdk.Pixmpa) GLib.Object.GetObject(raw_ret);

//			GLib.Object obj = GLib.Object.GetObject(mask_handle);
//			Debug.PrintLine(obj);
            mask = new Gdk.Pixmap(mask_handle);

            return(ret);
        }
Example #20
0
		void SetInputMask (Gdk.Rectangle area)
		{
			if (!IsRealized || current_mask_area == area)
				return;

			current_mask_area = area;
			if (area.Width == 0 || area.Height == 0) {
				InputShapeCombineMask (null, 0, 0);
				return;
			}

			using (Gdk.Pixmap pixmap = new Gdk.Pixmap (null, area.Width, area.Height, 1)) {
				using (Cairo.Context cr = Gdk.CairoHelper.Create (pixmap)) {
					cr.Color = new Cairo.Color (0, 0, 0, 1);
					cr.Paint ();
					
					InputShapeCombineMask (pixmap, area.X, area.Y);
					(cr.Target as IDisposable).Dispose ();
				}
			}
		}
	private void HandleSpinChanged (object sender, EventArgs args) {
				
				Console.WriteLine(m_list.Count);
				if((int)m_spin.Value > m_list.Count || m_spin.Value<1)
					return;
				m_face = (Face)m_list[(int)m_spin.Value-1];
				if(m_face.TagId>0)
					tag_entry.Text = m_face.Tag.Name;
				else tag_entry.Text = "";
				Gdk.Pixmap bitmap = new Gdk.Pixmap (GdkWindow, 
							    m_face.Rect.Width, 
							    m_face.Rect.Height, 1);
				
				//Console.WriteLine(m_fac.X + " " + m_rect.Y + " " + m_rect.Width + " " + m_rect.Height);
	}
Example #22
0
        ///<summary>Draws the a byte</summary>

        abstract protected void Draw(Gdk.GC gc, Gdk.Drawable dest, int x, int y, byte b, Gdk.Pixmap pix);
Example #23
0
    public void on_event_execute_drawingarea_expose_event(object o, ExposeEventArgs args)
    {
        /* in some mono installations, configure_event is not called, but expose_event yes.
         * Do here the initialization
         */

        Gdk.Rectangle allocation = event_execute_drawingarea.Allocation;
        if(event_execute_pixmap == null || sizeChanged || allocation.Width != allocationXOld) {
            event_execute_pixmap = new Gdk.Pixmap (event_execute_drawingarea.GdkWindow, allocation.Width, allocation.Height, -1);
            event_execute_erasePaint(event_execute_drawingarea);

            sizeChanged = false;
        }

        Gdk.Rectangle area = args.Event.Area;

        //sometimes this is called when pait is finished
        //don't let this erase win
        if(event_execute_pixmap != null) {
            args.Event.Window.DrawDrawable(event_execute_drawingarea.Style.WhiteGC, event_execute_pixmap,
                area.X, area.Y,
                area.X, area.Y,
                area.Width, area.Height);
        }

        allocationXOld = allocation.Width;
    }
Example #24
0
    /*
    private void eventExecuteCreateComboGraphResultsSize() {
        combo_graph_results_width = ComboBox.NewText ();
        UtilGtk.ComboUpdate(combo_graph_results_width, comboGraphResultsSize, "");
        combo_graph_results_width.Active=2; //300

        hbox_combo_graph_results_width.PackStart(combo_graph_results_width, true, true, 0);
        hbox_combo_graph_results_width.ShowAll();
        combo_graph_results_width.Sensitive = true;

        combo_graph_results_width.Changed += new EventHandler (on_combo_graph_results_changed);

        combo_graph_results_height = ComboBox.NewText ();
        UtilGtk.ComboUpdate(combo_graph_results_height, comboGraphResultsSize, "");
        combo_graph_results_height.Active=1; //200

        hbox_combo_graph_results_height.PackStart(combo_graph_results_height, true, true, 0);
        hbox_combo_graph_results_height.ShowAll();
        combo_graph_results_height.Sensitive = true;

        combo_graph_results_height.Changed += new EventHandler (on_combo_graph_results_changed);
    }
    */
    /*
    private void on_combo_graph_results_changed(object o, EventArgs args) {
        //event_execute_drawingarea.Size(
        event_execute_alignment_drawingarea.SetSizeRequest(
                Convert.ToInt32(UtilGtk.ComboGetActive(combo_graph_results_width)),
                Convert.ToInt32(UtilGtk.ComboGetActive(combo_graph_results_height)));
        sizeChanged = true;
    }
    */
    //called for cleaning the graph of a event done before than the current
    private void event_execute_clearDrawingArea()
    {
        if(event_execute_pixmap == null)
            event_execute_pixmap = new Gdk.Pixmap (event_execute_drawingarea.GdkWindow, event_execute_drawingarea.Allocation.Width, event_execute_drawingarea.Allocation.Height, -1);

        event_execute_erasePaint(event_execute_drawingarea);
    }
Example #25
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;
        }
Example #26
0
 ///<summary>
 /// Add the pixmap to the collection
 ///</summary>
 public void AddPixmap(string id, Gdk.Pixmap pix)
 {
     pixmaps[id]    = pix;
     references[id] = 0;
 }
Example #27
0
        private void RenderBubbles(Gdk.Window win, Gdk.Rectangle size,
                                   out Pixbuf pbactive, out Pixbuf pbinactive,
                                   out Gdk.Pixmap pbpm)
        {
            int pmHeight, pmWidth;

            Gdk.Pixmap daPixmap;
            Gdk.Pixmap daOtherPixmap;

            pmHeight = size.Height - (wbsize * 2);
            pmWidth  = size.Width - (wbsize * 2);

            Gdk.GC gc = new Gdk.GC(win);

            // Build active Pixbuf
//			Gdk.Pixmap pm = new Pixmap(win, pmWidth, pmHeight, -1);
            Gdk.Pixmap pm = new Pixmap(win, size.Width, size.Height, -1);

            // Paint the background white
            gc.RgbFgColor = new Gdk.Color(255, 255, 255);
            pm.DrawRectangle(gc, true, 0, 0, size.Width, size.Height);

            /***********************************
            *       draw painted oval window
            ***********************************/
            // Paint the inside of the window
            gc.RgbFgColor = new Gdk.Color(249, 253, 202);
            Gdk.Point[] roundedSquare = CalculateRect(wbsize, wbsize,
                                                      pmWidth, pmHeight);
            pm.DrawPolygon(gc, true, roundedSquare);

            // Paint the border of the window
            Gdk.Point[] roundedborder = CalculateRect(wbsize, wbsize,
                                                      pmWidth - 1, pmHeight - 1);
            gc.RgbFgColor = new Gdk.Color(0, 0, 0);
            pm.DrawPolygon(gc, false, roundedborder);

            /***********************************
            *       add tab to bitmap
            ***********************************/
            Gdk.Point[] balloonptr = CalcPointerMoveWindow(size.Width,
                                                           size.Height);
            // Draw colored pointer
            gc.RgbFgColor = new Gdk.Color(249, 253, 202);
            pm.DrawPolygon(gc, true, balloonptr);
            gc.RgbFgColor = new Gdk.Color(0, 0, 0);
            // subtract one because the fill above used and extra line
            pm.DrawLine(gc, balloonptr[0].X, balloonptr[0].Y - 1, balloonptr[1].X,
                        balloonptr[1].Y);
            pm.DrawLine(gc, balloonptr[1].X, balloonptr[1].Y, balloonptr[2].X,
                        balloonptr[2].Y - 1);

            Gdk.Pixbuf pb = new Pixbuf(Gdk.Colorspace.Rgb, false,
                                       8, size.Width, size.Height);

            pb = Pixbuf.FromDrawable(pm, pm.Colormap, 0, 0, 0, 0,
                                     size.Width, size.Height);
            pb = pb.AddAlpha(true, 255, 255, 255);

            RenderPixmapAndMask(pb, out daPixmap, out daOtherPixmap, 2);
            pbactive = pb;
            pbpm     = daOtherPixmap;

            // Reset backgound to white and get next bitmap
            gc.RgbFgColor = new Gdk.Color(255, 255, 255);
            pm.DrawRectangle(gc, true, 0, 0, size.Width, size.Height);

            // Paint the border of the window
            gc.RgbFgColor = new Gdk.Color(0, 0, 0);
            pm.DrawPolygon(gc, false, roundedborder);

            // Draw white pointer
            gc.RgbFgColor = new Gdk.Color(255, 255, 255);
            pm.DrawPolygon(gc, true, balloonptr);
            gc.RgbFgColor = new Gdk.Color(0, 0, 0);
            // subtract one because the fill above used and extra line
            pm.DrawLine(gc, balloonptr[0].X, balloonptr[0].Y - 1, balloonptr[1].X,
                        balloonptr[1].Y);
            pm.DrawLine(gc, balloonptr[1].X, balloonptr[1].Y, balloonptr[2].X,
                        balloonptr[2].Y - 1);

            pb = Pixbuf.FromDrawable(pm,
                                     pm.Colormap, 0, 0, 0, 0, size.Width, size.Height);

            pbinactive = pb;
        }
Example #28
0
        public static void Init()
        {
            // we initialize this here so that other classes can ask it questions immediately
            _drawThread = new Thread(new ThreadStart(Draw));
            _pixmap = new Pixmap(Game.Window.GdkWindow, Globals.WIDTH, Globals.HEIGHT);

            _img_cloud = new Pixbuf(typeof(Graphics).Assembly, "charfull.cloud.jpg");
            _img_tifa = new Pixbuf(typeof(Graphics).Assembly, "charfull.tifa.jpg");
            _img_aeris = new Pixbuf(typeof(Graphics).Assembly, "charfull.aeris.jpg");
            _img_barret = new Pixbuf(typeof(Graphics).Assembly, "charfull.barret.jpg");
            _img_redxiii = new Pixbuf(typeof(Graphics).Assembly, "charfull.redxiii.jpg");
            _img_yuffie = new Pixbuf(typeof(Graphics).Assembly, "charfull.yuffie.jpg");
            _img_caitsith = new Pixbuf(typeof(Graphics).Assembly, "charfull.caitsith.jpg");
            _img_vincent = new Pixbuf(typeof(Graphics).Assembly, "charfull.vincent.jpg");
            _img_cid = new Pixbuf(typeof(Graphics).Assembly, "charfull.cid.jpg");
            _img_sephiroth = new Pixbuf(typeof(Graphics).Assembly, "charfull.sephiroth.jpg");

            _img_cloud_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.cloud.jpg");
            _img_tifa_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.tifa.jpg");
            _img_aeris_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.aeris.jpg");
            _img_barret_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.barret.jpg");
            _img_redxiii_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.redxiii.jpg");
            _img_yuffie_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.yuffie.jpg");
            _img_caitsith_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.caitsith.jpg");
            _img_vincent_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.vincent.jpg");
            _img_cid_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.cid.jpg");
            _img_sephiroth_small = new Pixbuf(typeof(Graphics).Assembly, "charsmall.sephiroth.jpg");

            _profileTable = new Dictionary<string, Pixbuf>();
            _profileTable.Add("Cloud", _img_cloud);
            _profileTable.Add("Tifa", _img_tifa);
            _profileTable.Add("Aeris", _img_aeris);
            _profileTable.Add("Barret", _img_barret);
            _profileTable.Add("RedXIII", _img_redxiii);
            _profileTable.Add("Yuffie", _img_yuffie);
            _profileTable.Add("CaitSith", _img_caitsith);
            _profileTable.Add("Vincent", _img_vincent);
            _profileTable.Add("Cid", _img_cid);
            _profileTable.Add("Sephiroth", _img_sephiroth);

            _phsTable = new Dictionary<string, Pixbuf>();
            _phsTable.Add("Cloud", _img_cloud_small);
            _phsTable.Add("Tifa", _img_tifa_small);
            _phsTable.Add("Aeris", _img_aeris_small);
            _phsTable.Add("Barret", _img_barret_small);
            _phsTable.Add("RedXIII", _img_redxiii_small);
            _phsTable.Add("Yuffie", _img_yuffie_small);
            _phsTable.Add("CaitSith", _img_caitsith_small);
            _phsTable.Add("Vincent", _img_vincent_small);
            _phsTable.Add("Cid", _img_cid_small);
            _phsTable.Add("Sephiroth", _img_sephiroth_small);
        }
Example #29
0
        private void UpdatePixbuf()
        {
            if (base.Image == null)
            {
                return;
            }

            if (notifyCount > 0)
            {
                if (base.Image.ParentWindow == null)
                {
                    return;
                }

                Gdk.Window win = Image.ParentWindow;

                Pixmap image;

                image = new Gdk.Pixmap(win, 18, 18);

                if (image == null)
                {
                    return;
                }

                int wide, high;

                image.GetSize(out wide, out high);

                Cairo.Context cc = CairoHelper.CreateCairoDrawable(image);
                //Cairo.Context cc = new Cairo.Context(surface);

                cc.Save();
//				cc.PaintWithAlpha(1.0);
                cc.Rectangle(0, 0, wide, high);
                cc.SetSourceRGBA(1.0, 1.0, 1.0, 1.0);
                //cc.FillPreserve();
                cc.Fill();
                cc.Restore();
                cc.Stroke();

                cc.Save();
//				cc.LineWidth = 0.01;
                cc.Arc(((double)wide) / 2.0, ((double)high) / 2.0, (((double)wide) / 2.0), 0.0, 2.0 * 3.14);
                if (notifyCount < 10)                 // yellow
                {
                    cc.SetSourceRGBA(0.99, 0.91, 0.31, 1.0);
                }
                else if (notifyCount < 25)                // orange
                {
                    cc.SetSourceRGBA(0.99, 0.69, 0.24, 1.0);
                }
                else                 // red
                {
                    cc.SetSourceRGBA(0.94, 0.16, 0.16, 1.0);
                }
//				cc.FillPreserve();
                cc.Fill();
                cc.Restore();
                cc.Stroke();

                string badgeString = String.Format("{0}", notifyCount);
                cc.Save();
                cc.SetSourceRGBA(0.0, 0.0, 0.0, 1.0);
                cc.FontFace("sans", FontSlant.Normal, FontWeight.Bold);
                cc.FontSize = 12;
                Cairo.TextExtents extents = cc.TextExtents(badgeString);
                double            xpos, ypos;
                xpos = ((double)wide) / 2.0 - extents.Width / 2.0;
                ypos = (((double)high) / 2.0) + (extents.Height / 2.0) - 0.5;
                cc.MoveTo(xpos, ypos);
                cc.ShowText(badgeString);
                cc.Restore();
                cc.Stroke();

                Pixbuf dp = Gdk.Pixbuf.FromDrawable(image, image.Colormap, 0, 0, 0, 0, 18, 18);

                // Create the composite image
                Colorspace colorspace    = originalPixbuf.Colorspace;
                bool       hasAlpha      = originalPixbuf.HasAlpha;
                int        bitsPerSample = originalPixbuf.BitsPerSample;
                newPixbuf = new Pixbuf(colorspace,
                                       true,
                                       bitsPerSample,
                                       originalPixbuf.Width,
                                       originalPixbuf.Height);

                originalPixbuf.CopyArea(0, 0, originalPixbuf.Width, originalPixbuf.Height, newPixbuf, 0, 0);
                dp.CopyArea(0, 0, dp.Width, dp.Height, newPixbuf, originalPixbuf.Width - dp.Width, 0);

                ((Gtk.Image)base.Image).Pixbuf = newPixbuf;
            }
            else
            {
                if (((Gtk.Image)base.Image).Pixbuf != originalPixbuf)
                {
                    ((Gtk.Image)base.Image).Pixbuf = originalPixbuf;
                }
            }
            imageNeedsUpdating = false;
        }
Example #30
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];
 }
Example #31
0
    public void on_encoder_capture_signal_drawingarea_expose_event(object o, ExposeEventArgs args)
    {
        /* in some mono installations, configure_event is not called, but expose_event yes.
         * Do here the initialization
         */
        //LogB.Debug("EXPOSE");

        Gdk.Rectangle allocation = encoder_capture_signal_drawingarea.Allocation;
        if(encoder_capture_signal_pixmap == null || encoder_capture_signal_sizeChanged ||
                allocation.Width != encoder_capture_signal_allocationXOld) {
            encoder_capture_signal_pixmap = new Gdk.Pixmap (encoder_capture_signal_drawingarea.GdkWindow,
                    allocation.Width, allocation.Height, -1);

            if(eCapture != null && capturingCsharp == encoderCaptureProcess.CAPTURING)
                eCapture.EncoderCapturePointsPainted = -1; //mark meaning screen should be erased and start painting from the beginning
            else
                UtilGtk.ErasePaint(encoder_capture_signal_drawingarea, encoder_capture_signal_pixmap);

            encoder_capture_signal_sizeChanged = false;
        }

        Gdk.Rectangle area = args.Event.Area;

        //sometimes this is called when pait is finished
        //don't let this erase win
        if(encoder_capture_signal_pixmap != null) {
            args.Event.Window.DrawDrawable(encoder_capture_signal_drawingarea.Style.WhiteGC, encoder_capture_signal_pixmap,
                area.X, area.Y,
                area.X, area.Y,
                area.Width, area.Height);
        }

        encoder_capture_signal_allocationXOld = allocation.Width;
    }
Example #32
0
 void DoFlipBuffer()
 {
     Gdk.Pixmap tmp = buffer;
     buffer     = flipBuffer;
     flipBuffer = tmp;
 }
		void AllocateWindowBuffer (Rectangle allocation)
		{
			DisposeBgBuffer ();
			if (this.IsRealized) {
				buffer = new Gdk.Pixmap (this.GdkWindow, allocation.Width, allocation.Height);
				flipBuffer = new Gdk.Pixmap (this.GdkWindow, allocation.Width, allocation.Height);
			}
		}
Example #34
0
    //called for cleaning the graph of a event done before than the current
    public static void ClearDrawingArea(Gtk.DrawingArea da, Gdk.Pixmap px)
    {
        if(px == null)
            px = new Gdk.Pixmap (da.GdkWindow, da.Allocation.Width, da.Allocation.Height, -1);

        UtilGtk.ErasePaint(da, px);
    }
Example #35
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
    }
Example #36
0
    public void on_event_execute_drawingarea_configure_event(object o, ConfigureEventArgs args)
    {
        Gdk.EventConfigure ev = args.Event;
        Gdk.Window window = ev.Window;

        Gdk.Rectangle allocation = event_execute_drawingarea.Allocation;

        if(event_execute_pixmap == null || sizeChanged || allocation.Width != allocationXOld) {
            event_execute_pixmap = new Gdk.Pixmap (window, allocation.Width, allocation.Height, -1);

            event_execute_erasePaint(event_execute_drawingarea);

            sizeChanged = false;
        }

        allocationXOld = allocation.Width;
    }
		void DisposeBgBuffer ()
		{
			if (buffer != null) {
				buffer.Dispose ();
				buffer = null;
			}
			if (flipBuffer !=  null) {
				flipBuffer.Dispose ();
				flipBuffer = null;
			}
		}
		void DoFlipBuffer ()
		{
			Gdk.Pixmap tmp = buffer;
			buffer = flipBuffer;
			flipBuffer = tmp;
		}
Example #39
0
        private void UpdatePixbuf()
        {
            if(base.Image == null)
                return;

            if(notifyCount > 0) {
                if(base.Image.ParentWindow == null)
                    return;

                Gdk.Window win = Image.ParentWindow;

                Pixmap image;

                image = new Gdk.Pixmap(win, 18, 18);

                if (image == null)
                    return;

                int wide, high;

                image.GetSize(out wide, out high);

                Cairo.Context cc = CairoHelper.CreateCairoDrawable(image);
                //Cairo.Context cc = new Cairo.Context(surface);

                cc.Save();
            //				cc.PaintWithAlpha(1.0);
                cc.Rectangle(0, 0, wide, high);
                cc.SetSourceRGBA(1.0, 1.0, 1.0, 1.0);
                //cc.FillPreserve();
                cc.Fill();
                cc.Restore();
                cc.Stroke();

                cc.Save();
            //				cc.LineWidth = 0.01;
                cc.Arc( ((double)wide)/2.0, ((double)high)/2.0, (((double)wide) / 2.0), 0.0, 2.0 * 3.14);
                if(notifyCount < 10)  // yellow
                    cc.SetSourceRGBA(0.99, 0.91, 0.31, 1.0);
                else if(notifyCount < 25) // orange
                    cc.SetSourceRGBA(0.99, 0.69, 0.24, 1.0);
                else // red
                    cc.SetSourceRGBA(0.94, 0.16, 0.16, 1.0);
            //				cc.FillPreserve();
                cc.Fill();
                cc.Restore();
                cc.Stroke();

                string badgeString = String.Format("{0}", notifyCount);
                cc.Save();
                cc.SetSourceRGBA(0.0, 0.0, 0.0, 1.0);
                cc.FontFace("sans", FontSlant.Normal, FontWeight.Bold);
                cc.FontSize = 12;
                Cairo.TextExtents extents = cc.TextExtents(badgeString);
                double xpos, ypos;
                xpos = ((double)wide)/2.0 - extents.Width/2.0;
                ypos = (((double)high)/2.0) + (extents.Height/2.0) - 0.5;
                cc.MoveTo(xpos, ypos);
                cc.ShowText(badgeString);
                cc.Restore();
                cc.Stroke();

                Pixbuf dp = Gdk.Pixbuf.FromDrawable(image, image.Colormap, 0, 0, 0, 0, 18, 18);

                // Create the composite image
                Colorspace colorspace = originalPixbuf.Colorspace;
                bool hasAlpha           = originalPixbuf.HasAlpha;
                int bitsPerSample     = originalPixbuf.BitsPerSample;
                newPixbuf		      = new Pixbuf (colorspace,
                                                    true,
                                                    bitsPerSample,
                                                    originalPixbuf.Width,
                                                    originalPixbuf.Height);

                originalPixbuf.CopyArea(0, 0, originalPixbuf.Width, originalPixbuf.Height, newPixbuf, 0, 0);
                dp.CopyArea(0, 0, dp.Width, dp.Height, newPixbuf, originalPixbuf.Width - dp.Width, 0);

                ( (Gtk.Image)base.Image).Pixbuf = newPixbuf;
            } else {
                if( ((Gtk.Image)base.Image).Pixbuf != originalPixbuf) {
                    ((Gtk.Image)base.Image).Pixbuf = originalPixbuf;
                }
            }
            imageNeedsUpdating = false;
        }
Example #40
0
 protected override void Draw(Gdk.GC gc, Gdk.Drawable dest, int x, int y, byte b, Gdk.Pixmap pix)
 {
 }
Example #41
0
      public static Gdk.Pixmap CreateFromXpm(Gdk.Drawable drawable,
 out Gdk.Pixmap mask, Gdk.Color transparent_color, string filename)
      {
          IntPtr mask_handle;
             IntPtr raw_ret = gdk_pixmap_create_from_xpm(drawable.Handle,
          out mask_handle, ref transparent_color, filename);
             Gdk.Pixmap ret;
             if (raw_ret == IntPtr.Zero)
          ret = null;
             else
          ret = new Gdk.Pixmap(raw_ret);
             mask = new Gdk.Pixmap(mask_handle);
             return ret;
      }
Example #42
0
    public void on_encoder_capture_curves_bars_drawingarea_configure_event(object o, ConfigureEventArgs args)
    {
        Gdk.EventConfigure ev = args.Event;
        Gdk.Window window = ev.Window;

        Gdk.Rectangle allocation = encoder_capture_curves_bars_drawingarea.Allocation;

        if(encoder_capture_curves_bars_pixmap == null || encoder_capture_curves_sizeChanged ||
                allocation.Width != encoder_capture_curves_allocationXOld ||
                allocation.Height != encoder_capture_curves_allocationYOld)
        {
            encoder_capture_curves_bars_pixmap = new Gdk.Pixmap (window, allocation.Width, allocation.Height, -1);

            callPlotCurvesGraphDoPlot();

            encoder_capture_curves_sizeChanged = false;
        }

        encoder_capture_curves_allocationXOld = allocation.Width;
        encoder_capture_curves_allocationYOld = allocation.Height;
    }
Example #43
0
        private void ShapeWindow()
        {
            Layout ();
            Gdk.Pixmap bitmap = new Gdk.Pixmap (GdkWindow,
                                Allocation.Width,
                                Allocation.Height, 1);

            #if CAIRO_1_2_5
            Context g = CairoHelper.Create (bitmap);
            #else
            Context g = CairoUtils.CreateContext (bitmap);
            #endif
            DrawShape (g, Allocation.Width, Allocation.Height);

            ((IDisposable)g).Dispose ();

            if (use_shape_ext)
                ShapeCombineMask (bitmap, 0, 0);
            else {
            #if CAIRO_1_2_5
                Cairo.Context rgba = CairoHelper.Create (GdkWindow);
            #else
                Context rgba = CairoUtils.CreateContext (GdkWindow);
            #endif
                DrawShape (rgba, Allocation.Width, Allocation.Height);
                ((IDisposable)rgba).Dispose ();
                try {
                    CompositeUtils.InputShapeCombineMask (this, bitmap, 0,0);
                } catch (EntryPointNotFoundException) {
                    System.Console.WriteLine ("Warning: gtk+ version doesn't support input shapping");
                }
            }
            bitmap.Dispose ();
        }
Example #44
0
    public void on_encoder_capture_curves_bars_drawingarea_expose_event(object o, ExposeEventArgs args)
    {
        /* in some mono installations, configure_event is not called, but expose_event yes.
         * Do here the initialization
         */
        //LogB.Debug("EXPOSE");

        Gdk.Rectangle allocation = encoder_capture_curves_bars_drawingarea.Allocation;
        if(encoder_capture_curves_bars_pixmap == null || encoder_capture_curves_sizeChanged ||
                allocation.Width != encoder_capture_curves_allocationXOld ||
                allocation.Height != encoder_capture_curves_allocationYOld)
        {
            encoder_capture_curves_bars_pixmap = new Gdk.Pixmap (
                    encoder_capture_curves_bars_drawingarea.GdkWindow, allocation.Width, allocation.Height, -1);

            callPlotCurvesGraphDoPlot();

            encoder_capture_curves_sizeChanged = false;
        }

        Gdk.Rectangle area = args.Event.Area;

        //sometimes this is called when pait is finished
        //don't let this erase win
        if(encoder_capture_curves_bars_pixmap != null) {
            args.Event.Window.DrawDrawable(encoder_capture_curves_bars_drawingarea.Style.WhiteGC,
                    encoder_capture_curves_bars_pixmap,
                area.X, area.Y,
                area.X, area.Y,
                area.Width, area.Height);
        }

        encoder_capture_curves_allocationXOld = allocation.Width;
        encoder_capture_curves_allocationYOld = allocation.Height;
    }
Example #45
0
    public void on_encoder_capture_signal_drawingarea_configure_event(object o, ConfigureEventArgs args)
    {
        Gdk.EventConfigure ev = args.Event;
        Gdk.Window window = ev.Window;

        Gdk.Rectangle allocation = encoder_capture_signal_drawingarea.Allocation;

        if(encoder_capture_signal_pixmap == null || encoder_capture_signal_sizeChanged ||
                allocation.Width != encoder_capture_signal_allocationXOld)
        {
            encoder_capture_signal_pixmap = new Gdk.Pixmap (window, allocation.Width, allocation.Height, -1);

            if(eCapture != null && capturingCsharp == encoderCaptureProcess.CAPTURING)
                eCapture.EncoderCapturePointsPainted = -1; //mark meaning screen should be erased and start painting from the beginning
            else
                UtilGtk.ErasePaint(encoder_capture_signal_drawingarea, encoder_capture_signal_pixmap);

            encoder_capture_signal_sizeChanged = false;
        }

        encoder_capture_signal_allocationXOld = allocation.Width;
    }
Example #46
0
     public void RenderPixmapAndMask(Gdk.Pixbuf pixbuf,
 out Gdk.Pixmap pixmap_return, out Gdk.Pixmap mask_return,
 int alpha_threshold)
     {
         IntPtr pm_handle;
            IntPtr bm_handle;
            gdk_pixbuf_render_pixmap_and_mask(pixbuf.Handle, out pm_handle,
          out bm_handle, alpha_threshold);
            pixmap_return = new Gdk.Pixmap(pm_handle);
            mask_return = new Gdk.Pixmap(bm_handle);
     }
 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);
             }
         }
     }
 }