text.hh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifndef __TEXT_HH_
  9. #define __TEXT_HH_
  10. #include "window/window.hh"
  11. #include "string/string.hh"
  12. #include "window/style.hh"
  13. class i4_text_window_class : public i4_window_class
  14. {
  15. i4_str *text;
  16. i4_graphical_style_class *hint;
  17. i4_font_class *font;
  18. public:
  19. i4_text_window_class(const i4_const_str &text,
  20. i4_graphical_style_class *hint,
  21. i4_font_class *_font=0)
  22. : i4_window_class(0, 0),
  23. hint(hint),
  24. text(new i4_str(text)),
  25. font(_font)
  26. {
  27. if (!font)
  28. font=hint->font_hint->normal_font;
  29. resize(font->width(text), font->height(text));
  30. }
  31. virtual void draw(i4_draw_context_class &context)
  32. {
  33. local_image->add_dirty(0,0,width()-1,height()-1,context);
  34. font->set_color(hint->color_hint->text_foreground);
  35. hint->deco_neutral_fill(local_image, 0,0, width()-1, height()-1, context);
  36. // local_image->clear(hint->color_hint->window.passive.medium,context);
  37. if (text)
  38. font->put_string(local_image,0,0,*text,context);
  39. }
  40. ~i4_text_window_class() { delete text; }
  41. void set_text(i4_str *new_text)
  42. {
  43. if (text)
  44. delete text;
  45. text = new_text;
  46. request_redraw();
  47. }
  48. char *name() { return "text_window"; }
  49. };
  50. #endif