Created
July 17, 2013 17:17
-
-
Save shaina7837/6022540 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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