30 |
// List of loaded themes |
// List of loaded themes |
31 |
hash_map<string, win_theme *> win_manager::theme; |
hash_map<string, win_theme *> win_manager::theme; |
32 |
// List of loaded fonts |
// List of loaded fonts |
33 |
hash_map<string, win_font *> win_manager::font; |
hash_map<string, win_ttf *> win_manager::font; |
34 |
|
// True type font to use |
35 |
using namespace std; |
string win_manager::font_file; |
36 |
|
|
37 |
|
|
38 |
win_manager::win_manager () |
win_manager::win_manager () |
73 |
wnd_focus = NULL; |
wnd_focus = NULL; |
74 |
} |
} |
75 |
|
|
76 |
void win_manager::init () |
void win_manager::init (const string & font) |
77 |
{ |
{ |
78 |
|
font_file = font; |
79 |
|
TTF_Init (); |
80 |
} |
} |
81 |
|
|
82 |
// Delete all fonts and themes |
// Delete all fonts and themes |
89 |
theme.clear (); |
theme.clear (); |
90 |
|
|
91 |
// Cleaning up fonts |
// Cleaning up fonts |
92 |
for (hash_map <string, win_font *>::iterator ifo = font.begin (); |
for (hash_map <string, win_ttf *>::iterator ifo = font.begin (); |
93 |
ifo != font.end (); ifo++) |
ifo != font.end (); ifo++) |
94 |
delete ifo->second; |
delete ifo->second; |
95 |
font.clear (); |
font.clear (); |
96 |
|
|
97 |
|
TTF_Quit (); |
98 |
} |
} |
99 |
|
|
100 |
// add a window |
// add a window |
225 |
// load a font from disk |
// load a font from disk |
226 |
void win_manager::add_font (string name) |
void win_manager::add_font (string name) |
227 |
{ |
{ |
228 |
font[name] = new win_font ((char *) name.c_str ()); |
font[name] = new win_ttf ((char *) name.c_str (), font_file); |
229 |
} |
} |
230 |
|
|
231 |
// remove a font |
// remove a font |
232 |
bool win_manager::remove_font (string name) |
bool win_manager::remove_font (string name) |
233 |
{ |
{ |
234 |
hash_map <string, win_font *>::iterator it = font.find (name); |
hash_map <string, win_ttf *>::iterator it = font.find (name); |
235 |
if (it == font.end ()) return false; |
if (it == font.end ()) return false; |
236 |
|
|
237 |
delete it->second; |
delete it->second; |
242 |
// return a pointer to a font |
// return a pointer to a font |
243 |
win_font * win_manager::get_font (string name) |
win_font * win_manager::get_font (string name) |
244 |
{ |
{ |
245 |
hash_map <string, win_font *>::iterator it = font.find (name); |
hash_map <string, win_ttf *>::iterator it = font.find (name); |
246 |
|
|
247 |
// try to load the font if it's not in memory yet |
// try to load the font if it's not in memory yet |
248 |
if (it == font.end ()) |
if (it == font.end ()) |