FLTK 1.3.x
|
00001 // 00002 // "$Id: Fl_Image.H 7903 2010-11-28 21:06:39Z matt $" 00003 // 00004 // Image header file for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 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 00068 void w(int W) {w_ = W;} 00076 void h(int H) {h_ = H;} 00085 void d(int D) {d_ = D;} 00087 void ld(int LD) {ld_ = LD;} 00089 void data(const char * const *p, int c) {data_ = p; count_ = c;} 00090 void draw_empty(int X, int Y); 00091 00092 static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la); 00093 static void measure(const Fl_Label *lo, int &lw, int &lh); 00094 00095 public: 00096 00098 int w() const {return w_;} 00100 int h() const {return h_;} 00109 int d() const {return d_;} 00118 int ld() const {return ld_;} 00125 int count() const {return count_;} 00134 const char * const *data() const {return data_;} 00135 00142 Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;} 00143 virtual ~Fl_Image(); 00144 virtual Fl_Image *copy(int W, int H); 00152 Fl_Image *copy() { return copy(w(), h()); } 00153 virtual void color_average(Fl_Color c, float i); 00160 void inactive() { color_average(FL_GRAY, .33f); } 00161 virtual void desaturate(); 00162 virtual void label(Fl_Widget*w); 00163 virtual void label(Fl_Menu_Item*m); 00170 virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent 00175 void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent 00176 virtual void uncache(); 00177 }; 00178 00190 class FL_EXPORT Fl_RGB_Image : public Fl_Image { 00191 friend class Fl_Quartz_Graphics_Driver; 00192 friend class Fl_GDI_Graphics_Driver; 00193 friend class Fl_Xlib_Graphics_Driver; 00194 public: 00195 00196 const uchar *array; 00197 int alloc_array; // Non-zero if array was allocated 00198 00199 private: 00200 00201 #if defined(__APPLE__) || defined(WIN32) 00202 void *id_; // for internal use 00203 void *mask_; // for internal use (mask bitmap) 00204 #else 00205 unsigned id_; // for internal use 00206 unsigned mask_; // for internal use (mask bitmap) 00207 #endif // __APPLE__ || WIN32 00208 00209 public: 00210 00212 Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) : 00213 Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);} 00214 virtual ~Fl_RGB_Image(); 00215 virtual Fl_Image *copy(int W, int H); 00216 Fl_Image *copy() { return copy(w(), h()); } 00217 virtual void color_average(Fl_Color c, float i); 00218 virtual void desaturate(); 00219 virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); 00220 void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} 00221 virtual void label(Fl_Widget*w); 00222 virtual void label(Fl_Menu_Item*m); 00223 virtual void uncache(); 00224 }; 00225 00226 #endif // !Fl_Image_H 00227 00228 // 00229 // End of "$Id: Fl_Image.H 7903 2010-11-28 21:06:39Z matt $". 00230 //