|  | #include <Wt/WApplication>
 | 
  
    |  | #include <Wt/WEnvironment>
 | 
  
    |  | 
 | 
  
    |  | #include <iostream>
 | 
  
    |  | #include <Wt/WContainerWidget>
 | 
  
    |  | #include <Wt/WRectArea>
 | 
  
    |  | #include <Wt/WPushButton>
 | 
  
    |  | #include <Wt/WVBoxLayout>
 | 
  
    |  | #include <Wt/WPaintedWidget>
 | 
  
    |  | #include <Wt/WPainter>
 | 
  
    |  | #include <Wt/WPaintDevice>
 | 
  
    |  | using namespace Wt;
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  | class PaintedWidget : public WPaintedWidget {
 | 
  
    |  | public:
 | 
  
    |  |   PaintedWidget()
 | 
  
    |  |   {
 | 
  
    |  |     Wt::WRectArea *rect = new Wt::WRectArea(294, 226, 265, 41);
 | 
  
    |  |     rect->setToolTip("title");
 | 
  
    |  |     rect->setCursor(Wt::CrossCursor);
 | 
  
    |  |     addArea(rect);
 | 
  
    |  |   }
 | 
  
    |  | 
 | 
  
    |  |   bool placed;
 | 
  
    |  | protected:
 | 
  
    |  |   virtual void paintEvent(WPaintDevice *device)
 | 
  
    |  |   {
 | 
  
    |  |     WPainter painter(device);
 | 
  
    |  |     painter.drawRect(0, 0, 400, 400);
 | 
  
    |  |   }
 | 
  
    |  | };
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  | Wt::WApplication *createApp(const Wt::WEnvironment& env)
 | 
  
    |  | {
 | 
  
    |  |   WApplication *app = new WApplication(env);
 | 
  
    |  |   app->setCssTheme("polished");
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  |   Wt::WVBoxLayout *layout = new WVBoxLayout();
 | 
  
    |  |   app->root()->setLayout(layout);
 | 
  
    |  | 
 | 
  
    |  |   PaintedWidget *painter = new PaintedWidget();
 | 
  
    |  |   WPushButton *btn = new WPushButton("hide/show");
 | 
  
    |  | 
 | 
  
    |  |   layout->insertWidget(0, painter);
 | 
  
    |  |   layout->insertWidget(1, btn);
 | 
  
    |  |   painter->placed = true;
 | 
  
    |  | 
 | 
  
    |  |   btn->clicked().connect(std::bind([ = ]() {
 | 
  
    |  |     if (painter->placed)
 | 
  
    |  |       layout->removeWidget(painter);
 | 
  
    |  |     else layout->insertWidget(1, painter);
 | 
  
    |  | 
 | 
  
    |  |     painter->placed = ! painter->placed;
 | 
  
    |  |   }));
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  |   return app;
 | 
  
    |  | }
 | 
  
    |  | 
 | 
  
    |  | int main(int argc, char **argv)
 | 
  
    |  | {
 | 
  
    |  |   std::cout << WT_CLASS << std::endl;
 | 
  
    |  |   return WRun(argc, argv, &createApp);
 | 
  
    |  | }
 | 
  
    |  | 
 |