mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-28 18:20:14 +01:00
[escher] TableViewDataSource: implement default cumulatedWidthFromIndex,
cumulatedWidthFromIndex, indexFromCumulatedWidth, indexFromCumulatedHeight
This commit is contained in:
@@ -95,27 +95,11 @@ KDCoordinate CalculationController::rowHeight(int j) {
|
||||
return k_cellHeight;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::cumulatedWidthFromIndex(int i) {
|
||||
int result = 0;
|
||||
for (int k = 0; k < i; k++) {
|
||||
result += columnWidth(k);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::cumulatedHeightFromIndex(int j) {
|
||||
return j*rowHeight(0);
|
||||
}
|
||||
|
||||
int CalculationController::indexFromCumulatedWidth(KDCoordinate offsetX) {
|
||||
int result = 0;
|
||||
int i = 0;
|
||||
while (result < offsetX && i < numberOfRows()) {
|
||||
result += rowHeight(i++);
|
||||
}
|
||||
return (result < offsetX || offsetX == 0) ? i : i - 1;
|
||||
}
|
||||
|
||||
int CalculationController::indexFromCumulatedHeight(KDCoordinate offsetY) {
|
||||
return (offsetY-1) / rowHeight(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user