Project

General

Profile

Bug #1627 » dialogSizeTest.cpp

test case - Jan Hrubeš, 01/08/2013 09:51 AM

 
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WPushButton>
#include <Wt/WDialog>
#include <Wt/WEnvironment>
#include <Wt/WText>

using namespace Wt;

class TestApplication : public WApplication
{
public:
TestApplication(const WEnvironment& env);

private:
void addDivBar(const WLength &width, const WLength &height, const WColor &color);
};



TestApplication::TestApplication(const WEnvironment& env)
: WApplication(env)
{
setCssTheme("polished");

WString txt = "Insert some long text with multiple paragraphs.";

WDialog* dlg = new WDialog("Dialog");
dlg->contents()->addWidget(new WText(txt, XHTMLText));
dlg->contents()->setOverflow(WContainerWidget::OverflowAuto,Vertical|Horizontal);
WLength lmax(600), lset(300), lmin(100);

dlg->setMaximumSize( lmax, lmax);
dlg->setMinimumSize( lmin, lmin);
dlg->resize( lset, lset); // malfunctional
dlg->setModal(false);
dlg->setResizable(true);
dlg->setClosable(true);

WPushButton* bt = new WPushButton("show dialog", root());
bt->clicked().connect(dlg, &WDialog::show);
bt->clicked().connect(boost::bind(&WDialog::resize,dlg,lset,lset)); // malfunctional

addDivBar(lmax, lmax, WColor(155,185,230,255));
addDivBar(lset, lset, WColor(150,175,210,255));
addDivBar(lmin, lmin, WColor(146,165,192,255));

dlg->show();

}

void TestApplication::addDivBar(const WLength &width, const WLength &height, const WColor &color)
{
WCssDecorationStyle style;
style.setBackgroundColor(color);
WContainerWidget* ct = new WContainerWidget(root());
ct->setPositionScheme(Absolute);
ct->resize(width,height);
ct->setDecorationStyle(style);
}

WApplication *createApplication(const WEnvironment& env)
{
return new TestApplication(env);
}

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

    (1-1/1)