summaryrefslogtreecommitdiffstats
path: root/qtsharp/src/examples/samples/display.cs
blob: 00703b4b59a376d583b495c2c6590d864156c5da (plain)
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
namespace QtSamples {

	using Qt;
	using System;

	public class Display : TTQMainWindow {

		private TextArea textarea;
		private TTQScrollView scrollview;
		private TTQMenuBar menubar;
		private TTQPopupMenu filemenu, aboutmenu;

		private class TextArea : TTQTextEdit {

			public TextArea (TTQWidget parent) : base (parent)
			{
				TTQFile file = new TTQFile ("display.cs");
				if ( file.Open(1) ) {
					TTQTextStream ts = new TTQTextStream (file);
					this.SetText (ts.Read ());
					this.SetTabStopWidth (30);
				}
			}
		}

		public Display ()
		{
			filemenu = new TTQPopupMenu (null, "filemenu");
			filemenu.InsertItem	("&Quit", qApp, TQT_SLOT ("quit()"));

			aboutmenu = new TTQPopupMenu(null, "aboutmenu");
			aboutmenu.InsertItem("&About Qt-Sharp", this, TQT_SLOT("slotAbout()"));

			menubar = new TTQMenuBar(this, "");
			menubar.InsertItem("&File", filemenu);
			menubar.InsertItem("&About", aboutmenu);

			textarea = new TextArea (this);
			textarea.SetGeometry(0, menubar.Height(), Width(), Height() - menubar.Height());
			this.SetCentralWidget (textarea);
		}

		public void slotAbout ()
		{
			TTQMessageBox.Information (
				this, "About Qt-Sharp-0.7",
					  "A Qt (http://www.trolltech.com) to C# language binding.\n" +
					  "Qt-Sharp is compatible with Mono (http://go-mono.org) and\n" +
					  "Portable.NET (http://www.southern-storm.com.au/portable_net.html)\n" +
					  "(c) 2002 Adam Treat. Licensed under the terms of the GNU GPL.\n"
				);
		}

		public static void Main (String[] args)
		{
			TTQApplication app = new TTQApplication (args);
			Display demo = new Display ();
			demo.SetCaption ("Qt-Sharp-0.7!");
			app.SetMainWidget (demo);
			demo.Show ();
			app.Exec ();
			return;
		}
	}
}