X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Flabelwidget.cc;h=020e8b73ca50d3e6acaef7ea9f0166a27d021a76;hb=5face4c6f35172761367f63ac0b6eaf62d84e532;hp=d76bd3f13f522046659adac6ef7e4855625ee2af;hpb=cdcc526a0274cace9f542960fe4eee4ddcc23d31;p=chaz%2Fopenbox diff --git a/src/labelwidget.cc b/src/labelwidget.cc index d76bd3f1..020e8b73 100644 --- a/src/labelwidget.cc +++ b/src/labelwidget.cc @@ -14,15 +14,11 @@ LabelWidget::LabelWidget(otk::Widget *parent, WidgetBase::WidgetType type) : otk::Widget(parent), WidgetBase(type) { - const otk::ScreenInfo *info = otk::display->screenInfo(_screen); - _xftdraw = XftDrawCreate(**otk::display, _window, info->visual(), - info->colormap()); } LabelWidget::~LabelWidget() { - XftDrawDestroy(_xftdraw); } @@ -36,23 +32,24 @@ void LabelWidget::setText(const otk::ustring &text) 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 LabelWidget::setStyle(otk::Style *style) +void LabelWidget::setStyle(otk::RenderStyle *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(); } @@ -70,11 +67,11 @@ void LabelWidget::unfocus() } -void LabelWidget::update() +void LabelWidget::renderForeground() { bool draw = _dirty; - otk::Widget::update(); + otk::Widget::renderForeground(); if (draw) { otk::ustring t = _text; @@ -95,18 +92,19 @@ void LabelWidget::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; } } - _font->drawString(_xftdraw, x, 0, *_text_color, t); + otk::display->renderControl(_screen)->drawString + (*_surface, *_font, x, 0, *_text_color, t); } }