2002-07-12 17:15:06 +00:00
|
|
|
//
|
|
|
|
// WidgetViewer.cs
|
|
|
|
//
|
|
|
|
// Author: Duncan Mak (duncan@ximian.com)
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002, Duncan Mak, Ximian Inc.
|
|
|
|
//
|
|
|
|
|
2002-07-12 16:52:55 +00:00
|
|
|
using System;
|
|
|
|
|
|
|
|
using Gtk;
|
|
|
|
using GtkSharp;
|
|
|
|
|
|
|
|
namespace WidgetViewer {
|
|
|
|
public class Viewer
|
|
|
|
{
|
|
|
|
static Window window = null;
|
|
|
|
static Window viewer = null;
|
|
|
|
static Button button = null;
|
2002-07-16 10:11:49 +00:00
|
|
|
static VBox box2 = null;
|
2002-07-12 16:52:55 +00:00
|
|
|
|
|
|
|
static void Main ()
|
|
|
|
{
|
|
|
|
Application.Init ();
|
|
|
|
window = new Window ("Gtk# Widget viewer");
|
2002-07-17 08:59:11 +00:00
|
|
|
window.DeleteEvent += new DeleteEventHandler (Window_Delete);
|
2002-07-12 16:52:55 +00:00
|
|
|
window.SetDefaultSize (250, 200);
|
|
|
|
|
|
|
|
VBox box1 = new VBox (false, 0);
|
|
|
|
window.Add (box1);
|
|
|
|
|
2002-07-16 10:11:49 +00:00
|
|
|
box2 = new VBox (false, 5);
|
2002-07-12 16:52:55 +00:00
|
|
|
box2.BorderWidth = 10;
|
|
|
|
box1.PackStart (box2, true, true, 0);
|
|
|
|
|
2002-07-16 10:11:49 +00:00
|
|
|
AddButton ("Bi-directional flipping", new EventHandler (Flipping));
|
|
|
|
AddButton ("Check Buttons", new EventHandler (Check_Buttons));
|
|
|
|
AddButton ("Color Selection", new EventHandler (Color_Selection));
|
|
|
|
AddButton ("Dialog", new EventHandler (Dialog));
|
|
|
|
AddButton ("File Selection", new EventHandler (File_Selection));
|
2002-07-17 15:14:55 +00:00
|
|
|
AddButton ("Menus", new EventHandler (Menus));
|
2002-07-16 10:11:49 +00:00
|
|
|
AddButton ("Radio Buttons", new EventHandler (Radio_Buttons));
|
|
|
|
AddButton ("Range Controls", new EventHandler (Range_Controls));
|
|
|
|
AddButton ("Statusbar", new EventHandler (Statusbar));
|
|
|
|
AddButton ("Toolbar", new EventHandler (Toolbar));
|
2002-07-12 16:52:55 +00:00
|
|
|
|
|
|
|
box1.PackStart (new HSeparator (), false, false, 0);
|
|
|
|
|
|
|
|
box2 = new VBox (false, 10);
|
|
|
|
box2.BorderWidth = 10;
|
|
|
|
box1.PackStart (box2, false, false, 0);
|
|
|
|
|
|
|
|
Button close_button = new Button ("_Close");
|
|
|
|
close_button.Clicked += new EventHandler (Close_Button);
|
|
|
|
box2.PackStart (close_button, true, true, 0);
|
|
|
|
|
|
|
|
window.ShowAll ();
|
|
|
|
Application.Run ();
|
|
|
|
}
|
|
|
|
|
2002-07-16 10:11:49 +00:00
|
|
|
static void AddButton (string caption, EventHandler handler)
|
|
|
|
{
|
|
|
|
button = new Button (caption);
|
|
|
|
button.Clicked += handler;
|
|
|
|
box2.PackStart (button, false, false, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void AddWindow (Window dialog)
|
|
|
|
{
|
|
|
|
viewer = dialog;
|
2002-07-17 08:59:11 +00:00
|
|
|
viewer.DeleteEvent += new DeleteEventHandler (Viewer_Delete);
|
2002-07-16 10:11:49 +00:00
|
|
|
viewer.ShowAll ();
|
|
|
|
}
|
|
|
|
|
2002-07-17 08:59:11 +00:00
|
|
|
static void Window_Delete (object o, DeleteEventArgs args)
|
2002-07-12 16:52:55 +00:00
|
|
|
{
|
|
|
|
Application.Quit ();
|
2002-07-17 08:59:11 +00:00
|
|
|
args.RetVal = true;
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
2002-07-17 08:59:11 +00:00
|
|
|
static void Viewer_Delete (object o, DeleteEventArgs args)
|
2002-07-12 16:52:55 +00:00
|
|
|
{
|
|
|
|
viewer.Destroy ();
|
2002-07-17 08:59:11 +00:00
|
|
|
args.RetVal = true;
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Close_Button (object o, EventArgs args)
|
|
|
|
{
|
2002-07-18 12:06:17 +00:00
|
|
|
Application.Quit ();
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Check_Buttons (object o, EventArgs args)
|
|
|
|
{
|
2002-07-16 10:11:49 +00:00
|
|
|
AddWindow (TestCheckButton.Create ());
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Color_Selection (object o, EventArgs args)
|
|
|
|
{
|
2002-07-16 10:11:49 +00:00
|
|
|
AddWindow (TestColorSelection.Create ());
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void File_Selection (object o, EventArgs args)
|
|
|
|
{
|
2002-07-16 10:11:49 +00:00
|
|
|
AddWindow (TestFileSelection.Create ());
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Radio_Buttons (object o, EventArgs args)
|
|
|
|
{
|
2002-07-16 10:11:49 +00:00
|
|
|
AddWindow (TestRadioButton.Create ());
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Range_Controls (object o, EventArgs args)
|
|
|
|
{
|
2002-07-16 10:11:49 +00:00
|
|
|
AddWindow (TestRange.Create ());
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Statusbar (object o, EventArgs args)
|
|
|
|
{
|
2002-07-16 10:11:49 +00:00
|
|
|
AddWindow (TestStatusbar.Create ());
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Toolbar (object o, EventArgs args)
|
|
|
|
{
|
2002-07-16 10:11:49 +00:00
|
|
|
AddWindow (TestToolbar.Create ());
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Dialog (object o, EventArgs args)
|
|
|
|
{
|
2002-07-16 10:11:49 +00:00
|
|
|
AddWindow (TestDialog.Create ());
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
2002-07-16 10:11:49 +00:00
|
|
|
static void Flipping (object o, EventArgs args)
|
|
|
|
{
|
|
|
|
AddWindow (TestFlipping.Create ());
|
|
|
|
}
|
2002-07-17 15:14:55 +00:00
|
|
|
|
|
|
|
static void Menus (object o, EventArgs args)
|
|
|
|
{
|
|
|
|
AddWindow (TestMenus.Create ());
|
|
|
|
}
|
2002-07-12 16:52:55 +00:00
|
|
|
}
|
|
|
|
}
|