]> git.saurik.com Git - wxWidgets.git/blame_incremental - interface/wx/icon.h
Add files necessary to run Expat configure.
[wxWidgets.git] / interface / wx / icon.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: icon.h
3// Purpose: interface of wxIcon
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows licence
7/////////////////////////////////////////////////////////////////////////////
8
9
10
11/**
12 In wxIcon context this value means: "use the screen depth".
13*/
14#define wxICON_SCREEN_DEPTH (-1)
15
16
17/**
18 @class wxIcon
19
20 An icon is a small rectangular bitmap usually used for denoting a minimized
21 application.
22
23 It differs from a wxBitmap in always having a mask associated with it for
24 transparent drawing. On some platforms, icons and bitmaps are implemented
25 identically, since there is no real distinction between a wxBitmap with a
26 mask and an icon; and there is no specific icon format on some platforms
27 (X-based applications usually standardize on XPMs for small bitmaps and icons).
28 However, some platforms (such as Windows) make the distinction, so a
29 separate class is provided.
30
31 @remarks
32 It is usually desirable to associate a pertinent icon with a frame.
33 Icons can also be used for other purposes, for example with wxTreeCtrl and wxListCtrl.
34 Icons have different formats on different platforms therefore separate icons
35 will usually be created for the different environments.
36 Platform-specific methods for creating a wxIcon structure are catered for,
37 and this is an occasion where conditional compilation will probably be required.
38 Note that a new icon must be created for every time the icon is to be used
39 for a new window. In Windows, the icon will not be reloaded if it has already
40 been used.
41 An icon allocated to a frame will be deleted when the frame is deleted.
42 For more information please see @ref overview_bitmap.
43
44 @library{wxcore}
45 @category{gdi}
46
47 @stdobjects
48 ::wxNullIcon
49
50 @see @ref overview_bitmap, @ref overview_bitmap_supportedformats,
51 wxDC::DrawIcon, wxCursor
52*/
53class wxIcon : public wxGDIObject
54{
55public:
56 /**
57 Default ctor.
58
59 Constructs an icon object with no data; an assignment or another member
60 function such as LoadFile() must be called subsequently.
61 */
62 wxIcon();
63
64 /**
65 Copy ctor.
66 */
67 wxIcon(const wxIcon& icon);
68
69 /*
70 Creates an icon from the given data, which can be of arbitrary type.
71
72 wxIcon(void* data, int type, int width, int height, int depth = -1);
73
74 NOTE: this ctor is not implemented by all ports, is somewhat useless
75 without further description of the "data" supported formats and
76 uses 'int type' instead of wxBitmapType, so don't document it.
77 */
78
79 /**
80 Creates an icon from an array of bits.
81 You should only use this function for monochrome bitmaps (depth 1) in
82 portable programs: in this case the bits parameter should contain an XBM image.
83
84 For other bit depths, the behaviour is platform dependent: under Windows,
85 the data is passed without any changes to the underlying CreateBitmap() API.
86 Under other platforms, only monochrome bitmaps may be created using this
87 constructor and wxImage should be used for creating colour bitmaps from
88 static data.
89
90 @param bits
91 Specifies an array of pixel values.
92 @param width
93 The width of the image.
94 @param height
95 The height of the image.
96
97 @beginWxPerlOnly
98 In wxPerl use Wx::Icon->newBits(bits, width, height, depth = -1);
99 @endWxPerlOnly
100
101 @onlyfor{wxmsw,wxosx}
102 */
103 wxIcon(const char bits[], int width, int height);
104
105 /**
106 Creates a bitmap from XPM data.
107 To use this constructor, you must first include an XPM file.
108 For example, assuming that the file mybitmap.xpm contains an XPM array
109 of character pointers called @e mybitmap:
110
111 @code
112 #include "mybitmap.xpm"
113 ...
114 wxIcon *icon = new wxIcon(mybitmap);
115 @endcode
116
117 A macro, wxICON, is available which creates an icon using an XPM on
118 the appropriate platform, or an icon resource on Windows.
119
120 @code
121 wxIcon icon(wxICON(sample));
122
123 // Equivalent to:
124 #if defined(__WXGTK__) || defined(__WXMOTIF__)
125 wxIcon icon(sample_xpm);
126 #endif
127
128 #if defined(__WXMSW__)
129 wxIcon icon("sample");
130 #endif
131 @endcode
132
133 @beginWxPerlOnly
134 In wxPerl use Wx::Icon->newFromXPM(data).
135 @endWxPerlOnly
136 */
137 wxIcon(const char* const* bits);
138
139 /**
140 Loads an icon from a file or resource.
141
142 @param name
143 This can refer to a resource name or a filename under MS Windows and X.
144 Its meaning is determined by the @a type parameter.
145 @param type
146 May be one of the ::wxBitmapType values and indicates which type of
147 bitmap should be loaded. See the note in the class detailed description.
148 Note that the wxICON_DEFAULT_TYPE constant has different value under
149 different wxWidgets ports. See the icon.h header for the value it takes
150 for a specific port.
151 @param desiredWidth
152 Specifies the desired width of the icon. This parameter only has
153 an effect in Windows where icon resources can contain several icons
154 of different sizes.
155 @param desiredHeight
156 Specifies the desired height of the icon. This parameter only has
157 an effect in Windows where icon resources can contain several icons
158 of different sizes.
159
160 @see LoadFile()
161 */
162 wxIcon(const wxString& name, wxBitmapType type = wxICON_DEFAULT_TYPE,
163 int desiredWidth = -1, int desiredHeight = -1);
164
165 /**
166 Loads an icon from the specified location.
167 */
168 wxIcon(const wxIconLocation& loc);
169
170 /**
171 Destructor.
172 See @ref overview_refcount_destruct for more info.
173
174 If the application omits to delete the icon explicitly, the icon will be
175 destroyed automatically by wxWidgets when the application exits.
176
177 @warning
178 Do not delete an icon that is selected into a memory device context.
179 */
180 virtual ~wxIcon();
181
182 /**
183 Attach a Windows icon handle.
184
185 This wxMSW-specific method allows to assign a native Windows @c HICON
186 (which must be castes to @c WXHICON opaque handle type) to wxIcon.
187 Notice that this means that the @c HICON will be destroyed by wxIcon
188 when it is destroyed.
189
190 @return @true if successful.
191
192 @onlyfor{wxmsw}
193
194 @since 2.9.5
195 */
196 bool CreateFromHICON(WXHICON icon);
197
198 /**
199 Returns disabled (dimmed) version of the icon.
200
201 This method is available in wxIcon only under wxMSW, other ports only
202 have it in wxBitmap. You can always use wxImage::ConvertToDisabled()
203 and create the icon from wxImage manually however.
204
205 @onlyfor{wxmsw}
206
207 @since 2.9.0
208 */
209 wxIcon ConvertToDisabled(unsigned char brightness = 255) const;
210
211 /**
212 Copies @a bmp bitmap to this icon.
213 Under MS Windows the bitmap must have mask colour set.
214
215 @see LoadFile()
216 */
217 void CopyFromBitmap(const wxBitmap& bmp);
218
219 /**
220 Gets the colour depth of the icon.
221 A value of 1 indicates a monochrome icon.
222 */
223 int GetDepth() const;
224
225 /**
226 Gets the height of the icon in pixels.
227
228 @see GetWidth()
229 */
230 int GetHeight() const;
231
232 /**
233 Gets the width of the icon in pixels.
234
235 @see GetHeight()
236 */
237 int GetWidth() const;
238
239 /**
240 Returns @true if icon data is present.
241 */
242 virtual bool IsOk() const;
243
244 /**
245 Loads an icon from a file or resource.
246
247 @param name
248 Either a filename or a Windows resource name.
249 The meaning of name is determined by the @a type parameter.
250 @param type
251 One of the ::wxBitmapType values; see the note in the class
252 detailed description.
253 Note that the wxICON_DEFAULT_TYPE constant has different value under
254 different wxWidgets ports. See the icon.h header for the value it takes
255 for a specific port.
256 @param desiredWidth
257 Specifies the desired width of the icon. This parameter only has
258 an effect in Windows where icon resources can contain several icons
259 of different sizes.
260 @param desiredHeight
261 Specifies the desired height of the icon. This parameter only has
262 an effect in Windows where icon resources can contain several icons
263 of different sizes.
264
265 @return @true if the operation succeeded, @false otherwise.
266 */
267 bool LoadFile(const wxString& name, wxBitmapType type = wxICON_DEFAULT_TYPE,
268 int desiredWidth = -1, int desiredHeight = -1);
269
270 /**
271 Sets the depth member (does not affect the icon data).
272
273 @param depth
274 Icon depth.
275 */
276 void SetDepth(int depth);
277
278 /**
279 Sets the height member (does not affect the icon data).
280
281 @param height
282 Icon height in pixels.
283 */
284 void SetHeight(int height);
285
286 /**
287 Sets the width member (does not affect the icon data).
288
289 @param width
290 Icon width in pixels.
291 */
292 void SetWidth(int width);
293
294 /**
295 Assignment operator, using @ref overview_refcount.
296
297 @param icon
298 Icon to assign.
299 */
300 wxIcon& operator=(const wxIcon& icon);
301};
302
303/**
304 An empty wxIcon.
305*/
306wxIcon wxNullIcon;
307
308