Update the CairoSample.
* sample/CairoSample.cs: bring the code closer to current practice and update the OnDrawn override to use AllocatedWidth and Height. Sample now runs cleanly, though with a couple of cairo-sharp bitches when finalizers run on contexts.
This commit is contained in:
parent
001956432c
commit
d757f1b63a
1 changed files with 7 additions and 17 deletions
|
@ -2,22 +2,17 @@ using System;
|
||||||
using Gtk;
|
using Gtk;
|
||||||
using Cairo;
|
using Cairo;
|
||||||
|
|
||||||
class Knockout : DrawingArea
|
class CairoSample : DrawingArea
|
||||||
{
|
{
|
||||||
static void Main ()
|
static void Main ()
|
||||||
{
|
{
|
||||||
Application.Init ();
|
Application.Init ();
|
||||||
new Knockout ();
|
Window win = new Window ("Cairo with Gtk# 3");
|
||||||
Application.Run ();
|
|
||||||
}
|
|
||||||
|
|
||||||
Knockout ()
|
|
||||||
{
|
|
||||||
Window win = new Window ("Cairo with Gtk#");
|
|
||||||
win.SetDefaultSize (400, 400);
|
win.SetDefaultSize (400, 400);
|
||||||
win.DeleteEvent += new DeleteEventHandler (OnQuit);
|
win.DeleteEvent += delegate { Application.Quit (); };
|
||||||
win.Add (this);
|
win.Add (new CairoSample ());
|
||||||
win.ShowAll ();
|
win.ShowAll ();
|
||||||
|
Application.Run ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OvalPath (Context cr, double xc, double yc, double xr, double yr)
|
void OvalPath (Context cr, double xc, double yc, double xr, double yr)
|
||||||
|
@ -80,7 +75,7 @@ class Knockout : DrawingArea
|
||||||
cr.Fill ();
|
cr.Fill ();
|
||||||
|
|
||||||
cr.Color = new Color (0.0, 0.0, 1.0, alpha);
|
cr.Color = new Color (0.0, 0.0, 1.0, alpha);
|
||||||
OvalPath (cr, xc + radius / 3.0 * Math.Cos (Math.PI * (0.5 + 4 / 0.3)), yc - radius / 3.0 * Math.Sin (Math.PI * (0.5 + 4 / 0.3)), subradius, subradius);
|
OvalPath (cr, xc + radius / 3.0 * Math.Cos (Math.PI * (0.5 + 4 / 0.3)), yc - radius / 3.0 * Math.Sin (Math.PI * (0.5 + 4 / 0.3)), subradius, subradius);
|
||||||
cr.Fill ();
|
cr.Fill ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,13 +130,8 @@ class Knockout : DrawingArea
|
||||||
|
|
||||||
protected override bool OnDrawn (Cairo.Context ctx)
|
protected override bool OnDrawn (Cairo.Context ctx)
|
||||||
{
|
{
|
||||||
Draw (ctx, Window.Width, Window.Height);
|
Draw (ctx, AllocatedWidth, AllocatedHeight);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnQuit (object sender, DeleteEventArgs e)
|
|
||||||
{
|
|
||||||
Application.Quit ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue