[Gtk-sharp-list] calendar sample

Lee Mallabone gnome@fonicmonkey.net
22 Mar 2003 10:04:37 +0000


--=-ezAaZbjR28A2lMoNaChR
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi,

While documenting the Gtk.Calendar, I wrote a bit of code to demonstrate
it.

I made it into a sample class. The sample and a makefile.in patch are
attached.

Okay to commit?

Regards,

Lee.


--=-ezAaZbjR28A2lMoNaChR
Content-Disposition: attachment; filename=cal.diff
Content-Type: text/plain; name=cal.diff; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

? cal.diff
? gconf/Settings.cs
Index: Makefile.in
===================================================================
RCS file: /cvs/public/gtk-sharp/sample/Makefile.in,v
retrieving revision 1.24
diff -u -r1.24 Makefile.in
--- Makefile.in	15 Mar 2003 18:52:24 -0000	1.24
+++ Makefile.in	22 Mar 2003 09:44:41 -0000
@@ -18,7 +18,7 @@
 	$(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs
 	$(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs
 
-linux: gtk-hello-world.exe button.exe subclass.exe menu.exe size.exe scribble.exe treeviewdemo.exe $(GNOME_TARGETS) $(GLADE_TARGETS)
+linux: gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe size.exe scribble.exe treeviewdemo.exe $(GNOME_TARGETS) $(GLADE_TARGETS)
 @ENABLE_GNOME_TRUE@	$(MAKE) -C gconf 
 @ENABLE_GNOME_TRUE@	$(MAKE) -C rsvg
 
@@ -36,6 +36,9 @@
 
 button.exe: ButtonApp.cs
 	$(MCS) --unsafe -o button.exe $(local_paths) $(all_assemblies) ButtonApp.cs
+
+calendar.exe: CalendarApp.cs
+	$(MCS) --unsafe -o calendar.exe $(local_paths) $(all_assemblies) CalendarApp.cs
 
 subclass.exe: Subclass.cs
 	$(MCS) --unsafe -o subclass.exe $(local_paths) $(all_assemblies) Subclass.cs

--=-ezAaZbjR28A2lMoNaChR
Content-Disposition: attachment; filename=CalendarApp.cs
Content-Type: text/plain; name=CalendarApp.cs; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

// CalendarApp.cs - Gtk.Calendar class Test implementation
//
// Author: Lee Mallabone <gnome@fonicmonkey.net>
//
// (c) 2003 Lee Mallabone

namespace GtkSamples {

	using Gtk;
	using GtkSharp;
	using System;
	using System.Drawing;

	public class CalendarApp  {

		public static Calendar CreateCalendar ()
		{
			Calendar cal = new Calendar();
			cal.DisplayOptions (CalendarDisplayOptions.ShowHeading | CalendarDisplayOptions.ShowDayNames | CalendarDisplayOptions.ShowWeekNumbers);
			return cal;
		}

		public static int Main (string[] args)
		{
			Application.Init ();
			Window win = new Window ("Calendar Tester");
			win.DefaultSize = new Size (200, 150);
			win.DeleteEvent += new DeleteEventHandler (Window_Delete);
			Calendar cal = CreateCalendar();
			cal.DaySelected += new EventHandler (DaySelected);
			win.Add (cal);
			win.ShowAll ();
			Application.Run ();
			return 0;
		}

		static void DaySelected (object obj, EventArgs args)
		{
			Calendar activatedCalendar = (Calendar) obj;
			uint year, month, day;
			activatedCalendar.GetDate(out year, out month, out day);
			// The month is zero-based, so tweak it before output
			Console.WriteLine ("Selected date: {0}/{1}/{2}",
					   year, month+1, day);
		}

		static void Window_Delete (object obj, DeleteEventArgs args)
		{
			Application.Quit ();
			args.RetVal = true;
		}

	}
}

--=-ezAaZbjR28A2lMoNaChR--