FLTK 1.3.2
Fl_Image.H
1 //
2 // "$Id: Fl_Image.H 9709 2012-11-09 16:02:08Z manolo $"
3 //
4 // Image header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2011 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 
19 /* \file
20  Fl_Image, Fl_RGB_Image classes . */
21 
22 #ifndef Fl_Image_H
23 # define Fl_Image_H
24 
25 # include "Enumerations.H"
26 #include <stdlib.h>
27 
28 class Fl_Widget;
29 struct Fl_Menu_Item;
30 struct Fl_Label;
31 
43 class FL_EXPORT Fl_Image {
44  int w_, h_, d_, ld_, count_;
45  const char * const *data_;
46 
47  // Forbid use of copy contructor and assign operator
48  Fl_Image & operator=(const Fl_Image &);
49  Fl_Image(const Fl_Image &);
50 
51  protected:
52 
56  void w(int W) {w_ = W;}
60  void h(int H) {h_ = H;}
64  void d(int D) {d_ = D;}
68  void ld(int LD) {ld_ = LD;}
72  void data(const char * const *p, int c) {data_ = p; count_ = c;}
73  void draw_empty(int X, int Y);
74 
75  static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la);
76  static void measure(const Fl_Label *lo, int &lw, int &lh);
77 
78  public:
79 
83  int w() const {return w_;}
86  int h() const {return h_;}
92  int d() const {return d_;}
98  int ld() const {return ld_;}
105  int count() const {return count_;}
110  const char * const *data() const {return data_;}
111 
118  Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;}
119  virtual ~Fl_Image();
120  virtual Fl_Image *copy(int W, int H);
128  Fl_Image *copy() { return copy(w(), h()); }
129  virtual void color_average(Fl_Color c, float i);
136  void inactive() { color_average(FL_GRAY, .33f); }
137  virtual void desaturate();
138  virtual void label(Fl_Widget*w);
139  virtual void label(Fl_Menu_Item*m);
147  virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
152  void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
153  virtual void uncache();
154 };
155 
167 class FL_EXPORT Fl_RGB_Image : public Fl_Image {
168  friend class Fl_Quartz_Graphics_Driver;
169  friend class Fl_GDI_Graphics_Driver;
170  friend class Fl_Xlib_Graphics_Driver;
171  static size_t max_size_;
172 public:
173 
174  const uchar *array;
175  int alloc_array; // Non-zero if array was allocated
176 
177  private:
178 
179 #if defined(__APPLE__) || defined(WIN32)
180  void *id_; // for internal use
181  void *mask_; // for internal use (mask bitmap)
182 #else
183  unsigned id_; // for internal use
184  unsigned mask_; // for internal use (mask bitmap)
185 #endif // __APPLE__ || WIN32
186 
187  public:
188 
204  Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
205  Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
206  virtual ~Fl_RGB_Image();
207  virtual Fl_Image *copy(int W, int H);
208  Fl_Image *copy() { return copy(w(), h()); }
209  virtual void color_average(Fl_Color c, float i);
210  virtual void desaturate();
211  virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
212  void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
213  virtual void label(Fl_Widget*w);
214  virtual void label(Fl_Menu_Item*m);
215  virtual void uncache();
225  static void max_size(size_t size) { max_size_ = size;}
230  static size_t max_size() {return max_size_;}
231 };
232 
233 #endif // !Fl_Image_H
234 
235 //
236 // End of "$Id: Fl_Image.H 9709 2012-11-09 16:02:08Z manolo $".
237 //