This file is indexed.

/usr/lib/Wt/examples/widgetgallery/DialogWidgets.C is in witty-examples 3.1.10-1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#include "DialogWidgets.h"
#include "EventDisplayer.h"
#include "DeferredWidget.h"

#include <Wt/WText>
#include <Wt/WBreak>
#include <Wt/WVBoxLayout>
#include <Wt/Ext/Button>
#include <Wt/Ext/Dialog>
#include <Wt/Ext/MessageBox>
#include <Wt/Ext/ProgressDialog>
#include <Wt/WBorderLayout>
#include <Wt/WFitLayout>
#include <Wt/WApplication>
#include <Wt/WString>
#ifdef WIN32
#include <windows.h>
#undef MessageBox
#endif

using namespace Wt;

NonModalDialog::NonModalDialog(const WString& title, EventDisplayer *ed)
  : WDialog(title)
{  
  setModal(false);

  new WText("You can freely format the contents of a WDialog by "
	    "adding any widget you want to it.<br/>Here, we added WText, "
	    "WLineEdit and WPushButton to a dialog", contents());
  new WBreak(contents());
  new WText("Enter your name: ", contents());
  edit_ = new WLineEdit(contents());
  new WBreak(contents());
  ok_ = new WPushButton("Ok", contents());

  edit_->enterPressed().connect(this, &NonModalDialog::welcome);
  ok_->clicked().connect(this, &NonModalDialog::welcome);

  ed_ = ed;
}

DialogWidgets::DialogWidgets(EventDisplayer *ed)
  : ControlsWidget(ed, true)
{
  new WText(tr("dialogs-intro"), this);
}

void DialogWidgets::populateSubMenu(WMenu *menu)
{
  menu->addItem("WDialog", wDialog());
  menu->addItem("WMessageBox", wMessageBox());
#ifndef WT_TARGET_JAVA
  menu->addItem("Ext Dialogs",
		deferCreate(boost::bind(&DialogWidgets::eDialogs, this)));
#endif
}

WWidget *DialogWidgets::wDialog()
{
  WContainerWidget *result = new WContainerWidget();

  topic("WDialog", result);
  new WText(tr("dialogs-WDialog"), result);
  WPushButton *button = new WPushButton("Modal dialog", result);
  button->clicked().connect(this, &DialogWidgets::customModal);

  button = new WPushButton("Non-modal dialog", result);
  button->clicked().connect(this, &DialogWidgets::customNonModal);

  return result;
}

WWidget *DialogWidgets::wMessageBox()
{
  WContainerWidget *result = new WContainerWidget();

  topic("WMessageBox", result);
  new WText(tr("dialogs-WMessageBox"),
	    result);
  
  WContainerWidget *ex = new WContainerWidget(result);
  
  WVBoxLayout *vLayout = new WVBoxLayout();
  ex->setLayout(vLayout, AlignTop | AlignLeft);
  vLayout->setContentsMargins(0, 0, 0, 0);
  vLayout->setSpacing(3);

  WPushButton *button;
  vLayout->addWidget(button = new WPushButton("One liner"));
  button->clicked().connect(this, &DialogWidgets::messageBox1);
  vLayout->addWidget(button = new WPushButton("Show some buttons"));
  button->clicked().connect(this, &DialogWidgets::messageBox2);
  vLayout->addWidget(button = new WPushButton("Need confirmation"));
  button->clicked().connect(this, &DialogWidgets::messageBox3);
  vLayout->addWidget(button = new WPushButton("Discard"));
  button->clicked().connect(this, &DialogWidgets::messageBox4);

  return result;
}

#ifndef WT_TARGET_JAVA
WWidget *DialogWidgets::eDialogs()
{
  WContainerWidget *result = new WContainerWidget();

  topic("Ext::Dialog", "Ext::MessageBox", "Ext::ProgressDialog", result);
  new WText(tr("dialogs-ExtDialog"), result);
  WContainerWidget *ex = new WContainerWidget(result);
  
  WVBoxLayout *vLayout = new WVBoxLayout();
  ex->setLayout(vLayout, AlignTop);
  vLayout->setContentsMargins(0, 0, 0, 0);
  vLayout->setSpacing(3);
  
  
  WPushButton *button;
  
  vLayout->addWidget(button = new WPushButton("Ext Message Box"));
  button->clicked().connect(this, &DialogWidgets::createExtMessageBox);
  vLayout->addWidget(button = new WPushButton("Ext Dialog"));
  button->clicked().connect(this, &DialogWidgets::createExtDialog);
  vLayout->addWidget(button = new WPushButton("Ext Progress Bar"));
  button->clicked().connect(this, &DialogWidgets::createExtProgress);

  return result;
}
#endif

void DialogWidgets::messageBox1()
{
  WMessageBox::show("Information",
		    "One-liner dialogs have a simple constructor", Ok);
  ed_->setStatus("Ok'ed");
}

void DialogWidgets::messageBox2()
{
  messageBox_
    = new WMessageBox("Question",
		      "This is a modal dialog that invokes a signal when a button is pushed",
		      NoIcon, Yes | No | Cancel);

  messageBox_
    ->buttonClicked().connect(this, &DialogWidgets::messageBoxDone);

  messageBox_->show();
}

void DialogWidgets::messageBox3()
{
  StandardButton
    result = WMessageBox::show("Push it",
			       "Yes/No questions can be tested by "
			       "checking show()'s return value",
			       Ok | Cancel);

  if (result == Ok)
    ed_->setStatus("Accepted!");
  else
    ed_->setStatus("Cancelled!");
}

