File: WidgetViewer.cs

package info (click to toggle)
gtk-sharp3 2.99.3-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 25,488 kB
  • sloc: xml: 308,885; cs: 38,796; sh: 11,336; perl: 1,295; makefile: 1,099; ansic: 903
file content (141 lines) | stat: -rw-r--r-- 3,332 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//
// WidgetViewer.cs
//
// Author: Duncan Mak  (duncan@ximian.com)
//
// Copyright (C) 2002, Duncan Mak, Ximian Inc.
//

using System;

using Gtk;

namespace WidgetViewer {
	public class Viewer
	{
		static Window window = null;
		static Window viewer = null;
		static Button button = null;
		static VBox box2 = null;
		
		static void Main ()
		{
			Application.Init ();
			window = new Window ("Gtk# Widget viewer");
			window.DeleteEvent += new DeleteEventHandler (Window_Delete);
			window.SetDefaultSize (250, 200);
			
			VBox box1 = new VBox (false, 0);
			window.Add (box1);
			
			box2 = new VBox (false, 5);
			box2.BorderWidth = 10;
			
			Frame frame = new Frame ("Select a widget");
			frame.BorderWidth = 5;
			frame.Add (box2);
			
			box1.PackStart (frame, true, true, 0);

			AddButton ("Bi-directional flipping", new EventHandler (Flipping));
			AddButton ("Check Buttons", new EventHandler (Check_Buttons));
			AddButton ("Color Selection", new EventHandler (Color_Selection));
			AddButton ("Combo Box", new EventHandler (Combo_Box));
			AddButton ("Dialog", new EventHandler (Dialog));
			AddButton ("Radio Buttons", new EventHandler (Radio_Buttons));
			AddButton ("Range Controls", new EventHandler (Range_Controls));
			AddButton ("Size Groups", new EventHandler (Size_Groups));
			AddButton ("Statusbar", new EventHandler (Statusbar));
			
			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 (Stock.Close);
			close_button.Clicked += new EventHandler (Close_Button);
			box2.PackStart (close_button, true, true, 0);

			window.ShowAll ();
			Application.Run ();
		}

		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;
			viewer.DeleteEvent += new DeleteEventHandler (Viewer_Delete);
			viewer.ShowAll ();
		}

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

		static void Viewer_Delete (object o, DeleteEventArgs args)
		{
			viewer.Destroy ();
			viewer = null;
			args.RetVal = true;
		}

		static void Close_Button (object o, EventArgs args)
		{
			Application.Quit ();
		}

		static void Check_Buttons (object o, EventArgs args)
		{
			AddWindow (TestCheckButton.Create ());
		}

		static void Color_Selection (object o, EventArgs args)
		{
			AddWindow (TestColorSelection.Create ());
		}

		static void Radio_Buttons (object o, EventArgs args)
		{
			AddWindow (TestRadioButton.Create ());
		}

		static void Range_Controls (object o, EventArgs args)
		{
			AddWindow (TestRange.Create ());
		}

		static void Statusbar (object o, EventArgs args)
		{
			AddWindow (TestStatusbar.Create ());
		}

		static void Dialog (object o, EventArgs args)
		{
			AddWindow (TestDialog.Create ());
		}

		static void Flipping (object o, EventArgs args)
		{
			AddWindow (TestFlipping.Create ());
		}

		static void Size_Groups (object o, EventArgs args)
		{
			AddWindow (TestSizeGroup.Create ());
		}

		static void Combo_Box (object o, EventArgs args)
		{
			AddWindow (TestComboBox.Create ());
		}
	}
}