From 95a377444b5e2ae47d8dfb63ee84efa4a33476be Mon Sep 17 00:00:00 2001 From: unodgs Date: Wed, 5 Jun 2013 07:12:19 +0000 Subject: [PATCH] GridCtrl: Fixed empty popup if cell contains AttrText value git-svn-id: svn://ultimatepp.org/upp/trunk@6133 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/GridCtrl/GridCtrl.cpp | 44 ++++++++++++++++++++---------------- uppsrc/GridCtrl/GridCtrl.h | 3 ++- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/uppsrc/GridCtrl/GridCtrl.cpp b/uppsrc/GridCtrl/GridCtrl.cpp index 5a441a452..5b7cee15d 100644 --- a/uppsrc/GridCtrl/GridCtrl.cpp +++ b/uppsrc/GridCtrl/GridCtrl.cpp @@ -997,7 +997,17 @@ Value GridCtrl::GetItemValue(const Item& it, int id, const ItemRect& hi, const I ? GetConvertedColumn(id, it.val) : it.val; - return val; + return val; +} + +Value GridCtrl::GetAttrTextVal(const Value& val) +{ + if(IsType(val)) + { + const AttrText& t = ValueTo(val); + return t.text; + } + return val; } void GridCtrl::GetItemAttrs(const Item& it, const Value& value, int r, int c, const ItemRect& vi, const ItemRect& hi, dword& style, GridDisplay*& gd, Color& fg, Color& bg, Font& fnt) @@ -1508,11 +1518,7 @@ void GridCtrl::Paint(Draw &w) gd->row = i - fixed_cols; gd->parent = this; - if(IsType(val)) - { - const AttrText& t = ValueTo(val); - val = t.text; - } + val = GetAttrTextVal(val); gd->Paint(w, x, y, cx, cy, val, style, @@ -1618,9 +1624,19 @@ void GridCtrl::DrawVertDragLine(Draw &w, int pos, int size, int dx, Color c) w.DrawRect(1 + dx, pos, size - dx - 1, 2, c); } -Value GridCtrl::GetStdConvertedValue(const Value& v) +Value GridCtrl::GetStdConvertedValue(const Value& v) const { - return IsString(v) ? v : StdConvert().Format(v); + if(IsString(v)) + { + return v; + } + else if(IsType(v)) + { + const AttrText& t = ValueTo(v); + return t.text; + } + else + return StdConvert().Format(v); } Value GridCtrl::GetConvertedColumn(int col, const Value &v) const @@ -1632,17 +1648,7 @@ Value GridCtrl::GetConvertedColumn(int col, const Value &v) const Value GridCtrl::GetStdConvertedColumn(int col, const Value &v) const { Value val = GetConvertedColumn(col, v); - if(IsString(val)) - { - return val; - } - else if(IsType(val)) - { - const AttrText& t = ValueTo(val); - return t.text; - } - else - return StdConvert().Format(val);//GetStdConvertedValue(val); + return GetStdConvertedValue(val); } String GridCtrl::GetString(Id id) const diff --git a/uppsrc/GridCtrl/GridCtrl.h b/uppsrc/GridCtrl/GridCtrl.h index c38ce1791..06b2ca095 100644 --- a/uppsrc/GridCtrl/GridCtrl.h +++ b/uppsrc/GridCtrl/GridCtrl.h @@ -1598,7 +1598,7 @@ class GridCtrl : public Ctrl ScrollBar& HorzScroll() { return sbx; } ScrollBar& VertScroll() { return sby; } - Value GetStdConvertedValue(const Value& v); + Value GetStdConvertedValue(const Value& v) const; Value GetConvertedColumn(int col, const Value& v) const; Value GetStdConvertedColumn(int col, const Value& v) const; String GetString(Id id) const; @@ -1764,6 +1764,7 @@ class GridCtrl : public Ctrl Value GetItemValue(const Item& it, int id, const ItemRect& hi, const ItemRect& vi); void GetItemAttrs(const Item& it, const Value& val, int r, int c, const ItemRect& vi, const ItemRect& hi, dword& style, GridDisplay*& gd, Color& fg, Color& bg, Font& fnt); Item& GetItemSize(int &r, int &c, int &x, int &y, int &cx, int &cy, bool &skip, bool relx = true, bool rely = true); + Value GetAttrTextVal(const Value& val); Image HorzPosImage(); Image VertPosImage();