]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dcmemory.h
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / interface / wx / dcmemory.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcmemory.h
e54c96f1 3// Purpose: interface of wxMemoryDC
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxMemoryDC
7c913512 10
3a7fb603
BP
11 A memory device context provides a means to draw graphics onto a bitmap.
12 When drawing in to a mono-bitmap, using @c wxWHITE, @c wxWHITE_PEN and
13 @c wxWHITE_BRUSH will draw the background colour (i.e. 0) whereas all other
14 colours will draw the foreground colour (i.e. 1).
15
16 A bitmap must be selected into the new memory DC before it may be used for
17 anything. Typical usage is as follows:
18
19 @code
20 // Create a memory DC
21 wxMemoryDC temp_dc;
22 temp_dc.SelectObject(test_bitmap);
23
24 // We can now draw into the memory DC...
25 // Copy from this DC to another DC.
26 old_dc.Blit(250, 50, BITMAP_WIDTH, BITMAP_HEIGHT, temp_dc, 0, 0);
27 @endcode
28
29 Note that the memory DC must be deleted (or the bitmap selected out of it)
30 before a bitmap can be reselected into another memory DC.
31
32 And, before performing any other operations on the bitmap data, the bitmap
33 must be selected out of the memory DC:
34
35 @code
36 temp_dc.SelectObject(wxNullBitmap);
37 @endcode
38
39 This happens automatically when wxMemoryDC object goes out of scope.
7c913512 40
23324ae1
FM
41 @library{wxcore}
42 @category{dc}
7c913512 43
e54c96f1 44 @see wxBitmap, wxDC
23324ae1
FM
45*/
46class wxMemoryDC : public wxDC
47{
48public:
23324ae1 49 /**
3a7fb603
BP
50 Constructs a new memory device context.
51
8b93348e 52 Use the wxDC::IsOk() member to test whether the constructor was
3a7fb603
BP
53 successful in creating a usable device context. Don't forget to select
54 a bitmap into the DC before drawing on it.
23324ae1
FM
55 */
56 wxMemoryDC();
80ccb346
VZ
57
58 /**
59 Constructs a new memory device context having the same characteristics
60 as the given existing device context.
61
62 This constructor creates a memory device context @e compatible with @a
63 dc in wxMSW, the argument is ignored in the other ports. If @a dc is
64 @NULL, a device context compatible with the screen is created, just as
65 with the default constructor.
66 */
67 wxMemoryDC(wxDC *dc);
68
3a7fb603
BP
69 /**
70 Constructs a new memory device context and calls SelectObject() with
71 the given bitmap.
72
8b93348e 73 Use the wxDC::IsOk() member to test whether the constructor was
3a7fb603
BP
74 successful in creating a usable device context.
75 */
7c913512 76 wxMemoryDC(wxBitmap& bitmap);
23324ae1
FM
77
78 /**
3a7fb603
BP
79 Works exactly like SelectObjectAsSource() but this is the function you
80 should use when you select a bitmap because you want to modify it, e.g.
81 drawing on this DC.
82
71f5b0e7 83 Using SelectObjectAsSource() when modifying the bitmap may incur some
3a7fb603
BP
84 problems related to wxBitmap being a reference counted object (see
85 @ref overview_refcount).
86
71f5b0e7
VZ
87 Before using the updated bitmap data, make sure to select it out of
88 context first either by selecting ::wxNullBitmap into the device
89 context or destroying the device context entirely.
90
91 If the bitmap is already selected in this device context, nothing is
92 done. If it is selected in another context, the function asserts and
93 drawing on the bitmap won't work correctly.
3a7fb603
BP
94
95 @see wxDC::DrawBitmap()
23324ae1
FM
96 */
97 void SelectObject(wxBitmap& bitmap);
98
99 /**
100 Selects the given bitmap into the device context, to use as the memory
101 bitmap. Selecting the bitmap into a memory DC allows you to draw into
3a7fb603
BP
102 the DC (and therefore the bitmap) and also to use wxDC::Blit() to copy
103 the bitmap to a window. For this purpose, you may find wxDC::DrawIcon()
23324ae1 104 easier to use instead.
3a7fb603 105
8b93348e 106 If the argument is ::wxNullBitmap (or some other uninitialised wxBitmap)
3a7fb603
BP
107 the current bitmap is selected out of the device context, and the
108 original bitmap restored, allowing the current bitmap to be destroyed
109 safely.
23324ae1
FM
110 */
111 void SelectObjectAsSource(const wxBitmap& bitmap);
112};
e54c96f1 113