+void OBFrame::adjustSize()
+{
+ // XXX: only if not overridden or something!!! MORE LOGIC HERE!!
+ _decorations = _client->decorations();
+ _decorations = 0xffffffff;
+
+ int width; // the width of the client and its border
+ int bwidth; // width to make borders
+ int cbwidth; // width of the inner client border
+ const int bevel = _style->getBevelWidth();
+
+ if (_decorations & OBClient::Decor_Border) {
+ bwidth = _style->getBorderWidth();
+ cbwidth = _style->getFrameWidth();
+ } else
+ bwidth = cbwidth = 0;
+ _innersize.left = _innersize.top = _innersize.bottom = _innersize.right =
+ cbwidth;
+ width = _client->area().width() + cbwidth * 2;
+
+ _plate.setBorderWidth(cbwidth);
+
+ setBorderWidth(bwidth);
+ _titlebar.setBorderWidth(bwidth);
+ _grip_left.setBorderWidth(bwidth);
+ _grip_right.setBorderWidth(bwidth);
+ _handle.setBorderWidth(bwidth);
+
+ if (_decorations & OBClient::Decor_Titlebar) {
+ // set the titlebar size
+ _titlebar.setGeometry(-bwidth,
+ -bwidth,
+ width,
+ _style->getFont()->height() + bevel * 2);
+ _innersize.top += _titlebar.height() + bwidth;
+
+ // set the label size
+ _label.setGeometry(0, bevel, width, _style->getFont()->height());
+ // set the buttons sizes
+ if (_decorations & OBClient::Decor_Iconify)
+ _button_iconify.setGeometry(0, bevel + 1,
+ _label.height() - 2,
+ _label.height() - 2);
+ if (_decorations & OBClient::Decor_Maximize)
+ _button_max.setGeometry(0, bevel + 1,
+ _label.height() - 2,
+ _label.height() - 2);
+ if (_decorations & OBClient::Decor_Sticky)
+ _button_stick.setGeometry(0, bevel + 1,
+ _label.height() - 2,
+ _label.height() - 2);
+ if (_decorations & OBClient::Decor_Close)
+ _button_close.setGeometry(0, bevel + 1,
+ _label.height() - 2,
+ _label.height() - 2);
+
+ // separation between titlebar elements
+ const int sep = bevel + 1;
+
+ std::string layout = "SLIMC"; // XXX: get this from somewhere
+ // XXX: it is REQUIRED that by this point, the string only has one of each
+ // possible letter, all of the letters are valid, and L exists somewhere in
+ // the string!
+
+ // the size of the label. this ASSUMES the layout has only buttons other
+ // that the ONE LABEL!!
+ // adds an extra sep so that there's a space on either side of the
+ // titlebar.. note: x = sep, below.
+ int lwidth = width - sep * 2 -
+ (_button_iconify.width() + sep) * (layout.size() - 1);
+ // quick sanity check for really small windows. if this is needed, its
+ // obviously not going to be displayed right...
+ // XXX: maybe we should make this look better somehow? constraints?
+ if (lwidth <= 0) lwidth = 1;
+ _label.setWidth(lwidth);
+
+ int x = sep;
+ for (int i = 0, len = layout.size(); i < len; ++i) {
+ switch (layout[i]) {
+ case 'I':
+ _button_iconify.move(x, _button_iconify.rect().y());
+ x += _button_iconify.width();
+ break;
+ case 'L':
+ _label.move(x, _label.rect().y());
+ x += _label.width();
+ break;
+ case 'M':
+ _button_max.move(x, _button_max.rect().y());
+ x += _button_max.width();
+ break;
+ case 'S':
+ _button_stick.move(x, _button_stick.rect().y());
+ x += _button_stick.width();
+ break;
+ case 'C':
+ _button_close.move(x, _button_close.rect().y());
+ x += _button_close.width();
+ break;
+ default:
+ assert(false); // the layout string is invalid!
+ }
+ x += sep;
+ }
+ }
+
+ if (_decorations & OBClient::Decor_Handle) {
+ _handle.setGeometry(-bwidth,
+ _innersize.top + _client->area().height() + cbwidth,
+ width, _style->getHandleWidth());
+ _grip_left.setGeometry(-bwidth,
+ -bwidth,
+ // XXX: get a Point class in otk and use that for
+ // the 'buttons size' since theyre all the same
+ _button_iconify.width() * 2,
+ _handle.height());
+ _grip_right.setGeometry(((_handle.rect().right() + 1) -
+ _button_iconify.width() * 2),
+ -bwidth,
+ // XXX: get a Point class in otk and use that for
+ // the 'buttons size' since theyre all the same
+ _button_iconify.width() * 2,
+ _handle.height());
+ _innersize.bottom += _handle.height() + bwidth;
+ }
+
+
+ // position/size all the windows
+
+ resize(_innersize.left + _innersize.right + _client->area().width(),
+ _innersize.top + _innersize.bottom + _client->area().height());
+
+ _plate.setGeometry(_innersize.left - cbwidth, _innersize.top - cbwidth,
+ _client->area().width(), _client->area().height());
+
+ // map/unmap all the windows
+ if (_decorations & OBClient::Decor_Titlebar) {
+ _label.show();
+ if (_decorations & OBClient::Decor_Iconify)
+ _button_iconify.show();
+ else
+ _button_iconify.hide();
+ if (_decorations & OBClient::Decor_Maximize)
+ _button_max.show();
+ else
+ _button_max.hide();
+ if (_decorations & OBClient::Decor_Sticky)
+ _button_stick.show();
+ else
+ _button_stick.hide();
+ if (_decorations & OBClient::Decor_Close)
+ _button_close.show();
+ else
+ _button_close.hide();
+ _titlebar.show();
+ } else {
+ _titlebar.hide(true);