X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Flabelwidget.cc;h=020e8b73ca50d3e6acaef7ea9f0166a27d021a76;hb=ff98438acca3ae7ca0b2be66cb39cc29643ecaba;hp=5a33cf3dd0bfdf78e857d74ee587504b8c78ee76;hpb=2ae2b257d39ea62640c2590f794e4275c6db1cd4;p=chaz%2Fopenbox diff --git a/src/labelwidget.cc b/src/labelwidget.cc index 5a33cf3d..020e8b73 100644 --- a/src/labelwidget.cc +++ b/src/labelwidget.cc @@ -10,70 +10,71 @@ namespace ob { -OBLabelWidget::OBLabelWidget(otk::OtkWidget *parent, OBWidget::WidgetType type) - : otk::OtkWidget(parent), - OBWidget(type) +LabelWidget::LabelWidget(otk::Widget *parent, WidgetBase::WidgetType type) + : otk::Widget(parent), + WidgetBase(type) { - const otk::ScreenInfo *info = otk::OBDisplay::screenInfo(_screen); - _xftdraw = XftDrawCreate(otk::OBDisplay::display, _window, info->visual(), - info->colormap()); } -OBLabelWidget::~OBLabelWidget() +LabelWidget::~LabelWidget() { - XftDrawDestroy(_xftdraw); } -void OBLabelWidget::setText(const std::string &text) +void LabelWidget::setText(const otk::ustring &text) { _text = text; _dirty = true; } -void OBLabelWidget::setTextures() +void LabelWidget::setTextures() { if (_focused) { - setTexture(_style->getLabelFocus()); - _text_color = _style->getTextFocus(); + setTexture(_style->labelFocusBackground()); + _text_color = _style->textFocusColor(); } else { - setTexture(_style->getLabelUnfocus()); - _text_color = _style->getTextUnfocus(); + setTexture(_style->labelUnfocusBackground()); + _text_color = _style->textUnfocusColor(); } } -void OBLabelWidget::setStyle(otk::Style *style) +void LabelWidget::setStyle(otk::RenderStyle *style) { - OtkWidget::setStyle(style); + otk::Widget::setStyle(style); setTextures(); - _font = style->getFont(); + _font = style->labelFont(); + _sidemargin = style->bevelWidth() * 2; + _justify = style->labelTextJustify(); + assert(_font); - _sidemargin = style->getBevelWidth() * 2; - _justify = style->textJustify(); } -void OBLabelWidget::focus() +void LabelWidget::focus() { - otk::OtkWidget::focus(); + otk::Widget::focus(); setTextures(); } -void OBLabelWidget::unfocus() +void LabelWidget::unfocus() { - otk::OtkWidget::unfocus(); + otk::Widget::unfocus(); setTextures(); } -void OBLabelWidget::update() +void LabelWidget::renderForeground() { - if (_dirty) { - std::string t = _text; + 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 @@ -91,28 +92,26 @@ void OBLabelWidget::update() // justify the text switch (_justify) { - case otk::Style::RightJustify: + case otk::RenderStyle::RightJustify: x += max_length - length; break; - case otk::Style::CenterJustify: + case otk::RenderStyle::CenterJustify: x += (max_length - length) / 2; break; - case otk::Style::LeftJustify: + case otk::RenderStyle::LeftJustify: break; } } - OtkWidget::update(); - - _font->drawString(_xftdraw, x, 0, *_text_color, t); - } else - OtkWidget::update(); + otk::display->renderControl(_screen)->drawString + (*_surface, *_font, x, 0, *_text_color, t); + } } -void OBLabelWidget::adjust() +void LabelWidget::adjust() { - // XXX: adjust shit + // nothing to adjust. no children. } }