Wt examples
4.5.0
C:
_
M
mingw-w64-wt
src
wt-4.5.0
examples
javascript
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
14
using namespace
Wt
;
15
20
32
class
Popup
:
public
WObject
33
{
34
public
:
37
enum
Type
{
Confirm
,
Alert
,
Prompt
};
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
77
JSlot
show
;
78
81
JSignal<std::string>&
okPressed
() {
return
okPressed_
; }
82
85
JSignal<>&
cancelPressed
() {
return
cancelPressed_
; }
86
87
private
:
88
JSignal<std::string>
okPressed_
;
89
JSignal<>
cancelPressed_
;
90
91
Type
t_
;
92
WString
message_
;
93
std::string
defaultValue_
;
94
97
void
setJavaScript
();
98
};
99
102
#endif
// POPUP_H_
Popup
A JavaScript based popup window, encapsulating the Javascript functions alert(), confirm(),...
Definition:
Popup.h:33
Popup::cancelPressed
JSignal & cancelPressed()
Signal emitted when cancel is pressed.
Definition:
Popup.h:85
Popup::setMessage
void setMessage(const WString &message)
Change the message.
Definition:
Popup.C:61
Popup::okPressed
JSignal< std::string > & okPressed()
Signal emitted when ok pressed.
Definition:
Popup.h:81
Popup::cancelPressed_
JSignal cancelPressed_
Definition:
Popup.h:89
Popup::createConfirm
static std::unique_ptr< Popup > createConfirm(const WString &message)
Create a confirm dialog.
Definition:
Popup.C:73
Popup::defaultValue
const std::string & defaultValue() const
Get the default value for a prompt dialog.
Definition:
Popup.h:70
Popup::show
JSlot show
Show the dialog.
Definition:
Popup.h:77
Popup::Popup
Popup(Type t, const WString &message, const std::string defaultValue)
Popup constructor.
Definition:
Popup.C:14
Popup::t_
Type t_
Definition:
Popup.h:91
Popup::createAlert
static std::unique_ptr< Popup > createAlert(const WString &message)
Create an alert dialog.
Definition:
Popup.C:78
Popup::message_
WString message_
Definition:
Popup.h:92
Popup::setDefaultValue
void setDefaultValue(const std::string defaultValue)
Change the default value for a prompt dialog.
Definition:
Popup.C:67
Popup::message
const WString & message() const
Get the current message.
Definition:
Popup.h:66
Popup::createPrompt
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
Popup::defaultValue_
std::string defaultValue_
Definition:
Popup.h:93
Popup::Type
Type
Popup type.
Definition:
Popup.h:37
Popup::Alert
@ Alert
Definition:
Popup.h:37
Popup::Prompt
@ Prompt
Definition:
Popup.h:37
Popup::Confirm
@ Confirm
Definition:
Popup.h:37
Popup::okPressed_
JSignal< std::string > okPressed_
Definition:
Popup.h:88
Popup::setJavaScript
void setJavaScript()
Update the javascript code.
Definition:
Popup.C:25
Wt
Definition:
ChartConfig.h:13
Generated on Fri Aug 27 2021 for
the C++ Web Toolkit (Wt)
by
1.9.2