1
0
Fork 0

layout-props.cxx: hrule/vrule shall be accepted as widgets even if they

have no children (in which case they default to 1px thickness & stretch).
    This allows to just write <hrule/> instead of <hrule><dummy/></hrule>.
    One can still use <hrule><pref-height>3</pref-height></hrule>, of course.
layout.cxx: drop silly do??Box calls for hrule/vrule (yes, I wrote that :-)
This commit is contained in:
mfranz 2007-03-26 15:17:38 +00:00
parent 60516c8a3f
commit f27d7b2340
2 changed files with 12 additions and 8 deletions

View file

@ -42,11 +42,16 @@ LayoutWidget LayoutWidget::parent()
int LayoutWidget::nChildren()
{
// Hack: assume that any non-leaf nodes are widgets...
// Hack: assume that any non-leaf nodes but "hrule" and "vrule"
// are widgets...
int n = 0;
for(int i=0; i<_prop->nChildren(); i++)
if(_prop->getChild(i)->nChildren() != 0)
for(int i=0; i<_prop->nChildren(); i++) {
SGPropertyNode* p = _prop->getChild(i);
const char* name = p->getName();
if(p->nChildren() != 0 || !strcmp(name, "hrule")
|| !strcmp(name, "vrule"))
n++;
}
return n;
}
@ -57,7 +62,9 @@ LayoutWidget LayoutWidget::getChild(int idx)
int n = 0;
for(int i=0; i<_prop->nChildren(); i++) {
SGPropertyNode* p = _prop->getChild(i);
if(p->nChildren() != 0) {
const char* name = p->getName();
if(p->nChildren() != 0 || !strcmp(name, "hrule")
|| !strcmp(name, "vrule")) {
if(idx == n) return LayoutWidget(p);
n++;
}

View file

@ -185,10 +185,7 @@ void LayoutWidget::layout(int x, int y, int w, int h)
if (eq(layout, "hbox" )) doHVBox(true, false);
else if(eq(layout, "vbox" )) doHVBox(true, true);
else if(eq(layout, "table")) doTable(true);
} else if(isType("hrule"))
doHVBox(true, false);
else if(isType("vrule"))
doHVBox(true, true);
}
}
// Convention: the "A" cooridinate refers to the major axis of the