FLTK 1.3.0
|
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; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 /* \file 00029 Fl_Image, Fl_RGB_Image classes . */ 00030 00031 #ifndef Fl_Image_H 00032 # define Fl_Image_H 00033 00034 # include "Enumerations.H" 00035 00036 class Fl_Widget; 00037 struct Fl_Menu_Item; 00038 struct Fl_Label; 00039 00051 class FL_EXPORT Fl_Image { 00052 int w_, h_, d_, ld_, count_; 00053 const char * const *data_; 00054 00055 // Forbid use of copy contructor and assign operator 00056 Fl_Image & operator=(const Fl_Image &); 00057 Fl_Image(const Fl_Image &); 00058 00059 protected: 00060 00064 void w(int W) {w_ = W;} 00068 void h(int H) {h_ = H;} 00072 void d(int D) {d_ = D;} 00076 void ld(int LD) {ld_ = LD;} 00080 void data(const char * const *p, int c) {data_ = p; count_ = c;} 00081 void draw_empty(int X, int Y); 00082 00083 static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la); 00084 static void measure(const Fl_Label *lo, int &lw, int &lh); 00085 00086 public: 00087 00091 int w() const {return w_;} 00094 int h() const {return h_;} 00100 int d() const {return d_;} 00106 int ld() const {return ld_;} 00113 int count() const {return count_;} 00118 const char * const *data() const {return data_;} 00119 00126 Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;} 00127 virtual ~Fl_Image(); 00128 virtual Fl_Image *copy(int W, int H); 00136 Fl_Image *copy() { return copy(w(), h()); } 00137 virtual void color_average(Fl_Color c, float i); 00144 void inactive() { color_average(FL_GRAY, .33f); } 00145 virtual void desaturate(); 00146 virtual void label(Fl_Widget*w); 00147 virtual void label(Fl_Menu_Item*m); 00155 virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent 00160 void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent 00161 virtual void uncache(); 00162 }; 00163 00175 class FL_EXPORT Fl_RGB_Image : public Fl_Image { 00176 friend class Fl_Quartz_Graphics_Driver; 00177 friend class Fl_GDI_Graphics_Driver; 00178 friend class Fl_Xlib_Graphics_Driver; 00179 public: 00180 00181 const uchar *array; 00182 int alloc_array; // Non-zero if array was allocated 00183 00184 private: 00185 00186 #if defined(__APPLE__) || defined(WIN32) 00187 void *id_; // for internal use 00188 void *mask_; // for internal use (mask bitmap) 00189 #else 00190 unsigned id_; // for internal use 00191 unsigned mask_; // for internal use (mask bitmap) 00192 #endif // __APPLE__ || WIN32 00193 00194 public: 00195 00197 Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) : 00198 Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);} 00199 virtual ~Fl_RGB_Image(); 00200 virtual Fl_Image *copy(int W, int H); 00201 Fl_Image *copy() { return copy(w(), h()); } 00202 virtual void color_average(Fl_Color c, float i); 00203 virtual void desaturate(); 00204 virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); 00205 void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} 00206 virtual void label(Fl_Widget*w); 00207 virtual void label(Fl_Menu_Item*m); 00208 virtual void uncache(); 00209 }; 00210 00211 #endif // !Fl_Image_H 00212 00213 // 00214 // End of "$Id$". 00215 //