From 956645f4673f3985298420ed2ede71b6d1f0badd Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Wed, 11 Jun 2014 13:31:43 +0400 Subject: [PATCH] string grid is working ok --- examples/example1/src/main.d | 2 +- src/dlangui/widgets/grid.d | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/examples/example1/src/main.d b/examples/example1/src/main.d index 91e6592c..53cda07a 100644 --- a/examples/example1/src/main.d +++ b/examples/example1/src/main.d @@ -520,7 +520,7 @@ extern (C) int UIAppMain(string[] args) { grid.resize(30, 50); grid.fixedCols = 3; grid.fixedRows = 2; - grid.rowSelect = true; + //grid.rowSelect = true; // testing full row selection grid.selectCell(4, 6, false); // create sample grid content for (int y = 0; y < grid.rows; y++) { diff --git a/src/dlangui/widgets/grid.d b/src/dlangui/widgets/grid.d index 360dbf55..02eea97e 100644 --- a/src/dlangui/widgets/grid.d +++ b/src/dlangui/widgets/grid.d @@ -1005,7 +1005,7 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler { protected int measureColWidth(int x) { int m = 0; for (int i = 0; i < _rows; i++) { - Point sz = measureCell(x - _headerCols, i); + Point sz = measureCell(x - _headerCols, i - _headerRows); if (m < sz.x) m = sz.x; } @@ -1017,7 +1017,7 @@ class GridWidgetBase : WidgetGroup, OnScrollHandler { protected int measureRowHeight(int y) { int m = 0; for (int i = 0; i < _cols; i++) { - Point sz = measureCell(i, y - _headerRows); + Point sz = measureCell(i - _headerCols, y - _headerRows); if (m < sz.y) m = sz.y; } @@ -1203,10 +1203,6 @@ class StringGridWidget : StringGridWidgetBase { dstring txt = cellText(col, row); Point sz = fnt.textSize(txt); Align ha = Align.Left; - if (col < _headerCols) - ha = Align.Right; - if (row < _headerRows) - ha = Align.HCenter; applyAlign(rc, sz, ha, Align.VCenter); fnt.drawText(buf, rc.left + 1, rc.top + 1, txt, 0x000000); } @@ -1220,13 +1216,13 @@ class StringGridWidget : StringGridWidgetBase { txt = colTitle(col); else if (row >= 0 && col < 0) txt = rowTitle(row); - if (txt) + if (!txt.length) return; Point sz = fnt.textSize(txt); Align ha = Align.Left; - if (col < _headerCols) + if (col < 0) ha = Align.Right; - if (row < _headerRows) + if (row < 0) ha = Align.HCenter; applyAlign(rc, sz, ha, Align.VCenter); fnt.drawText(buf, rc.left + 1, rc.top + 1, txt, 0x000000);