X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/82edfbe7d99a970b00ca37e5017ce74c3c9a37e0..e4c903b2ea42fe104ef50d0ea6028f14d8309dfa:/include/wx/generic/private/grid.h diff --git a/include/wx/generic/private/grid.h b/include/wx/generic/private/grid.h index e8fc6ec037..ebc8e2bcca 100644 --- a/include/wx/generic/private/grid.h +++ b/include/wx/generic/private/grid.h @@ -158,6 +158,15 @@ protected: private: wxGrid *GetOwner() const { return static_cast(GetParent()); } + static wxMouseEvent GetDummyMouseEvent() + { + // make up a dummy event for the grid event to use -- unfortunately we + // can't do anything else here + wxMouseEvent e; + e.SetState(wxGetMouseState()); + return e; + } + // override the base class method to update our m_columns array virtual void OnColumnCountChanging(unsigned int count) { @@ -195,7 +204,8 @@ private: // as this is done by the user we should notify the main program about // it - GetOwner()->SendEvent(wxEVT_GRID_COL_SIZE, -1, idx); + GetOwner()->SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, idx, + GetDummyMouseEvent()); } // overridden to react to the columns order changes in the customization @@ -209,9 +219,33 @@ private: // event handlers forwarding wxHeaderCtrl events to wxGrid void OnClick(wxHeaderCtrlEvent& event) { + GetOwner()->SendEvent(wxEVT_GRID_LABEL_LEFT_CLICK, + -1, event.GetColumn(), + GetDummyMouseEvent()); + GetOwner()->DoColHeaderClick(event.GetColumn()); } + void OnDoubleClick(wxHeaderCtrlEvent& event) + { + if ( !GetOwner()->SendEvent(wxEVT_GRID_LABEL_LEFT_DCLICK, + -1, event.GetColumn(), + GetDummyMouseEvent()) ) + { + event.Skip(); + } + } + + void OnRightClick(wxHeaderCtrlEvent& event) + { + if ( !GetOwner()->SendEvent(wxEVT_GRID_LABEL_RIGHT_CLICK, + -1, event.GetColumn(), + GetDummyMouseEvent()) ) + { + event.Skip(); + } + } + void OnBeginResize(wxHeaderCtrlEvent& event) { GetOwner()->DoStartResizeCol(event.GetColumn()); @@ -226,7 +260,12 @@ private: void OnEndResize(wxHeaderCtrlEvent& event) { - GetOwner()->DoEndDragResizeCol(); + // we again need to pass a mouse event to be used for the grid event + // generation but we don't have it here so use a dummy one as in + // UpdateColumnVisibility() + wxMouseEvent e; + e.SetState(wxGetMouseState()); + GetOwner()->DoEndDragResizeCol(e); event.Skip(); } @@ -505,8 +544,10 @@ public: // // NB: currently this is always identity for the rows as reordering is only // implemented for the lines - virtual int GetLineAt(const wxGrid *grid, int line) const = 0; + virtual int GetLineAt(const wxGrid *grid, int pos) const = 0; + // Return the index of the line just before the given one. + virtual int GetLineBefore(const wxGrid* grid, int line) const = 0; // Get the row or column label window virtual wxWindow *GetHeaderWindow(wxGrid *grid) const = 0; @@ -575,6 +616,9 @@ public: virtual int GetLineAt(const wxGrid * WXUNUSED(grid), int line) const { return line; } // TODO: implement row reordering + virtual int GetLineBefore(const wxGrid* WXUNUSED(grid), int line) const + { return line ? line - 1 : line; } + virtual wxWindow *GetHeaderWindow(wxGrid *grid) const { return grid->GetGridRowLabelWindow(); } virtual int GetHeaderWindowSize(wxGrid *grid) const @@ -636,6 +680,9 @@ public: virtual int GetLineAt(const wxGrid *grid, int line) const { return grid->GetColAt(line); } + virtual int GetLineBefore(const wxGrid* grid, int line) const + { return grid->GetColAt(wxMax(0, grid->GetColPos(line) - 1)); } + virtual wxWindow *GetHeaderWindow(wxGrid *grid) const { return grid->GetGridColLabelWindow(); } virtual int GetHeaderWindowSize(wxGrid *grid) const @@ -746,23 +793,6 @@ private: const int m_numLines; }; -// ---------------------------------------------------------------------------- -// private helpers -// ---------------------------------------------------------------------------- - -namespace -{ - -// ensure that first is less or equal to second, swapping the values if -// necessary -void EnsureFirstLessThanSecond(int& first, int& second) -{ - if ( first > second ) - wxSwap(first, second); -} - -} // anonymous namespace - // ---------------------------------------------------------------------------- // data structures used for the data type registry // ----------------------------------------------------------------------------