Yes, this is a bug. Using the Control.setMinSize() method works correctly:
#include <pjsr/Sizer.jsh>
function TestDialog1(minWidth, minHeight)
{
this.__base__ = Dialog;
this.__base__();
this.frame = new Frame(this);
this.frame.backgroundColor=0xff00ff00;
this.frame.setMinSize( (minWidth > 0) ? 400 : 0, (minHeight > 0) ? 400 : 0 );
/*
if(minWidth>0)
this.frame.minWidth=400;
if(minHeight>0)
this.frame.minHeight=400;
*/
// Stack of rows
this.sizer = new VerticalSizer;
this.sizer.margin = 8;
this.sizer.spacing = 6;
this.sizer.add(this.frame);
this.windowTitle = format("mw=%d mh=%d",minWidth,minHeight);
this.adjustToContents();
}
TestDialog1.prototype = new Dialog;
new TestDialog1(0,0).execute();
new TestDialog1(400,0).execute();
new TestDialog1(400,400).execute();
Just for the sake of completeness (and fun), note that the same can be accomplished with pure CSS:
#include <pjsr/Sizer.jsh>
function TestDialog1(minWidth, minHeight)
{
this.__base__ = Dialog;
this.__base__();
this.frame = new Frame(this);
this.frame.styleSheet = "QWidget { background: #00ff00; " +
"min-width: " + ((minWidth > 0) ? 400 : 0).toString() + "px; " +
"min-height: " + ((minHeight > 0) ? 400 : 0).toString() + "px; }";
/*
this.frame.backgroundColor=0xff00ff00;
this.frame.setMinSize( (minWidth > 0) ? 400 : 0, (minHeight > 0) ? 400 : 0 );
*/
/*
if(minWidth>0)
this.frame.minWidth=400;
if(minHeight>0)
this.frame.minHeight=400;
*/
// Stack of rows
this.sizer = new VerticalSizer;
this.sizer.margin = 8;
this.sizer.spacing = 6;
this.sizer.add(this.frame);
this.windowTitle = format("mw=%d mh=%d",minWidth,minHeight);
this.adjustToContents();
}
TestDialog1.prototype = new Dialog;
new TestDialog1(0,0).execute();
new TestDialog1(400,0).execute();
new TestDialog1(400,400).execute();
But of course calling setMinSize(), or setting the minWidth and minHeight properties (when I fix this bug) are obviously much simpler and more readable.
Thanks for catching this one!