summaryrefslogtreecommitdiff
path: root/wx+
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-06-19 16:18:18 -0400
committerB Stack <bgstack15@gmail.com>2020-06-19 16:18:18 -0400
commitb2801fb887fe40875b3ec90619b011b45c1d2796 (patch)
treefbbe856cbc0ba5a5d3a831f3ec514563cc69ecb1 /wx+
parentMerge branch '10.24' into 'master' (diff)
downloadFreeFileSync-b2801fb887fe40875b3ec90619b011b45c1d2796.tar.gz
FreeFileSync-b2801fb887fe40875b3ec90619b011b45c1d2796.tar.bz2
FreeFileSync-b2801fb887fe40875b3ec90619b011b45c1d2796.zip
add upstream 10.25
Diffstat (limited to 'wx+')
-rw-r--r--wx+/dc.h10
-rw-r--r--wx+/graph.cpp4
-rw-r--r--wx+/grid.cpp51
-rw-r--r--wx+/grid.h7
4 files changed, 41 insertions, 31 deletions
diff --git a/wx+/dc.h b/wx+/dc.h
index f1b067ac..f6f5518b 100644
--- a/wx+/dc.h
+++ b/wx+/dc.h
@@ -73,8 +73,8 @@ class RecursiveDcClipper
public:
RecursiveDcClipper(wxDC& dc, const wxRect& r) : dc_(dc)
{
- auto it = clippingAreas.find(&dc);
- if (it != clippingAreas.end())
+ if (auto it = clippingAreas.find(&dc);
+ it != clippingAreas.end())
{
oldRect_ = it->second;
@@ -103,6 +103,9 @@ public:
}
private:
+ RecursiveDcClipper (const RecursiveDcClipper&) = delete;
+ RecursiveDcClipper& operator=(const RecursiveDcClipper&) = delete;
+
//associate "active" clipping area with each DC
inline static std::unordered_map<wxDC*, wxRect> clippingAreas;
@@ -156,6 +159,9 @@ public:
}
private:
+ BufferedPaintDC (const BufferedPaintDC&) = delete;
+ BufferedPaintDC& operator=(const BufferedPaintDC&) = delete;
+
std::optional<wxBitmap>& buffer_;
wxPaintDC paintDc_;
};
diff --git a/wx+/graph.cpp b/wx+/graph.cpp
index ec338e99..1fb3775c 100644
--- a/wx+/graph.cpp
+++ b/wx+/graph.cpp
@@ -831,7 +831,7 @@ void Graph2D::render(wxDC& dc) const
size_t drawIndexFirst = 0;
while (drawIndexFirst < points.size())
{
- size_t drawIndexLast = std::find(marker.begin() + drawIndexFirst, marker.end(), true) - marker.begin();
+ size_t drawIndexLast = std::find(marker.begin() + drawIndexFirst, marker.end(), static_cast<char>(true)) - marker.begin();
if (drawIndexLast < points.size()) ++drawIndexLast;
const int pointCount = static_cast<int>(drawIndexLast - drawIndexFirst);
@@ -841,7 +841,7 @@ void Graph2D::render(wxDC& dc) const
dc.DrawLines(pointCount, &points[drawIndexFirst]);
dc.DrawPoint(points[drawIndexLast - 1]); //wxDC::DrawLines() doesn't draw last pixel
}
- drawIndexFirst = std::find(marker.begin() + drawIndexLast, marker.end(), false) - marker.begin();
+ drawIndexFirst = std::find(marker.begin() + drawIndexLast, marker.end(), static_cast<char>(false)) - marker.begin();
}
}
}
diff --git a/wx+/grid.cpp b/wx+/grid.cpp
index c7b43d4a..0ce5c978 100644
--- a/wx+/grid.cpp
+++ b/wx+/grid.cpp
@@ -145,24 +145,25 @@ void GridData::drawCellBackground(wxDC& dc, const wxRect& rect, bool enabled, bo
}
-wxSize GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& text, int alignment)
+void GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& text, int alignment, const wxSize* textExtentHint)
{
- /*
- performance notes (Windows):
- - wxDC::GetTextExtent() is by far the most expensive call (20x more expensive than wxDC::DrawText())
- - wxDC::DrawLabel() is inefficiently implemented; internally calls: wxDC::GetMultiLineTextExtent(), wxDC::GetTextExtent(), wxDC::DrawText()
- - wxDC::GetMultiLineTextExtent() calls wxDC::GetTextExtent()
- - wxDC::DrawText also calls wxDC::GetTextExtent()!!
- => wxDC::DrawLabel() boils down to 3(!) calls to wxDC::GetTextExtent()!!!
- - wxDC::DrawLabel results in GetTextExtent() call even for empty strings!!!
- => skip the wxDC::DrawLabel() cruft and directly call wxDC::DrawText!
- */
+ /* Performance Notes (Windows):
+ - wxDC::GetTextExtent() is by far the most expensive call (20x more expensive than wxDC::DrawText())
+ - wxDC::DrawLabel() is inefficiently implemented; internally calls: wxDC::GetMultiLineTextExtent(), wxDC::GetTextExtent(), wxDC::DrawText()
+ - wxDC::GetMultiLineTextExtent() calls wxDC::GetTextExtent()
+ - wxDC::DrawText also calls wxDC::GetTextExtent()!!
+ => wxDC::DrawLabel() boils down to 3(!) calls to wxDC::GetTextExtent()!!!
+ - wxDC::DrawLabel results in GetTextExtent() call even for empty strings!!!
+ => skip the wxDC::DrawLabel() cruft and directly call wxDC::DrawText()! */
+ assert(!contains(text, L'\n'));
+ if (text.empty())
+ return;
//truncate large texts and add ellipsis
- assert(!contains(text, L'\n'));
+ wxString textTrunc = text;
+ wxSize extentTrunc = textExtentHint ? *textExtentHint : dc.GetTextExtent(text);
+ assert(!textExtentHint || *textExtentHint == dc.GetTextExtent(text)); //"trust, but verify" :>
- std::wstring textTrunc = text;
- wxSize extentTrunc = dc.GetTextExtent(textTrunc);
if (extentTrunc.GetWidth() > rect.width)
{
//unlike Windows 7 Explorer, we truncate UTF-16 correctly: e.g. CJK-Ideogramm encodes to TWO wchar_t: utfTo<std::wstring>("\xf0\xa4\xbd\x9c");
@@ -182,7 +183,7 @@ wxSize GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring&
}
const size_t middle = (low + high) / 2; //=> never 0 when "high - low > 1"
- const std::wstring& candidate = getUnicodeSubstring(text, 0, middle) + ELLIPSIS;
+ const wxString candidate = getUnicodeSubstring(text, 0, middle) + ELLIPSIS;
const wxSize extentCand = dc.GetTextExtent(candidate); //perf: most expensive call of this routine!
if (extentCand.GetWidth() <= rect.width)
@@ -207,9 +208,11 @@ wxSize GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring&
else if (alignment & wxALIGN_CENTER_VERTICAL)
pt.y += static_cast<int>(std::floor((rect.height - extentTrunc.GetHeight()) / 2.0)); //round down negative values, too!
- RecursiveDcClipper clip(dc, rect);
+ //std::unique_ptr<RecursiveDcClipper> clip; -> redundant!? RecursiveDcClipper already used during Grid cell rendering
+ //if (extentTrunc.GetWidth() > rect.width)
+ // clip = std::make_unique<RecursiveDcClipper>(dc, rect);
+
dc.DrawText(textTrunc, pt);
- return extentTrunc;
}
@@ -660,7 +663,7 @@ private:
void drawColumnLabel(wxDC& dc, const wxRect& rect, size_t col, ColumnType colType, bool enabled)
{
- if (auto dataView = refParent().getDataProvider())
+ if (auto prov = refParent().getDataProvider())
{
const bool isHighlighted = activeResizing_ ? col == activeResizing_ ->getColumn () : //highlight_ column on mouse-over
activeClickOrMove_ ? col == activeClickOrMove_->getColumnFrom() :
@@ -668,7 +671,7 @@ private:
false;
RecursiveDcClipper clip(dc, rect);
- dataView->renderColumnLabel(dc, rect, colType, enabled, isHighlighted);
+ prov->renderColumnLabel(dc, rect, colType, enabled, isHighlighted);
//draw move target location
if (refParent().allowColumnMove_)
@@ -1688,21 +1691,21 @@ void Grid::onKeyDown(wxKeyEvent& event)
case WXK_PAGEUP:
case WXK_NUMPAD_PAGEUP:
if (event.ShiftDown())
- selectWithCursorTo(cursorRow - GetClientSize().GetHeight() / rowLabelWin_->getRowHeight());
+ selectWithCursorTo(cursorRow - rowLabelWin_->GetClientSize().GetHeight() / rowLabelWin_->getRowHeight());
//else if (event.ControlDown())
// ;
else
- moveCursorTo(cursorRow - GetClientSize().GetHeight() / rowLabelWin_->getRowHeight());
+ moveCursorTo(cursorRow - rowLabelWin_->GetClientSize().GetHeight() / rowLabelWin_->getRowHeight());
return;
case WXK_PAGEDOWN:
case WXK_NUMPAD_PAGEDOWN:
if (event.ShiftDown())
- selectWithCursorTo(cursorRow + GetClientSize().GetHeight() / rowLabelWin_->getRowHeight());
+ selectWithCursorTo(cursorRow + rowLabelWin_->GetClientSize().GetHeight() / rowLabelWin_->getRowHeight());
//else if (event.ControlDown())
// ;
else
- moveCursorTo(cursorRow + GetClientSize().GetHeight() / rowLabelWin_->getRowHeight());
+ moveCursorTo(cursorRow + rowLabelWin_->GetClientSize().GetHeight() / rowLabelWin_->getRowHeight());
return;
case 'A': //Ctrl + A - select all
@@ -2163,7 +2166,7 @@ void Grid::scrollTo(size_t row)
size_t Grid::getTopRow() const
{
- const wxPoint absPos = CalcUnscrolledPosition(wxPoint(0, 0));
+ const wxPoint absPos = CalcUnscrolledPosition(wxPoint(0, 0));
const ptrdiff_t row = rowLabelWin_->getRowAtPos(absPos.y); //return -1 for invalid position; >= rowCount if out of range
assert((getRowCount() == 0 && row == 0) || (0 <= row && row < static_cast<ptrdiff_t>(getRowCount())));
return row;
diff --git a/wx+/grid.h b/wx+/grid.h
index 662c4fc1..05710e3f 100644
--- a/wx+/grid.h
+++ b/wx+/grid.h
@@ -111,7 +111,7 @@ public:
virtual void renderCell (wxDC& dc, const wxRect& rect, size_t row, ColumnType colType, bool enabled, bool selected, HoverArea rowHover);
virtual int getBestSize (wxDC& dc, size_t row, ColumnType colType); //must correspond to renderCell()!
virtual std::wstring getToolTip (size_t row, ColumnType colType) const { return std::wstring(); }
- virtual HoverArea getRowMouseHover(size_t row, ColumnType colType, int cellRelativePosX, int cellWidth) { return HoverArea::NONE; }
+ virtual HoverArea getRowMouseHover (size_t row, ColumnType colType, int cellRelativePosX, int cellWidth) { return HoverArea::NONE; }
//label area:
virtual std::wstring getColumnLabel(ColumnType colType) const = 0;
@@ -123,7 +123,8 @@ public:
static wxColor getColorSelectionGradientTo();
//optional helper routines:
- static wxSize drawCellText (wxDC& dc, const wxRect& rect, const std::wstring& text, int alignment = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); //returns text extent
+ static void drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& text,
+ int alignment = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, const wxSize* textExtentHint = nullptr); //returns text extent
static wxRect drawCellBorder (wxDC& dc, const wxRect& rect); //returns inner rectangle
static void drawCellBackground(wxDC& dc, const wxRect& rect, bool enabled, bool selected, const wxColor& backgroundColor);
@@ -285,7 +286,7 @@ private:
}
private:
- std::vector<char> selected_; //effectively a vector<bool> of size "number of rows"
+ std::vector<unsigned char> selected_; //effectively a vector<bool> of size "number of rows"
};
struct VisibleColumn
bgstack15