Author: jluke
Date: 2005-11-16 16:13:25 -0500 (Wed, 16 Nov 2005)
New Revision: 53145
Added:
trunk/mcs/class/Mono.Cairo/snippets/SnippetsGtk.cs
Modified:
trunk/mcs/class/Mono.Cairo/snippets/
trunk/mcs/class/Mono.Cairo/snippets/Makefile
Log:
add the gtk version of snippets
Property changes on: trunk/mcs/class/Mono.Cairo/snippets
___________________________________________________________________
Name: svn:ignore
+ *.png
*.exe
*.mdb
Modified: trunk/mcs/class/Mono.Cairo/snippets/Makefile
===================================================================
--- trunk/mcs/class/Mono.Cairo/snippets/Makefile 2005-11-16 20:03:39 UTC
(rev 53144)
+++ trunk/mcs/class/Mono.Cairo/snippets/Makefile 2005-11-16 21:13:25 UTC
(rev 53145)
@@ -1,12 +1,18 @@
CSC = mcs -debug
REFS = -r:Mono.Cairo.dll
SNIPPETS = snippets.exe
+SNIPPETSGTK = snippets-gtk.exe
all: $(SNIPPETS)
clean:
rm -f $(SNIPPETS) $(SNIPPETS).mdb
+ rm -f $(SNIPPETSGTK) $(SNIPPETSGTK).mdb
snippets.exe: Snippets.cs SnippetsPng.cs
$(CSC) -out:$@ $(REFS) Snippets.cs SnippetsPng.cs
+# only for gtk 2.8
+snippets-gtk.exe: Snippets.cs SnippetsGtk.cs
+ $(CSC) -out:$@ $(REFS) -pkg:gtk-sharp-2.0 Snippets.cs SnippetsGtk.cs
+
Added: trunk/mcs/class/Mono.Cairo/snippets/SnippetsGtk.cs
===================================================================
--- trunk/mcs/class/Mono.Cairo/snippets/SnippetsGtk.cs 2005-11-16 20:03:39 UTC
(rev 53144)
+++ trunk/mcs/class/Mono.Cairo/snippets/SnippetsGtk.cs 2005-11-16 21:13:25 UTC
(rev 53145)
@@ -0,0 +1,89 @@
+using System;
+using Cairo;
+using Gtk;
+
+namespace Cairo.Snippets
+{
+ public class CairoSnippetsGtk
+ {
+ int width = 400;
+ int height = 400;
+
+ DrawingArea da = new DrawingArea ();
+
+ Snippets snips = new Snippets ();
+ string selected = "";
+
+ public static void Main(string[] args)
+ {
+ Application.Init ();
+ new CairoSnippetsGtk ();
+ Application.Run ();
+ }
+
+ public CairoSnippetsGtk ()
+ {
+ Window w = new Window ("Cairo snippets");
+ w.SetDefaultSize (width, height);
+ w.DeleteEvent += delegate { Application.Quit (); };
+
+ HPaned hpane = new HPaned ();
+ ScrolledWindow sw = new ScrolledWindow ();
+ TreeView tv = new TreeView ();
+ tv.HeadersVisible = false;
+ tv.AppendColumn ("snippets", new CellRendererText (),
"text", 0);
+ tv.Model = GetModel ();
+ tv.Selection.Changed += OnSelectionChanged;
+ sw.Add (tv);
+ hpane.Add1 (sw);
+ da = new DrawingArea ();
+ da.ExposeEvent += OnExposed;
+ hpane.Add2 (da);
+ hpane.Position = width / 2;
+ w.Add (hpane);
+
+ w.ShowAll ();
+ }
+
+ ListStore GetModel ()
+ {
+ ListStore store = new ListStore (typeof (string));
+ foreach (string s in Snippets.snippets)
+ store.AppendValues (s);
+ return store;
+ }
+
+ void OnExposed (object sender, ExposeEventArgs e)
+ {
+ Graphics cr = Gdk.CairoHelper.Create (da.GdkWindow);
+
+ int w, h;
+ da.GdkWindow.GetSize (out w, out h);
+
+ // set window bg
+ cr.ColorRgb = new Color (1, 1, 1);
+ cr.Rectangle (0, 0, w, h);
+ cr.Fill ();
+ cr.ColorRgb = new Color (1, 1, 1);
+
+ Snippets.InvokeSnippet (snips, selected, cr, w, h);
+
+ e.RetVal = true;
+ }
+
+ void OnSelectionChanged (object sender, EventArgs e)
+ {
+ TreeIter iter;
+ TreeModel model;
+ TreeSelection selection = sender as TreeSelection;
+
+ if (selection.GetSelected (out model, out iter))
+ {
+ selected = (string) model.GetValue (iter, 0);
+ }
+
+ da.QueueDraw ();
+ }
+ }
+}
+
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches