/usr/include/Wt/Ext/Dialog is in libwtext-dev 3.3.4+dfsg-6ubuntu1.
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 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef EXT_DIALOG_H_
#define EXT_DIALOG_H_
#include <Wt/WJavaScript>
#include <Wt/Ext/Panel>
namespace Wt {
namespace Ext {
class Button;
/*! \class Dialog Wt/Ext/Dialog Wt/Ext/Dialog
* \brief A dialog emulates a modal window that blocks the user-interface.
*
* A modal window blocks the user interface, and does not allow the
* user to interact with any other part of the user interface until
* the dialog is closed.
*
* There are two ways for using a %Dialog window.
*
* The easiest way is using the exec() method: after creating a
* %Dialog window, call the exec() method which blocks until
* the dialog window is closed, and returns the dialog
* result. Typically, an OK button will be connected to the accept()
* slot, and a Cancel button to the reject() slot. This solution has
* the drawback that it is not scalable to many concurrent sessions,
* since every recursive event loop (which is running during the
* exec() method) locks a thread. Therefore it is only suitable for
* software that doesn't need to scale (to thousands of users).
*
* A second way is by treating the %Dialog as another widget. The
* dialog may be closed by calling accept(), reject() or done() (or
* connecting a signal to one of these methods). This will hide the
* dialog and emit the finished() signal, which you then can listen
* for to process the dialog result and delete the dialog. Unlike
* other widgets, a dialog is hidden by default. You must use the
* method show() or setHidden(true) to show the dialog.
*
* Since %Dialog is a Panel, the dialog contents may be layed out
* inside the dialog using layout managers. To be compatible with
* WDialog howevere, a contents() method is provided which creates a
* WFitLayout that fits a single WContainerWidget widget inside the
* dialog.
*
* Only one %Dialog window may exist at any time in a single
* application. An attempt to instantiate a second dialog will result
* in undefined behaviour.
*
* The API is a superset of the WDialog API:
* <ul>
* <li>has additional methods to manage standard buttons
* (addButton(), removeButton(), buttons());</li>
* <li>may be resized by the user (unless disabled using
* setSizeGripEnabled()).</li>
* </ul>
*
* \image html ExtDialog-1.png "An example Dialog using BorderLayouts"
*
* \ingroup ext
*/
class WT_EXT_API Dialog : public Panel
{
public:
/*! \brief The result of a modal dialog execution.
*/
enum DialogCode { Rejected, //!< Dialog closed with reject()
Accepted //!< Dialog closed with accept()
};
/*! \brief Construct a %Dialog with a given window title.
*
* Only a single %Dialog may be constructed at any time. Unlike
* other widgets, a dialog should not need be added to a container
* widget to be displayed.
*/
Dialog(const WString& windowTitle = WString());
/*! \brief Destruct a %Dialog.
*/
~Dialog();
/*! \brief Set the dialog window title.
*
* Is the same as Panel::setTitle(const WString&)
*/
void setWindowTitle(const WString& windowTitle);
/*! \brief Return the dialog window title.
*
* Is the same as Panel::title()
*/
const WString& windowTitle() const { return Panel::title(); }
/*! \brief Return the dialog contents container.
*
* The first invocation to this method creates a single
* WContainerWidget that is fitted in the panel content area, like
* this:
* \code
* WContainerWidget *contents = new WContainerWidget();
* dialog->setLayout(new WFitLayout());
* dialog->layout()->addWidget(contents);
* \endcode
*/
WContainerWidget *contents() const;
/*! \brief Execute the dialog in a recursive event loop.
*
* Executes the dialog. This blocks the current thread of execution
* until one of done(DialogCode), accept() or reject() is called.
*
* <i>Warning: using exec() does not scale to many concurrent
* sessions, since the thread is locked.</i>
*
* \sa done(DialogCode r), accept(), reject()
*/
DialogCode exec();
/*! \brief Stop a recursive event loop.
*
* Sets the dialog result, and ends a recursive event loop that was
* started using the exec() method.
*/
virtual void done(DialogCode r);
/*! \brief Stop a recursive event loop with result Accepted.
*
* \sa done(DialogCode), reject()
*/
virtual void accept();
/*! \brief Stop a recursive event loop with result Rejected.
*
* \sa done(DialogCode), accept()
*/
virtual void reject();
/*! \brief %Signal emitted when the recursive event loop is ended.
*
* \sa done(DialogCode), accept(), reject()
*/
Signal<DialogCode>& finished() { return finished_; }
/*! \brief Return the result that was set for this dialog.
*
* \sa done(DialogCode)
*/
DialogCode result() const { return result_; }
virtual void setHidden(bool hidden,
const WAnimation& animation = WAnimation());
/*! \brief Add a button at the bottom of this dialog.
*
* Is the same as Panel::addFooterButton()
*/
void addButton(Button *button);
/*! \brief Remove a button from the bottom of this dialog.
*
* The <i>button</i> must have been previously added using addButton().
* Is the same as Panel::removeFooterButton()
*/
void removeButton(Button *button);
/*! \brief Return the list of buttons at the bottom of this dialog.
*
* Is the same as Panel::footerButtons()
*/
const std::vector<Button *>& buttons()
const { return Panel::footerButtons(); }
/*! \brief Configure a default button for this dialog.
*
* The <i>button</i> must have been previously added using addButton().
* A default button is activated when the user presses Return in the
* dialog.
*
* \sa Button::setDefault()
*/
void setDefaultButton(Button *button);
/*! \brief Return the default button for this dialog.
*
* \sa setDefaultButton(), Button::isDefault()
*/
Button *defaultButton() const;
/*! \brief Configure a size grip to allow the user to resize this dialog.
*
* When a size grip is enabled, then the user may resize the dialog window.
*
* The default is <i>true</i>.
*/
void setSizeGripEnabled(bool enabled);
/*! \brief Return if the size grip is enabled.
*
* \sa setSizeGripEnabled()
*/
bool isSizeGripEnabled() const { return sizeGripEnabled_; }
private:
Signal<DialogCode> finished_;
WContainerWidget *contents_;
bool sizeGripEnabled_;
DialogCode result_;
bool recursiveEventLoop_;
JSignal<void> hiddenS_;
std::string createJS(DomElement *inContainer);
void wasHidden();
protected:
virtual void createConfig(std::ostream& config);
virtual std::string extClassName() const;
class Bla { };
Dialog(Bla);
void setExposeMask(WApplication *app);
void restoreExposeMask(WApplication *app);
bool hidden_;
};
}
}
#endif // EXT_DIALOG_H_
|