Project

General

Profile

Bug #1236 » set_window.cpp

Boris Nagaev, 04/13/2012 12:29 AM

 
1

    
2
#include <Wt/WApplication>
3
#include <Wt/WPaintedWidget>
4
#include <Wt/WPainter>
5
#include <Wt/WPainterPath>
6

    
7
using namespace Wt;
8

    
9
class SetWindowWidget : public WPaintedWidget {
10
public:
11
    SetWindowWidget(WContainerWidget* p = 0) :
12
        WPaintedWidget(p) {
13
        resize(500, 500);
14
    }
15

    
16
protected:
17
    void paintEvent(WPaintDevice* device) {
18
        Wt::WPainter painter(device);
19
        painter.setWindow(0, 0, 1, 1);
20
        painter.drawEllipse(0, 0, 1, 1);
21
        Wt::WPainterPath path;
22
        path.moveTo(0, 0);
23
        path.lineTo(1, 1);
24
        painter.drawPath(path);
25
    }
26
};
27

    
28
class SomePaintedApp : public WApplication {
29
public:
30
    SomePaintedApp(const WEnvironment& env):
31
        WApplication(env) {
32
        SetWindowWidget* png = new SetWindowWidget(root());
33
        png->setPreferredMethod(WPaintedWidget::PngImage);
34
        SetWindowWidget* normal = new SetWindowWidget(root());
35
    }
36
};
37

    
38
WApplication* createSomePaintedApp(const WEnvironment& env) {
39
    return new SomePaintedApp(env);
40
}
41

    
42
int main(int argc, char** argv) {
43
    return WRun(argc, argv, &createSomePaintedApp);
44
}
45

    
(1-1/3)