Advertisement
Guest User

WT Progression Test

a guest
May 13th, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. #include <Wt/WApplication>
  2. #include <Wt/WEnvironment>
  3.  
  4. #include <Wt/WContainerWidget>
  5. #include <Wt/WPushButton>
  6. #include <Wt/WText>
  7. #include <Wt/WBreak>
  8.  
  9. using namespace Wt;
  10.  
  11. class ProgressionTestApplication : public WApplication
  12. {
  13. public:
  14.     ProgressionTestApplication(const WEnvironment& env);
  15.     void printajaxinfo();
  16. private:
  17.  
  18.     WPushButton* upgradeButton;
  19.     WContainerWidget* outputBox;
  20.  
  21.     WText* progressedText;
  22.     WText* jsEnabledText;
  23.     WText* ajaxEnabledText;
  24.     WText* wsEnabledText;
  25.  
  26.     bool progressed;
  27.  
  28. protected:
  29.     void enableAjax();
  30. };
  31.  
  32. ProgressionTestApplication::ProgressionTestApplication(const WEnvironment& env)
  33.     : WApplication(env)
  34. {
  35.     setTitle("Progression Test: Will Progressive BootStrap upgrade to AJAX then WebSockets?");
  36.     progressed = false;
  37.  
  38.     upgradeButton = new WPushButton(root());
  39.     upgradeButton->setText("Upgrade!");
  40.     upgradeButton->clicked().connect(this,&ProgressionTestApplication::printajaxinfo);
  41.  
  42.     outputBox = new WContainerWidget(root());
  43.  
  44.     progressedText = new WText("Has WT Progressed to AJAX: No",outputBox);
  45.         outputBox->addWidget(new WBreak());
  46.     jsEnabledText = new WText("Is JavaScript Enabled: N/A",outputBox);
  47.     outputBox->addWidget(new WBreak());
  48.     ajaxEnabledText = new WText("Is AJAX Enabled: N/A",outputBox);
  49. }
  50.  
  51. void ProgressionTestApplication::printajaxinfo( void )
  52. {
  53.     bool jse = environment().javaScript();
  54.     bool ajaxe = environment().ajax();
  55.  
  56.     progressedText->setText("Has WT Progressed to AJAX: " + WString(progressed ? "Yes" : "No"));
  57.     jsEnabledText->setText("Is JavaScript Enabled: " + WString(jse ? "Yes" : "No"));
  58.         ajaxEnabledText->setText("Is AJAX Enabled: " + WString(ajaxe ? "Yes" : "No"));
  59.  
  60. }
  61.  
  62. void ProgressionTestApplication::enableAjax()
  63. {
  64.     progressed = true;
  65.     WApplication::enableAjax();
  66.     printajaxinfo();
  67. }
  68.  
  69. WApplication *createApplication(const WEnvironment& env)
  70. {
  71.     return new ProgressionTestApplication(env);
  72. }
  73.  
  74. int main(int argc, char **argv)
  75. {
  76.     return WRun(argc, argv, &createApplication);
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement