fl_html_label.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // fl_html_label 1.0
  2. //
  3. // Copyright 2009 by Roman Kantor.
  4. //
  5. // License: LGPL + fltk exceptions, see license for fltk library at http://fltk.org
  6. //
  7. // This library is free software; you can redistribute it and/or
  8. // modify it under the terms of the GNU Library General Public License
  9. // version 2 as published by the Free Software Foundation.
  10. //
  11. // This library is distributed WITHOUT ANY WARRANTY;
  12. // without even the implied warranty of MERCHANTABILITY
  13. // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. // Library General Public License for more details.
  15. // You should have received a copy of the GNU Library General Public
  16. // License along with this library; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  18. #ifndef _fl_html_label_h_
  19. #define _fl_html_label_h_
  20. #include <FL/Fl.H>
  21. #include <FL/Fl_Shared_Image.H>
  22. // For impatient:
  23. // Following functions are for instant use of FL_HTM_LABEL type
  24. // without the need to use Fl::set_labeltype() function
  25. FL_EXPORT Fl_Labeltype fl_define_html_label(int position);
  26. #define _FL_HTML_LABEL 15 // default position in the labeltype table
  27. #define FL_HTML_LABEL fl_define_html_label(_FL_HTML_LABEL)
  28. // Drawing and measurement functions for labeltypes.
  29. // These functions should be used for the definition
  30. // of the HTML labeltype using Fl::set_labeltype() function.
  31. FL_EXPORT void fl_draw_html(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align);
  32. FL_EXPORT void fl_measure_html(const Fl_Label *label, int &w, int &h);
  33. // Some usefull functions to directly draw or measure a HTML text string.
  34. // The functions use current fl_font() and fl_size() as the base font
  35. // parameters for formatting and fl_color() as the base text color.
  36. FL_EXPORT void fl_draw_html(const char * html_text, int x, int y);
  37. FL_EXPORT void fl_draw_html(const char * html_text, int x, int y, int w, int h, Fl_Align align, Fl_Image* img =0);
  38. FL_EXPORT void fl_measure_html(const char * html_text, int &w, int &h);
  39. // A trick to use in-memory images within html labels/strings is creating "named" shared image.
  40. // We need to make constructor public and register the name.
  41. Fl_Shared_Image * fl_name_image(Fl_Image * im, const char * name);
  42. #endif // _fl_html_label_h_