1 #include "bcresources.h"
3 #include "bcresources.h"
7 BC_Title::BC_Title(int x,
14 : BC_SubWindow(x, y, -1, -1, -1)
18 this->color = get_resources()->default_text_color;
21 this->centered = centered;
22 this->fixed_w = fixed_w;
23 strcpy(this->text, text);
31 int BC_Title::initialize()
36 if(centered) x -= w / 2;
38 BC_SubWindow::initialize();
43 int BC_Title::set_color(int color)
50 int BC_Title::resize(int w, int h)
57 int BC_Title::reposition(int x, int y)
59 reposition_window(x, y, w, h);
65 int BC_Title::update(char *text)
69 strcpy(this->text, text);
70 get_size(new_w, new_h);
71 if(new_w > w || new_h > h)
73 resize_window(new_w, new_h);
79 char* BC_Title::get_text()
88 // Fix background for block fonts.
89 // This should eventually be included in a BC_WindowBase::is_blocked_font()
91 if(font == MEDIUM_7SEGMENT)
93 //leave it up to the theme to decide if we need a background or not.
94 if (top_level->get_resources()->draw_clock_background)
96 BC_WindowBase::set_color(BLACK);
101 draw_top_background(parent_window, 0, 0, w, h);
104 BC_WindowBase::set_color(color);
105 for(i = 0, j = 0, x = 0, y = get_text_ascent(font);
109 if(text[i] == '\n' || text[i] == 0)
113 draw_center_text(get_w() / 2,
127 y += get_text_height(font);
130 set_font(MEDIUMFONT); // reset
136 int BC_Title::get_size(int &w, int &h)
138 int i, j, x, y, line_w = 0;
142 for(i = 0, j = 0; i <= strlen(text); i++)
148 line_w = get_text_width(font, &text[j], i - j);
155 line_w = get_text_width(font, &text[j]);
157 if(line_w > w) w = line_w;
160 h *= get_text_height(font);
162 if(fixed_w > 0) w = fixed_w;