15#include <wx/dcclient.h>
26 if (pOverlay.expired())
30 pOverlay.lock()->SequenceNumber(),
32 return p.expired() || p.lock()->SequenceNumber() < value;
45 if ( !IsShownOnScreen() )
50 using Pair = std::pair<wxRect,
bool >;
51 std::vector< Pair > pairs;
52 pairs.reserve(n_pairs);
61 pairs.push_back( pOverlay.lock()->GetRectangle(
size) );
71 bool some_overlays_need_repainting =
73 std::any_of( pairs.begin(), pairs.end(),
74 [](
const Pair &pair ){ return pair.second; } );
76 if (!some_overlays_need_repainting) {
90 for (
size_t ii = 0; ii < n_pairs - 1; ++ii) {
91 for (
size_t jj = ii + 1; jj < n_pairs; ++jj) {
92 if (pairs[ii].second != pairs[jj].second &&
93 pairs[ii].first.Intersects(pairs[jj].first)) {
95 pairs[ii].second = pairs[jj].second =
true;
102 std::optional<wxClientDC> myDC;
103 auto &dc = pDC ? *pDC : (myDC.emplace(
this), *myDC);
106 auto it2 = pairs.begin();
108 if (repaint_all || it2->second)
116 if (repaint_all || it2->second) {
120 pOverlay.lock()->Draw(*
this, dc);
131 auto newEnd = std::remove_if(
begin,
end,
132 [](
const std::weak_ptr<Overlay> &pOverlay ){
133 return pOverlay.expired(); } );
146 pDC->SetBrush(brush);
153 long(pDC->GetLogicalFunction()) } }
#define wxRasterOperationMode
Makes temporary drawing context changes that you back out of, RAII style.
std::unique_ptr< wxDC, ::DCUnchanger > Base
BackedPanel is for a panel that consists of a bitmap with something drawn over it....
std::weak_ptr< Overlay > OverlayPtr
OverlayPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
std::vector< OverlayPtr > mOverlays
void DrawOverlays(bool repaint_all, wxDC *pDC=nullptr)
void AddOverlay(const std::weak_ptr< Overlay > &pOverlay)
auto GetBrush(double kneeX, double kneeY, const wxColor &colorAtKnee, const wxSize &size, const wxGraphicsContext &gc)
std::pair< const char *, const char * > Pair
const char * end(const char *str) noexcept
const char * begin(const char *str) noexcept
Used to restore pen, brush and logical-op in a DC back to what they were.