Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
00001 /******************************************************************************** 00002 * * 00003 * I c o n - O b j e c t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2004 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.25 2004/02/08 17:17:33 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 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 protected: 00056 FXIcon(){} 00057 FXColor guesstransp(); 00058 private: 00059 FXIcon(const FXIcon&); 00060 FXIcon &operator=(const FXIcon&); 00061 public: 00062 00063 /** 00064 * Create an icon with an initial pixel buffer pix, a transparent color clr, 00065 * and options as in FXImage. The transparent color is used to determine which 00066 * pixel values are transparent, i.e. need to be masked out in the absence of 00067 * a true alpha channel. 00068 * If the flag IMAGE_OPAQUE is passed, the shape and etch bitmaps are generated 00069 * as if the image is fully opaque, even if it has an alpha channel or transparancy 00070 * color. The flag IMAGE_ALPHACOLOR is used to force a specific alpha color instead 00071 * of the alpha channel obtained from the image file. 00072 * Specifying IMAGE_ALPHAGUESS causes Icon to obtain the alpha color from the background 00073 * color of the image; it has the same effect as IMAGE_ALPHACOLOR in the sense that 00074 * the icon will be transparent for those colors matching the alpha color. 00075 */ 00076 FXIcon(FXApp* a,const FXColor *pix=NULL,FXColor clr=0,FXuint opts=0,FXint w=1,FXint h=1); 00077 00078 /** 00079 * Create the server side pixmap, the shape bitmap, and the etch bitmap, then 00080 * call render() to fill it with the pixel data from the client-side buffer. After the server- 00081 * side pixmap and bitmaps have been created, the client-side pixel buffer will be deleted unless 00082 * IMAGE_KEEP has been specified. If the pixel buffer is not owned, i.e. the flag IMAGE_OWNED 00083 * is not set, the pixel buffer will not be deleted. 00084 */ 00085 virtual void create(); 00086 00087 /** 00088 * Detach the server side pixmap, shape bitmap, and etch bitmap from the Icon. 00089 * Afterwards, the Icon is left as if it never had a server-side resources. 00090 */ 00091 virtual void detach(); 00092 00093 /** 00094 * Destroy the server-side pixmap and the shape bitmap and etch bitmap. 00095 * The client-side pixel buffer is not affected. 00096 */ 00097 virtual void destroy(); 00098 00099 /** 00100 * Render the server-side pixmap, shape bitmap and etch bitmap for the icon 00101 * from the client-side pixel buffer. 00102 */ 00103 virtual void render(); 00104 00105 /** 00106 * Resize both client-side and server-side representations (if any) to the 00107 * given width and height. The new representations typically contain garbage 00108 * after this operation and need to be re-filled. 00109 */ 00110 virtual void resize(FXint w,FXint h); 00111 00112 /// Obtain transparency color 00113 FXColor getTransparentColor() const { return transp; } 00114 00115 /// Change transparency color 00116 void setTransparentColor(FXColor color){ transp=color; } 00117 00118 /// Destructor 00119 virtual ~FXIcon(); 00120 }; 00121 00122 } 00123 00124 #endif
Copyright © 1997-2004 Jeroen van der Zijp |