Project

General

Profile

Bug #1236 » set_window.cpp

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

 

#include <Wt/WApplication>
#include <Wt/WPaintedWidget>
#include <Wt/WPainter>
#include <Wt/WPainterPath>

using namespace Wt;

class SetWindowWidget : public WPaintedWidget {
public:
SetWindowWidget(WContainerWidget* p = 0) :
WPaintedWidget(p) {
resize(500, 500);
}

protected:
void paintEvent(WPaintDevice* device) {
Wt::WPainter painter(device);
painter.setWindow(0, 0, 1, 1);
painter.drawEllipse(0, 0, 1, 1);
Wt::WPainterPath path;
path.moveTo(0, 0);
path.lineTo(1, 1);
painter.drawPath(path);
}
};

class SomePaintedApp : public WApplication {
public:
SomePaintedApp(const WEnvironment& env):
WApplication(env) {
SetWindowWidget* png = new SetWindowWidget(root());
png->setPreferredMethod(WPaintedWidget::PngImage);
SetWindowWidget* normal = new SetWindowWidget(root());
}
};

WApplication* createSomePaintedApp(const WEnvironment& env) {
return new SomePaintedApp(env);
}

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

(1-1/3)