void DialogWidgets::messageBox4()
{
  messageBox_
    = new WMessageBox("Your work",
		      "Provide your own button text.<br/>"
		      "Your work is not saved",
		      NoIcon, NoButton);

  messageBox_->addButton("Cancel modifications", Cancel);
  messageBox_->addButton("Continue modifying work", Ok);

  messageBox_
    ->buttonClicked().connect(this, &DialogWidgets::messageBoxDone);

  messageBox_->show();
}

void DialogWidgets::messageBoxDone(StandardButton result)
{
  switch (result) {
  case Ok:
    ed_->setStatus("Ok'ed"); break;
  case Cancel:
    ed_->setStatus("Cancelled!"); break;
  case Yes:
    ed_->setStatus("Me too!"); break;
  case No:
    ed_->setStatus("Me neither!"); break;
  default:
    ed_->setStatus("Unkonwn result?");
  }

  delete messageBox_;
  messageBox_ = 0;
}

void DialogWidgets::customNonModal()
{
   NonModalDialog *dialog = new NonModalDialog("Personalia (non-modal)", ed_);
   dialog->show();
}

void DialogWidgets::customModal()
{
  WDialog dialog("Personalia (modal)");

  new WText("You can freely format the contents of a WDialog by "
	    "adding any widget you want to it.<br/>Here, we added WText, "
	    "WLineEdit and WPushButton to a dialog", dialog.contents());
  new WBreak(dialog.contents());
  new WText("Enter your name: ", dialog.contents());
  WLineEdit edit(dialog.contents());
  new WBreak(dialog.contents());
  WPushButton ok("Ok", dialog.contents());

  edit.enterPressed().connect(&dialog, &WDialog::accept);
  ok.clicked().connect(&dialog, &WDialog::accept);

  if (dialog.exec() == WDialog::Accepted) {
    ed_->setStatus("Welcome, " + edit.text());
  }
}

#ifndef WT_TARGET_JAVA
void DialogWidgets::createExtMessageBox()
{
  Ext::MessageBox *mb = new Ext::MessageBox();

  mb->setWindowTitle("Wt is magnificent");
  mb->setText("Isn't Wt the ruler of them all?");

  mb->setButtons(Wt::Yes);
  mb->finished().connect(this, &DialogWidgets::deleteExtDialog);

  mb->show();

  extDialog_ = mb;
}

void DialogWidgets::createExtDialog()
{
  Ext::Dialog *d = new Ext::Dialog();
  d->setWindowTitle("Ext::Dialog with WBorderLayout");
  d->resize(400,300);
  d->setStyleClass("dialog");

  Ext::Button *okButton = new Ext::Button("Ok");
  okButton->activated().connect(d, &Ext::Dialog::accept);
  d->addButton(okButton);
  okButton->setDefault(true);

  Ext::Button *cancelButton = new Ext::Button("Cancel");
  cancelButton->activated().connect(d, &Ext::Dialog::reject);
  d->addButton(cancelButton);

  WBorderLayout *layout = new WBorderLayout();
  d->setLayout(layout);

  Ext::Panel *west = new Ext::Panel();
  west->setTitle("West");
  west->setResizable(true);
  west->setCollapsible(true);
  west->resize(100, WLength::Auto);
  west->setLayout(new WFitLayout());
  west->layout()->addWidget(new WText("This is a resizable and collapsible "
				      "panel"));
  layout->addWidget(west, WBorderLayout::West);

  Ext::Panel *center = new Ext::Panel();
  center->setTitle("Center");

  WBorderLayout *nestedLayout = new WBorderLayout();
  center->setLayout(nestedLayout);

  Ext::Panel *nestedNorth = new Ext::Panel();
  nestedLayout->addWidget(nestedNorth, WBorderLayout::North);
  nestedNorth->resize(WLength::Auto, 70);
  nestedNorth->layout()->addWidget(
    new WText("Ext Dialogs, like Wt Dialogs, can contain any widget. This "
	      "is a dialog with a layout manager. The left pane can be "
	      "resized."));

  Ext::Panel *nestedCenter = new Ext::Panel();
  nestedLayout->addWidget(nestedCenter, WBorderLayout::Center);
  nestedCenter->layout()->addWidget(new WText("This is simply WText, but "
					      "could have been any widget."));

  layout->addWidget(center, WBorderLayout::Center);

  d->show();
  extDialog_ = d;
  extDialog_->finished().connect(this, &DialogWidgets::deleteExtDialog);
}

void DialogWidgets::createExtProgress()
{
  Ext::ProgressDialog d("Please wait while calculating Pi ...", "Cancel", 0, 7);
  d.setWindowTitle("Calculator");

  d.show();

  for (unsigned i = 0; i < 7; ++i) {
    d.setValue(i);
    wApp->processEvents();

    if (!d.wasCanceled()) {
      /* Do some work ... */
#ifdef WIN32
      Sleep(1000);
#else
      sleep(1);
#endif
    } else {
      Ext::MessageBox
	::show("Operation cancelled",
	       "It does not matter, Pi is overrated", Ok);
      break;
    }
  }
}

void DialogWidgets::deleteExtDialog()
{
  if (extDialog_->result() == Ext::Dialog::Accepted) {
    ed_->setStatus("Ext dialog accecpted");
  } else {
    ed_->setStatus("Ext dialog rejected");
  }
  delete extDialog_;
}
#endif