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

FXIcon.h

00001 /******************************************************************************** 00002 * * 00003 * I c o n - O b j e c t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2005 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 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 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser 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 USA. * 00021 ********************************************************************************* 00022 * $Id: FXIcon.h,v 1.28 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXICON_H 00025 #define FXICON_H 00026 00027 #ifndef FXIMAGE_H 00028 #include "FXImage.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 class FXDC; 00034 class FXDCWindow; 00035 class FXDrawable; 00036 class FXTopWindow; 00037 00038 00039 /** 00040 * An Icon is an image with two additional server-side resources: a shape 00041 * bitmap, which is used to mask those pixels where the background should 00042 * be preserved during the drawing, and a etch bitmap, which is used to 00043 * draw the icon when it is disabled. 00044 */ 00045 class FXAPI FXIcon : public FXImage { 00046 FXDECLARE(FXIcon) 00047 friend class FXDC; 00048 friend class FXWindow; 00049 friend class FXDCWindow; 00050 friend class FXDrawable; 00051 friend class FXTopWindow; 00052 protected: 00053 FXID shape; // Shape pixmap 00054 FXID etch; // Etch pixmap 00055 FXColor transp; // Transparency color 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 /// Obtain transparency color 00115 FXColor getTransparentColor() const { return transp; } 00116 00117 /// Change transparency color 00118 void setTransparentColor(FXColor color){ transp=color; } 00119 00120 /// Destructor 00121 virtual ~FXIcon(); 00122 }; 00123 00124 } 00125 00126 #endif

Copyright © 1997-2005 Jeroen van der Zijp