Fl_Pixmap.H 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // "$Id: Fl_Pixmap.H 9706 2012-11-06 20:46:14Z matt $"
  3. //
  4. // Pixmap header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2012 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. #if defined(WIN32)
  24. # include "x.H"
  25. #endif
  26. class Fl_Widget;
  27. class Fl_Menu_Item;
  28. // Older C++ compilers don't support the explicit keyword... :(
  29. # if defined(__sgi) && !defined(_COMPILER_VERSION)
  30. # define explicit
  31. # endif // __sgi && !_COMPILER_VERSION
  32. /**
  33. The Fl_Pixmap class supports caching and drawing of colormap
  34. (pixmap) images, including transparency.
  35. */
  36. class FL_EXPORT Fl_Pixmap : public Fl_Image {
  37. friend class Fl_Quartz_Graphics_Driver;
  38. friend class Fl_GDI_Graphics_Driver;
  39. friend class Fl_GDI_Printer_Graphics_Driver;
  40. friend class Fl_Xlib_Graphics_Driver;
  41. void copy_data();
  42. void delete_data();
  43. void set_data(const char * const *p);
  44. int prepare(int XP, int YP, int WP, int HP, int &cx, int &cy,
  45. int &X, int &Y, int &W, int &H);
  46. protected:
  47. void measure();
  48. public:
  49. int alloc_data; // Non-zero if data was allocated
  50. private:
  51. #if defined(WIN32)
  52. #if FLTK_ABI_VERSION < 10301
  53. static // a static member is needed for ABI compatibility
  54. #endif
  55. UINT pixmap_bg_color; // RGB color used for pixmap background
  56. #endif // WIN32
  57. #if defined(__APPLE__) || defined(WIN32)
  58. void *id_; // for internal use
  59. void *mask_; // for internal use (mask bitmap)
  60. #else
  61. unsigned id_; // for internal use
  62. unsigned mask_; // for internal use (mask bitmap)
  63. #endif // __APPLE__ || WIN32
  64. public:
  65. /** The constructors create a new pixmap from the specified XPM data. */
  66. 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();}
  67. /** The constructors create a new pixmap from the specified XPM data. */
  68. 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();}
  69. /** The constructors create a new pixmap from the specified XPM data. */
  70. 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();}
  71. /** The constructors create a new pixmap from the specified XPM data. */
  72. 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();}
  73. virtual ~Fl_Pixmap();
  74. virtual Fl_Image *copy(int W, int H);
  75. Fl_Image *copy() { return copy(w(), h()); }
  76. virtual void color_average(Fl_Color c, float i);
  77. virtual void desaturate();
  78. virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
  79. void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
  80. virtual void label(Fl_Widget*w);
  81. virtual void label(Fl_Menu_Item*m);
  82. virtual void uncache();
  83. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Pixmap, Fl_Image)
  84. };
  85. #endif
  86. //
  87. // End of "$Id: Fl_Pixmap.H 9706 2012-11-06 20:46:14Z matt $".
  88. //