]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: bitmap.h | |
698d17c3 | 3 | // Purpose: interface of wxBitmap* classes |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
8024723d FM |
9 | |
10 | /** | |
11 | In wxBitmap and wxBitmapHandler context this value means: "use the screen depth". | |
12 | */ | |
13 | #define wxBITMAP_SCREEN_DEPTH (-1) | |
14 | ||
23324ae1 FM |
15 | /** |
16 | @class wxBitmapHandler | |
17 | @wxheader{bitmap.h} | |
7c913512 | 18 | |
698d17c3 FM |
19 | This is the base class for implementing bitmap file loading/saving, and |
20 | bitmap creation from data. | |
23324ae1 | 21 | It is used within wxBitmap and is not normally seen by the application. |
7c913512 | 22 | |
23324ae1 | 23 | If you wish to extend the capabilities of wxBitmap, derive a class from |
1413ac04 | 24 | wxBitmapHandler and add the handler using wxBitmap::AddHandler() in your |
23324ae1 | 25 | application initialisation. |
7c913512 | 26 | |
23324ae1 | 27 | @library{wxcore} |
698d17c3 | 28 | @category{misc} |
7c913512 | 29 | |
698d17c3 | 30 | @see @ref overview_bitmap, wxBitmap, wxIcon, wxCursor |
23324ae1 FM |
31 | */ |
32 | class wxBitmapHandler : public wxObject | |
33 | { | |
34 | public: | |
35 | /** | |
698d17c3 FM |
36 | Default constructor. |
37 | ||
38 | In your own default constructor, initialise the members m_name, | |
39 | m_extension and m_type. | |
23324ae1 FM |
40 | */ |
41 | wxBitmapHandler(); | |
42 | ||
43 | /** | |
44 | Destroys the wxBitmapHandler object. | |
45 | */ | |
d2aa927a | 46 | virtual ~wxBitmapHandler(); |
23324ae1 FM |
47 | |
48 | /** | |
698d17c3 FM |
49 | Creates a bitmap from the given data, which can be of arbitrary type. |
50 | The wxBitmap object @a bitmap is manipulated by this function. | |
51 | ||
7c913512 | 52 | @param bitmap |
4cc4bfaf | 53 | The wxBitmap object. |
7c913512 | 54 | @param width |
4cc4bfaf | 55 | The width of the bitmap in pixels. |
7c913512 | 56 | @param height |
4cc4bfaf | 57 | The height of the bitmap in pixels. |
7c913512 | 58 | @param depth |
8024723d FM |
59 | The depth of the bitmap in pixels. |
60 | If this is ::wxBITMAP_SCREEN_DEPTH, the screen depth is used. | |
7c913512 | 61 | @param data |
4cc4bfaf | 62 | Data whose type depends on the value of type. |
7c913512 | 63 | @param type |
698d17c3 | 64 | A bitmap type identifier - see ::wxBitmapType for a list |
4cc4bfaf | 65 | of possible values. |
698d17c3 | 66 | |
d29a9a8a | 67 | @return @true if the call succeeded, @false otherwise (the default). |
23324ae1 | 68 | */ |
8024723d | 69 | virtual bool Create(wxBitmap* bitmap, const void* data, wxBitmapType type, |
1413ac04 | 70 | int width, int height, int depth = 1); |
23324ae1 FM |
71 | |
72 | /** | |
73 | Gets the file extension associated with this handler. | |
74 | */ | |
8024723d | 75 | const wxString& GetExtension() const; |
23324ae1 FM |
76 | |
77 | /** | |
78 | Gets the name of this handler. | |
79 | */ | |
8024723d | 80 | const wxString& GetName() const; |
23324ae1 FM |
81 | |
82 | /** | |
83 | Gets the bitmap type associated with this handler. | |
84 | */ | |
8024723d | 85 | wxBitmapType GetType() const; |
23324ae1 FM |
86 | |
87 | /** | |
698d17c3 FM |
88 | Loads a bitmap from a file or resource, putting the resulting data into |
89 | @a bitmap. | |
90 | ||
7c913512 | 91 | @param bitmap |
4cc4bfaf | 92 | The bitmap object which is to be affected by this operation. |
7c913512 | 93 | @param name |
4cc4bfaf FM |
94 | Either a filename or a Windows resource name. |
95 | The meaning of name is determined by the type parameter. | |
7c913512 | 96 | @param type |
8024723d | 97 | See ::wxBitmapType for values this can take. |
2fd0ada5 FM |
98 | @param desiredWidth |
99 | The desired width for the loaded bitmap. | |
100 | @param desiredHeight | |
101 | The desired height for the loaded bitmap. | |
698d17c3 | 102 | |
d29a9a8a | 103 | @return @true if the operation succeeded, @false otherwise. |
698d17c3 | 104 | |
4cc4bfaf | 105 | @see wxBitmap::LoadFile, wxBitmap::SaveFile, SaveFile() |
23324ae1 | 106 | */ |
1413ac04 FM |
107 | virtual bool LoadFile(wxBitmap* bitmap, const wxString& name, wxBitmapType type, |
108 | int desiredWidth, int desiredHeight); | |
23324ae1 FM |
109 | |
110 | /** | |
111 | Saves a bitmap in the named file. | |
698d17c3 | 112 | |
7c913512 | 113 | @param bitmap |
4cc4bfaf | 114 | The bitmap object which is to be affected by this operation. |
7c913512 | 115 | @param name |
4cc4bfaf | 116 | A filename. The meaning of name is determined by the type parameter. |
7c913512 | 117 | @param type |
8024723d | 118 | See ::wxBitmapType for values this can take. |
7c913512 | 119 | @param palette |
4cc4bfaf | 120 | An optional palette used for saving the bitmap. |
698d17c3 | 121 | |
d29a9a8a | 122 | @return @true if the operation succeeded, @false otherwise. |
698d17c3 | 123 | |
4cc4bfaf | 124 | @see wxBitmap::LoadFile, wxBitmap::SaveFile, LoadFile() |
23324ae1 | 125 | */ |
1413ac04 | 126 | virtual bool SaveFile(const wxBitmap* bitmap, const wxString& name, wxBitmapType type, |
2fd0ada5 | 127 | const wxPalette* palette = NULL) const; |
23324ae1 FM |
128 | |
129 | /** | |
130 | Sets the handler extension. | |
698d17c3 | 131 | |
7c913512 | 132 | @param extension |
4cc4bfaf | 133 | Handler extension. |
23324ae1 FM |
134 | */ |
135 | void SetExtension(const wxString& extension); | |
136 | ||
137 | /** | |
138 | Sets the handler name. | |
698d17c3 | 139 | |
7c913512 | 140 | @param name |
4cc4bfaf | 141 | Handler name. |
23324ae1 FM |
142 | */ |
143 | void SetName(const wxString& name); | |
144 | ||
145 | /** | |
146 | Sets the handler type. | |
698d17c3 | 147 | |
698d17c3 | 148 | @param type |
4cc4bfaf | 149 | Handler type. |
23324ae1 | 150 | */ |
8024723d | 151 | void SetType(wxBitmapType type); |
23324ae1 FM |
152 | }; |
153 | ||
154 | ||
155 | /** | |
156 | @class wxBitmap | |
157 | @wxheader{bitmap.h} | |
7c913512 | 158 | |
23324ae1 FM |
159 | This class encapsulates the concept of a platform-dependent bitmap, |
160 | either monochrome or colour or colour with alpha channel support. | |
de022e4f RR |
161 | |
162 | If you need direct access the bitmap data instead going through | |
163 | drawing to it using wxMemoryDC you need to use the wxPixelData | |
164 | class (either wxNativePixelData for RGB bitmaps or wxAlphaPixelData | |
165 | for bitmaps with an additionaly alpha channel). | |
7c913512 | 166 | |
698d17c3 | 167 | @note |
8024723d FM |
168 | Many wxBitmap functions take a @e type parameter, which is a value of the |
169 | ::wxBitmapType enumeration. | |
698d17c3 FM |
170 | The validity of those values depends however on the platform where your program |
171 | is running and from the wxWidgets configuration. | |
172 | If all possible wxWidgets settings are used, the Windows platform supports BMP file, | |
173 | BMP resource, XPM data, and XPM. | |
174 | Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file. | |
175 | Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file. | |
176 | In addition, wxBitmap can load and save all formats that wxImage; see wxImage for | |
177 | more info. Of course, you must have wxImage handlers loaded. | |
178 | ||
23324ae1 FM |
179 | @library{wxcore} |
180 | @category{gdi} | |
7c913512 | 181 | |
23324ae1 | 182 | @stdobjects |
698d17c3 | 183 | ::wxNullBitmap |
7c913512 | 184 | |
698d17c3 | 185 | @see @ref overview_bitmap, @ref overview_bitmap_supportedformats, |
de022e4f | 186 | wxDC::Blit, wxIcon, wxCursor, wxMemoryDC, wxImage, wxPixelData |
23324ae1 FM |
187 | */ |
188 | class wxBitmap : public wxGDIObject | |
189 | { | |
190 | public: | |
23324ae1 | 191 | /** |
698d17c3 FM |
192 | Default constructor. |
193 | ||
194 | Constructs a bitmap object with no data; an assignment or another member | |
195 | function such as Create() or LoadFile() must be called subsequently. | |
196 | */ | |
197 | wxBitmap(); | |
198 | ||
199 | /** | |
200 | Copy constructor, uses @ref overview_refcount "reference counting". | |
201 | To make a real copy, you can use: | |
202 | ||
203 | @code | |
204 | wxBitmap newBitmap = oldBitmap.GetSubBitmap( | |
205 | wxRect(0, 0, oldBitmap.GetWidth(), oldBitmap.GetHeight())); | |
206 | @endcode | |
207 | */ | |
208 | wxBitmap(const wxBitmap& bitmap); | |
209 | ||
8024723d FM |
210 | |
211 | /* | |
698d17c3 FM |
212 | Creates a bitmap from the given @a data which is interpreted in |
213 | platform-dependent manner. | |
214 | ||
215 | @param data | |
216 | Specifies the bitmap data in a platform-dependent format. | |
217 | @param type | |
218 | May be one of the ::wxBitmapType values and indicates which type of | |
219 | bitmap does @a data contains. See the note in the class | |
220 | detailed description. | |
221 | @param width | |
222 | Specifies the width of the bitmap. | |
223 | @param height | |
224 | Specifies the height of the bitmap. | |
225 | @param depth | |
226 | Specifies the depth of the bitmap. | |
227 | If this is omitted, the display depth of the screen is used. | |
8024723d | 228 | wxBitmap(const void* data, int type, int width, int height, int depth = -1); |
698d17c3 | 229 | |
698d17c3 | 230 | |
1413ac04 | 231 | NOTE: this ctor is not implemented by all ports, is somewhat useless |
8024723d FM |
232 | without further description of the "data" supported formats and |
233 | uses 'int type' instead of wxBitmapType, so don't document it. | |
698d17c3 | 234 | */ |
698d17c3 FM |
235 | |
236 | /** | |
237 | Creates a bitmap from the given array @a bits. | |
238 | You should only use this function for monochrome bitmaps (depth 1) in | |
239 | portable programs: in this case the bits parameter should contain an XBM image. | |
240 | ||
241 | For other bit depths, the behaviour is platform dependent: under Windows, | |
242 | the data is passed without any changes to the underlying CreateBitmap() API. | |
8024723d FM |
243 | Under other platforms, only monochrome bitmaps may be created using this |
244 | constructor and wxImage should be used for creating colour bitmaps from | |
245 | static data. | |
698d17c3 | 246 | |
7c913512 | 247 | @param bits |
4cc4bfaf | 248 | Specifies an array of pixel values. |
7c913512 | 249 | @param width |
4cc4bfaf | 250 | Specifies the width of the bitmap. |
7c913512 | 251 | @param height |
4cc4bfaf | 252 | Specifies the height of the bitmap. |
7c913512 | 253 | @param depth |
698d17c3 | 254 | Specifies the depth of the bitmap. |
8024723d | 255 | If this is omitted, then a value of 1 (monochrome bitmap) is used. |
698d17c3 FM |
256 | */ |
257 | wxBitmap(const char bits[], int width, int height, int depth = 1); | |
258 | ||
259 | /** | |
8024723d FM |
260 | Creates a new bitmap. A depth of ::wxBITMAP_SCREEN_DEPTH indicates the |
261 | depth of the current screen or visual. | |
1413ac04 | 262 | |
8024723d | 263 | Some platforms only support 1 for monochrome and ::wxBITMAP_SCREEN_DEPTH for |
698d17c3 FM |
264 | the current colour setting. |
265 | ||
266 | A depth of 32 including an alpha channel is supported under MSW, Mac and GTK+. | |
267 | */ | |
8024723d | 268 | wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); |
698d17c3 FM |
269 | |
270 | /** | |
271 | Creates a bitmap from XPM data. | |
272 | */ | |
273 | wxBitmap(const char* const* bits); | |
274 | ||
275 | /** | |
276 | Loads a bitmap from a file or resource. | |
277 | ||
7c913512 | 278 | @param name |
698d17c3 FM |
279 | This can refer to a resource name or a filename under MS Windows and X. |
280 | Its meaning is determined by the @a type parameter. | |
7c913512 | 281 | @param type |
698d17c3 FM |
282 | May be one of the ::wxBitmapType values and indicates which type of |
283 | bitmap should be loaded. See the note in the class detailed description. | |
284 | ||
4cc4bfaf | 285 | @see LoadFile() |
23324ae1 | 286 | */ |
8024723d | 287 | wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_XPM); |
698d17c3 FM |
288 | |
289 | /** | |
8024723d FM |
290 | Creates this bitmap object from the given image. |
291 | This has to be done to actually display an image as you cannot draw an | |
292 | image directly on a window. | |
698d17c3 FM |
293 | |
294 | The resulting bitmap will use the provided colour depth (or that of the | |
8024723d FM |
295 | current system if depth is ::wxBITMAP_SCREEN_DEPTH) which entails that a |
296 | colour reduction may take place. | |
698d17c3 FM |
297 | |
298 | When in 8-bit mode (PseudoColour mode), the GTK port will use a color cube | |
299 | created on program start-up to look up colors. This ensures a very fast conversion, | |
300 | but the image quality won't be perfect (and could be better for photo images using | |
301 | more sophisticated dithering algorithms). | |
302 | ||
303 | On Windows, if there is a palette present (set with SetPalette), it will be | |
304 | used when creating the wxBitmap (most useful in 8-bit display mode). | |
305 | On other platforms, the palette is currently ignored. | |
306 | ||
307 | @param img | |
308 | Platform-independent wxImage object. | |
309 | @param depth | |
310 | Specifies the depth of the bitmap. | |
311 | If this is omitted, the display depth of the screen is used. | |
312 | */ | |
8024723d | 313 | wxBitmap(const wxImage& img, int depth = wxBITMAP_SCREEN_DEPTH); |
23324ae1 FM |
314 | |
315 | /** | |
316 | Destructor. | |
698d17c3 FM |
317 | See @ref overview_refcount_destruct for more info. |
318 | ||
23324ae1 FM |
319 | If the application omits to delete the bitmap explicitly, the bitmap will be |
320 | destroyed automatically by wxWidgets when the application exits. | |
698d17c3 FM |
321 | |
322 | @warning | |
23324ae1 FM |
323 | Do not delete a bitmap that is selected into a memory device context. |
324 | */ | |
d2aa927a | 325 | virtual ~wxBitmap(); |
23324ae1 FM |
326 | |
327 | /** | |
328 | Adds a handler to the end of the static list of format handlers. | |
698d17c3 | 329 | |
7c913512 | 330 | @param handler |
4cc4bfaf FM |
331 | A new bitmap format handler object. There is usually only one instance |
332 | of a given handler class in an application session. | |
698d17c3 | 333 | |
4cc4bfaf | 334 | @see wxBitmapHandler |
23324ae1 FM |
335 | */ |
336 | static void AddHandler(wxBitmapHandler* handler); | |
337 | ||
338 | /** | |
339 | Deletes all bitmap handlers. | |
23324ae1 FM |
340 | This function is called by wxWidgets on exit. |
341 | */ | |
342 | static void CleanUpHandlers(); | |
343 | ||
344 | /** | |
345 | Creates an image from a platform-dependent bitmap. This preserves | |
346 | mask information so that bitmaps and images can be converted back | |
347 | and forth without loss in that respect. | |
348 | */ | |
1413ac04 | 349 | virtual wxImage ConvertToImage() const; |
23324ae1 FM |
350 | |
351 | /** | |
352 | Creates the bitmap from an icon. | |
353 | */ | |
1413ac04 | 354 | virtual bool CopyFromIcon(const wxIcon& icon); |
23324ae1 | 355 | |
698d17c3 FM |
356 | /** |
357 | Creates a fresh bitmap. | |
358 | If the final argument is omitted, the display depth of the screen is used. | |
359 | ||
360 | This overload works on all platforms. | |
361 | */ | |
1413ac04 | 362 | virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); |
698d17c3 | 363 | |
8024723d | 364 | /* |
23324ae1 | 365 | Creates a bitmap from the given data, which can be of arbitrary type. |
698d17c3 FM |
366 | |
367 | @param data | |
368 | Data whose type depends on the value of type. | |
369 | @param type | |
370 | A bitmap type identifier; see ::wxBitmapType for the list of values. | |
371 | See the note in the class detailed description for more info. | |
7c913512 | 372 | @param width |
4cc4bfaf | 373 | The width of the bitmap in pixels. |
7c913512 | 374 | @param height |
4cc4bfaf | 375 | The height of the bitmap in pixels. |
7c913512 | 376 | @param depth |
4cc4bfaf | 377 | The depth of the bitmap in pixels. If this is -1, the screen depth is used. |
698d17c3 | 378 | |
d29a9a8a | 379 | @return @true if the call succeeded, @false otherwise. |
698d17c3 FM |
380 | |
381 | This overload depends on the @a type of data. | |
698d17c3 | 382 | |
7c913512 | 383 | virtual bool Create(const void* data, int type, int width, |
698d17c3 | 384 | int height, int depth = -1); |
23324ae1 | 385 | |
8024723d FM |
386 | NOTE: leave this undoc for the same reason of the relative ctor. |
387 | */ | |
388 | ||
23324ae1 | 389 | /** |
698d17c3 FM |
390 | Finds the handler with the given @a name. |
391 | ||
d29a9a8a | 392 | @return A pointer to the handler if found, @NULL otherwise. |
698d17c3 FM |
393 | */ |
394 | static wxBitmapHandler* FindHandler(const wxString& name); | |
395 | ||
396 | /** | |
397 | Finds the handler associated with the given @a extension and @a type. | |
398 | ||
7c913512 | 399 | @param extension |
698d17c3 | 400 | The file extension, such as "bmp" (without the dot). |
7c913512 | 401 | @param bitmapType |
698d17c3 FM |
402 | The bitmap type managed by the handler, see ::wxBitmapType. |
403 | ||
d29a9a8a | 404 | @return A pointer to the handler if found, @NULL otherwise. |
23324ae1 | 405 | */ |
7c913512 FM |
406 | static wxBitmapHandler* FindHandler(const wxString& extension, |
407 | wxBitmapType bitmapType); | |
698d17c3 FM |
408 | |
409 | /** | |
410 | Finds the handler associated with the given bitmap type. | |
411 | ||
412 | @param bitmapType | |
413 | The bitmap type managed by the handler, see ::wxBitmapType. | |
414 | ||
d29a9a8a | 415 | @return A pointer to the handler if found, @NULL otherwise. |
698d17c3 FM |
416 | |
417 | @see wxBitmapHandler | |
418 | */ | |
419 | ||
7c913512 | 420 | static wxBitmapHandler* FindHandler(wxBitmapType bitmapType); |
23324ae1 FM |
421 | |
422 | /** | |
8024723d FM |
423 | Gets the colour depth of the bitmap. |
424 | A value of 1 indicates a monochrome bitmap. | |
23324ae1 | 425 | */ |
1413ac04 | 426 | virtual int GetDepth() const; |
23324ae1 FM |
427 | |
428 | /** | |
429 | Returns the static list of bitmap format handlers. | |
698d17c3 | 430 | |
4cc4bfaf | 431 | @see wxBitmapHandler |
23324ae1 FM |
432 | */ |
433 | static wxList GetHandlers(); | |
434 | ||
435 | /** | |
436 | Gets the height of the bitmap in pixels. | |
437 | */ | |
1413ac04 | 438 | virtual int GetHeight() const; |
23324ae1 FM |
439 | |
440 | /** | |
441 | Gets the associated mask (if any) which may have been loaded from a file | |
442 | or set for the bitmap. | |
698d17c3 | 443 | |
4cc4bfaf | 444 | @see SetMask(), wxMask |
23324ae1 | 445 | */ |
1413ac04 | 446 | virtual wxMask* GetMask() const; |
23324ae1 FM |
447 | |
448 | /** | |
449 | Gets the associated palette (if any) which may have been loaded from a file | |
450 | or set for the bitmap. | |
698d17c3 | 451 | |
4cc4bfaf | 452 | @see wxPalette |
23324ae1 | 453 | */ |
1413ac04 | 454 | virtual wxPalette* GetPalette() const; |
23324ae1 FM |
455 | |
456 | /** | |
457 | Returns a sub bitmap of the current one as long as the rect belongs entirely to | |
458 | the bitmap. This function preserves bit depth and mask information. | |
459 | */ | |
1413ac04 | 460 | virtual wxBitmap GetSubBitmap(const wxRect& rect) const; |
23324ae1 FM |
461 | |
462 | /** | |
463 | Gets the width of the bitmap in pixels. | |
698d17c3 | 464 | |
4cc4bfaf | 465 | @see GetHeight() |
23324ae1 | 466 | */ |
1413ac04 | 467 | virtual int GetWidth() const; |
23324ae1 FM |
468 | |
469 | /** | |
470 | Adds the standard bitmap format handlers, which, depending on wxWidgets | |
698d17c3 FM |
471 | configuration, can be handlers for Windows bitmap, Windows bitmap resource, |
472 | and XPM. | |
473 | ||
23324ae1 | 474 | This function is called by wxWidgets on startup. |
698d17c3 | 475 | |
4cc4bfaf | 476 | @see wxBitmapHandler |
23324ae1 FM |
477 | */ |
478 | static void InitStandardHandlers(); | |
479 | ||
480 | /** | |
481 | Adds a handler at the start of the static list of format handlers. | |
698d17c3 | 482 | |
7c913512 | 483 | @param handler |
4cc4bfaf FM |
484 | A new bitmap format handler object. There is usually only one instance |
485 | of a given handler class in an application session. | |
698d17c3 | 486 | |
4cc4bfaf | 487 | @see wxBitmapHandler |
23324ae1 FM |
488 | */ |
489 | static void InsertHandler(wxBitmapHandler* handler); | |
490 | ||
491 | /** | |
492 | Returns @true if bitmap data is present. | |
493 | */ | |
328f5751 | 494 | bool IsOk() const; |
23324ae1 FM |
495 | |
496 | /** | |
497 | Loads a bitmap from a file or resource. | |
698d17c3 | 498 | |
7c913512 | 499 | @param name |
4cc4bfaf | 500 | Either a filename or a Windows resource name. |
698d17c3 | 501 | The meaning of name is determined by the @a type parameter. |
7c913512 | 502 | @param type |
698d17c3 FM |
503 | One of the ::wxBitmapType values; see the note in the class |
504 | detailed description. | |
505 | ||
d29a9a8a | 506 | @return @true if the operation succeeded, @false otherwise. |
698d17c3 | 507 | |
23324ae1 | 508 | @remarks A palette may be associated with the bitmap if one exists |
4cc4bfaf FM |
509 | (especially for colour Windows bitmaps), and if the |
510 | code supports it. You can check if one has been created | |
698d17c3 FM |
511 | by using the GetPalette() member. |
512 | ||
4cc4bfaf | 513 | @see SaveFile() |
23324ae1 | 514 | */ |
1413ac04 | 515 | virtual bool LoadFile(const wxString& name, wxBitmapType type); |
23324ae1 FM |
516 | |
517 | /** | |
698d17c3 FM |
518 | Finds the handler with the given name, and removes it. |
519 | The handler is not deleted. | |
520 | ||
7c913512 | 521 | @param name |
4cc4bfaf | 522 | The handler name. |
698d17c3 | 523 | |
d29a9a8a | 524 | @return @true if the handler was found and removed, @false otherwise. |
698d17c3 | 525 | |
4cc4bfaf | 526 | @see wxBitmapHandler |
23324ae1 FM |
527 | */ |
528 | static bool RemoveHandler(const wxString& name); | |
529 | ||
530 | /** | |
531 | Saves a bitmap in the named file. | |
698d17c3 | 532 | |
7c913512 | 533 | @param name |
4cc4bfaf | 534 | A filename. The meaning of name is determined by the type parameter. |
7c913512 | 535 | @param type |
698d17c3 FM |
536 | One of the ::wxBitmapType values; see the note in the class |
537 | detailed description. | |
7c913512 | 538 | @param palette |
4cc4bfaf | 539 | An optional palette used for saving the bitmap. |
698d17c3 | 540 | |
d29a9a8a | 541 | @return @true if the operation succeeded, @false otherwise. |
698d17c3 | 542 | |
23324ae1 | 543 | @remarks Depending on how wxWidgets has been configured, not all formats |
4cc4bfaf | 544 | may be available. |
698d17c3 | 545 | |
4cc4bfaf | 546 | @see LoadFile() |
23324ae1 | 547 | */ |
1413ac04 FM |
548 | virtual bool SaveFile(const wxString& name, wxBitmapType type, |
549 | const wxPalette* palette = NULL) const; | |
23324ae1 FM |
550 | |
551 | /** | |
552 | Sets the depth member (does not affect the bitmap data). | |
698d17c3 FM |
553 | |
554 | @todo since these functions do not affect the bitmap data, | |
555 | why they exist?? | |
556 | ||
7c913512 | 557 | @param depth |
4cc4bfaf | 558 | Bitmap depth. |
23324ae1 | 559 | */ |
1413ac04 | 560 | virtual void SetDepth(int depth); |
23324ae1 FM |
561 | |
562 | /** | |
563 | Sets the height member (does not affect the bitmap data). | |
698d17c3 | 564 | |
7c913512 | 565 | @param height |
4cc4bfaf | 566 | Bitmap height in pixels. |
23324ae1 | 567 | */ |
1413ac04 | 568 | virtual void SetHeight(int height); |
23324ae1 FM |
569 | |
570 | /** | |
571 | Sets the mask for this bitmap. | |
698d17c3 | 572 | |
23324ae1 | 573 | @remarks The bitmap object owns the mask once this has been called. |
698d17c3 | 574 | |
4cc4bfaf | 575 | @see GetMask(), wxMask |
23324ae1 | 576 | */ |
1413ac04 | 577 | virtual void SetMask(wxMask* mask); |
23324ae1 FM |
578 | |
579 | /** | |
580 | Sets the associated palette. (Not implemented under GTK+). | |
698d17c3 | 581 | |
7c913512 | 582 | @param palette |
4cc4bfaf | 583 | The palette to set. |
698d17c3 | 584 | |
4cc4bfaf | 585 | @see wxPalette |
23324ae1 | 586 | */ |
1413ac04 | 587 | virtual void SetPalette(const wxPalette& palette); |
23324ae1 FM |
588 | |
589 | /** | |
590 | Sets the width member (does not affect the bitmap data). | |
698d17c3 | 591 | |
7c913512 | 592 | @param width |
4cc4bfaf | 593 | Bitmap width in pixels. |
23324ae1 | 594 | */ |
1413ac04 | 595 | virtual void SetWidth(int width); |
23324ae1 FM |
596 | }; |
597 | ||
e54c96f1 | 598 | /** |
698d17c3 | 599 | An empty wxBitmap object. |
e54c96f1 FM |
600 | */ |
601 | wxBitmap wxNullBitmap; | |
602 | ||
603 | ||
604 | ||
605 | ||
23324ae1 FM |
606 | /** |
607 | @class wxMask | |
608 | @wxheader{bitmap.h} | |
7c913512 | 609 | |
23324ae1 | 610 | This class encapsulates a monochrome mask bitmap, where the masked area is |
698d17c3 FM |
611 | black and the unmasked area is white. |
612 | ||
613 | When associated with a bitmap and drawn in a device context, the unmasked | |
614 | area of the bitmap will be drawn, and the masked area will not be drawn. | |
7c913512 | 615 | |
23324ae1 FM |
616 | @library{wxcore} |
617 | @category{gdi} | |
7c913512 | 618 | |
e54c96f1 | 619 | @see wxBitmap, wxDC::Blit, wxMemoryDC |
23324ae1 FM |
620 | */ |
621 | class wxMask : public wxObject | |
622 | { | |
623 | public: | |
698d17c3 FM |
624 | |
625 | /** | |
626 | Default constructor. | |
627 | */ | |
628 | wxMask(); | |
629 | ||
23324ae1 FM |
630 | /** |
631 | Constructs a mask from a bitmap and a palette index that indicates the | |
698d17c3 FM |
632 | background. |
633 | Not yet implemented for GTK. | |
634 | ||
7c913512 | 635 | @param bitmap |
4cc4bfaf | 636 | A valid bitmap. |
7c913512 | 637 | @param index |
4cc4bfaf | 638 | Index into a palette, specifying the transparency colour. |
23324ae1 | 639 | */ |
7c913512 | 640 | wxMask(const wxBitmap& bitmap, int index); |
698d17c3 FM |
641 | |
642 | /** | |
643 | Constructs a mask from a monochrome bitmap. | |
644 | ||
645 | @beginWxPythonOnly | |
646 | This is the default constructor for wxMask in wxPython. | |
647 | @endWxPythonOnly | |
648 | */ | |
649 | wxMask(const wxBitmap& bitmap); | |
650 | ||
651 | /** | |
652 | Constructs a mask from a bitmap and a colour that indicates the background. | |
653 | ||
654 | @beginWxPythonOnly | |
655 | wxPython has an alternate wxMask constructor matching this form called wxMaskColour. | |
656 | @endWxPythonOnly | |
657 | */ | |
658 | wxMask(const wxBitmap& bitmap, const wxColour& colour); | |
23324ae1 FM |
659 | |
660 | /** | |
661 | Destroys the wxMask object and the underlying bitmap data. | |
662 | */ | |
d2aa927a | 663 | virtual ~wxMask(); |
23324ae1 | 664 | |
23324ae1 FM |
665 | /** |
666 | Constructs a mask from a bitmap and a palette index that indicates the | |
698d17c3 FM |
667 | background. |
668 | Not yet implemented for GTK. | |
669 | ||
7c913512 | 670 | @param bitmap |
4cc4bfaf | 671 | A valid bitmap. |
7c913512 | 672 | @param index |
4cc4bfaf | 673 | Index into a palette, specifying the transparency colour. |
23324ae1 | 674 | */ |
698d17c3 FM |
675 | bool Create(const wxBitmap& bitmap, int index); |
676 | ||
677 | /** | |
678 | Constructs a mask from a monochrome bitmap. | |
679 | */ | |
23324ae1 | 680 | bool Create(const wxBitmap& bitmap); |
698d17c3 FM |
681 | |
682 | /** | |
683 | Constructs a mask from a bitmap and a colour that indicates the background. | |
684 | */ | |
7c913512 | 685 | bool Create(const wxBitmap& bitmap, const wxColour& colour); |
23324ae1 | 686 | }; |
e54c96f1 | 687 |