33 |
// Widget implementation. |
// Widget implementation. |
34 |
//---------------------------------------- |
//---------------------------------------- |
35 |
Widget::Widget(Widget *parent) |
Widget::Widget(Widget *parent) |
36 |
: area(), menu(0), m_parent(parent) |
: area(), menu(0), m_parent(parent), listener(0) |
37 |
{} |
{} |
38 |
|
|
39 |
void |
void |
183 |
// Label implementation |
// Label implementation |
184 |
//---------------------------------------- |
//---------------------------------------- |
185 |
|
|
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), |
190 |
|
m_valign(ALIGN_CENTER) |
191 |
{} |
{} |
192 |
|
|
193 |
|
|
194 |
void Label::set_text (const std::string &text) |
void Label::set_text (const std::string &text) |
195 |
{ |
{ |
196 |
if (text != m_text) { |
if (text != m_text) { |
197 |
m_text = text; |
m_text = text; |
199 |
} |
} |
200 |
} |
} |
201 |
|
|
202 |
void Label::set_font (px::Font *font) |
void Label::set_font (px::Font *font) |
203 |
{ |
{ |
204 |
if (m_font != font) { |
if (m_font != font) { |
205 |
m_font = font; |
m_font = font; |
206 |
redraw(); |
redraw(); |
207 |
} |
} |
208 |
} |
} |
209 |
|
|
210 |
void Label::draw (px::GC &gc, const px::Rect &r) |
void Label::draw (px::GC &gc, const px::Rect &r) |
211 |
{ |
{ |
212 |
Font *f = m_font; |
Font *f = m_font; |
213 |
int h = f->get_height(); |
int h = f->get_height(); |
245 |
Button::draw(px::GC &gc, const px::Rect &r) |
Button::draw(px::GC &gc, const px::Rect &r) |
246 |
{ |
{ |
247 |
const int borderw = 4; |
const int borderw = 4; |
248 |
|
|
249 |
px::Surface *s = enigma::GetImage (highlighted ? "buttonhl" : "button"); |
px::Surface *s = enigma::GetImage (highlighted ? "buttonhl" : "button"); |
250 |
|
|
251 |
if (s) { // Ugly, but hey, it works |
if (s) { // Ugly, but hey, it works |
273 |
int x = area.x + borderw; |
int x = area.x + borderw; |
274 |
for (int i=0; i<ntiles; ++i) { |
for (int i=0; i<ntiles; ++i) { |
275 |
blit (gc, x, area.y, s, Rect (borderw, 0, tilew, borderw)); |
blit (gc, x, area.y, s, Rect (borderw, 0, tilew, borderw)); |
276 |
blit (gc, x, area.y+area.h-borderw, s, |
blit (gc, x, area.y+area.h-borderw, s, |
277 |
Rect (borderw, s->height()-borderw, tilew, borderw)); |
Rect (borderw, s->height()-borderw, tilew, borderw)); |
278 |
x += tilew; |
x += tilew; |
279 |
} |
} |
280 |
int restw = (area.w - 2*borderw) - tilew*ntiles; |
int restw = (area.w - 2*borderw) - tilew*ntiles; |
281 |
blit (gc, x, area.y, s, Rect (borderw, 0, restw, borderw)); |
blit (gc, x, area.y, s, Rect (borderw, 0, restw, borderw)); |
282 |
blit (gc, x, area.y+area.h-borderw, s, |
blit (gc, x, area.y+area.h-borderw, s, |
283 |
Rect (borderw, s->height()-borderw, restw, borderw)); |
Rect (borderw, s->height()-borderw, restw, borderw)); |
284 |
} |
} |
285 |
// vertical borders |
// vertical borders |
289 |
int y = area.y + borderw; |
int y = area.y + borderw; |
290 |
for (int i=0; i<ntiles; ++i) { |
for (int i=0; i<ntiles; ++i) { |
291 |
blit (gc, area.x, y, s, Rect (0, borderw, borderw, tileh)); |
blit (gc, area.x, y, s, Rect (0, borderw, borderw, tileh)); |
292 |
blit (gc, area.x+area.w-borderw, y, s, |
blit (gc, area.x+area.w-borderw, y, s, |
293 |
Rect (s->width()-borderw, borderw, borderw, tileh)); |
Rect (s->width()-borderw, borderw, borderw, tileh)); |
294 |
y += tileh; |
y += tileh; |
295 |
} |
} |
296 |
int resth = (area.h - 2*borderw) - tileh*ntiles; |
int resth = (area.h - 2*borderw) - tileh*ntiles; |
297 |
blit (gc, area.x, y, s, Rect (0, borderw, borderw, resth)); |
blit (gc, area.x, y, s, Rect (0, borderw, borderw, resth)); |
298 |
blit (gc, area.x+area.w-borderw, y, s, |
blit (gc, area.x+area.w-borderw, y, s, |
299 |
Rect (s->width()-borderw, borderw, borderw, resth)); |
Rect (s->width()-borderw, borderw, borderw, resth)); |
300 |
} |
} |
301 |
} |
} |