#include <labelwidget.hh>
Inheritance diagram for ob::LabelWidget:
Public Methods | |
LabelWidget (otk::Widget *parent, WidgetBase::WidgetType type) | |
virtual | ~LabelWidget () |
virtual void | setStyle (otk::RenderStyle *style) |
virtual void | adjust () |
virtual void | focus () |
virtual void | unfocus () |
virtual void | renderForeground () |
const otk::ustring & | text () const |
void | setText (const otk::ustring &text) |
Private Methods | |
void | setTextures () |
Private Attributes | |
const otk::Font * | _font |
otk::RenderColor * | _text_color |
int | _sidemargin |
otk::RenderStyle::TextJustify | _justify |
otk::ustring | _text |
|
Definition at line 13 of file labelwidget.cc.
00014 : otk::Widget(parent), 00015 WidgetBase(type) 00016 { 00017 } |
|
Definition at line 20 of file labelwidget.cc.
00021 { 00022 } |
|
Reimplemented from otk::Widget. Definition at line 112 of file labelwidget.cc.
00113 {
00114 // nothing to adjust. no children.
00115 }
|
|
Reimplemented from otk::Widget. Definition at line 56 of file labelwidget.cc. References otk::Widget::focus(), and setTextures().
00057 { 00058 otk::Widget::focus(); 00059 setTextures(); 00060 } |
|
Reimplemented from otk::Widget. Definition at line 70 of file labelwidget.cc. References otk::Widget::_dirty, _font, _sidemargin, otk::Widget::_surface, _text, _text_color, otk::RenderStyle::CenterJustify, otk::RenderStyle::LeftJustify, otk::Font::measureString(), otk::Widget::renderForeground(), otk::ustring::resize(), otk::RenderStyle::RightJustify, otk::ustring::size(), and otk::Widget::width().
00071 { 00072 bool draw = _dirty; 00073 00074 otk::Widget::renderForeground(); 00075 00076 if (draw) { 00077 otk::ustring t = _text; 00078 int x = _sidemargin; // x coord for the text 00079 00080 // find a string that will fit inside the area for text 00081 int max_length = width() - _sidemargin * 2; 00082 if (max_length <= 0) { 00083 t = ""; // can't fit anything 00084 } else { 00085 size_t text_len = t.size(); 00086 int length; 00087 00088 do { 00089 t.resize(text_len); 00090 length = _font->measureString(t); 00091 } while (length > max_length && text_len-- > 0); 00092 00093 // justify the text 00094 switch (_justify) { 00095 case otk::RenderStyle::RightJustify: 00096 x += max_length - length; 00097 break; 00098 case otk::RenderStyle::CenterJustify: 00099 x += (max_length - length) / 2; 00100 break; 00101 case otk::RenderStyle::LeftJustify: 00102 break; 00103 } 00104 } 00105 00106 otk::display->renderControl(_screen)->drawString 00107 (*_surface, *_font, x, 0, *_text_color, t); 00108 } 00109 } |
|
Reimplemented from otk::Widget. Definition at line 44 of file labelwidget.cc. References _font, _justify, _sidemargin, otk::RenderStyle::bevelWidth(), otk::RenderStyle::labelFont(), otk::RenderStyle::labelTextJustify(), otk::Widget::setStyle(), and setTextures().
00045 { 00046 otk::Widget::setStyle(style); 00047 setTextures(); 00048 _font = style->labelFont(); 00049 _sidemargin = style->bevelWidth() * 2; 00050 _justify = style->labelTextJustify(); 00051 00052 assert(_font); 00053 } |
|
Definition at line 25 of file labelwidget.cc. References otk::Widget::_dirty, and _text. Referenced by ob::Frame::Frame(), and ob::Frame::setTitle().
|
|
Definition at line 32 of file labelwidget.cc. References otk::Widget::_style, _text_color, and otk::Widget::setTexture(). Referenced by focus(), setStyle(), and unfocus().
00033 { 00034 if (_focused) { 00035 setTexture(_style->labelFocusBackground()); 00036 _text_color = _style->textFocusColor(); 00037 } else { 00038 setTexture(_style->labelUnfocusBackground()); 00039 _text_color = _style->textUnfocusColor(); 00040 } 00041 } |
|
Definition at line 36 of file labelwidget.hh.
00036 { return _text; } |
|
Reimplemented from otk::Widget. Definition at line 63 of file labelwidget.cc. References setTextures(), and otk::Widget::unfocus().
00064 { 00065 otk::Widget::unfocus(); 00066 setTextures(); 00067 } |
|
Definition at line 17 of file labelwidget.hh. Referenced by renderForeground(), and setStyle(). |
|
Definition at line 20 of file labelwidget.hh. Referenced by setStyle(). |
|
Definition at line 19 of file labelwidget.hh. Referenced by renderForeground(), and setStyle(). |
|
Definition at line 21 of file labelwidget.hh. Referenced by renderForeground(), and setText(). |
|
Definition at line 18 of file labelwidget.hh. Referenced by renderForeground(), and setTextures(). |