main.C 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2008 Emweb bvba
  3. *
  4. * See the LICENSE file for terms of use.
  5. */
  6. #include <Wt/WApplication>
  7. #include <Wt/WEnvironment>
  8. #include <Wt/WHBoxLayout>
  9. #include <Wt/WBootstrapTheme>
  10. #include <Wt/WCssTheme>
  11. #include "WidgetGallery.h"
  12. Wt::WApplication *createApplication(const Wt::WEnvironment& env)
  13. {
  14. Wt::WApplication* app = new Wt::WApplication(env);
  15. if (app->appRoot().empty()) {
  16. std::cerr << "!!!!!!!!!!" << std::endl
  17. << "!! Warning: read the README.md file for hints on deployment,"
  18. << " the approot looks suspect!" << std::endl
  19. << "!!!!!!!!!!" << std::endl;
  20. }
  21. // app->setLayoutDirection(Wt::RightToLeft);
  22. // Choice of theme: defaults to bootstrap3 but can be overridden using
  23. // a theme parameter (for testing)
  24. const std::string *themePtr = env.getParameter("theme");
  25. std::string theme;
  26. if (!themePtr)
  27. theme = "bootstrap3";
  28. else
  29. theme = *themePtr;
  30. if (theme == "bootstrap3") {
  31. Wt::WBootstrapTheme *bootstrapTheme = new Wt::WBootstrapTheme(app);
  32. bootstrapTheme->setVersion(Wt::WBootstrapTheme::Version3);
  33. bootstrapTheme->setResponsive(true);
  34. app->setTheme(bootstrapTheme);
  35. // load the default bootstrap3 (sub-)theme
  36. app->useStyleSheet("resources/themes/bootstrap/3/bootstrap-theme.min.css");
  37. } else if (theme == "bootstrap2") {
  38. Wt::WBootstrapTheme *bootstrapTheme = new Wt::WBootstrapTheme(app);
  39. bootstrapTheme->setResponsive(true);
  40. app->setTheme(bootstrapTheme);
  41. } else
  42. app->setTheme(new Wt::WCssTheme(theme));
  43. // load text bundles (for the tr() function)
  44. app->messageResourceBundle().use(app->appRoot() + "report");
  45. app->messageResourceBundle().use(app->appRoot() + "text");
  46. app->messageResourceBundle().use(app->appRoot() + "src");
  47. Wt::WHBoxLayout *layout = new Wt::WHBoxLayout(app->root());
  48. layout->setContentsMargins(0, 0, 0, 0);
  49. layout->addWidget(new WidgetGallery());
  50. app->setTitle("Wt Widget Gallery");
  51. app->useStyleSheet("style/everywidget.css");
  52. app->useStyleSheet("style/dragdrop.css");
  53. app->useStyleSheet("style/combostyle.css");
  54. app->useStyleSheet("style/pygments.css");
  55. app->useStyleSheet("style/layout.css");
  56. app->useStyleSheet("style/filedrop.css");
  57. return app;
  58. }
  59. int main(int argc, char **argv)
  60. {
  61. return Wt::WRun(argc, argv, &createApplication);
  62. }