Wt examples  4.10.4
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 
78 
81  JSignal<std::string>& okPressed() { return okPressed_; }
82 
85  JSignal<>& cancelPressed() { return cancelPressed_; }
86 
87 private:
90 
93  std::string defaultValue_;
94 
97  void setJavaScript();
98 };
99 
102 #endif // POPUP_H_
A JavaScript based popup window, encapsulating the Javascript functions alert(), confirm(),...
Definition: Popup.h:33
JSignal< std::string > & okPressed()
Signal emitted when ok pressed.
Definition: Popup.h:81
const WString & message() const
Get the current message.
Definition: Popup.h:66
JSignal cancelPressed_
Definition: Popup.h:89
JSlot show
Show the dialog.
Definition: Popup.h:77
const std::string & defaultValue() const
Get the default value for a prompt dialog.
Definition: Popup.h:70
Type t_
Definition: Popup.h:91
WString message_
Definition: Popup.h:92
JSignal & cancelPressed()
Signal emitted when cancel is pressed.
Definition: Popup.h:85
std::string defaultValue_
Definition: Popup.h:93
Type
Popup type.
Definition: Popup.h:37
@ Alert
Definition: Popup.h:37
JSignal< std::string > okPressed_
Definition: Popup.h:88
Type