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); }
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); } }
void DrawFileName(Draw& ww, int x0, int y, int wcx0, int cy, const WString& mname, bool isdir, Font font, Color ink, Color extink, const WString& desc, Font descfont, bool justname, Color uln) { for(int pass = IsNull(uln); pass < 2; pass++) { NilDraw nd; Draw *w = pass ? &ww : &nd; FontInfo fi = font.Info(); int extpos = (isdir ? -1 : mname.ReverseFind('.')); int slash = isdir ? -1 : max(mname.ReverseFind('\\'), mname.ReverseFind('/')); if(extpos < slash) extpos = -1; const wchar *ext = extpos >= slash && extpos >= 0 ? mname.Begin() + extpos + 1 : mname.End(); const wchar *name = mname; if(justname && slash >= 0) name += slash + 1; int txtcx = GetTextSize(fi, name); int x = x0; int wcx = wcx0; if(txtcx <= wcx) { if(pass == 0) ww.DrawRect(x0, y + fi.GetAscent() + 1, txtcx, 1, uln); ww.DrawText(x, y, name, font, ink, (int)(ext - name)); ww.DrawText(x + GetTextSize(fi, name, ext), y, ext, font, extink, (int)(mname.End() - ext)); if(!IsEmpty(desc) && pass) DrawTextEllipsis(ww, x + fi.GetHeight(), y, wcx - txtcx, desc, "...", descfont, extink); x += txtcx; return; } else { int dot3 = 3 * fi['.']; if(2 * dot3 > wcx) { int n = GetTextFitCount(fi, name, wcx); w->DrawText(x, y, name, font, ink, n); x += GetTextSize(fi, name, name + n); } else { const wchar *end = mname.End(); int dircx = 2 * fi['.'] + fi[DIR_SEP]; const wchar *bk = strdirsep(name); if(bk) { wcx -= dircx; w->DrawText(x, y, ".." DIR_SEPS, font, SColorDisabled, 3); x += dircx; do { txtcx -= GetTextSize(fi, name, bk + 1); name = bk + 1; if(txtcx < wcx) { w->DrawText(x, y, name, font, ink, (int)(ext - name)); x += GetTextSize(fi, name, ext); w->DrawText(x, y, ext, font, extink, (int)(end - ext)); x += GetTextSize(fi, ext, end); goto end; } bk = strdirsep(name); } while(bk); } wcx -= dot3; int extcx = GetTextSize(fi, ext, end); if(2 * extcx > wcx || ext == end) { int n = GetTextFitCount(fi, name, wcx); w->DrawText(x, y, name, font, ink, n); x += GetTextSize(fi, name, name + n); w->DrawText(x, y, "...", font, SColorDisabled, 3); x += dot3; } else { wcx -= extcx; int n = (int)(GetTextFitLim(fi, name, end, wcx) - name); w->DrawText(x, y, name, font, ink, n); x += GetTextSize(fi, name, name + n); w->DrawText(x, y, "...", font, SColorDisabled, 3); w->DrawText(x + dot3, y, ext, font, extink, (int)(end - ext)); x += dot3 + extcx; } } } end: if(pass == 0) ww.DrawRect(x0, y + fi.GetAscent() + 1, x - x0, 1, uln); } }