forked from magiblot/tvision
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello.cpp
74 lines (61 loc) · 1.92 KB
/
hello.cpp
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
#include <tvision/tv.h>
const int GreetThemCmd = 100;
class THelloApp : public TApplication {
public:
THelloApp();
virtual void handleEvent(TEvent& event);
static TMenuBar* initMenuBar(TRect);
static TStatusLine* initStatusLine(TRect);
private:
void greetingBox();
};
THelloApp::THelloApp()
: TProgInit(&THelloApp::initStatusLine, &THelloApp::initMenuBar, &THelloApp::initDeskTop)
{
}
void THelloApp::greetingBox()
{
TDialog* d = new TDialog(TRect(25, 5, 55, 16), "Hello, World!");
d->insert(new TStaticText(TRect(3, 5, 15, 6), "How are you?"));
d->insert(new TButton(TRect(16, 2, 28, 4), "Terrific", cmCancel, TButton::Flags::bfNormal));
d->insert(new TButton(TRect(16, 4, 28, 6), "Ok", cmCancel, TButton::Flags::bfNormal));
d->insert(new TButton(TRect(16, 6, 28, 8), "Lousy", cmCancel, TButton::Flags::bfNormal));
d->insert(new TButton(TRect(16, 8, 28, 10), "Cancel", cmCancel, TButton::Flags::bfNormal));
deskTop->execView(d);
destroy(d);
}
void THelloApp::handleEvent(TEvent& event)
{
TApplication::handleEvent(event);
if (event.what == evCommand) {
switch (event.message.command) {
case GreetThemCmd:
greetingBox();
clearEvent(event);
break;
default:
break;
}
}
}
TMenuBar* THelloApp::initMenuBar(TRect r)
{
r.b.y = r.a.y + 1;
return new TMenuBar(r,
*new TSubMenu("~H~ello", kbAltH) + *new TMenuItem("~G~reeting...", GreetThemCmd, kbAltG)
+ newLine() + *new TMenuItem("E~x~it", cmQuit, cmQuit, hcNoContext, "Alt-X"));
}
TStatusLine* THelloApp::initStatusLine(TRect r)
{
r.a.y = r.b.y - 1;
return new TStatusLine(r,
*new TStatusDef(0, 0xFFFF) + *new TStatusItem("~Alt-X~ Exit", kbAltX, cmQuit)
+ *new TStatusItem("", kbF10, cmMenu));
}
int main()
{
THelloApp helloWorld;
helloWorld.run();
helloWorld.shutDown();
return 0;
}