void FileTabs::ComposeStackedTab(Tab& tab, const Tab& stacked_tab, const Font &font, Color ink, int style) { tab.AddImage(TabBarImg::STSEP); if (stackedicons && tab.HasIcon()) { tab.AddImage(style == CTRL_HOT ? stacked_tab.img : (greyedicons ? DisabledImage(stacked_tab.img) : stacked_tab.img)) .Clickable(); } else { WString txt = IsString(stacked_tab.value) ? stacked_tab.value : StdConvert().Format(stacked_tab.value); int extpos = txt.ReverseFind('.'); Color c = (style == CTRL_HOT) ? extcolor : SColorDisabled(); if (extpos >= 0) { tab.AddText( txt.Mid(extpos + 1), font, c ).Clickable(); } else { tab.AddText("-", font, c).Clickable(); } } }
Size FileTabs::GetStackedSize(const Tab &t) { if (stackedicons && t.HasIcon()) return min(t.img.GetSize(), Size(TB_ICON, TB_ICON)) + Size(TB_SPACEICON, 0) + 5; WString txt = IsString(t.value) ? t.value : StdConvert().Format(t.value); int extpos = txt.ReverseFind('.'); txt = extpos >= 0 ? txt.Mid(extpos + 1) : "-"; return GetTextSize(txt, GetStyle().font) + Size(TabBarImg::STSEP().GetSize().cx, 0); }
Value JoinConvert::Format(const Value& v) const { String r; ValueArray a = v; for(int i = 0; i < item.GetCount(); i++) { const Item& m = item[i]; if(m.pos < 0) r << m.text; else r << (String) StdConvert().Format(m.convert->Format(a[m.pos])); } return r; }
void StdDisplayClass::Paint0(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword s) const { LLOG("StdDisplay::Paint0: " << q << " ink:" << ink << " paper:" << paper); WString txt; Font font = StdFont(); int a = align; int x = r.left; int width = r.GetWidth(); if(IsType<AttrText>(q)) { const AttrText& t = ValueTo<AttrText>(q); txt = t.text; font = t.font; if(!IsNull(t.paper)) paper = t.paper; if(!IsNull(t.ink)) ink = t.ink; if(!IsNull(t.normalink) && !(s & (CURSOR|SELECT|READONLY))) ink = t.normalink; if(!IsNull(t.normalpaper) && !(s & (CURSOR|SELECT|READONLY))) paper = t.normalpaper; if(!IsNull(t.align)) a = t.align; if(!IsNull(t.img)) { Size isz = t.img.GetSize(); w.DrawImage(x, r.top + max((r.Height() - isz.cy) / 2, 0), t.img); x += isz.cx + t.imgspc; } } else txt = IsString(q) ? q : StdConvert().Format(q); Size tsz = GetTLTextSize(txt, font); if(a == ALIGN_RIGHT) x = r.right - tsz.cx; if(a == ALIGN_CENTER) x += (width - tsz.cx) / 2; int tcy = GetTLTextHeight(txt, font); int tt = r.top + max((r.Height() - tcy) / 2, 0); if(tsz.cx > width) { Size isz = DrawImg::threedots().GetSize(); int wd = width - isz.cx; w.Clip(r.left, r.top, wd, r.GetHeight()); DrawTLText(w, x, tt, width, txt, font, ink); w.End(); w.DrawImage(r.left + wd, tt + font.Info().GetAscent() - isz.cy, DrawImg::threedots(), ink); } else DrawTLText(w, x, tt, width, txt, font, ink); }
void FileTabs::ComposeTab(Tab& tab, const Font &font, Color ink, int style) { if(PaintIcons() && tab.HasIcon()) { tab.AddImage(tab.img); tab.AddSpace(TB_SPACEICON); } WString txt = IsString(tab.value) ? tab.value : StdConvert().Format(tab.value); int extpos = txt.ReverseFind('.'); tab.AddText(extpos >= 0 ? txt.Left(extpos) : txt, font, filecolor); if (extpos >= 0) { tab.AddText(txt.Right(txt.GetLength() - extpos), font, extcolor); } }
Size StdDisplayClass::GetStdSize(const Value& q) const { Font font = StdFont(); WString txt; Size isz(0, 0); if(IsType<AttrText>(q)) { const AttrText& t = ValueTo<AttrText>(q); txt = t.text; font = t.font; if(!IsNull(t.img)) { isz = t.img.GetSize(); isz.cx += t.imgspc; } } else txt = IsString(q) ? q : StdConvert().Format(q); Size sz = GetTLTextSize(txt, font); return Size(sz.cx + isz.cx, max(sz.cy, isz.cy)); }
JoinConvert& JoinConvert::Add(int pos) { Add(pos, StdConvert()); return *this; }
String StdFormat(const Value& q) { return StdConvert().Format(q); }
WString GridDisplay::GetStdConvertedValue(const Value &v) const { return IsString(v) ? v : StdConvert().Format(v); }