1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use crateDeviceContext;
use crateWxWidget;
/// An automatically buffered paint DC that provides flicker-free drawing.
///
/// This DC automatically chooses between wxPaintDC (on platforms with native
/// double-buffering) and wxBufferedPaintDC (on platforms without) to provide
/// optimal performance while eliminating flicker.
///
/// Use this instead of PaintDC for smooth animations and frequent redraws.
///
/// # Usage
///
/// ```rust,no_run
/// # use wxdragon::prelude::*;
///
/// # let frame = Frame::builder()
/// # .with_title("AutoBufferedPaintDC Example")
/// # .with_size(Size::new(400, 300))
/// # .build();
/// # let panel = Panel::builder(&frame).build();
/// # let panel_clone = panel.clone();
/// panel.on_paint(move |_event| {
/// let dc = AutoBufferedPaintDC::new(&panel_clone);
///
/// // Clear the background
/// dc.set_background(Colour::rgb(255, 255, 255));
/// dc.clear();
///
/// // Draw your animation content
/// dc.set_pen(Colour::rgb(255, 0, 0), 2, PenStyle::Solid);
/// dc.draw_circle(100, 100, 50);
/// });
/// ```
///
/// # Important Notes
///
/// For best results, make sure to call `set_background_style(BackgroundStyle::Paint)`
/// on your widget during initialization. This tells wxWidgets to not erase the
/// background automatically, which is essential for flicker-free drawing.
///
/// Also consider handling the erase background event with an empty handler to
/// prevent unwanted background erasing.