]> git.saurik.com Git - wxWidgets.git/blame_incremental - interface/wx/dcmemory.h
Implement setFont on the iOS port of wxStaticText.
[wxWidgets.git] / interface / wx / dcmemory.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcmemory.h
3// Purpose: interface of wxMemoryDC
4// Author: wxWidgets team
5// Licence: wxWindows licence
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxMemoryDC
10
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.
40
41 @library{wxcore}
42 @category{dc}
43
44 @see wxBitmap, wxDC
45*/
46class wxMemoryDC : public wxDC
47{
48public:
49 /**
50 Constructs a new memory device context.
51
52 Use the wxDC::IsOk() member to test whether the constructor was
53 successful in creating a usable device context. Don't forget to select
54 a bitmap into the DC before drawing on it.
55 */
56 wxMemoryDC();
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
69 /**
70 Constructs a new memory device context and calls SelectObject() with
71 the given bitmap.
72
73 Use the wxDC::IsOk() member to test whether the constructor was
74 successful in creating a usable device context.
75 */
76 wxMemoryDC(wxBitmap& bitmap);
77
78 /**
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
83 Using SelectObjectAsSource() when modifying the bitmap may incur some
84 problems related to wxBitmap being a reference counted object (see
85 @ref overview_refcount).
86
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.
94
95 @see wxDC::DrawBitmap()
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
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()
104 easier to use instead.
105
106 If the argument is ::wxNullBitmap (or some other uninitialised wxBitmap)
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.
110 */
111 void SelectObjectAsSource(const wxBitmap& bitmap);
112};
113