mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-11 19:55:29 +00:00
Add some lovin'
svn path=/trunk/gtk-sharp/; revision=28385
This commit is contained in:
parent
977c36bd98
commit
ebff0837aa
|
@ -11,7 +11,7 @@ class X {
|
||||||
static void Main ()
|
static void Main ()
|
||||||
{
|
{
|
||||||
Application.Init ();
|
Application.Init ();
|
||||||
Gtk.Window w = new Gtk.Window ("Hello");
|
Gtk.Window w = new Gtk.Window ("System.Drawing and Gtk#");
|
||||||
|
|
||||||
// Custom widget sample
|
// Custom widget sample
|
||||||
a = new PrettyGraphic ();
|
a = new PrettyGraphic ();
|
||||||
|
@ -21,15 +21,27 @@ class X {
|
||||||
b.ExposeEvent += ExposeHandler;
|
b.ExposeEvent += ExposeHandler;
|
||||||
b.SizeAllocated += SizeAllocatedHandler;
|
b.SizeAllocated += SizeAllocatedHandler;
|
||||||
|
|
||||||
|
Button c = new Button ("Quit");
|
||||||
|
c.Clicked += quit;
|
||||||
|
|
||||||
|
MovingText m = new MovingText ();
|
||||||
|
|
||||||
Box box = new HBox (true, 0);
|
Box box = new HBox (true, 0);
|
||||||
box.Add (a);
|
box.Add (a);
|
||||||
//box.Add (b);
|
box.Add (b);
|
||||||
|
box.Add (m);
|
||||||
|
box.Add (c);
|
||||||
w.Add (box);
|
w.Add (box);
|
||||||
|
|
||||||
w.ShowAll ();
|
w.ShowAll ();
|
||||||
Application.Run ();
|
Application.Run ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void quit (object obj, EventArgs args)
|
||||||
|
{
|
||||||
|
Application.Quit ();
|
||||||
|
}
|
||||||
|
|
||||||
static Gdk.Rectangle rect;
|
static Gdk.Rectangle rect;
|
||||||
|
|
||||||
static void SizeAllocatedHandler (object obj, SizeAllocatedArgs args)
|
static void SizeAllocatedHandler (object obj, SizeAllocatedArgs args)
|
||||||
|
@ -43,7 +55,6 @@ class X {
|
||||||
Gdk.Window window = ev.Window;
|
Gdk.Window window = ev.Window;
|
||||||
|
|
||||||
using (Graphics g = Gdk.Graphics.FromDrawable (window)){
|
using (Graphics g = Gdk.Graphics.FromDrawable (window)){
|
||||||
Console.WriteLine ("{0} and {1}", -ev.Area.X, -ev.Area.Y);
|
|
||||||
g.TranslateTransform (ev.Area.X, ev.Area.Y);
|
g.TranslateTransform (ev.Area.X, ev.Area.Y);
|
||||||
using (Pen p = new Pen (Color.Red)){
|
using (Pen p = new Pen (Color.Red)){
|
||||||
g.DrawPie (p, 0, 0, rect.Width, rect.Height, 50, 90);
|
g.DrawPie (p, 0, 0, rect.Width, rect.Height, 50, 90);
|
||||||
|
@ -57,6 +68,11 @@ class X {
|
||||||
//
|
//
|
||||||
class PrettyGraphic : DrawingArea {
|
class PrettyGraphic : DrawingArea {
|
||||||
|
|
||||||
|
public PrettyGraphic ()
|
||||||
|
{
|
||||||
|
SetSizeRequest (200, 200);
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnExposeEvent (Gdk.EventExpose args)
|
protected override bool OnExposeEvent (Gdk.EventExpose args)
|
||||||
{
|
{
|
||||||
Gdk.Window win = args.Window;
|
Gdk.Window win = args.Window;
|
||||||
|
@ -66,11 +82,6 @@ class PrettyGraphic : DrawingArea {
|
||||||
//Console.WriteLine ("{0} and {1}", -args.Area.X, -args.Area.Y);
|
//Console.WriteLine ("{0} and {1}", -args.Area.X, -args.Area.Y);
|
||||||
//g.TranslateTransform (-args.Area.X, -args.Area.Y);
|
//g.TranslateTransform (-args.Area.X, -args.Area.Y);
|
||||||
Pen p = new Pen (Color.Blue, 1.0f);
|
Pen p = new Pen (Color.Blue, 1.0f);
|
||||||
Pen q = new Pen (Color.Red, 1.0f);
|
|
||||||
|
|
||||||
g.DrawLine (p, 0, 0, 100, 100);
|
|
||||||
g.DrawLine (q, 0, 0, 100, 100);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
for (int i = 0; i < 600; i += 60)
|
for (int i = 0; i < 600; i += 60)
|
||||||
for (int j = 0; j < 600; j += 60)
|
for (int j = 0; j < 600; j += 60)
|
||||||
|
@ -79,3 +90,40 @@ class PrettyGraphic : DrawingArea {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MovingText : DrawingArea {
|
||||||
|
static int d = 0;
|
||||||
|
|
||||||
|
public MovingText ()
|
||||||
|
{
|
||||||
|
Gtk.Timeout.Add (50, new Function (Forever));
|
||||||
|
SetSizeRequest (300, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Forever ()
|
||||||
|
{
|
||||||
|
QueueDraw ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnExposeEvent (Gdk.EventExpose args)
|
||||||
|
{
|
||||||
|
Gdk.Window win = args.Window;
|
||||||
|
Gdk.Rectangle area = args.Area;
|
||||||
|
|
||||||
|
using (Graphics g = Gdk.Graphics.FromDrawable (args.Window)){
|
||||||
|
Brush back = new SolidBrush (Color.White);
|
||||||
|
Brush fore = new SolidBrush (Color.Red);
|
||||||
|
Font f = new Font ("Times", 20);
|
||||||
|
|
||||||
|
g.FillRectangle (back, 0, 0, 400, 400);
|
||||||
|
g.TranslateTransform (150, 100);
|
||||||
|
g.RotateTransform (d);
|
||||||
|
d += 3;
|
||||||
|
g.DrawString ("Mono", f, fore, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ namespace Gdk {
|
||||||
object r = mi.Invoke (null, args);
|
object r = mi.Invoke (null, args);
|
||||||
System.Drawing.Graphics g = (System.Drawing.Graphics) r;
|
System.Drawing.Graphics g = (System.Drawing.Graphics) r;
|
||||||
|
|
||||||
Console.WriteLine ("-> {0} / {1}", x_off, y_off);
|
|
||||||
g.TranslateTransform (-x_off, -y_off);
|
g.TranslateTransform (-x_off, -y_off);
|
||||||
|
|
||||||
return g;
|
return g;
|
||||||
|
|
Loading…
Reference in a new issue