blob: 079ce765fe3b9282516119e066b71188c7e274f6 (
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
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
|
/*
* TDialog.cc
*
* Turbo Vision - Version 2.0
*
* Copyright (c) 1994 by Borland International
* All Rights Reserved.
*
* Modified by Sergio Sigala <sergio@sigala.it>
*/
#define Uses_TKeys
#define Uses_TDialog
#define Uses_TEvent
#include <tvision/tv.h>
// TMultiCheckboxes flags
// hibyte = number of bits
// lobyte = bit mask
TDialog::TDialog( const TRect& bounds, const char *aTitle ) :
TWindow( bounds, aTitle, wnNoNumber ),
TWindowInit( &TDialog::initFrame )
{
growMode = 0;
flags = wfMove | wfClose;
palette = dpGrayDialog;
}
TPalette& TDialog::getPalette() const
{
static TPalette paletteGray( cpGrayDialog, sizeof( cpGrayDialog )-1 );
static TPalette paletteBlue( cpBlueDialog, sizeof( cpBlueDialog )-1 );
static TPalette paletteCyan( cpCyanDialog, sizeof( cpCyanDialog )-1 );
switch (palette)
{
case dpGrayDialog:
return paletteGray;
case dpBlueDialog:
return paletteBlue;
case dpCyanDialog:
return paletteCyan;
}
return paletteGray;
}
void TDialog::handleEvent(TEvent& event)
{
TWindow::handleEvent(event);
switch (event.what)
{
case evKeyDown:
switch (event.keyDown.keyCode)
{
case kbEsc:
event.what = evCommand;
event.message.command = cmCancel;
event.message.infoPtr = 0;
putEvent(event);
clearEvent(event);
break;
case kbEnter:
event.what = evBroadcast;
event.message.command = cmDefault;
event.message.infoPtr = 0;
putEvent(event);
clearEvent(event);
break;
}
break;
case evCommand:
switch( event.message.command )
{
case cmOK:
case cmCancel:
case cmYes:
case cmNo:
if( (state & sfModal) != 0 )
{
endModal(event.message.command);
clearEvent(event);
}
break;
}
break;
}
}
Boolean TDialog::valid( ushort command )
{
if( command == cmCancel )
return True;
else
return TGroup::valid( command );
}
#if !defined(NO_STREAMABLE)
TStreamable *TDialog::build()
{
return new TDialog( streamableInit );
}
TDialog::TDialog( StreamableInit ) :
TWindow( streamableInit ),
TWindowInit( 0 )
{
}
#endif
|