1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef __TEXT_HH_
|
---|
10 | #define __TEXT_HH_
|
---|
11 |
|
---|
12 | #include "window/window.hh"
|
---|
13 | #include "string/string.hh"
|
---|
14 | #include "window/style.hh"
|
---|
15 |
|
---|
16 | class i4_text_window_class : public i4_window_class
|
---|
17 | {
|
---|
18 | i4_str *text;
|
---|
19 | i4_graphical_style_class *hint;
|
---|
20 | i4_font_class *font;
|
---|
21 |
|
---|
22 | public:
|
---|
23 | i4_text_window_class(const i4_const_str &text,
|
---|
24 | i4_graphical_style_class *hint,
|
---|
25 | i4_font_class *_font=0)
|
---|
26 | : i4_window_class(0, 0),
|
---|
27 | hint(hint),
|
---|
28 | text(new i4_str(text)),
|
---|
29 | font(_font)
|
---|
30 | {
|
---|
31 | if (!font)
|
---|
32 | font=hint->font_hint->normal_font;
|
---|
33 |
|
---|
34 | resize(font->width(text), font->height(text));
|
---|
35 | }
|
---|
36 |
|
---|
37 | virtual void draw(i4_draw_context_class &context)
|
---|
38 | {
|
---|
39 | local_image->add_dirty(0,0,width()-1,height()-1,context);
|
---|
40 | font->set_color(hint->color_hint->text_foreground);
|
---|
41 |
|
---|
42 | hint->deco_neutral_fill(local_image, 0,0, width()-1, height()-1, context);
|
---|
43 | // local_image->clear(hint->color_hint->window.passive.medium,context);
|
---|
44 | if (text)
|
---|
45 | font->put_string(local_image,0,0,*text,context);
|
---|
46 | }
|
---|
47 |
|
---|
48 | ~i4_text_window_class() { delete text; }
|
---|
49 |
|
---|
50 | void set_text(i4_str *new_text)
|
---|
51 | {
|
---|
52 | if (text)
|
---|
53 | delete text;
|
---|
54 | text = new_text;
|
---|
55 | request_redraw();
|
---|
56 | }
|
---|
57 |
|
---|
58 | char *name() { return "text_window"; }
|
---|
59 | };
|
---|
60 |
|
---|
61 |
|
---|
62 | #endif
|
---|