]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dcmemory.h
Remove more non-standard keywords from wxWebView MSW header.
[wxWidgets.git] / interface / wx / dcmemory.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcmemory.h
e54c96f1 3// Purpose: interface of wxMemoryDC
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxMemoryDC
7c913512 11
3a7fb603
BP
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.
7c913512 41
23324ae1
FM
42 @library{wxcore}
43 @category{dc}
7c913512 44
e54c96f1 45 @see wxBitmap, wxDC
23324ae1
FM
46*/
47class wxMemoryDC : public wxDC
48{
49public:
23324ae1 50 /**
3a7fb603
BP
51 Constructs a new memory device context.
52
8b93348e 53 Use the wxDC::IsOk() member to test whether the constructor was
3a7fb603
BP
54 successful in creating a usable device context. Don't forget to select
55 a bitmap into the DC before drawing on it.
23324ae1
FM
56 */
57 wxMemoryDC();
80ccb346
VZ
58
59 /**
60 Constructs a new memory device context having the same characteristics
61 as the given existing device context.
62
63 This constructor creates a memory device context @e compatible with @a
64 dc in wxMSW, the argument is ignored in the other ports. If @a dc is
65 @NULL, a device context compatible with the screen is created, just as
66 with the default constructor.
67 */
68 wxMemoryDC(wxDC *dc);
69
3a7fb603
BP
70 /**
71 Constructs a new memory device context and calls SelectObject() with
72 the given bitmap.
73
8b93348e 74 Use the wxDC::IsOk() member to test whether the constructor was
3a7fb603
BP
75 successful in creating a usable device context.
76 */
7c913512 77 wxMemoryDC(wxBitmap& bitmap);
23324ae1
FM
78
79 /**
3a7fb603
BP
80 Works exactly like SelectObjectAsSource() but this is the function you
81 should use when you select a bitmap because you want to modify it, e.g.
82 drawing on this DC.
83
71f5b0e7 84 Using SelectObjectAsSource() when modifying the bitmap may incur some
3a7fb603
BP
85 problems related to wxBitmap being a reference counted object (see
86 @ref overview_refcount).
87
71f5b0e7
VZ
88 Before using the updated bitmap data, make sure to select it out of
89 context first either by selecting ::wxNullBitmap into the device
90 context or destroying the device context entirely.
91
92 If the bitmap is already selected in this device context, nothing is
93 done. If it is selected in another context, the function asserts and
94 drawing on the bitmap won't work correctly.
3a7fb603
BP
95
96 @see wxDC::DrawBitmap()
23324ae1
FM
97 */
98 void SelectObject(wxBitmap& bitmap);
99
100 /**
101 Selects the given bitmap into the device context, to use as the memory
102 bitmap. Selecting the bitmap into a memory DC allows you to draw into
3a7fb603
BP
103 the DC (and therefore the bitmap) and also to use wxDC::Blit() to copy
104 the bitmap to a window. For this purpose, you may find wxDC::DrawIcon()
23324ae1 105 easier to use instead.
3a7fb603 106
8b93348e 107 If the argument is ::wxNullBitmap (or some other uninitialised wxBitmap)
3a7fb603
BP
108 the current bitmap is selected out of the device context, and the
109 original bitmap restored, allowing the current bitmap to be destroyed
110 safely.
23324ae1
FM
111 */
112 void SelectObjectAsSource(const wxBitmap& bitmap);
113};
e54c96f1 114