Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
ConfirmDlg.cpp
Go to the documentation of this file.
1
/* Project Starshatter 4.5
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: Stars.exe
6
FILE: ConfirmDlg.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
General-purpose confirmation dialog class
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
ConfirmDlg.h
"
17
#include "
MenuScreen.h
"
18
#include "
Starshatter.h
"
19
#include "
FormatUtil.h
"
20
21
#include "
Game.h
"
22
#include "
Keyboard.h
"
23
#include "
Button.h
"
24
25
// +--------------------------------------------------------------------+
26
// DECLARE MAPPING FUNCTIONS:
27
28
DEF_MAP_CLIENT
(
ConfirmDlg
, OnApply);
29
DEF_MAP_CLIENT
(
ConfirmDlg
, OnCancel);
30
31
// +--------------------------------------------------------------------+
32
33
ConfirmDlg::ConfirmDlg
(
Screen
* s,
FormDef
& def,
MenuScreen
* mgr)
34
:
FormWindow
(s, 0, 0, s->Width(), s->Height()), manager(mgr),
35
parent_control(0), btn_apply(0), btn_cancel(0)
36
{
37
Init
(def);
38
}
39
40
ConfirmDlg::~ConfirmDlg
()
41
{
42
}
43
44
void
45
ConfirmDlg::RegisterControls
()
46
{
47
if
(
btn_apply
)
48
return
;
49
50
btn_apply
= (
Button
*)
FindControl
(1);
51
REGISTER_CLIENT
(
EID_CLICK
,
btn_apply
,
ConfirmDlg
,
OnApply
);
52
53
btn_cancel
= (
Button
*)
FindControl
(2);
54
REGISTER_CLIENT
(
EID_CLICK
,
btn_cancel
,
ConfirmDlg
,
OnCancel
);
55
56
lbl_title
=
FindControl
(100);
57
lbl_message
=
FindControl
(101);
58
}
59
60
// +--------------------------------------------------------------------+
61
62
ActiveWindow
*
63
ConfirmDlg::GetParentControl
()
64
{
65
return
parent_control
;
66
}
67
68
void
69
ConfirmDlg::SetParentControl
(
ActiveWindow
* p)
70
{
71
parent_control
= p;
72
}
73
74
Text
75
ConfirmDlg::GetTitle
()
76
{
77
if
(
lbl_title
)
78
return
lbl_title
->
GetText
();
79
80
return
""
;
81
}
82
83
void
84
ConfirmDlg::SetTitle
(
const
char
* t)
85
{
86
if
(
lbl_title
)
87
lbl_title
->
SetText
(t);
88
}
89
90
Text
91
ConfirmDlg::GetMessage
()
92
{
93
if
(
lbl_message
)
94
return
lbl_message
->
GetText
();
95
96
return
""
;
97
}
98
99
void
100
ConfirmDlg::SetMessage
(
const
char
* m)
101
{
102
if
(
lbl_message
)
103
lbl_message
->
SetText
(m);
104
}
105
106
// +--------------------------------------------------------------------+
107
108
void
109
ConfirmDlg::ExecFrame
()
110
{
111
if
(
Keyboard::KeyDown
(VK_RETURN)) {
112
OnApply
(0);
113
}
114
115
if
(
Keyboard::KeyDown
(VK_ESCAPE)) {
116
OnCancel
(0);
117
}
118
}
119
120
// +--------------------------------------------------------------------+
121
122
void
123
ConfirmDlg::Show
()
124
{
125
if
(!
IsShown
()) {
126
Button::PlaySound
(
Button::SND_CONFIRM
);
127
}
128
129
FormWindow::Show
();
130
SetFocus
();
131
}
132
133
// +--------------------------------------------------------------------+
134
135
void
136
ConfirmDlg::OnApply
(
AWEvent
* event)
137
{
138
manager
->
HideConfirmDlg
();
139
140
if
(
parent_control
)
141
parent_control
->
ClientEvent
(
EID_USER_1
);
142
}
143
144
void
145
ConfirmDlg::OnCancel
(
AWEvent
* event)
146
{
147
manager
->
HideConfirmDlg
();
148
}
149
150
// +--------------------------------------------------------------------+
Stars45
ConfirmDlg.cpp
Generated on Tue Jun 5 2012 20:46:50 for Starshatter_Open by
1.8.1