use of org.eclipse.draw2d.Label in project yamcs-studio by yamcs.
the class TabFigure method layout.
@Override
protected void layout() {
super.layout();
Rectangle clientArea = getClientArea();
int left = clientArea.x;
int top = clientArea.y;
int width = getTabLabelWidth();
int height = getTabLabelHeight();
int i = 0;
for (Label label : tabLabelList) {
Dimension labelSize = label.getPreferredSize();
if (horizontal) {
if (getActiveTabIndex() == i)
label.setBounds(new Rectangle(left, top, labelSize.width + MARGIN + GAP, height));
else
label.setBounds(new Rectangle(left + GAP, top + 2, labelSize.width + MARGIN - GAP, height - 2));
left += (labelSize.width + MARGIN - 1);
} else {
int labelH = Math.max(labelSize.height, minimumTabHeight);
if (getActiveTabIndex() == i)
label.setBounds(new Rectangle(left, top, width, labelH + MARGIN + GAP));
else
label.setBounds(new Rectangle(left + 2, top + GAP, width - 2, labelH + MARGIN - GAP));
top += (labelH + MARGIN - 1);
}
i++;
}
if (horizontal) {
tabArea.setBounds(new Rectangle(clientArea.x, clientArea.y + height - 1, clientArea.width - 1, clientArea.height - height));
} else {
tabArea.setBounds(new Rectangle(clientArea.x + width - 1, clientArea.y, clientArea.width - width, clientArea.height - 1));
}
}
Aggregations