Image is growing with every update
Added by Markus Wolters over 12 years ago
Hi,
I've created a class messagebox derived from WContainerWidget, holding two WContainerWidget (notify and contentdata) itself. From my application a timer is calling
void messagebox::blink(tBlinkState state) {
if(bIsNotificationActive == false)
return;
if(state == On) {
notify->setHidden(false);
} else {
notify->setHidden(true);
}
}
every second. In a second class derived from messagebox I add an image at session start.
WContainerWidget *cwToday = new WContainerWidget();
Wt::WGridLayout *layout = new Wt::WGridLayout();
layout->addWidget(new WImage("css/images/weather/" + (*wdays.begin())->cond_image), 0, 0, 1, 2, AlignCenter);
layout->addWidget(new Wt::WText("Item 1 0"), 1, 0);
layout->addWidget(new Wt::WText("Item 1 1"), 1, 1);
cwToday->setLayout(layout);
contentdata->addWidget(cwToday);
My problem is, that every time the blink function is called, the cond_image is growing, even if no update should happen because bIsNotificationActive is set to false. Does this behavior make any sense to you?
Thanks in advance
Markus
Replies (1)
RE: Image is growing with every update - Added by Koen Deforche over 12 years ago
Hey,
The reason is the layout. From WGridLayout reference documentation:
If you want to use the layout manager for a container which does not have a height that is constrained somehow, you need to specify AlignTop in the alignment flags of WContainerWidget::setLayout(). Otherwise the behavior is undefined (the parent container will continue to increase in size as it tries to satisfy the constraints assuming a contrained height).
In your case, you'll thus need:
cwToday->setLayout(layout, AlignTop | AlignJustify);
Regards,
koen