186 |
Label::Label (const std::string &text) |
Label::Label (const std::string &text) |
187 |
: m_text (text), |
: m_text (text), |
188 |
m_font(enigma::GetFont("menufont")), |
m_font(enigma::GetFont("menufont")), |
189 |
m_halign(ALIGN_CENTER), |
m_halign(HALIGN_CENTER), |
190 |
m_valign(ALIGN_CENTER) |
m_valign(VALIGN_CENTER) |
191 |
{} |
{} |
192 |
|
|
193 |
|
|
215 |
|
|
216 |
int x = get_x(), y=get_y(); |
int x = get_x(), y=get_y(); |
217 |
switch (m_halign) { |
switch (m_halign) { |
218 |
case ALIGN_LEFT: break; |
case HALIGN_LEFT: break; |
219 |
case ALIGN_RIGHT: x += get_w() - w; break; |
case HALIGN_RIGHT: x += get_w() - w; break; |
220 |
case ALIGN_CENTER: x += (get_w()-w)/2; break; |
case HALIGN_CENTER: x += (get_w()-w)/2; break; |
221 |
} |
} |
222 |
switch (m_valign) { |
switch (m_valign) { |
223 |
case ALIGN_LEFT: break; |
case VALIGN_TOP: break; |
224 |
case ALIGN_RIGHT: y += get_h() - h; break; |
case VALIGN_BOTTOM: y += get_h() - h; break; |
225 |
case ALIGN_CENTER: y += (get_h()-h)/2; break; |
case VALIGN_CENTER: y += (get_h()-h)/2; break; |
226 |
} |
} |
227 |
|
|
228 |
f->render (gc, x, y, m_text.c_str()); |
f->render (gc, x, y, m_text.c_str()); |
229 |
} |
} |
230 |
|
|
231 |
void Label::set_alignment (Alignment horizontal, Alignment vertical) |
void Label::set_alignment (HAlignment halign, VAlignment valign) |
232 |
{ |
{ |
233 |
if (horizontal != m_halign || vertical != m_valign) { |
if (halign != m_halign || valign != m_valign) { |
234 |
m_halign = horizontal; |
m_halign = halign; |
235 |
m_valign = vertical; |
m_valign = valign; |
236 |
redraw(); |
redraw(); |
237 |
} |
} |
238 |
} |
} |