]> git.saurik.com Git - wxWidgets.git/blob - interface/dcbuffer.h
Fixed wxScrolledWindow references to properly link (and appropriately changed others...
[wxWidgets.git] / interface / dcbuffer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dcbuffer.h
3 // Purpose: interface of wxBufferedDC
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxBufferedDC
11 @wxheader{dcbuffer.h}
12
13 This class provides a simple way to avoid flicker: when drawing on it,
14 everything is in fact first drawn on an in-memory buffer (a wxBitmap) and
15 then copied to the screen, using the associated wxDC, only once, when this
16 object is destroyed. wxBufferedDC itself is typically associated with
17 wxClientDC, if you want to use it in your @c EVT_PAINT handler, you should
18 look at wxBufferedPaintDC instead.
19
20 When used like this, a valid @e DC must be specified in the constructor
21 while the @e buffer bitmap doesn't have to be explicitly provided, by
22 default this class will allocate the bitmap of required size itself.
23 However using a dedicated bitmap can speed up the redrawing process by
24 eliminating the repeated creation and destruction of a possibly big bitmap.
25 Otherwise, wxBufferedDC can be used in the same way as any other device
26 context.
27
28 There is another possible use for wxBufferedDC is to use it to maintain a
29 backing store for the window contents. In this case, the associated @e DC
30 may be @NULL but a valid backing store bitmap should be specified.
31
32 Finally, please note that GTK+ 2.0 as well as OS X provide double buffering
33 themselves natively. You can either use wxWindow::IsDoubleBuffered() to
34 determine whether you need to use buffering or not, or use
35 wxAutoBufferedPaintDC to avoid needless double buffering on the systems
36 which already do it automatically.
37
38 @library{wxcore}
39 @category{dc}
40
41 @see wxDC, wxMemoryDC, wxBufferedPaintDC, wxAutoBufferedPaintDC
42 */
43 class wxBufferedDC : public wxMemoryDC
44 {
45 public:
46 /**
47 Default constructor. You must call one of the Init() methods later in
48 order to use the device context.
49 */
50 wxBufferedDC();
51
52 //@{
53 /**
54 Creates a buffer for the provided @dc. Init() must not be called when
55 using this constructor.
56
57 @param dc
58 The underlying DC: everything drawn to this object will be flushed
59 to this DC when this object is destroyed. You may pass @NULL in
60 order to just initialize the buffer, and not flush it.
61 @param area
62 The size of the bitmap to be used for buffering (this bitmap is
63 created internally when it is not given explicitly).
64 @param buffer
65 Explicitly provided bitmap to be used for buffering: this is the
66 most efficient solution as the bitmap doesn't have to be recreated
67 each time but it also requires more memory as the bitmap is never
68 freed. The bitmap should have appropriate size, anything drawn
69 outside of its bounds is clipped.
70 @param style
71 wxBUFFER_CLIENT_AREA to indicate that just the client area of the
72 window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the
73 buffer bitmap covers the virtual area.
74 */
75 wxBufferedDC(wxDC* dc, const wxSize& area,
76 int style = wxBUFFER_CLIENT_AREA);
77 wxBufferedDC(wxDC* dc, wxBitmap& buffer,
78 int style = wxBUFFER_CLIENT_AREA);
79 //@}
80
81 /**
82 Copies everything drawn on the DC so far to the underlying DC
83 associated with this object, if any.
84 */
85 ~wxBufferedDC();
86
87 //@{
88 /**
89 Initializes the object created using the default constructor. Please
90 see the constructors for parameter details.
91 */
92 void Init(wxDC* dc, const wxSize& area,
93 int style = wxBUFFER_CLIENT_AREA);
94 void Init(wxDC* dc, wxBitmap& buffer,
95 int style = wxBUFFER_CLIENT_AREA);
96 //@}
97 };
98
99
100
101 /**
102 @class wxAutoBufferedPaintDC
103 @wxheader{dcbuffer.h}
104
105 This wxDC derivative can be used inside of an @c EVT_PAINT() event handler
106 to achieve double-buffered drawing. Just use this class instead of
107 wxPaintDC and make sure wxWindow::SetBackgroundStyle() is called with
108 wxBG_STYLE_CUSTOM somewhere in the class initialization code, and that's
109 all you have to do to (mostly) avoid flicker.
110
111 The difference between wxBufferedPaintDC and this class is that this class
112 won't double-buffer on platforms which have native double-buffering
113 already, avoiding any unneccessary buffering to avoid flicker.
114
115 wxAutoBufferedPaintDC is simply a typedef of wxPaintDC on platforms that
116 have native double-buffering, otherwise, it is a typedef of
117 wxBufferedPaintDC.
118
119 @library{wxbase}
120 @category{dc}
121
122 @see wxDC, wxBufferedPaintDC, wxPaintDC
123 */
124 class wxAutoBufferedPaintDC : public wxBufferedPaintDC
125 {
126 public:
127 /**
128 Constructor. Pass a pointer to the window on which you wish to paint.
129 */
130 wxAutoBufferedPaintDC(wxWindow* window);
131 };
132
133
134
135 /**
136 @class wxBufferedPaintDC
137 @wxheader{dcbuffer.h}
138
139 This is a subclass of wxBufferedDC which can be used inside of an
140 @c EVT_PAINT() event handler to achieve double-buffered drawing. Just use
141 this class instead of wxPaintDC and make sure
142 wxWindow::SetBackgroundStyle() is called with wxBG_STYLE_CUSTOM somewhere
143 in the class initialization code, and that's all you have to do to (mostly)
144 avoid flicker. The only thing to watch out for is that if you are using
145 this class together with wxScrolled, you probably do @b not want to call
146 wxScrolled::PrepareDC() on it as it already does this internally for the
147 real underlying wxPaintDC.
148
149 @library{wxcore}
150 @category{dc}
151
152 @see wxDC, wxBufferedDC, wxAutoBufferedPaintDC, wxPaintDC
153 */
154 class wxBufferedPaintDC : public wxBufferedDC
155 {
156 public:
157 //@{
158 /**
159 As with wxBufferedDC, you may either provide the bitmap to be used for
160 buffering or let this object create one internally (in the latter case,
161 the size of the client part of the window is used).
162
163 Pass wxBUFFER_CLIENT_AREA for the @a style parameter to indicate that
164 just the client area of the window is buffered, or
165 wxBUFFER_VIRTUAL_AREA to indicate that the buffer bitmap covers the
166 virtual area.
167 */
168 wxBufferedPaintDC(wxWindow* window, wxBitmap& buffer,
169 int style = wxBUFFER_CLIENT_AREA);
170 wxBufferedPaintDC(wxWindow* window,
171 int style = wxBUFFER_CLIENT_AREA);
172 //@}
173
174 /**
175 Copies everything drawn on the DC so far to the window associated with
176 this object, using a wxPaintDC.
177 */
178 ~wxBufferedPaintDC();
179 };
180