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