summaryrefslogtreecommitdiff
path: root/wx+/dc.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-07-15 09:50:54 -0400
committerB. Stack <bgstack15@gmail.com>2021-07-15 09:50:54 -0400
commitfccb76c1f19a08ee0f0db6014cd217a64ba3502f (patch)
tree774b9ac395e65f9346210dcf804aa58f1b3975d1 /wx+/dc.h
parentMerge branch '11.11' into 'master' (diff)
downloadFreeFileSync-fccb76c1f19a08ee0f0db6014cd217a64ba3502f.tar.gz
FreeFileSync-fccb76c1f19a08ee0f0db6014cd217a64ba3502f.tar.bz2
FreeFileSync-fccb76c1f19a08ee0f0db6014cd217a64ba3502f.zip
add upstream 11.12
Diffstat (limited to 'wx+/dc.h')
-rw-r--r--wx+/dc.h40
1 files changed, 31 insertions, 9 deletions
diff --git a/wx+/dc.h b/wx+/dc.h
index e12c04e3..c5b78119 100644
--- a/wx+/dc.h
+++ b/wx+/dc.h
@@ -37,6 +37,7 @@ void clearArea(wxDC& dc, const wxRect& rect, const wxColor& col)
if (rect.width > 0 && //clearArea() is surprisingly expensive
rect.height > 0)
{
+ assert(col.IsSolid());
//wxDC::DrawRectangle() just widens inner area if wxTRANSPARENT_PEN is used!
//bonus: wxTRANSPARENT_PEN is about 2x faster than redundantly drawing with col!
wxDCPenChanger areaPen (dc, *wxTRANSPARENT_PEN);
@@ -48,16 +49,37 @@ void clearArea(wxDC& dc, const wxRect& rect, const wxColor& col)
//properly draw rectangle respecting high DPI (and avoiding wxPen position fuzzyness)
inline
-void drawFilledRectangle(wxDC& dc, wxRect rect, int borderWidth, const wxColor& borderCol, const wxColor& innerCol)
+void drawInsetRectangle(wxDC& dc, wxRect rect, int borderWidth, const wxColor& borderCol, const wxColor& innerCol)
{
- assert(borderCol.IsSolid() && innerCol.IsSolid());
- wxDCPenChanger rectPen (dc, *wxTRANSPARENT_PEN);
- wxDCBrushChanger rectBrush(dc, borderCol);
- dc.DrawRectangle(rect);
- rect.Deflate(borderWidth); //attention, more wxWidgets design mistakes: behavior of wxRect::Deflate depends on object being const/non-const!!!
-
- dc.SetBrush(innerCol);
- dc.DrawRectangle(rect);
+ if (rect.width > 0 &&
+ rect.height > 0)
+ {
+ assert(borderCol.IsSolid() && innerCol.IsSolid());
+ wxDCPenChanger rectPen (dc, *wxTRANSPARENT_PEN);
+ wxDCBrushChanger rectBrush(dc, borderCol);
+ dc.DrawRectangle(rect);
+ rect.Deflate(borderWidth); //attention, more wxWidgets design mistakes: behavior of wxRect::Deflate depends on object being const/non-const!!!
+
+ dc.SetBrush(innerCol);
+ dc.DrawRectangle(rect);
+ }
+}
+
+
+inline
+void drawInsetRectangle(wxDC& dc, const wxRect& rect, int borderWidth, const wxColor& col)
+{
+ if (rect.width > 0 &&
+ rect.height > 0)
+ {
+ assert(col.IsSolid());
+ wxDCPenChanger areaPen (dc, *wxTRANSPARENT_PEN);
+ wxDCBrushChanger areaBrush(dc, col);
+ dc.DrawRectangle(rect.GetTopLeft(), {borderWidth, rect.height});
+ dc.DrawRectangle(rect.GetTopLeft() + wxPoint{rect.width - borderWidth, 0}, {borderWidth, rect.height});
+ dc.DrawRectangle(rect.GetTopLeft(), {rect.width, borderWidth});
+ dc.DrawRectangle(rect.GetTopLeft() + wxPoint{0, rect.height - borderWidth}, {rect.width, borderWidth});
+ }
}
bgstack15