|
#include "paint_test_widget.h"
|
|
|
|
#include <Wt/WPainter>
|
|
#include <Wt/WPaintDevice>
|
|
#include <Wt/WHBoxLayout>
|
|
#include <Wt/WVBoxLayout>
|
|
#include <stdio.h>
|
|
|
|
paint_test_widget::paint_test_widget(WContainerWidget *parent__ )
|
|
: WPaintedWidget(parent__)
|
|
{
|
|
max_heigth_ = 500;
|
|
max_width_ = 500;
|
|
|
|
//this->setHeight(max_heigth_);
|
|
//this->setWidth(max_width_);
|
|
//this->setMinimumSize(WLength::Auto, WLength::Auto); // HAS TO BE SET!!!!
|
|
//this->setMaximumSize(WLength::Auto, WLength::Auto);
|
|
//this->setHeight(100); // removeme
|
|
|
|
this->setStyleClass("paint_test_widget");
|
|
printf("test_constructor\n");
|
|
}
|
|
|
|
void paint_test_widget::paintEvent(WPaintDevice *paintDevice__) {
|
|
WPainter painter__(paintDevice__);
|
|
painter__.setBrush(WColor(145,172,188));
|
|
painter__.setPen(WColor(145,172,188));
|
|
max_width_ = paintDevice__->width().toPixels();
|
|
max_heigth_ = (1.0 / (double)max_width_) * 500000;
|
|
printf("height: %i width: %i\n", max_heigth_, max_width_);
|
|
container->setHeight(max_heigth_);
|
|
painter__.drawRect(0, 0, max_width_, max_heigth_);
|
|
}
|
|
|
|
|
|
void paint_test_widget::set_container_widget(WContainerWidget *container__)
|
|
{
|
|
container=container__;
|
|
}
|
|
|
|
#include <Wt/WApplication>
|
|
#include <Wt/WLabel>
|
|
#include <Wt/WPushButton>
|
|
#include <Wt/WContainerWidget>
|
|
#include <iostream>
|
|
|
|
using namespace Wt;
|
|
|
|
class Test : public WApplication
|
|
{
|
|
public:
|
|
Test(const WEnvironment& env)
|
|
: WApplication(env)
|
|
{
|
|
WContainerWidget *rootcontainer__ = new WContainerWidget();
|
|
WHBoxLayout *rootlayout = new WHBoxLayout();
|
|
|
|
WContainerWidget *container= new WContainerWidget();
|
|
container->setHeight(20);
|
|
WVBoxLayout *containerlayout = new WVBoxLayout();
|
|
container->setLayout(containerlayout);
|
|
|
|
paint_test_widget *test = new paint_test_widget();
|
|
test->set_container_widget(container);
|
|
containerlayout->addWidget(test);
|
|
|
|
rootlayout->addWidget(container);
|
|
rootcontainer__->setLayout(rootlayout, AlignTop | AlignJustify);
|
|
rootcontainer__->setOverflow(WContainerWidget::OverflowAuto);
|
|
|
|
root()->addWidget(rootcontainer__);
|
|
}
|
|
|
|
void foo() {
|
|
}
|
|
};
|
|
|
|
WApplication *createApplication(const WEnvironment& env){
|
|
return new Test(env);
|
|
}
|
|
|
|
int main(int argc, char *argv[]){
|
|
return WRun(argc, argv, createApplication);
|
|
}
|
|
|