// This file contains the actual layout engine. It has no dependence
// on outside libraries; see layout-props.cxx for the glue code.
// This file contains the actual layout engine. It has no dependence
// on outside libraries; see layout-props.cxx for the glue code.
// <default-padding> property, or per widget with <padding>.
int LayoutWidget::padding()
{
// <default-padding> property, or per widget with <padding>.
int LayoutWidget::padding()
{
// As comments above note, this was being set to 2. For some
// reason this causes the dialogs to shrink on subsequent pops
// so for now we'll make "dialog" padding 0.
// As comments above note, this was being set to 2. For some
// reason this causes the dialogs to shrink on subsequent pops
// so for now we'll make "dialog" padding 0.
if(!hasField("layout")) {
// Legacy support for groups without layout managers.
if(hasField("width")) *w = getNum("width");
if(!hasField("layout")) {
// Legacy support for groups without layout managers.
if(hasField("width")) *w = getNum("width");
// Set up geometry such that the widget lives "inside" the specified
void LayoutWidget::layout(int x, int y, int w, int h)
{
// Set up geometry such that the widget lives "inside" the specified
void LayoutWidget::layout(int x, int y, int w, int h)
{
if(hasField("valign")) valign = getStr("valign");
if(eq(valign, "bottom")) {
h = prefh;
if(hasField("valign")) valign = getStr("valign");
if(eq(valign, "bottom")) {
h = prefh;
// the x/y/w/h box we have calculated.
if (isType("text")) {
// puText labels are layed out to the right of the box, so
// the x/y/w/h box we have calculated.
if (isType("text")) {
// puText labels are layed out to the right of the box, so
int nEq = 0, eqA = 0, eqB = 0, eqTotalA = 0;
for(i=0; i<nc; i++) {
LayoutWidget child = getChild(i);
int nEq = 0, eqA = 0, eqB = 0, eqTotalA = 0;
for(i=0; i<nc; i++) {
LayoutWidget child = getChild(i);
int a, b;
child.calcPrefSize(vertical ? &b : &a, vertical ? &a : &b);
if(doLayout) prefA[i] = a;
int a, b;
child.calcPrefSize(vertical ? &b : &a, vertical ? &a : &b);
if(doLayout) prefA[i] = a;
// from top to bottom instead of along the cartesian Y axis.
int idx = vertical ? (nc-i-1) : i;
LayoutWidget child = getChild(idx);
// from top to bottom instead of along the cartesian Y axis.
int idx = vertical ? (nc-i-1) : i;
LayoutWidget child = getChild(idx);
if(child.getBool("equal")) {
int pad = child.padding();
prefA[idx] = eqA + 2*pad;
if(child.getBool("equal")) {
int pad = child.padding();
prefA[idx] = eqA + 2*pad;