Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXIcon.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                               I c o n - O b j e c t                           *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXIcon.h,v 1.34 2009/01/06 13:07:24 fox Exp $                            *
00022 ********************************************************************************/
00023 #ifndef FXICON_H
00024 #define FXICON_H
00025 
00026 #ifndef FXIMAGE_H
00027 #include "FXImage.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 class FXDC;
00033 class FXDCWindow;
00034 class FXDrawable;
00035 class FXTopWindow;
00036 
00037 
00038 /**
00039 * An Icon is an image with two additional server-side resources: a shape
00040 * bitmap, which is used to mask those pixels where the background should
00041 * be preserved during the drawing, and a etch bitmap, which is used to
00042 * draw the icon when it is disabled.
00043 */
00044 class FXAPI FXIcon : public FXImage {
00045   FXDECLARE(FXIcon)
00046   friend class FXDC;
00047   friend class FXWindow;
00048   friend class FXDCWindow;
00049   friend class FXDrawable;
00050   friend class FXTopWindow;
00051 protected:
00052   FXID     shape;             // Shape pixmap
00053   FXID     etch;              // Etch pixmap
00054   FXColor  transp;            // Transparency color
00055   FXshort  thresh;            // Treshold for etch mask
00056 protected:
00057   FXIcon();
00058   FXColor guesstransp();
00059 private:
00060   FXIcon(const FXIcon&);
00061   FXIcon &operator=(const FXIcon&);
00062 public:
00063 
00064   /**
00065   * Create an icon with an initial pixel buffer pix, a transparent color clr,
00066   * and options as in FXImage.  The transparent color is used to determine which
00067   * pixel values are transparent, i.e. need to be masked out in the absence of
00068   * a true alpha channel.
00069   * If the flag IMAGE_OPAQUE is passed, the shape and etch bitmaps are generated
00070   * as if the image is fully opaque, even if it has an alpha channel or transparancy
00071   * color.  The flag IMAGE_ALPHACOLOR is used to force a specific alpha color instead
00072   * of the alpha channel obtained from the image file.
00073   * Specifying IMAGE_ALPHAGUESS causes Icon to obtain the alpha color from the background
00074   * color of the image; it has the same effect as IMAGE_ALPHACOLOR in the sense that
00075   * the icon will be transparent for those colors matching the alpha color.
00076   */
00077   FXIcon(FXApp* a,const FXColor *pix=NULL,FXColor clr=0,FXuint opts=0,FXint w=1,FXint h=1);
00078 
00079   /**
00080   * Create the server side pixmap, the shape bitmap, and the etch bitmap, then
00081   * call render() to fill it with the pixel data from the client-side buffer.  After
00082   * the server-side pixmap and bitmaps have been created, the client-side pixel
00083   * buffer will be deleted unless IMAGE_KEEP has been specified. If the pixel buffer
00084   * is not owned, i.e. the flag IMAGE_OWNED is not set, the pixel buffer will not
00085   * be deleted; however the pixel buffer will be set to NULL.
00086   */
00087   virtual void create();
00088 
00089   /**
00090   * Detach the server side pixmap, shape bitmap, and etch bitmap from the Icon.
00091   * Afterwards, the Icon is left as if it never had a server-side resources.
00092   */
00093   virtual void detach();
00094 
00095   /**
00096   * Destroy the server-side pixmap and the shape bitmap and etch bitmap.
00097   * The client-side pixel buffer is not affected.
00098   */
00099   virtual void destroy();
00100 
00101   /**
00102   * Render the server-side pixmap, shape bitmap and etch bitmap for the icon
00103   * from the client-side pixel buffer.
00104   */
00105   virtual void render();
00106 
00107   /**
00108   * Resize both client-side and server-side representations (if any) to the
00109   * given width and height.  The new representations typically contain garbage
00110   * after this operation and need to be re-filled.
00111   */
00112   virtual void resize(FXint w,FXint h);
00113 
00114   /// Get transparency color
00115   FXColor getTransparentColor() const { return transp; }
00116 
00117   /// Change transparency color
00118   void setTransparentColor(FXColor color){ transp=color; }
00119 
00120   /// Get threshold value
00121   FXshort getThresholdValue() const { return thresh; }
00122 
00123   /// Change threshold value
00124   void setThresholdValue(FXshort value){ thresh=value; }
00125 
00126   /// Destructor
00127   virtual ~FXIcon();
00128   };
00129 
00130 }
00131 
00132 #endif

Copyright © 1997-2009 Jeroen van der Zijp