Wt examples
3.3.12
tmp
package-src
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 bvba, Kessel-Lo, 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>
11
#include <Wt/WString>
12
#include <Wt/WJavaScript>
13
14
using namespace
Wt
;
15
20
32
class
Popup
:
public
WObject
33
{
34
public
:
37
static
Popup
*
createConfirm
(
const
WString
&
message
,
WObject
*
parent
= 0);
38
41
static
Popup
*
createPrompt
(
const
WString
&
message
,
42
const
std::string
defaultValue
,
43
WObject
*
parent
= 0);
44
47
static
Popup
*
createAlert
(
const
WString
&
message
,
WObject
*
parent
= 0);
48
51
void
setMessage
(
const
WString
&
message
);
52
55
void
setDefaultValue
(
const
std::string
defaultValue
);
56
59
const
WString
&
message
()
const
{
return
message_
; }
60
63
const
std::string&
defaultValue
()
const
{
return
defaultValue_
; }
64
70
JSlot
show
;
71
74
JSignal<std::string>
&
okPressed
() {
return
okPressed_
; }
75
78
JSignal<void>
&
cancelPressed
() {
return
cancelPressed_
; }
79
80
private
:
83
enum
Type
{
Confirm
,
Alert
,
Prompt
};
84
87
Popup
(
Type
t,
const
WString
&
message
,
const
std::string
defaultValue
,
88
WObject
*
parent
);
89
90
JSignal<std::string>
okPressed_
;
91
JSignal<void>
cancelPressed_
;
92
93
Type
t_
;
94
WString
message_
;
95
std::string
defaultValue_
;
96
99
void
setJavaScript
();
100
};
101
104
#endif
// POPUP_H_
Popup
A JavaScript based popup window, encapsulating the Javascript functions alert(), confirm(),...
Definition
Popup.h:33
Popup::setMessage
void setMessage(const WString &message)
Change the message.
Definition
Popup.C:60
Popup::createConfirm
static Popup * createConfirm(const WString &message, WObject *parent=0)
Create a confirm dialog.
Definition
Popup.C:72
Popup::okPressed
JSignal< std::string > & okPressed()
Signal emitted when ok pressed.
Definition
Popup.h:74
Popup::defaultValue
const std::string & defaultValue() const
Get the default value for a prompt dialog.
Definition
Popup.h:63
Popup::show
JSlot show
Show the dialog.
Definition
Popup.h:70
Popup::t_
Type t_
Definition
Popup.h:93
Popup::message_
WString message_
Definition
Popup.h:94
Popup::setDefaultValue
void setDefaultValue(const std::string defaultValue)
Change the default value for a prompt dialog.
Definition
Popup.C:66
Popup::message
const WString & message() const
Get the current message.
Definition
Popup.h:59
Popup::cancelPressed_
JSignal< void > cancelPressed_
Definition
Popup.h:91
Popup::defaultValue_
std::string defaultValue_
Definition
Popup.h:95
Popup::Type
Type
Popup type.
Definition
Popup.h:83
Popup::Alert
@ Alert
Definition
Popup.h:83
Popup::Prompt
@ Prompt
Definition
Popup.h:83
Popup::Confirm
@ Confirm
Definition
Popup.h:83
Popup::createAlert
static Popup * createAlert(const WString &message, WObject *parent=0)
Create an alert dialog.
Definition
Popup.C:77
Popup::okPressed_
JSignal< std::string > okPressed_
Definition
Popup.h:90
Popup::createPrompt
static Popup * createPrompt(const WString &message, const std::string defaultValue, WObject *parent=0)
Create a prompt dialog with the given default value.
Definition
Popup.C:82
Popup::setJavaScript
void setJavaScript()
Update the javascript code.
Definition
Popup.C:24
Popup::cancelPressed
JSignal< void > & cancelPressed()
Signal emitted when cancel is pressed.
Definition
Popup.h:78
Wt::JSignal
Wt::JSlot
Wt::WObject
Wt::WObject::parent
WObject * parent() const
Wt::WString
Wt
Generated on Fri May 17 2024 for
the C++ Web Toolkit (Wt)
by
1.9.8