diff --git a/uppsrc/GridCtrl/GridCtrl.cpp b/uppsrc/GridCtrl/GridCtrl.cpp index 90149bc34..e84a84749 100644 --- a/uppsrc/GridCtrl/GridCtrl.cpp +++ b/uppsrc/GridCtrl/GridCtrl.cpp @@ -993,22 +993,14 @@ void GridCtrl::DrawLine(bool iniLine, bool delLine) Value GridCtrl::GetItemValue(const Item& it, int id, const ItemRect& hi, const ItemRect& vi) { - Value val; - - if(IsType(it.val)) - { - const AttrText& t = ValueTo(it.val); - val = t.text; - } - else - val = hi.IsConvertion() && vi.IsConvertion() - ? GetConvertedColumn(id, it.val) - : it.val; + Value val = hi.IsConvertion() && vi.IsConvertion() + ? GetConvertedColumn(id, it.val) + : it.val; return val; } -void GridCtrl::GetItemAttrs(const Item& it, int r, int c, const ItemRect& vi, const ItemRect& hi, dword& style, GridDisplay*& gd, Color& fg, Color& bg, Font& fnt) +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) { if(!IsNull(vi.fg)) fg = vi.fg; @@ -1029,11 +1021,21 @@ void GridCtrl::GetItemAttrs(const Item& it, int r, int c, const ItemRect& vi, co else if(!IsNull(vi.fnt)) fnt = vi.fnt; else if(!IsNull(hi.fnt)) - fnt = hi.fnt; + fnt = hi.fnt; - if(IsType(it.val)) + GridDisplay * hd = hi.display; + GridDisplay * vd = vi.display; + gd = display; + if(!hi.ignore_display && !vi.ignore_display) + gd = vd ? vd : (hd ? hd : (it.display ? it.display : display)); + + gd->SetLeftImage(Null); + + const Value& val = IsNull(value) ? it.val : value; + + if(IsType(val)) { - const AttrText& t = ValueTo(it.val); + const AttrText& t = ValueTo(val); if(!IsNull(t.paper)) bg = t.paper; if(!IsNull(t.ink)) fg = t.ink; @@ -1050,13 +1052,10 @@ void GridCtrl::GetItemAttrs(const Item& it, int r, int c, const ItemRect& vi, co style &= ~GD::HALIGN; style |= s; } + if(!IsNull(t.img)) + gd->SetLeftImage(t.img); } - GridDisplay * hd = hi.display; - GridDisplay * vd = vi.display; - gd = display; - if(!hi.ignore_display && !vi.ignore_display) - gd = vd ? vd : (hd ? hd : (it.display ? it.display : display)); } GridCtrl::Item& GridCtrl::GetItemSize(int &r, int &c, int &x, int &y, int &cx, int &cy, bool &skip, bool relx, bool rely) @@ -1442,7 +1441,7 @@ void GridCtrl::Paint(Draw &w) Font fnt = StdFont(); GridDisplay* gd; Value val = GetItemValue(it, id, hi, vi); - GetItemAttrs(it, i, j, vi, hi, style, gd, cfg, cbg, fnt); + GetItemAttrs(it, val, i, j, vi, hi, style, gd, cfg, cbg, fnt); Color fg = SColorText; Color bg = SColorPaper; @@ -1508,6 +1507,13 @@ void GridCtrl::Paint(Draw &w) gd->col = j - fixed_rows; gd->row = i - fixed_cols; gd->parent = this; + + if(IsType(val)) + { + const AttrText& t = ValueTo(val); + val = t.text; + } + gd->Paint(w, x, y, cx, cy, val, style, fg, bg, fnt, it.style & GD::FOUND, it.fs, it.fe); @@ -2053,7 +2059,7 @@ void GridCtrl::SyncPopup() int x = hi.npos + p0.x - p.x - 1 - sbx.Get() * int(!fc); int y = vi.npos + p0.y - p.y - 1 - sby.Get() * int(!fr); - GetItemAttrs(it, r, c, vi, hi, popup.style, popup.gd, popup.fg, popup.bg, popup.fnt); + GetItemAttrs(it, Null, r, c, vi, hi, popup.style, popup.gd, popup.fg, popup.bg, popup.fnt); popup.gd->row = r < fixed_rows ? -1 : r - fixed_rows; popup.gd->col = c < fixed_cols ? -1 : c - fixed_cols; Rect scr = GetWorkArea(); diff --git a/uppsrc/GridCtrl/GridCtrl.h b/uppsrc/GridCtrl/GridCtrl.h index 21a3ce7df..c38ce1791 100644 --- a/uppsrc/GridCtrl/GridCtrl.h +++ b/uppsrc/GridCtrl/GridCtrl.h @@ -1762,7 +1762,7 @@ class GridCtrl : public Ctrl int GetIdCol(int id, bool checkall = false) const; int GetIdRow(int id, bool checkall = false) const; Value GetItemValue(const Item& it, int id, const ItemRect& hi, const ItemRect& vi); - void GetItemAttrs(const Item& it, int r, int c, const ItemRect& vi, const ItemRect& hi, dword& style, GridDisplay*& gd, Color& fg, Color& bg, Font& fnt); + 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); Image HorzPosImage(); diff --git a/uppsrc/GridCtrl/GridDisplay.cpp b/uppsrc/GridCtrl/GridDisplay.cpp index b28866d3c..293a2e03a 100644 --- a/uppsrc/GridCtrl/GridDisplay.cpp +++ b/uppsrc/GridCtrl/GridDisplay.cpp @@ -79,6 +79,7 @@ void GridDisplay::Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, Size isz = leftImg.GetSize(); w.DrawImage(nx, ny + (cy - isz.cy) / 2, style & GD::READONLY ? Grayscale(leftImg) : leftImg); nx += isz.cx + 3; + ncx -= isz.cx + 3; } if(!rightImg.IsEmpty()) {