Wt examples  4.10.3
Loading...
Searching...
No Matches
Popup.h
Go to the documentation of this file.
1// This may look like C code, but it's really -*- C++ -*-
2/*
3 * Copyright (C) 2008 Emweb bv, Herent, Belgium.
4 *
5 * See the LICENSE file for terms of use.
6 */
7#ifndef POPUP_H_
8#define POPUP_H_
9
10#include <Wt/WObject.h>
11#include <Wt/WString.h>
12#include <Wt/WJavaScript.h>
13
14using namespace Wt;
15
20
32class Popup : public WObject
33{
34public:
38
41 Popup(Type t, const WString& message, const std::string defaultValue);
42
45 static std::unique_ptr<Popup> createConfirm(const WString& message);
46
49 static std::unique_ptr<Popup> createPrompt(const WString& message,
50 const std::string defaultValue);
51
54 static std::unique_ptr<Popup> createAlert(const WString& message);
55
58 void setMessage(const WString& message);
59
62 void setDefaultValue(const std::string defaultValue);
63
66 const WString& message() const { return message_; }
67
70 const std::string& defaultValue() const { return defaultValue_; }
71
78
82
86
87private:
90
93 std::string defaultValue_;
94
97 void setJavaScript();
98};
99
102#endif // POPUP_H_
Wt::Auth::Dbo::UserDatabase< AuthInfo > UserDatabase
Definition Session.h:22
A JavaScript based popup window, encapsulating the Javascript functions alert(), confirm(),...
Definition Popup.h:33
JSignal & cancelPressed()
Signal emitted when cancel is pressed.
Definition Popup.h:85
void setMessage(const WString &message)
Change the message.
Definition Popup.C:61
JSignal< std::string > & okPressed()
Signal emitted when ok pressed.
Definition Popup.h:81
JSignal cancelPressed_
Definition Popup.h:89
static std::unique_ptr< Popup > createConfirm(const WString &message)
Create a confirm dialog.
Definition Popup.C:73
const std::string & defaultValue() const
Get the default value for a prompt dialog.
Definition Popup.h:70
JSlot show
Show the dialog.
Definition Popup.h:77
Type t_
Definition Popup.h:91
static std::unique_ptr< Popup > createAlert(const WString &message)
Create an alert dialog.
Definition Popup.C:78
WString message_
Definition Popup.h:92
void setDefaultValue(const std::string defaultValue)
Change the default value for a prompt dialog.
Definition Popup.C:67
const WString & message() const
Get the current message.
Definition Popup.h:66
static std::unique_ptr< Popup > createPrompt(const WString &message, const std::string defaultValue)
Create a prompt dialog with the given default value.
Definition Popup.C:83
std::string defaultValue_
Definition Popup.h:93
Type
Popup type.
Definition Popup.h:37
@ Alert
Definition Popup.h:37
@ Prompt
Definition Popup.h:37
@ Confirm
Definition Popup.h:37
JSignal< std::string > okPressed_
Definition Popup.h:88
void setJavaScript()
Update the javascript code.
Definition Popup.C:25