+void LabelWidget::renderForeground()
+{
+ bool draw = _dirty;
+
+ otk::Widget::renderForeground();
+
+ if (draw) {
+ otk::ustring t = _text;
+ int x = _sidemargin; // x coord for the text
+
+ // find a string that will fit inside the area for text
+ int max_length = width() - _sidemargin * 2;
+ if (max_length <= 0) {
+ t = ""; // can't fit anything
+ } else {
+ size_t text_len = t.size();
+ int length;
+
+ do {
+ t.resize(text_len);
+ length = _font->measureString(t);
+ } while (length > max_length && text_len-- > 0);
+
+ // justify the text
+ switch (_justify) {
+ case otk::RenderStyle::RightJustify:
+ x += max_length - length;
+ break;
+ case otk::RenderStyle::CenterJustify:
+ x += (max_length - length) / 2;
+ break;
+ case otk::RenderStyle::LeftJustify:
+ break;
+ }
+ }
+
+ otk::display->renderControl(_screen)->drawString
+ (*_surface, *_font, x, 0, *_text_color, t);
+ }
+}
+
+
+void LabelWidget::adjust()
+{
+ // nothing to adjust. no children.
+}
+