4 BC_Title::BC_Title(int x,
11 : BC_SubWindow(x, y, -1, -1, -1)
15 this->centered = centered;
16 this->fixed_w = fixed_w;
17 strcpy(this->text, text);
25 int BC_Title::initialize()
30 if(centered) x -= w / 2;
32 BC_SubWindow::initialize();
37 int BC_Title::set_color(int color)
44 int BC_Title::resize(int w, int h)
51 int BC_Title::reposition(int x, int y)
53 reposition_window(x, y, w, h);
59 int BC_Title::update(char *text)
63 strcpy(this->text, text);
64 get_size(new_w, new_h);
65 if(new_w > w || new_h > h)
67 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;
149 //printf("BC_Title::get_size %d\n", w);