]>
Dogcows Code - chaz/openbox/blob - otk/label.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
11 Label::Label(Widget
*parent
)
12 : Widget(parent
), _text("")
20 void Label::setStyle(Style
*style
)
22 Widget::setStyle(style
);
25 //setTexture(style->getLabelUnfocus());
29 void Label::renderForeground(void)
31 const Font
*ft
= style()->getFont();
32 unsigned int sidemargin
= style()->getBevelWidth() * 2;
34 ustring t
= _text
; // the actual text to draw
35 int x
= sidemargin
; // x coord for the text
37 // find a string that will fit inside the area for text
38 int max_length
= width() - sidemargin
* 2;
39 if (max_length
<= 0) {
40 t
= ""; // can't fit anything
42 size_t text_len
= t
.size();
47 length
= ft
->measureString(t
);
48 } while (length
> max_length
&& text_len
-- > 0);
51 switch (style()->textJustify()) {
52 case Style::RightJustify
:
53 x
+= max_length
- length
;
55 case Style::CenterJustify
:
56 x
+= (max_length
- length
) / 2;
58 case Style::LeftJustify
:
63 display
->renderControl(_screen
)->
64 drawString(*_surface
, *ft
, x
, 0, *style()->getTextUnfocus(), t
);
This page took 0.035185 seconds and 4 git commands to generate.