summaryrefslogtreecommitdiff
path: root/wx+/grid.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2023-01-22 13:56:55 -0500
committerB. Stack <bgstack15@gmail.com>2023-01-22 13:56:55 -0500
commit75e05bc441382db69c842a64c562738cb749214e (patch)
tree698b60b3b4b914bf7958cf1174d0373909bf1e8f /wx+/grid.h
parentadd upstream 11.29 (diff)
downloadFreeFileSync-75e05bc441382db69c842a64c562738cb749214e.tar.gz
FreeFileSync-75e05bc441382db69c842a64c562738cb749214e.tar.bz2
FreeFileSync-75e05bc441382db69c842a64c562738cb749214e.zip
add upstream 12.0
Diffstat (limited to 'wx+/grid.h')
-rw-r--r--wx+/grid.h41
1 files changed, 24 insertions, 17 deletions
diff --git a/wx+/grid.h b/wx+/grid.h
index 3b3e76b7..302abda8 100644
--- a/wx+/grid.h
+++ b/wx+/grid.h
@@ -97,9 +97,6 @@ struct GridContextMenuEvent : public wxEvent
};
//------------------------------------------------------------------------------------------------------------
-class Grid;
-
-
class GridData
{
public:
@@ -113,21 +110,21 @@ 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 HoverArea getMouseHover (wxDC& dc, size_t row, ColumnType colType, int cellRelativePosX, int cellWidth) { return HoverArea::none; }
- virtual std::wstring getToolTip (size_t row, ColumnType colType, HoverArea rowHover) { return std::wstring(); }
+ virtual std::wstring getToolTip ( size_t row, ColumnType colType, HoverArea rowHover) { return std::wstring(); }
//label area:
virtual std::wstring getColumnLabel(ColumnType colType) const = 0;
virtual void renderColumnLabel(wxDC& dc, const wxRect& rect, ColumnType colType, bool enabled, bool highlighted); //default implementation
virtual std::wstring getToolTip(ColumnType colType) const { return std::wstring(); }
+ //optional helper routines:
static int getColumnGapLeft(); //for left-aligned text
static wxColor getColorSelectionGradientFrom();
static wxColor getColorSelectionGradientTo();
- //optional helper routines:
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
+ int alignment = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, const wxSize* textExtentHint = nullptr);
+ static wxRect drawCellBorder(wxDC& dc, const wxRect& rect); //returns inner rectangle
static wxRect drawColumnLabelBackground(wxDC& dc, const wxRect& rect, bool highlighted); //returns inner rectangle
static void drawColumnLabelText (wxDC& dc, const wxRect& rect, const std::wstring& text, bool enabled);
@@ -253,7 +250,7 @@ private:
class Selection
{
public:
- void init(size_t rowCount) { selected_.resize(rowCount); clear(); }
+ void resize(size_t rowCount) { selected_.resize(rowCount, false); }
size_t gridSize() const { return selected_.size(); }
@@ -266,20 +263,30 @@ private:
return result;
}
- void clear() { selectRange(0, selected_.size(), false); }
-
bool isSelected(size_t row) const { return row < selected_.size() ? selected_[row] != 0 : false; }
- void selectRange(size_t rowFirst, size_t rowLast, bool positive = true) //select [rowFirst, rowLast), trims if required!
+ bool matchesRange(size_t rowFirst, size_t rowLast, bool positive)
{
- if (rowFirst <= rowLast)
+ if (rowFirst <= rowLast && rowLast <= selected_.size())
{
- rowFirst = std::clamp<size_t>(rowFirst, 0, selected_.size());
- rowLast = std::clamp<size_t>(rowLast, 0, selected_.size());
-
- std::fill(selected_.begin() + rowFirst, selected_.begin() + rowLast, positive);
+ const auto rangeEnd = selected_.begin() + rowLast;
+ return std::find(selected_.begin() + rowFirst, rangeEnd, static_cast<unsigned char>(!positive)) == rangeEnd;
}
- else assert(false);
+ else
+ {
+ assert(false);
+ return false;
+ }
+ }
+
+ void clear() { selectRange(0, selected_.size(), false); }
+
+ void selectRange(size_t rowFirst, size_t rowLast, bool positive = true) //select [rowFirst, rowLast), trims if required!
+ {
+ assert(rowFirst <= rowLast && rowLast <= selected_.size());
+ if (rowFirst < rowLast)
+ std::fill(selected_.begin() + std::min(rowFirst, selected_.size()),
+ selected_.begin() + std::min(rowLast, selected_.size()), positive);
}
private:
bgstack15