MCPcopy Create free account
hub / github.com/audacity/audacity / OnPaint

Method OnPaint

libraries/lib-wx-wrappers/ArrowButton.cpp:43–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43void ArrowButton::OnPaint(wxPaintEvent&)
44{
45 wxSize size = GetSize();
46 wxAutoBufferedPaintDC dc(this);
47 dc.Clear();
48
49 // button background
50 dc.SetBrush(wxBrush(wxColour(207, 217, 239)));
51 dc.SetPen(*wxTRANSPARENT_PEN);
52 dc.DrawRoundedRectangle(roundXOffset, roundYOffset, size.GetWidth(), size.GetHeight(), roundingRadius);
53
54 // draw arrow (triangle)
55 wxPoint center = wxPoint(GetClientSize().GetWidth() / 2, GetClientSize().GetHeight() / 2);
56 wxPoint points[3];
57
58#if defined(__WXOSX__) || defined(__WXMSW__)
59 int radius = 6;
60#else
61 int radius = FromDIP(6);
62#endif
63 if (m_direction == ArrowDirection::Left) {
64 points[0] = { center.x + radius, center.y - radius };
65 points[1] = { center.x - radius, center.y };
66 points[2] = { center.x + radius, center.y + radius };
67 } else {
68 points[0] = { center.x - radius, center.y - radius };
69 points[1] = { center.x + radius, center.y };
70 points[2] = { center.x - radius, center.y + radius };
71 }
72
73 dc.SetBrush(*wxBLACK_BRUSH);
74 dc.DrawPolygon(3, points);
75
76 if (HasFocus()) {
77 wxPen dottedPen(*wxBLACK, 1, wxPENSTYLE_DOT);
78 dc.SetPen(dottedPen);
79 dc.SetBrush(*wxTRANSPARENT_BRUSH);
80 dc.DrawRoundedRectangle(roundXOffset + 2, roundYOffset + 2,
81 size.GetWidth() - 4, size.GetHeight() - 4,
82 roundingRadius);
83 }
84}

Callers

nothing calls this directly

Calls 6

wxBrushClass · 0.85
GetHeightMethod · 0.80
wxColourClass · 0.50
wxPointClass · 0.50
ClearMethod · 0.45
GetWidthMethod · 0.45

Tested by

no test coverage detected