Fl_Bitmap.H 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // "$Id: Fl_Bitmap.H 12433 2017-09-09 12:35:06Z manolo $"
  3. //
  4. // Bitmap 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_Bitmap widget . */
  20. #ifndef Fl_Bitmap_H
  21. #define Fl_Bitmap_H
  22. #include "Fl_Image.H"
  23. #include "Fl_Widget.H" // for fl_uintptr_t
  24. class Fl_Widget;
  25. struct Fl_Menu_Item;
  26. /**
  27. The Fl_Bitmap class supports caching and drawing of mono-color
  28. (bitmap) images. Images are drawn using the current color.
  29. */
  30. class FL_EXPORT Fl_Bitmap : public Fl_Image {
  31. friend class Fl_Graphics_Driver;
  32. public:
  33. /** pointer to raw bitmap data */
  34. const uchar *array;
  35. /** Non-zero if array points to bitmap data allocated internally */
  36. int alloc_array;
  37. private:
  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. /** for internal use */
  41. fl_uintptr_t id_;
  42. float cache_scale_; // graphics scaling value when id_ was computed
  43. protected:
  44. virtual int draw_scaled(int X, int Y, int W, int H);
  45. public:
  46. /** The constructors create a new bitmap from the specified bitmap data */
  47. Fl_Bitmap(const uchar *bits, int W, int H) :
  48. Fl_Image(W,H,0), array(bits), alloc_array(0), id_(0), cache_scale_(1) {data((const char **)&array, 1);}
  49. /** The constructors create a new bitmap from the specified bitmap data */
  50. Fl_Bitmap(const char *bits, int W, int H) :
  51. Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id_(0), cache_scale_(1) {data((const char **)&array, 1);}
  52. virtual ~Fl_Bitmap();
  53. virtual Fl_Image *copy(int W, int H);
  54. Fl_Image *copy() { return copy(w(), h()); }
  55. virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
  56. void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
  57. virtual void label(Fl_Widget*w);
  58. virtual void label(Fl_Menu_Item*m);
  59. virtual void uncache();
  60. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Bitmap, Fl_Image)
  61. };
  62. #endif
  63. //
  64. // End of "$Id: Fl_Bitmap.H 12433 2017-09-09 12:35:06Z manolo $".
  65. //