Fix resizing of wxGrid columns when they were reordered.

The column resizing code in wxGrid didn't take account of the fact that the
column positions and indices could be different. Correct it by inserting calls
to wxGrid::GetColAt() and GetColPos() in a new wxGridOperations::GetLineBefore()
method.

Closes #11984.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66137 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-11-13 15:02:42 +00:00
parent 76d23441fc
commit f71adb5029
3 changed files with 13 additions and 2 deletions

View File

@@ -428,6 +428,7 @@ All (GUI):
- Added wxToolbook XRC handler (Andrea Zanellato). - Added wxToolbook XRC handler (Andrea Zanellato).
- Added wxDocManager::FindTemplate() (troelsk). - Added wxDocManager::FindTemplate() (troelsk).
- Return bool, not void, from wxImage::ConvertAlphaToMask() (troelsk). - Return bool, not void, from wxImage::ConvertAlphaToMask() (troelsk).
- Fixed resizing columns in wxGrid when they were reordered.
MSW: MSW:

View File

@@ -544,8 +544,10 @@ public:
// //
// NB: currently this is always identity for the rows as reordering is only // NB: currently this is always identity for the rows as reordering is only
// implemented for the lines // 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 // Get the row or column label window
virtual wxWindow *GetHeaderWindow(wxGrid *grid) const = 0; virtual wxWindow *GetHeaderWindow(wxGrid *grid) const = 0;
@@ -614,6 +616,9 @@ public:
virtual int GetLineAt(const wxGrid * WXUNUSED(grid), int line) const virtual int GetLineAt(const wxGrid * WXUNUSED(grid), int line) const
{ return line; } // TODO: implement row reordering { 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 virtual wxWindow *GetHeaderWindow(wxGrid *grid) const
{ return grid->GetGridRowLabelWindow(); } { return grid->GetGridRowLabelWindow(); }
virtual int GetHeaderWindowSize(wxGrid *grid) const virtual int GetHeaderWindowSize(wxGrid *grid) const
@@ -675,6 +680,9 @@ public:
virtual int GetLineAt(const wxGrid *grid, int line) const virtual int GetLineAt(const wxGrid *grid, int line) const
{ return grid->GetColAt(line); } { 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 virtual wxWindow *GetHeaderWindow(wxGrid *grid) const
{ return grid->GetGridColLabelWindow(); } { return grid->GetGridColLabelWindow(); }
virtual int GetHeaderWindowSize(wxGrid *grid) const virtual int GetHeaderWindowSize(wxGrid *grid) const

View File

@@ -6281,7 +6281,9 @@ int wxGrid::PosToEdgeOfLine(int pos, const wxGridOperations& oper) const
else if ( line > 0 && else if ( line > 0 &&
pos - oper.GetLineStartPos(this, pos - oper.GetLineStartPos(this,
line) < WXGRID_LABEL_EDGE_ZONE ) line) < WXGRID_LABEL_EDGE_ZONE )
return line - 1; {
return oper.GetLineBefore(this, line);
}
} }
return -1; return -1;