5 BC_Title::BC_Title(int x,
12 : BC_SubWindow(x, y, -1, -1, -1)
16 this->centered = centered;
17 this->fixed_w = fixed_w;
18 strcpy(this->text, text);
26 int BC_Title::initialize()
31 if(centered) x -= w / 2;
33 BC_SubWindow::initialize();
38 int BC_Title::set_color(int color)
45 int BC_Title::resize(int w, int h)
52 int BC_Title::reposition(int x, int y)
54 reposition_window(x, y, w, h);
60 int BC_Title::update(char *text)
64 strcpy(this->text, text);
65 get_size(new_w, new_h);
66 if(new_w > w || new_h > h)
68 resize_window(new_w, new_h);
78 // Fix background for block fonts.
79 // This should eventually be included in a BC_WindowBase::is_blocked_font()
81 if(font == MEDIUM_7SEGMENT)
83 BC_WindowBase::set_color(BLACK);
87 draw_top_background(parent_window, 0, 0, w, h);
90 BC_WindowBase::set_color(color);
91 for(i = 0, j = 0, x = 0, y = get_text_ascent(font);
95 if(text[i] == '\n' || text[i] == 0)
99 draw_center_text(get_w() / 2,
113 y += get_text_height(font);
116 set_font(MEDIUMFONT); // reset
122 int BC_Title::get_size(int &w, int &h)
124 int i, j, x, y, line_w = 0;
128 for(i = 0, j = 0; i <= strlen(text); i++)
134 line_w = get_text_width(font, &text[j], i - j);
141 line_w = get_text_width(font, &text[j]);
143 if(line_w > w) w = line_w;
146 h *= get_text_height(font);
148 if(fixed_w > 0) w = fixed_w;