diff options
author | B Stack <bgstack15@gmail.com> | 2018-08-10 11:29:21 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2018-08-10 11:29:21 -0400 |
commit | a9255194193b04d599b9f0a64cde6b831dd7d916 (patch) | |
tree | 8b975393f5b0f7b4403da85f5095ad57581178e5 /wx+/grid.h | |
parent | 10.2 (diff) | |
download | FreeFileSync-10.3.tar.gz FreeFileSync-10.3.tar.bz2 FreeFileSync-10.3.zip |
10.310.3
Diffstat (limited to 'wx+/grid.h')
-rwxr-xr-x | wx+/grid.h | 31 |
1 files changed, 12 insertions, 19 deletions
@@ -47,23 +47,18 @@ struct GridClickEvent : public wxMouseEvent const HoverArea hoverArea_; //may be HoverArea::NONE }; -struct MouseSelect -{ - GridClickEvent click; - bool complete = false; //false if this is a preliminary "clear range" event for mouse-down, before the actual selection has happened during mouse-up -}; struct GridSelectEvent : public wxCommandEvent { - GridSelectEvent(size_t rowFirst, size_t rowLast, bool positive, const MouseSelect* mouseSelect) : + GridSelectEvent(size_t rowFirst, size_t rowLast, bool positive, const GridClickEvent* mouseClick) : wxCommandEvent(EVENT_GRID_SELECT_RANGE), rowFirst_(rowFirst), rowLast_(rowLast), positive_(positive), - mouseSelect_(mouseSelect ? *mouseSelect : Opt<MouseSelect>()) { assert(rowFirst <= rowLast); } + mouseClick_(mouseClick ? *mouseClick : Opt<GridClickEvent>()) { assert(rowFirst <= rowLast); } GridSelectEvent* Clone() const override { return new GridSelectEvent(*this); } const size_t rowFirst_; //selected range: [rowFirst_, rowLast_) const size_t rowLast_; const bool positive_; //"false" when clearing selection! - const Opt<MouseSelect> mouseSelect_; //filled unless selection was performed via keyboard shortcuts + const Opt<GridClickEvent> mouseClick_; //filled unless selection was performed via keyboard shortcuts }; struct GridLabelClickEvent : public wxMouseEvent @@ -127,16 +122,15 @@ public: 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); - static wxRect drawColumnLabelBorder (wxDC& dc, const wxRect& rect); //returns inner rectangle - static void drawColumnLabelBackground(wxDC& dc, const wxRect& rect, bool highlighted); + 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); }; -enum GridEventPolicy +enum class GridEventPolicy { - ALLOW_GRID_EVENT, - DENY_GRID_EVENT + ALLOW, + DENY }; @@ -187,7 +181,7 @@ public: std::vector<size_t> getSelectedRows() const { return selection_.get(); } void selectRow(size_t row, GridEventPolicy rangeEventPolicy); void selectAllRows (GridEventPolicy rangeEventPolicy); //turn off range selection event when calling this function in an event handler to avoid recursion! - void clearSelection(GridEventPolicy rangeEventPolicy) { clearSelectionImpl(nullptr /*mouseSelect*/, rangeEventPolicy); } // + void clearSelection(GridEventPolicy rangeEventPolicy); // void scrollDelta(int deltaX, int deltaY); //in scroll units @@ -212,7 +206,7 @@ public: void enableColumnMove (bool value) { allowColumnMove_ = value; } void enableColumnResize(bool value) { allowColumnResize_ = value; } - void setGridCursor(size_t row); //set + show + select cursor (+ emit range selection event) + void setGridCursor(size_t row, GridEventPolicy rangeEventPolicy); //set + show + select cursor size_t getGridCursor() const; //returns row void scrollTo(size_t row); @@ -232,7 +226,7 @@ private: void updateWindowSizes(bool updateScrollbar = true); - void selectWithCursor(ptrdiff_t row); + void selectWithCursor(ptrdiff_t row); //emits GridSelectEvent void redirectRowLabelEvent(wxMouseEvent& event); @@ -317,9 +311,8 @@ private: wxRect getColumnLabelArea(ColumnType colType) const; //returns empty rect if column not found - void selectRangeAndNotify(ptrdiff_t rowFrom, ptrdiff_t rowTo, bool positive, const MouseSelect* mouseSelect); //select inclusive range [rowFrom, rowTo] + notify event! - - void clearSelectionImpl(const MouseSelect* mouseSelect, GridEventPolicy rangeEventPolicy); + //select inclusive range [rowFrom, rowTo] + void selectRange(ptrdiff_t rowFrom, ptrdiff_t rowTo, bool positive, const GridClickEvent* mouseClick, GridEventPolicy rangeEventPolicy); bool isSelected(size_t row) const { return selection_.isSelected(row); } |