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