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

FXIcon.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * I c o n - O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXIcon.h,v 1.29 2006/01/22 17:58:04 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXICON_H
25 #define FXICON_H
26 
27 #ifndef FXIMAGE_H
28 #include "FXImage.h"
29 #endif
30 
31 namespace FX {
32 
33 class FXDC;
34 class FXDCWindow;
35 class FXDrawable;
36 class FXTopWindow;
37 
38 
39 /**
40 * An Icon is an image with two additional server-side resources: a shape
41 * bitmap, which is used to mask those pixels where the background should
42 * be preserved during the drawing, and a etch bitmap, which is used to
43 * draw the icon when it is disabled.
44 */
45 class FXAPI FXIcon : public FXImage {
47  friend class FXDC;
48  friend class FXWindow;
49  friend class FXDCWindow;
50  friend class FXDrawable;
51  friend class FXTopWindow;
52 protected:
53  FXID shape; // Shape pixmap
54  FXID etch; // Etch pixmap
55  FXColor transp; // Transparency color
56 protected:
57  FXIcon(){}
58  FXColor guesstransp();
59 private:
60  FXIcon(const FXIcon&);
61  FXIcon &operator=(const FXIcon&);
62 public:
63 
64  /**
65  * Create an icon with an initial pixel buffer pix, a transparent color clr,
66  * and options as in FXImage. The transparent color is used to determine which
67  * pixel values are transparent, i.e. need to be masked out in the absence of
68  * a true alpha channel.
69  * If the flag IMAGE_OPAQUE is passed, the shape and etch bitmaps are generated
70  * as if the image is fully opaque, even if it has an alpha channel or transparancy
71  * color. The flag IMAGE_ALPHACOLOR is used to force a specific alpha color instead
72  * of the alpha channel obtained from the image file.
73  * Specifying IMAGE_ALPHAGUESS causes Icon to obtain the alpha color from the background
74  * color of the image; it has the same effect as IMAGE_ALPHACOLOR in the sense that
75  * the icon will be transparent for those colors matching the alpha color.
76  */
77  FXIcon(FXApp* a,const FXColor *pix=NULL,FXColor clr=0,FXuint opts=0,FXint w=1,FXint h=1);
78 
79  /**
80  * Create the server side pixmap, the shape bitmap, and the etch bitmap, then
81  * call render() to fill it with the pixel data from the client-side buffer. After
82  * the server-side pixmap and bitmaps have been created, the client-side pixel
83  * buffer will be deleted unless IMAGE_KEEP has been specified. If the pixel buffer
84  * is not owned, i.e. the flag IMAGE_OWNED is not set, the pixel buffer will not
85  * be deleted; however the pixel buffer will be set to NULL.
86  */
87  virtual void create();
88 
89  /**
90  * Detach the server side pixmap, shape bitmap, and etch bitmap from the Icon.
91  * Afterwards, the Icon is left as if it never had a server-side resources.
92  */
93  virtual void detach();
94 
95  /**
96  * Destroy the server-side pixmap and the shape bitmap and etch bitmap.
97  * The client-side pixel buffer is not affected.
98  */
99  virtual void destroy();
100 
101  /**
102  * Render the server-side pixmap, shape bitmap and etch bitmap for the icon
103  * from the client-side pixel buffer.
104  */
105  virtual void render();
106 
107  /**
108  * Resize both client-side and server-side representations (if any) to the
109  * given width and height. The new representations typically contain garbage
110  * after this operation and need to be re-filled.
111  */
112  virtual void resize(FXint w,FXint h);
113 
114  /// Obtain transparency color
115  FXColor getTransparentColor() const { return transp; }
116 
117  /// Change transparency color
118  void setTransparentColor(FXColor color){ transp=color; }
119 
120  /// Destructor
121  virtual ~FXIcon();
122  };
123 
124 }
125 
126 #endif
unsigned long FXID
Definition: fxdefs.h:442
Base class for all windows.
Definition: FXWindow.h:115
unsigned int FXuint
Definition: fxdefs.h:396
#define FXAPI
Definition: fxdefs.h:122
Application Object.
Definition: FXApp.h:158
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:454
Abstract Device Context.
Definition: FXDC.h:191
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
Abstract base class for all top-level windows.
Definition: FXTopWindow.h:106
Window Device Context.
Definition: FXDCWindow.h:52
An Image is a rectangular array of pixels.
Definition: FXImage.h:67
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
Drawable is an abstract base class for any surface that can be drawn upon, such as a FXWindow...
Definition: FXDrawable.h:41

Copyright © 1997-2005 Jeroen van der Zijp