All pastes #49206 Raw Edit

MacSlow

public text v1 · immutable
#49206 ·published 2006-04-12 19:36 UTC
rendered paste body
public class CairoARGBDemo{	static Gtk.Window m_window;	static void Main ()	{		Gtk.Application.Init ();		m_window = new Gtk.Window ("Cairo ARGB Demo");		Gdk.Screen screen = m_window.Screen;		Gdk.Colormap colormap = screen.RgbaColormap;		if (colormap == null)			colormap = screen.RgbColormap;		m_window.Colormap = colormap;		m_window.Decorated = false;		m_window.AppPaintable = true;		m_window.Events |= 	Gdk.EventMask.ButtonPressMask;		m_window.KeyPressEvent += on_key_press;		m_window.ButtonPressEvent += on_button_press;		m_window.ExposeEvent += on_expose;		m_window.ConfigureEvent += on_configure;		m_window.Resize (500,500);		m_window.ShowAll ();		Gtk.Application.Run ();	}	static void on_key_press (object obj, Gtk.KeyPressEventArgs e)	{		switch (e.Event.Key)		{			case Gdk.Key.q :			case Gdk.Key.Escape :				Gtk.Application.Quit ();			break;		}		e.RetVal = true;	}	static void on_button_press (object obj, Gtk.ButtonPressEventArgs e)	{		if (e.Event.Button == 1)		{			m_window.BeginMoveDrag (1,									(int) e.Event.XRoot,									(int) e.Event.YRoot,									e.Event.Time);		}		// this doesn't work for some reason		if (e.Event.Button == 2)		{			m_window.BeginResizeDrag (Gdk.WindowEdge.NorthWest,									  2,									  (int) e.Event.XRoot,									  (int) e.Event.YRoot,									  e.Event.Time);		}		e.RetVal = false;	}	static void render (Cairo.Context cr, int iWidth, int iHeight)	{		cr.Scale (iWidth, iHeight);		cr.Color = new Cairo.Color (1.0, 1.0, 1.0, 0.0);		cr.Operator = Cairo.Operator.Source;		cr.Paint ();		cr.Color = new Cairo.Color (1.0, 0.0, 0.0, 0.75);		cr.LineWidth = 0.1;		cr.MoveTo (0.15f, 0.15f);		cr.LineTo (0.85f, 0.85f);		cr.MoveTo (0.85f, 0.15f);		cr.LineTo (0.15f, 0.85f);		cr.Stroke ();		cr.Arc (0.5, 0.5, 0.45, 0.0, 3.141592653/180.0 * 360.0);		cr.Stroke ();	}	static void on_expose (object obj, Gtk.ExposeEventArgs e)	{		Gdk.Window window = e.Event.Window;		Cairo.Context cr = Gdk.CairoHelper.Create (window);		int iX;		int iY;		int iWidth;		int iHeight;		int iDepth;		window.GetGeometry (out iX, out iY, out iWidth, out iHeight, out iDepth);		render (cr, iWidth, iHeight);		e.RetVal = true;	}	[GLib.ConnectBefore]	static void on_configure (object obj, Gtk.ConfigureEventArgs e)	{	}}