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