Hi all,
I have a widget that's very wide, so I used the WScrollArea to provide user
access to all the content. I would expect that the scrolled content would
not influence the width of the WScrollArea itself, but it will by default. I
have attached an example to illustrate the issue.
Thanks,
JDR
--
=============================================================
John D. Robertson, Computer / Engineering Consultant
Robertson & Robertson Consultants, Inc.
3637 West Georgia Rd.
Pelzer, SC 29669
Phone: (864) 243-2436
Email: j...@rrci.com
WWW: http://www.rrci.com
Blog: http://oopinc.blogspot.com
#include <Wt/WApplication>
#include <Wt/WScrollArea>
#include <Wt/WLabel>
#include <Wt/WTabWidget>
#include <Wt/WHBoxLayout>
#include <Wt/WVBoxLayout>
#include <Wt/WContainerWidget>
using namespace Wt;
using namespace std;
class App : public Wt::WApplication
{
public:
App(const Wt::WEnvironment& env);
};
App::App(const Wt::WEnvironment& env)
/**********************************************************
* Constructor for App.
*/
: WApplication(env)
{
setTitle("WScrollArea example v0.0");
WVBoxLayout *vbl= new WVBoxLayout;
root()->setLayout(vbl, AlignTop);
{ /* I assert this should be true */
WLabel *lbl= new WLabel("Width of the WContainerWidget managed by WScrollArea should not affect width of parent widgets.", root());
vbl->addWidget(lbl);
}
{ /* WScrollArea to manage widget with wide content */
WScrollArea *sa= new WScrollArea(root());
vbl->addWidget(sa);
sa->setHorizontalScrollBarPolicy(WScrollArea::ScrollBarAlwaysOn);
// This will work, but max width is now tied to font size
// sa->setMaximumSize(WLength(30, WLength::FontEm), WLength());
{ /* Here is the widget with wide content */
WContainerWidget *cw= new WContainerWidget;
sa->setWidget(cw);
WHBoxLayout *hbl= new WHBoxLayout;
cw->setLayout(hbl);
for(int i= 0; i < 20; i++) {
stringstream ss;
if(i) ss << " | ";
ss << "Content #" << i;
WLabel *lbl= new WLabel(ss.str(), cw);
hbl->addWidget(lbl);
}
}
}
}
WApplication* createApplication(const WEnvironment& env)
/**********************************************************
* Creates a new instance of App for each thread.
*/
{
return new App(env);
}
int
main(int argc, char **argv)
/**********************************************************
* This is where execution begins.
*/
{
return WRun(argc, argv, &createApplication);
}
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest