Wtx ~ Wt Extension Library
WtxLib
PopupMessage.cpp
1 
2 #include <Wt/WBreak.h>
3 #include <Wt/WPushButton.h>
4 #include <Wt/WText.h>
5 #include <Wt/WApplication.h>
6 
7 #include "PopupMessage.h"
8 
9 Wtx::PopupMessage::PopupMessage( const std::string & message )
10 : Wt::WDialog("Alert")
11 {
12  contents()-> addNew<Wt::WText>(message,Wt::TextFormat::UnsafeXHTML);
13  contents()-> addNew<Wt::WBreak>();
14  contents()-> addNew<Wt::WPushButton>("Ok")->
15  clicked().connect( [=]()
16  {
17  accept();
18  });
19 
20  rejectWhenEscapePressed();
21 
22  Wt::WDialog::show();
23 }
24 
25 
26 Wtx::PopupMessage * Wtx::PopupMessage::show( const std::string & message )
27 {
28  auto popup = wApp-> addChild( std::make_unique<Wtx::PopupMessage>( message ) );
29  popup-> finished().connect( [=](){ wApp-> removeChild(popup); });
30  return popup;
31 }
32 
33 Wtx::PopupMessage * Wtx::PopupMessage::show( const Wt::WString & message )
34 {
35  return show( message.toUTF8() );
36 }
37 
38 Wtx::PopupMessage * Wtx::PopupMessage::show( const char * message )
39 {
40  return show( std::string(message) );
41 }
42 
43 Wtx::PopupMessage * Wtx::PopupMessage::ask( const std::string & message )
44 {
45 }
46 
47 Wt::Signal<std::string> & Wtx::PopupMessage::finished()
48 {
49  return m_finished;
50 }