-
Notifications
You must be signed in to change notification settings - Fork 156
/
hello.cpp
116 lines (97 loc) · 2.88 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
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
/*---------------------------------------------------------*/
/* */
/* Turbo Vision Hello World Demo Source File */
/* */
/*---------------------------------------------------------*/
/*
* Turbo Vision - Version 2.0
*
* Copyright (c) 1994 by Borland International
* All Rights Reserved.
*
*/
#define Uses_TKeys
#define Uses_TApplication
#define Uses_TEvent
#define Uses_TRect
#define Uses_TDialog
#define Uses_TStaticText
#define Uses_TButton
#define Uses_TMenuBar
#define Uses_TSubMenu
#define Uses_TMenuItem
#define Uses_TStatusLine
#define Uses_TStatusItem
#define Uses_TStatusDef
#define Uses_TDeskTop
#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, bfNormal ) );
d->insert( new TButton( TRect( 16, 4, 28, 6 ), "Ok", cmCancel, bfNormal ) );
d->insert( new TButton( TRect( 16, 6, 28, 8 ), "Lousy", cmCancel, bfNormal ) );
d->insert( new TButton( TRect( 16, 8, 28, 10 ), "Cancel", cmCancel, 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( 0, kbF10, cmMenu )
);
}
int main()
{
THelloApp helloWorld;
helloWorld.run();
return 0;
}