diff --git a/docs/changes.txt b/docs/changes.txt index f12a9c8f13..d39ccd8a9e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -428,6 +428,7 @@ All (GUI): - Added wxToolbook XRC handler (Andrea Zanellato). - Added wxDocManager::FindTemplate() (troelsk). - Return bool, not void, from wxImage::ConvertAlphaToMask() (troelsk). +- Fixed resizing columns in wxGrid when they were reordered. MSW: diff --git a/include/wx/generic/private/grid.h b/include/wx/generic/private/grid.h index 2f3099d07e..388146d502 100644 --- a/include/wx/generic/private/grid.h +++ b/include/wx/generic/private/grid.h @@ -544,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; @@ -614,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 @@ -675,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 diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 1b23c55dac..d9a1a800d4 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -6281,7 +6281,9 @@ int wxGrid::PosToEdgeOfLine(int pos, const wxGridOperations& oper) const else if ( line > 0 && pos - oper.GetLineStartPos(this, line) < WXGRID_LABEL_EDGE_ZONE ) - return line - 1; + { + return oper.GetLineBefore(this, line); + } } return -1;