/usr/lib/Wt/examples/javascript/Popup.h is in witty-examples 3.3.0-1build1.
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 | // 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 POPUP_H_
#define POPUP_H_
#include <Wt/WObject>
#include <Wt/WString>
#include <Wt/WJavaScript>
using namespace Wt;
/**
* @addtogroup javascript
*/
/*@{*/
/*! \brief A JavaScript based popup window, encapsulating the Javascript
* functions alert(), confirm(), and prompt().
*
* Use one of the create static methods to create a popup. This will not
* display the popup, until either the show slot is triggered from an
* event handler, or is executed using it's exec() method.
*
* When the user closes the popup, either the okPressed or cancelPressed
* signal is emitted. For a prompt dialog, the value is passed as a parameter
* to the okPressed signal.
*/
class Popup : public WObject
{
public:
/*! \brief Create a confirm dialog.
*/
static Popup *createConfirm(const WString& message, WObject *parent = 0);
/*! \brief Create a prompt dialog with the given default value
*/
static Popup *createPrompt(const WString& message,
const std::string defaultValue,
WObject *parent = 0);
/*! \brief Create an alert dialog.
*/
static Popup *createAlert(const WString& message, WObject *parent = 0);
/*! \brief Change the message
*/
void setMessage(const WString& message);
/*! \brief Change the default value for a prompt dialog.
*/
void setDefaultValue(const std::string defaultValue);
/*! \brief Get the current message.
*/
const WString& message() const { return message_; }
/*! \brief Get the default value for a prompt dialog.
*/
const std::string& defaultValue() const { return defaultValue_; }
/*! \brief Show the dialog.
*
* Use show.exec() to show the dialog, or connect the slot to an EventSignal
* to directly show the dialog without a server round trip.
*/
JSlot show;
/*! \brief Signal emitted when ok pressed.
*/
JSignal<std::string>& okPressed() { return okPressed_; }
/*! \brief Signal emitted when cancel is pressed.
*/
JSignal<void>& cancelPressed() { return cancelPressed_; }
private:
/*! \brief Popup type.
*/
enum Type { Confirm, Alert, Prompt };
/*! \brief Popup constructor.
*/
Popup(Type t, const WString& message, const std::string defaultValue,
WObject *parent);
JSignal<std::string> okPressed_;
JSignal<void> cancelPressed_;
Type t_;
WString message_;
std::string defaultValue_;
/*! \brief Update the javascript code.
*/
void setJavaScript();
};
/*@}*/
#endif // POPUP_H_
|