FLTK 1.3.0
Fl_Pixmap.H
00001 //
00002 // "$Id$"
00003 //
00004 // Pixmap header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2012 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_Pixmap widget . */
00021 
00022 #ifndef Fl_Pixmap_H
00023 #define Fl_Pixmap_H
00024 #  include "Fl_Image.H"
00025 #if defined(WIN32)
00026 #  include "x.H"
00027 #endif
00028 
00029 class Fl_Widget;
00030 struct Fl_Menu_Item;
00031 
00032 // Older C++ compilers don't support the explicit keyword... :(
00033 #  if defined(__sgi) && !defined(_COMPILER_VERSION)
00034 #    define explicit
00035 #  endif // __sgi && !_COMPILER_VERSION
00036 
00041 class FL_EXPORT Fl_Pixmap : public Fl_Image {
00042   friend class Fl_Quartz_Graphics_Driver;
00043   friend class Fl_GDI_Graphics_Driver;
00044   friend class Fl_GDI_Printer_Graphics_Driver;
00045   friend class Fl_Xlib_Graphics_Driver;
00046   void copy_data();
00047   void delete_data();
00048   void set_data(const char * const *p);
00049   int prepare(int XP, int YP, int WP, int HP, int &cx, int &cy,
00050                          int &X, int &Y, int &W, int &H);
00051 
00052   protected:
00053 
00054   void measure();
00055 
00056   public:
00057 
00058   int alloc_data; // Non-zero if data was allocated
00059   
00060   private:
00061 
00062 #if defined(WIN32)
00063 #if FLTK_ABI_VERSION < 10302
00064   static // a static member is needed for ABI compatibility
00065 #endif
00066   UINT pixmap_bg_color; // RGB color used for pixmap background
00067 #endif // WIN32
00068 #if defined(__APPLE__) || defined(WIN32)
00069   void *id_; // for internal use
00070   void *mask_; // for internal use (mask bitmap)
00071 #else
00072   unsigned id_; // for internal use
00073   unsigned mask_; // for internal use (mask bitmap)
00074 #endif // __APPLE__ || WIN32
00075   
00076   public:
00077 
00079   explicit Fl_Pixmap(char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
00081   explicit Fl_Pixmap(uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
00083   explicit Fl_Pixmap(const char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
00085   explicit Fl_Pixmap(const uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
00086   virtual ~Fl_Pixmap();
00087   virtual Fl_Image *copy(int W, int H);
00088   Fl_Image *copy() { return copy(w(), h()); }
00089   virtual void color_average(Fl_Color c, float i);
00090   virtual void desaturate();
00091   virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
00092   void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
00093   virtual void label(Fl_Widget*w);
00094   virtual void label(Fl_Menu_Item*m);
00095   virtual void uncache();
00096 };
00097 
00098 #endif
00099 
00100 //
00101 // End of "$Id$".
00102 //