Fl_Pixmap.H 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // "$Id: Fl_Pixmap.H 12433 2017-09-09 12:35:06Z manolo $"
  3. //
  4. // Pixmap header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2017 by Bill Spitzak and others.
  7. //
  8. // This library is free software. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. /* \file
  19. Fl_Pixmap widget . */
  20. #ifndef Fl_Pixmap_H
  21. #define Fl_Pixmap_H
  22. # include "Fl_Image.H"
  23. class Fl_Widget;
  24. struct Fl_Menu_Item;
  25. // Older C++ compilers don't support the explicit keyword... :(
  26. # if defined(__sgi) && !defined(_COMPILER_VERSION)
  27. # define explicit
  28. # endif // __sgi && !_COMPILER_VERSION
  29. /**
  30. The Fl_Pixmap class supports caching and drawing of colormap
  31. (pixmap) images, including transparency.
  32. */
  33. class FL_EXPORT Fl_Pixmap : public Fl_Image {
  34. friend class Fl_Graphics_Driver;
  35. void copy_data();
  36. void delete_data();
  37. void set_data(const char * const *p);
  38. int prepare(int XP, int YP, int WP, int HP, int &cx, int &cy,
  39. int &X, int &Y, int &W, int &H);
  40. protected:
  41. void measure();
  42. virtual int draw_scaled(int X, int Y, int W, int H);
  43. public:
  44. int alloc_data; // Non-zero if data was allocated
  45. private:
  46. // for internal use
  47. fl_uintptr_t id_;
  48. fl_uintptr_t mask_;
  49. Fl_Color pixmap_bg_color;
  50. float cache_scale_; // graphics scaling value when id_ was computed
  51. public:
  52. /** The constructors create a new pixmap from the specified XPM data. */
  53. explicit Fl_Pixmap(char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
  54. /** The constructors create a new pixmap from the specified XPM data. */
  55. explicit Fl_Pixmap(uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
  56. /** The constructors create a new pixmap from the specified XPM data. */
  57. explicit Fl_Pixmap(const char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
  58. /** The constructors create a new pixmap from the specified XPM data. */
  59. explicit Fl_Pixmap(const uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
  60. virtual ~Fl_Pixmap();
  61. virtual Fl_Image *copy(int W, int H);
  62. Fl_Image *copy() { return copy(w(), h()); }
  63. virtual void color_average(Fl_Color c, float i);
  64. virtual void desaturate();
  65. virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
  66. void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
  67. virtual void label(Fl_Widget*w);
  68. virtual void label(Fl_Menu_Item*m);
  69. virtual void uncache();
  70. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Pixmap, Fl_Image)
  71. };
  72. #endif
  73. //
  74. // End of "$Id: Fl_Pixmap.H 12433 2017-09-09 12:35:06Z manolo $".
  75. //