forked from FNNDSC/KWWidgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvtkKWDialog.cxx
182 lines (141 loc) · 4.38 KB
/
vtkKWDialog.cxx
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*=========================================================================
Module: $RCSfile: vtkKWDialog.cxx,v $
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkKWDialog.h"
#include "vtkObjectFactory.h"
#include "vtkKWApplication.h"
#include "vtkKWTkUtilities.h"
#include "vtkKWFrame.h"
#include "vtkKWInternationalization.h"
#include <vtksys/stl/string>
//----------------------------------------------------------------------------
vtkStandardNewMacro( vtkKWDialog );
//vtkCxxRevisionMacro(vtkKWDialog, "$Revision: 1.63 $");
//----------------------------------------------------------------------------
vtkKWDialog::vtkKWDialog()
{
this->Done = vtkKWDialog::StatusCanceled;
this->Beep = 0;
this->Modal = 1;
}
//----------------------------------------------------------------------------
int vtkKWDialog::PreInvoke()
{
this->Done = vtkKWDialog::StatusActive;
if (!this->IsCreated())
{
this->Create();
}
if (!this->IsMapped())
{
vtkKWTopLevel *master_top =
vtkKWTopLevel::SafeDownCast(this->GetMasterWindow());
if (master_top && !master_top->IsMapped())
{
master_top->Display();
}
this->Display();
}
if (this->Beep)
{
vtkKWTkUtilities::Bell(this->GetApplication());
}
return 1;
}
//----------------------------------------------------------------------------
void vtkKWDialog::PostInvoke()
{
if (this->IsMapped())
{
// OK(), Cancel() should take care of that, but who knows, if another
// button was user-created and forgot to Withdraw(), or simply the
// dialog was closed programmatically by a subclass by setting
// this->Done and breaking the event-loop in Invoke()
this->Withdraw();
}
}
//----------------------------------------------------------------------------
int vtkKWDialog::IsUserDoneWithDialog()
{
return this->Done != vtkKWDialog::StatusActive;
}
//----------------------------------------------------------------------------
int vtkKWDialog::Invoke()
{
if (!this->PreInvoke())
{
return 0;
}
this->GetApplication()->RegisterDialogUp(this);
// Wait for the end
while (!this->IsUserDoneWithDialog())
{
Tcl_DoOneEvent(0);
}
this->GetApplication()->UnRegisterDialogUp(this);
this->PostInvoke();
return (this->Done == vtkKWDialog::StatusCanceled ? 0 : 1);
}
//----------------------------------------------------------------------------
void vtkKWDialog::Display()
{
if (!this->IsCreated())
{
this->Create();
}
this->Done = vtkKWDialog::StatusActive;
this->Superclass::Display();
}
//----------------------------------------------------------------------------
void vtkKWDialog::Cancel()
{
this->Done = vtkKWDialog::StatusCanceled;
this->Withdraw();
}
//----------------------------------------------------------------------------
void vtkKWDialog::OK()
{
this->Done = vtkKWDialog::StatusOK;
this->Withdraw();
}
//----------------------------------------------------------------------------
void vtkKWDialog::CreateWidget()
{
// Check if already created
if (this->IsCreated())
{
vtkErrorMacro(<< this->GetClassName() << " already created");
return;
}
// Call the superclass to create the whole widget
this->Superclass::CreateWidget();
this->SetDeleteWindowProtocolCommand(this, "Cancel");
// Tcl Interactor
const char *context = k_("Dialog");
if (!this->GetApplication()->GetReleaseMode())
{
this->SetKeyBinding(
"<Control-t>", this, "DisplayTclInteractor",
context, ks_("Main Window|Display Tcl interactor"));
}
// Error log
vtksys_stl::string cmd;
cmd = "DisplayLogDialog {";
cmd += this->GetTclName();
cmd += "}";
this->SetKeyBinding(
"<Control-Alt-e>", this->GetApplication(), cmd.c_str(),
context, ks_("Main Window|Display error log"));
}
//----------------------------------------------------------------------------
void vtkKWDialog::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "Beep: " << this->GetBeep() << endl;
}