]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/dcmemory.h
document recently added enums
[wxWidgets.git] / interface / wx / dcmemory.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dcmemory.h
3 // Purpose: interface of wxMemoryDC
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxMemoryDC
11
12 A memory device context provides a means to draw graphics onto a bitmap.
13 When drawing in to a mono-bitmap, using @c wxWHITE, @c wxWHITE_PEN and
14 @c wxWHITE_BRUSH will draw the background colour (i.e. 0) whereas all other
15 colours will draw the foreground colour (i.e. 1).
16
17 A bitmap must be selected into the new memory DC before it may be used for
18 anything. Typical usage is as follows:
19
20 @code
21 // Create a memory DC
22 wxMemoryDC temp_dc;
23 temp_dc.SelectObject(test_bitmap);
24
25 // We can now draw into the memory DC...
26 // Copy from this DC to another DC.
27 old_dc.Blit(250, 50, BITMAP_WIDTH, BITMAP_HEIGHT, temp_dc, 0, 0);
28 @endcode
29
30 Note that the memory DC must be deleted (or the bitmap selected out of it)
31 before a bitmap can be reselected into another memory DC.
32
33 And, before performing any other operations on the bitmap data, the bitmap
34 must be selected out of the memory DC:
35
36 @code
37 temp_dc.SelectObject(wxNullBitmap);
38 @endcode
39
40 This happens automatically when wxMemoryDC object goes out of scope.
41
42 @library{wxcore}
43 @category{dc}
44
45 @see wxBitmap, wxDC
46 */
47 class wxMemoryDC : public wxDC
48 {
49 public:
50 /**
51 Constructs a new memory device context.
52
53 Use the wxDC::Ok() member to test whether the constructor was
54 successful in creating a usable device context. Don't forget to select
55 a bitmap into the DC before drawing on it.
56 */
57 wxMemoryDC();
58 /**
59 Constructs a new memory device context and calls SelectObject() with
60 the given bitmap.
61
62 Use the wxDC::Ok() member to test whether the constructor was
63 successful in creating a usable device context.
64 */
65 wxMemoryDC(wxBitmap& bitmap);
66
67 /**
68 Works exactly like SelectObjectAsSource() but this is the function you
69 should use when you select a bitmap because you want to modify it, e.g.
70 drawing on this DC.
71
72 Using SelectObjectAsSource() when modifying the bitmap may incurr some
73 problems related to wxBitmap being a reference counted object (see
74 @ref overview_refcount).
75
76 Also, before using the updated bitmap data, make sure to select it out
77 of context first (for example by selecting wxNullBitmap into the device
78 context).
79
80 @see wxDC::DrawBitmap()
81 */
82 void SelectObject(wxBitmap& bitmap);
83
84 /**
85 Selects the given bitmap into the device context, to use as the memory
86 bitmap. Selecting the bitmap into a memory DC allows you to draw into
87 the DC (and therefore the bitmap) and also to use wxDC::Blit() to copy
88 the bitmap to a window. For this purpose, you may find wxDC::DrawIcon()
89 easier to use instead.
90
91 If the argument is wxNullBitmap (or some other uninitialised wxBitmap)
92 the current bitmap is selected out of the device context, and the
93 original bitmap restored, allowing the current bitmap to be destroyed
94 safely.
95 */
96 void SelectObjectAsSource(const wxBitmap& bitmap);
97 };
98