00001 // This may look like C code, but it's really -*- C++ -*- 00002 /* 00003 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium. 00004 * 00005 * See the LICENSE file for terms of use. 00006 */ 00007 #ifndef POPUP_H_ 00008 #define POPUP_H_ 00009 00010 #include <Wt/WObject> 00011 #include <Wt/WString> 00012 #include <Wt/WJavaScript> 00013 00014 using namespace Wt; 00015 00020 00032 class Popup : public WObject 00033 { 00034 public: 00037 static Popup *createConfirm(const WString& message, WObject *parent = 0); 00038 00041 static Popup *createPrompt(const WString& message, 00042 const std::string defaultValue, 00043 WObject *parent = 0); 00044 00047 static Popup *createAlert(const WString& message, WObject *parent = 0); 00048 00051 void setMessage(const WString& message); 00052 00055 void setDefaultValue(const std::string defaultValue); 00056 00059 const WMessage& message() const { return message_; } 00060 00063 const std::string& defaultValue() const { return defaultValue_; } 00064 00070 JSlot show; 00071 00074 JSignal<std::string>& okPressed() { return okPressed_; } 00075 00078 JSignal<void>& cancelPressed() { return cancelPressed_; } 00079 00080 private: 00083 enum Type { Confirm, Alert, Prompt }; 00084 00087 Popup(Type t, const WString& message, const std::string defaultValue, 00088 WObject *parent); 00089 00090 JSignal<std::string> okPressed_; 00091 JSignal<void> cancelPressed_; 00092 00093 Type t_; 00094 WString message_; 00095 std::string defaultValue_; 00096 00099 void setJavaScript(); 00100 }; 00101 00104 #endif // POPUP_H_