+ adjustShape();
+}
+
+void Frame::renderLabel()
+{
+ const otk::RenderStyle *style = otk::RenderStyle::style(_client->screen());
+ const otk::RenderControl *control =
+ otk::display->renderControl(_client->screen());
+ const otk::Font *font = style->labelFont();
+
+ otk::Surface *s = new otk::Surface(_client->screen(),
+ otk::Size(geom.label_width,
+ geom.label_height()));
+ control->drawBackground(*s, *(_client->focused() ?
+ style->labelFocusBackground() :
+ style->labelUnfocusBackground()));
+
+ otk::ustring t = _client->title(); // the actual text to draw
+ int x = geom.bevel; // x coord for the text
+
+ if (x * 2 < geom.label_width) {
+ // find a string that will fit inside the area for text
+ otk::ustring::size_type text_len = t.size();
+ int length;
+ int maxsize = geom.label_width - geom.bevel * 2;
+
+ do {
+ t.resize(text_len);
+ length = font->measureString(t);// this returns an unsigned, so check < 0
+ if (length < 0) length = maxsize;// if the string's that long just adjust
+ } while (length > maxsize && text_len-- > 0);
+
+ // justify the text
+ switch (style->labelTextJustify()) {
+ case otk::RenderStyle::RightBottomJustify:
+ x += maxsize - length;
+ break;
+ case otk::RenderStyle::CenterJustify:
+ x += (maxsize - length) / 2;
+ break;
+ case otk::RenderStyle::LeftTopJustify:
+ break;
+ }
+
+ if (text_len > 0)
+ control->drawString(*s, *font, x, 0,
+ *(_client->focused() ? style->textFocusColor() :
+ style->textUnfocusColor()), t);
+ }
+
+ XSetWindowBackgroundPixmap(**otk::display, _label, s->pixmap());
+ XClearWindow(**otk::display, _label);
+ if (_label_sur) delete _label_sur;
+ s->freePixelData();
+ _label_sur = s;
+}
+
+static void renderButton(int screen, bool focus, bool press, Window win,
+ otk::Surface **sur, int butsize,
+ const otk::PixmapMask *mask)
+{
+ const otk::RenderStyle *style = otk::RenderStyle::style(screen);
+ const otk::RenderControl *control = otk::display->renderControl(screen);
+ otk::Surface *s = new otk::Surface(screen, otk::Size(butsize, butsize));
+
+ const otk::RenderTexture *tx = (focus ?
+ (press ?
+ style->buttonPressFocusBackground() :
+ style->buttonUnpressFocusBackground()) :
+ (press ?
+ style->buttonPressUnfocusBackground() :
+ style->buttonUnpressUnfocusBackground()));
+ const otk::RenderColor *maskcolor = (focus ?
+ style->buttonFocusColor() :
+ style->buttonUnfocusColor());
+ control->drawBackground(*s, *tx);
+ control->drawMask(*s, *maskcolor, *mask);
+
+ XSetWindowBackgroundPixmap(**otk::display, win, s->pixmap());
+ XClearWindow(**otk::display, win);
+ if (*sur) delete *sur;
+ s->freePixelData();
+ *sur = s;
+}
+
+void Frame::renderMax()
+{
+ if (!(_decorations & Client::Decor_Maximize)) return;
+ bool press = _max_press || _client->maxVert() || _client->maxHorz();
+ renderButton(_client->screen(), _client->focused(), press, _max,
+ &_max_sur, geom.button_size,
+ otk::RenderStyle::style(_client->screen())->maximizeMask());
+}
+
+void Frame::renderDesk()
+{
+ if (!(_decorations & Client::Decor_AllDesktops)) return;
+ bool press = _desk_press || _client->desktop() == 0xffffffff;
+ renderButton(_client->screen(), _client->focused(), press, _desk,
+ &_desk_sur, geom.button_size,
+ otk::RenderStyle::style(_client->screen())->alldesktopsMask());
+}
+
+void Frame::renderIconify()
+{
+ if (!(_decorations & Client::Decor_Iconify)) return;
+ renderButton(_client->screen(), _client->focused(), _iconify_press, _iconify,
+ &_iconify_sur, geom.button_size,
+ otk::RenderStyle::style(_client->screen())->iconifyMask());
+}