Hey Joseph,

2009/8/19 Joseph VanAndel <[email protected]>:
>> If I leave a dialog box visible (don't dismiss it), it gradually
>> grows vertically.

This a common gotcha with layout managers. A layout manager can only
manage layout vertically if the container has its vertical size
constrained, which is not the case for your dialog.

There are a number of ways to deal with this.

The following is the straight forward solution, in which you do not
let the layout manager manage the height, by using
container->setLayout(..., AlignTop | ...). This makes it look ugly
though. If you want the grid layout to equalize the height of every
row, then you need to let the layout manager manage the height (see
further).

--- dialogDemo.C        2009-08-20 09:02:56.000000000 +0200
+++ dialogDemo.C.new    2009-08-20 09:02:45.000000000 +0200
@@ -401,13 +401,13 @@
     if (buttonId < 0) return;

     WDialog    dialog("Edit the PPI Parameters");
-    dialog.setMinimumSize(700,500);
+    //dialog.setMinimumSize(700,500);

     WContainerWidget *container = new WContainerWidget(dialog.contents());
     //  container->resize(WLength(), 400);
     container->setStyleClass("yellow-box");
     WGridLayout *grid = new WGridLayout();
-    container->setLayout(grid);
+    container->setLayout(grid, AlignTop | AlignJustify);
     // WButtonGroup *buttonGroup= new WButtonGroup(grid);

     char buffer[20];

Any alternative will require you to specify a size for either the
dialog or the dialog contents, and make sure that everything is linked
together using layout managers, thus using a layout managers on
dialog.contents().

The following is a patch which solves it in that way:

--- /home/koen/tmp/dialogDemo.C 2009-08-20 09:23:28.000000000 +0200
+++ dialogDemo.C        2009-08-20 09:20:31.000000000 +0200
@@ -401,13 +401,13 @@
     if (buttonId < 0) return;

     WDialog    dialog("Edit the PPI Parameters");
-    dialog.setMinimumSize(700,500);

-    WContainerWidget *container = new WContainerWidget(dialog.contents());
-    //  container->resize(WLength(), 400);
-    container->setStyleClass("yellow-box");
+    WVBoxLayout *contentsLayout = new WVBoxLayout();
+    dialog.contents()->setLayout(contentsLayout);
+    dialog.contents()->resize(WLength(), 400);
+
     WGridLayout *grid = new WGridLayout();
-    container->setLayout(grid);
+    contentsLayout->addLayout(grid, 1);
     // WButtonGroup *buttonGroup= new WButtonGroup(grid);

     char buffer[20];
@@ -457,10 +457,11 @@
     grid->addWidget(ant_rate_txt, row, 0);
     grid->addWidget(ant_rate_le, row++, 1);

-    new WBreak(dialog.contents());
-    WPushButton ok("OK", dialog.contents());
+    WContainerWidget *buttons = new WContainerWidget();
+    contentsLayout->addWidget(buttons);
+    WPushButton ok("OK", buttons);
     ok.clicked().connect(SLOT(&dialog, WDialog::accept));
-    WPushButton cancel("Cancel", dialog.contents());
+    WPushButton cancel("Cancel", buttons);
     cancel.clicked().connect(SLOT(&dialog, WDialog::reject));

     WButtonGroup aListGroup(grid);

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to