X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Flabelwidget.cc;h=020e8b73ca50d3e6acaef7ea9f0166a27d021a76;hb=5face4c6f35172761367f63ac0b6eaf62d84e532;hp=9ff45298a834f59a5bcc4f17c91169f217e33b5f;hpb=77ab46d1e35d48e73c201e6de88b26f48bb06425;p=chaz%2Fopenbox diff --git a/src/labelwidget.cc b/src/labelwidget.cc index 9ff45298..020e8b73 100644 --- a/src/labelwidget.cc +++ b/src/labelwidget.cc @@ -1,5 +1,4 @@ // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- #ifdef HAVE_CONFIG_H # include "../config.h" @@ -15,19 +14,15 @@ 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::display, _window, info->visual(), - info->colormap()); } LabelWidget::~LabelWidget() { - XftDrawDestroy(_xftdraw); } -void LabelWidget::setText(const std::string &text) +void LabelWidget::setText(const otk::ustring &text) { _text = text; _dirty = true; @@ -37,23 +32,24 @@ void LabelWidget::setText(const std::string &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(); } @@ -71,14 +67,14 @@ void LabelWidget::unfocus() } -void LabelWidget::update() +void LabelWidget::renderForeground() { bool draw = _dirty; - otk::Widget::update(); + otk::Widget::renderForeground(); if (draw) { - std::string t = _text; + otk::ustring t = _text; int x = _sidemargin; // x coord for the text // find a string that will fit inside the area for text @@ -96,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); } }