Skip to content

Instantly share code, notes, and snippets.

@shaina7837
Created July 17, 2013 17:17
Show Gist options
  • Save shaina7837/6022540 to your computer and use it in GitHub Desktop.
Save shaina7837/6022540 to your computer and use it in GitHub Desktop.
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WPainter>
#include <Wt/WPaintedWidget>
#include <Wt/WPaintDevice>
using namespace Wt;
using namespace std;
class PaintApplication : public WPaintedWidget //Paint class
{
int angle_,size_;
public: PaintApplication(WContainerWidget *parent)
: WPaintedWidget(parent),
angle_(0),size_(1)
{
resize(710, 400);
}
void paintEvent(WPaintDevice *paintDevice) //function to draw rectangle
{
WPainter painter(paintDevice);
painter.setBrush(Wt::WBrush(Wt::WBrush(Wt::red)));
painter.drawRect(10,10,180,180);
}
void setRelativeSize(double);
};
void PaintApplication::setRelativeSize(double size) //function to define size of rectangle
{
size = std::max(0.1, std::min(1.0, size));
if (size_ != size) {
size_ = size;
update();
}
}
class MyApplication : public WApplication //main Application Class
{
PaintApplication *shapes_;
public: MyApplication(const WEnvironment &env): WApplication(env) {
setTitle("Paint example");
new PaintApplication(root());
}
};
WApplication *createApplication(const WEnvironment& env)
{
return new MyApplication(env);
}
int main(int argc, char **argv)
{
return WRun(argc, argv, &createApplication);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment