string grid is working ok

This commit is contained in:
Vadim Lopatin 2014-06-11 13:31:43 +04:00
parent 388a2bc970
commit 956645f467
2 changed files with 6 additions and 10 deletions

View File

@ -520,7 +520,7 @@ extern (C) int UIAppMain(string[] args) {
grid.resize(30, 50); grid.resize(30, 50);
grid.fixedCols = 3; grid.fixedCols = 3;
grid.fixedRows = 2; grid.fixedRows = 2;
grid.rowSelect = true; //grid.rowSelect = true; // testing full row selection
grid.selectCell(4, 6, false); grid.selectCell(4, 6, false);
// create sample grid content // create sample grid content
for (int y = 0; y < grid.rows; y++) { for (int y = 0; y < grid.rows; y++) {

View File

@ -1005,7 +1005,7 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
protected int measureColWidth(int x) { protected int measureColWidth(int x) {
int m = 0; int m = 0;
for (int i = 0; i < _rows; i++) { for (int i = 0; i < _rows; i++) {
Point sz = measureCell(x - _headerCols, i); Point sz = measureCell(x - _headerCols, i - _headerRows);
if (m < sz.x) if (m < sz.x)
m = sz.x; m = sz.x;
} }
@ -1017,7 +1017,7 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler {
protected int measureRowHeight(int y) { protected int measureRowHeight(int y) {
int m = 0; int m = 0;
for (int i = 0; i < _cols; i++) { for (int i = 0; i < _cols; i++) {
Point sz = measureCell(i, y - _headerRows); Point sz = measureCell(i - _headerCols, y - _headerRows);
if (m < sz.y) if (m < sz.y)
m = sz.y; m = sz.y;
} }
@ -1203,10 +1203,6 @@ class StringGridWidget : StringGridWidgetBase {
dstring txt = cellText(col, row); dstring txt = cellText(col, row);
Point sz = fnt.textSize(txt); Point sz = fnt.textSize(txt);
Align ha = Align.Left; Align ha = Align.Left;
if (col < _headerCols)
ha = Align.Right;
if (row < _headerRows)
ha = Align.HCenter;
applyAlign(rc, sz, ha, Align.VCenter); applyAlign(rc, sz, ha, Align.VCenter);
fnt.drawText(buf, rc.left + 1, rc.top + 1, txt, 0x000000); fnt.drawText(buf, rc.left + 1, rc.top + 1, txt, 0x000000);
} }
@ -1220,13 +1216,13 @@ class StringGridWidget : StringGridWidgetBase {
txt = colTitle(col); txt = colTitle(col);
else if (row >= 0 && col < 0) else if (row >= 0 && col < 0)
txt = rowTitle(row); txt = rowTitle(row);
if (txt) if (!txt.length)
return; return;
Point sz = fnt.textSize(txt); Point sz = fnt.textSize(txt);
Align ha = Align.Left; Align ha = Align.Left;
if (col < _headerCols) if (col < 0)
ha = Align.Right; ha = Align.Right;
if (row < _headerRows) if (row < 0)
ha = Align.HCenter; ha = Align.HCenter;
applyAlign(rc, sz, ha, Align.VCenter); applyAlign(rc, sz, ha, Align.VCenter);
fnt.drawText(buf, rc.left + 1, rc.top + 1, txt, 0x000000); fnt.drawText(buf, rc.left + 1, rc.top + 1, txt, 0x000000);