diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-02-08 07:37:22 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-02-08 07:37:22 +0000 |
| commit | 17b0266979137ad957a701c7093a14841a8c2091 (patch) | |
| tree | f924d5efcc92a251fcc399ca5523b8792080e21a /src/labelwidget.cc | |
| parent | 1c97e9fb7bede1607b9680d29a791a72b1768019 (diff) | |
No longer using otk widgets for the frame decorations.
The titlebar no long has any buttons, in preparation for a new button system.
Using otk::Size for sizes, and unsigned ints (*PAIN*) we'll see..
Diffstat (limited to 'src/labelwidget.cc')
| -rw-r--r-- | src/labelwidget.cc | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/src/labelwidget.cc b/src/labelwidget.cc deleted file mode 100644 index 020e8b73..00000000 --- a/src/labelwidget.cc +++ /dev/null @@ -1,117 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- - -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif - -#include "otk/screeninfo.hh" -#include "otk/display.hh" -#include "labelwidget.hh" - -namespace ob { - -LabelWidget::LabelWidget(otk::Widget *parent, WidgetBase::WidgetType type) - : otk::Widget(parent), - WidgetBase(type) -{ -} - - -LabelWidget::~LabelWidget() -{ -} - - -void LabelWidget::setText(const otk::ustring &text) -{ - _text = text; - _dirty = true; -} - - -void LabelWidget::setTextures() -{ - if (_focused) { - setTexture(_style->labelFocusBackground()); - _text_color = _style->textFocusColor(); - } else { - setTexture(_style->labelUnfocusBackground()); - _text_color = _style->textUnfocusColor(); - } -} - - -void LabelWidget::setStyle(otk::RenderStyle *style) -{ - otk::Widget::setStyle(style); - setTextures(); - _font = style->labelFont(); - _sidemargin = style->bevelWidth() * 2; - _justify = style->labelTextJustify(); - - assert(_font); -} - - -void LabelWidget::focus() -{ - otk::Widget::focus(); - setTextures(); -} - - -void LabelWidget::unfocus() -{ - otk::Widget::unfocus(); - setTextures(); -} - - -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. -} - -} |
