diff --git a/uppsrc/CtrlLib/ArrayCtrl.cpp b/uppsrc/CtrlLib/ArrayCtrl.cpp index 3c724e1d3..d3de9292c 100644 --- a/uppsrc/CtrlLib/ArrayCtrl.cpp +++ b/uppsrc/CtrlLib/ArrayCtrl.cpp @@ -2,7 +2,7 @@ NAMESPACE_UPP -#define LTIMING(x) // TIMING(x) +#define LTIMING(x) // DTIMING(x) ArrayCtrl::Column::Column() { convert = NULL; @@ -796,6 +796,7 @@ const Display& ArrayCtrl::GetCellInfo(int i, int j, bool f0, Size ArrayCtrl::DoPaint(Draw& w, bool sample) { LTIMING("Paint"); + SyncColumnsPos(); bool hasfocus0 = HasFocusDeep() || sample; Size size = sample ? StdSampleSize() : GetSize(); Rect r; @@ -903,6 +904,7 @@ void ArrayCtrl::MinMaxLine() } void ArrayCtrl::Scroll() { + SyncColumnsPos(); MinMaxLine(); SyncPageCtrls(); PlaceEdits(); @@ -911,7 +913,22 @@ void ArrayCtrl::Scroll() { WhenScroll(); } +void ArrayCtrl::SyncColumnsPos() +{ + int x = 0; + column_pos.Clear(); + column_width.Clear(); + for(int i = 0; i < header.GetCount(); i++) { + int w = header.GetTabWidth(i); + int ii = header.GetTabIndex(i); + column_pos.At(ii, 0) = x; + column_width.At(ii, 0) = w; + x += w; + } +} + void ArrayCtrl::HeaderLayout() { + SyncColumnsPos(); MinMaxLine(); Refresh(); SyncInfo(); @@ -1054,15 +1071,13 @@ void ArrayCtrl::AddRowNumCtrl(Ctrl& ctrl) { Rect ArrayCtrl::GetCellRect(int i, int col) const { + LTIMING("GetCellRect"); Rect r; r.top = GetLineY(i) - sb; r.bottom = r.top + GetLineCy(i); - int x = 0; - HeaderCtrl& h = const_cast(header); // Ugly!!! - for(i = 0; header.GetTabIndex(i) != col; i++) - x += h.GetTabWidth(i); - r.left = x - header.GetScroll(); - r.right = r.left + h.GetTabWidth(i) - vertgrid + (col == column.GetCount() - 1); + r.left = (col < column_pos.GetCount() ? column_pos[col] : 0) - header.GetScroll(); + r.right = r.left + (col < column_width.GetCount() ? column_width[col] : 0) - vertgrid + + (col == column.GetCount() - 1); return r; } diff --git a/uppsrc/CtrlLib/ArrayCtrl.h b/uppsrc/CtrlLib/ArrayCtrl.h index 57cb90966..9bae33e62 100644 --- a/uppsrc/CtrlLib/ArrayCtrl.h +++ b/uppsrc/CtrlLib/ArrayCtrl.h @@ -188,6 +188,7 @@ private: Vector< Vector > cellinfo; Vector modify; FrameBottom scrollbox; + Vector column_width, column_pos; DisplayPopup info; const Order *columnsortsecondary; int min_visible_line, max_visible_line; @@ -252,6 +253,7 @@ private: void SetSb(); void MinMaxLine(); + void SyncColumnsPos(); void HeaderLayout(); void HeaderScroll(); void Scroll(); diff --git a/uppsrc/CtrlLib/HeaderCtrl.cpp b/uppsrc/CtrlLib/HeaderCtrl.cpp index 7ed14cfa8..0ffbf6051 100644 --- a/uppsrc/CtrlLib/HeaderCtrl.cpp +++ b/uppsrc/CtrlLib/HeaderCtrl.cpp @@ -323,8 +323,8 @@ void HeaderCtrl::RefreshDistribution() } else { Distribute(GetVisibleCi(0), 0); - oszcx = szcx; } + oszcx = szcx; ReCompute(); } }