]>
Dogcows Code - chaz/openbox/blob - label.cc
40a85bb39ca922e0ea145b54c3ea3df591f53209
5 OtkLabel::OtkLabel(OtkWidget
*parent
)
6 : OtkWidget(parent
), _text("")
8 setTexture(getStyle()->getLabelUnfocus());
15 void OtkLabel::update(void)
18 const BFont
&ft
= getStyle()->getFont();
19 unsigned int bevel
= getStyle()->getBevelWidth();
21 std::string t
= _text
; // the actual text to draw
22 int x
= bevel
; // x coord for the text
24 // find a string that will fit inside the area for text
25 int max_length
= width() - getBevelWidth() * 2;
26 if (max_length
<= 0) {
27 t
= ""; // can't fit anything
29 size_t text_len
= t
.size();
34 length
= ft
.measureString(t
);
35 } while (length
> max_length
&& text_len
-- > 0);
38 switch (getStyle()->textJustify()) {
39 case Style::RightJustify
:
40 x
+= max_length
- length
;
42 case Style::CenterJustify
:
43 x
+= (max_length
- length
) / 2;
45 case Style::LeftJustify
:
52 ft
.drawString(getWindow(), x
, bevel
, *getStyle()->getTextUnfocus(), t
);
This page took 0.034978 seconds and 3 git commands to generate.