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