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