FLTK 1.3.0
Fl_Image.H
00001 //
00002 // "$Id$"
00003 //
00004 // Image header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2011 by Bill Spitzak and others.
00007 //
00008 // This library is free software. Distribution and use rights are outlined in
00009 // the file "COPYING" which should have been included with this file.  If this
00010 // file is missing or damaged, see the license at:
00011 //
00012 //     http://www.fltk.org/COPYING.php
00013 //
00014 // Please report all bugs and problems on the following page:
00015 //
00016 //     http://www.fltk.org/str.php
00017 //
00018 
00019 /* \file
00020    Fl_Image, Fl_RGB_Image classes . */
00021 
00022 #ifndef Fl_Image_H
00023 #  define Fl_Image_H
00024 
00025 #  include "Enumerations.H"
00026 
00027 class Fl_Widget;
00028 struct Fl_Menu_Item;
00029 struct Fl_Label;
00030 
00042 class FL_EXPORT Fl_Image {
00043   int w_, h_, d_, ld_, count_;
00044   const char * const *data_;
00045 
00046   // Forbid use of copy contructor and assign operator
00047   Fl_Image & operator=(const Fl_Image &);
00048   Fl_Image(const Fl_Image &);
00049 
00050   protected:
00051 
00055   void w(int W) {w_ = W;}
00059   void h(int H) {h_ = H;}
00063   void d(int D) {d_ = D;}
00067   void ld(int LD) {ld_ = LD;}
00071   void data(const char * const *p, int c) {data_ = p; count_ = c;}
00072   void draw_empty(int X, int Y);
00073 
00074   static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la);
00075   static void measure(const Fl_Label *lo, int &lw, int &lh);
00076 
00077   public:
00078 
00082   int w() const {return w_;}
00085   int h() const {return h_;}
00091   int d() const {return d_;}
00097   int ld() const {return ld_;}
00104   int count() const {return count_;}
00109   const char * const *data() const {return data_;}
00110   
00117   Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;}
00118   virtual ~Fl_Image();
00119   virtual Fl_Image *copy(int W, int H);
00127   Fl_Image *copy() { return copy(w(), h()); }
00128   virtual void color_average(Fl_Color c, float i);
00135   void inactive() { color_average(FL_GRAY, .33f); }
00136   virtual void desaturate();
00137   virtual void label(Fl_Widget*w);
00138   virtual void label(Fl_Menu_Item*m);
00146   virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
00151   void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
00152   virtual void uncache();
00153 };
00154 
00166 class FL_EXPORT Fl_RGB_Image : public Fl_Image {
00167   friend class Fl_Quartz_Graphics_Driver;
00168   friend class Fl_GDI_Graphics_Driver;
00169   friend class Fl_Xlib_Graphics_Driver;
00170 public:
00171 
00172   const uchar *array;
00173   int alloc_array; // Non-zero if array was allocated
00174 
00175   private:
00176 
00177 #if defined(__APPLE__) || defined(WIN32)
00178   void *id_; // for internal use
00179   void *mask_; // for internal use (mask bitmap)
00180 #else
00181   unsigned id_; // for internal use
00182   unsigned mask_; // for internal use (mask bitmap)
00183 #endif // __APPLE__ || WIN32
00184 
00185   public:
00186 
00202   Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
00203     Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
00204   virtual ~Fl_RGB_Image();
00205   virtual Fl_Image *copy(int W, int H);
00206   Fl_Image *copy() { return copy(w(), h()); }
00207   virtual void color_average(Fl_Color c, float i);
00208   virtual void desaturate();
00209   virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
00210   void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
00211   virtual void label(Fl_Widget*w);
00212   virtual void label(Fl_Menu_Item*m);
00213   virtual void uncache();
00214 };
00215 
00216 #endif // !Fl_Image_H
00217 
00218 //
00219 // End of "$Id$".
00220 //