Wt examples  3.7.1
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>
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 
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 
92 
95  std::string defaultValue_;
96 
99  void setJavaScript();
100 };
101 
104 #endif // POPUP_H_
JSlot show
Show the dialog.
Definition: Popup.h:70
WString message_
Definition: Popup.h:94
std::string defaultValue_
Definition: Popup.h:95
JSignal< void > cancelPressed_
Definition: Popup.h:91
JSignal< std::string > & okPressed()
Signal emitted when ok pressed.
Definition: Popup.h:74
JSignal< void > & cancelPressed()
Signal emitted when cancel is pressed.
Definition: Popup.h:78
const std::string & defaultValue() const
Get the default value for a prompt dialog.
Definition: Popup.h:63
const WString & message() const
Get the current message.
Definition: Popup.h:59
Type t_
Definition: Popup.h:93
JSignal< std::string > okPressed_
Definition: Popup.h:90
A JavaScript based popup window, encapsulating the Javascript functions alert(), confirm(), and prompt().
Definition: Popup.h:32
Type
Popup type.
Definition: Popup.h:83

Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13