]>
Dogcows Code - chaz/openbox/blob - otk/label.cc
1537b9277a514b736b75c8bf64e9ec949b021729
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
11 OtkLabel::OtkLabel(OtkWidget
*parent
)
12 : OtkWidget(parent
), _text("")
14 setTexture(getStyle()->getLabelUnfocus());
21 void OtkLabel::update(void)
24 const BFont
&ft
= getStyle()->getFont();
25 unsigned int bevel
= getStyle()->getBevelWidth();
27 std::string t
= _text
; // the actual text to draw
28 int x
= bevel
; // x coord for the text
30 // find a string that will fit inside the area for text
31 int max_length
= width() - getBevelWidth() * 2;
32 if (max_length
<= 0) {
33 t
= ""; // can't fit anything
35 size_t text_len
= t
.size();
40 length
= ft
.measureString(t
);
41 } while (length
> max_length
&& text_len
-- > 0);
44 switch (getStyle()->textJustify()) {
45 case Style::RightJustify
:
46 x
+= max_length
- length
;
48 case Style::CenterJustify
:
49 x
+= (max_length
- length
) / 2;
51 case Style::LeftJustify
:
58 ft
.drawString(getWindow(), x
, bevel
, *getStyle()->getTextUnfocus(), t
);
This page took 0.035703 seconds and 4 git commands to generate.