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(); } } }
void AutoHideBar::ComposeTab(Tab& tab, const Font &font, Color ink, int style) { DockableCtrl *d; WString txt; const Value &q = tab.value; ink = (style == CTRL_DISABLED) ? SColorDisabled : ink; if (IsTypeRaw<DockCont *>(q)) { DockCont *c = ValueTo<DockCont *>(q); d = &c->GetCurrent(); txt = c->GetTitle(); } else { ASSERT(IsTypeRaw<DockableCtrl *>(q)); d = ValueTo<DockableCtrl *>(q); txt = d->GetTitle(); } if(icons) { tab.AddImage((style == CTRL_DISABLED) ? DisabledImage(d->GetIcon()) : d->GetIcon()); } if (showtext) { tab.AddText(txt, font, ink); } }
void ToolButton::Paint(Draw& w) { LTIMING("ToolButton::Paint"); paint_checked = checked; Size sz = GetSize(); UPP::Image image = GetImage(); Size isz = image.GetSize(); // Ctrl *q = GetParent()->GetParent(); // if(!q || !q->IsTransparent()) // w.DrawRect(sz, checked && !HasMouse() ? Blend(SColorFace, SColorLight) : SColorFace); int li = IsEnabled() ? HasMouse() ? GetMouseLeft() ? CTRL_PRESSED : checked ? CTRL_HOTCHECKED : CTRL_HOT : checked ? CTRL_CHECKED : CTRL_NORMAL : CTRL_DISABLED; ChPaint(w, sz, style->look[li]); Point off = style->offset[li]; Point ip = (sz - isz) / 2 + off; Size tsz(0, 0); if(kind != NOLABEL) tsz = GetTextSize(text, style->font); if(kind == BOTTOMLABEL) { ip.y -= tsz.cy / 2 + 1; w.DrawText((sz.cx - tsz.cx) / 2 + off.x, ip.y + isz.cy + 2 + off.y, text, style->font, style->textcolor[li]); } if(kind == RIGHTLABEL) { ip.x -= tsz.cx / 2 + 2; w.DrawText(ip.x + isz.cx + 3 + off.x, (sz.cy - tsz.cy) / 2 + off.y, text, style->font, style->textcolor[li]); } UPP::Image img = CachedContrast(image, style->contrast[li]); if(!IsEnabled()) img = DisabledImage(img); if(IsEnabled() && style->light[li]) DrawHighlightImage(w, ip.x, ip.y, img, true); else w.DrawImage(ip.x, ip.y, img); }
Size DrawLabel::Paint(Ctrl *ctrl, Draw& w, const Rect& r, bool visibleaccesskey) const { int lspc = this->lspc; int rspc = this->rspc; Size sz1 = limg.GetSize(); Size sz2 = rimg.GetSize(); int txtcx = r.GetWidth() - sz1.cx - Nvl(lspc, 0) - sz2.cx - Nvl(rspc, 0); Size txtsz = *text ? GetSmartTextSize(text, font, txtcx) : paintrect.GetStdSize(); if(txtsz.cx) { if(!rimg_never_hide && txtsz.cx + sz1.cx + sz2.cx + Nvl(lspc, 0) + Nvl(rspc, 0) > r.GetWidth()) { sz2.cx = 0; rspc = 0; } if(!limg_never_hide && txtsz.cx + sz1.cx + sz2.cx + Nvl(lspc, 0) + Nvl(rspc, 0) > r.GetWidth()) { sz1.cx = 0; lspc = 0; } } Size isz = GetSize(txtcx, sz1, lspc, sz2, rspc); Point p = r.TopLeft(), ip; if(align == ALIGN_LEFT) p.x = r.left; else if(align == ALIGN_RIGHT) p.x = r.right - isz.cx; else if(align == ALIGN_CENTER) p.x = (r.right + r.left - isz.cx) / 2; if(valign == ALIGN_TOP) p.y = r.top; else if(valign == ALIGN_BOTTOM) p.y = r.bottom - isz.cy; else if(valign == ALIGN_CENTER) p.y = (r.bottom + r.top - txtsz.cy) / 2; Color color = disabled && !IsNull(disabledink) ? disabledink : ink; if(IsNull(color)) color = disabled ? SColorDisabled : GetLabelTextColor(ctrl); int ix; if(IsNull(lspc)) ix = r.left + push; else { ix = p.x + push; p.x += sz1.cx; p.x += lspc; } int iy = push + (r.top + r.bottom - sz1.cy) / 2; if(sz1.cx) if(IsNull(lcolor)) w.DrawImage(ix, iy, DisabledImage(limg, disabled)); else w.DrawImage(ix, iy, limg, lcolor); iy = push + (r.top + r.bottom - sz2.cy) / 2; ix = (IsNull(rspc) ? r.right - sz2.cx : p.x + txtsz.cx + rspc) + push; if(sz2.cx) if(IsNull(rcolor)) w.DrawImage(ix, iy, DisabledImage(rimg, disabled)); else w.DrawImage(ix, iy, rimg, rcolor); paintrect.Paint(w, p.x + push, p.y + push, txtsz.cx, isz.cy, color, Null); if(*text) { if(disabled) DrawSmartText(w, p.x + push + 1, p.y + push + (isz.cy - txtsz.cy) / 2 + 1, txtsz.cx, text, font, SColorPaper); DrawSmartText(w, p.x + push, p.y + push, txtcx, text, font, color, visibleaccesskey ? accesskey : 0); if(focus) DrawFocus(w, p.x - 2, p.y, txtsz.cx + 5, isz.cy); } return isz; }
void MenuItem::Paint(Draw& w) { int q = text.Find('\t'); String txt, keydesc; if(accel) keydesc = GetKeyDesc(accel); if(q >= 0) { keydesc = text.Mid(q + 1); txt = text.Mid(0, q); } else txt = text; state = GetVisualState(); bool hl = state != NORMAL; Size sz = GetSize(); if(hl) { if(GUI_GlobalStyle() >= GUISTYLE_XP) ChPaint(w, 0, 0, sz.cx, sz.cy, style->item); else w.DrawRect(sz, SColorHighlight); } UPP::Image li = licon; if(li.IsEmpty()) { switch(type) { case CHECK0: li = CtrlImg::MenuCheck0(); break; case CHECK1: li = CtrlImg::MenuCheck1(); break; case RADIO0: li = CtrlImg::MenuRadio0(); break; case RADIO1: li = CtrlImg::MenuRadio1(); break; } } Size isz = li.GetSize(); // Size isz = min(maxiconsize, imsz); // if(isz != imsz) // li = CachedRescale(li, isz); int iy = (sz.cy - isz.cy) / 2; bool chk = false; int x = Zx(2); if(!licon.IsEmpty() && type) { chk = type == CHECK1 || type == RADIO1; if(GUI_GlobalStyle() >= GUISTYLE_XP) { if(chk && !hl) DrawXPButton(w, RectC(0, iy - Zy(2), isz.cx + Zx(4), isz.cy + Zy(4)), BUTTON_EDGE|BUTTON_CHECKED); } else { w.DrawRect(x - Zx(1), iy - Zy(1), isz.cx + Zx(2), isz.cy + Zy(2), chk ? Blend(SColorFace, SColorLight) : SColorFace); DrawBorder(w, x - Zx(2), iy - Zy(2), isz.cx + Zx(4), isz.cy + Zy(4), chk ? ThinInsetBorder : ThinOutsetBorder); } } if(isenabled) DrawHighlightImage(w, x, iy, li, hl || chk, true); else w.DrawImage(x, iy, DisabledImage(li)); x = max(isz.cx, leftgap) + textgap; isz = GetTextSize(text, StdFont()); DrawMenuText(w, x, (sz.cy - isz.cy) / 2, txt, font, isenabled, hl, style->menutext, style->itemtext); isz = ricon.GetSize(); if(isenabled) w.DrawImage(sz.cx - isz.cx, (sz.cy - isz.cy) / 2, ricon, hl ? style->itemtext : style->menutext); else w.DrawImage(sz.cx - isz.cx, (sz.cy - isz.cy) / 2, DisabledImage(ricon)); x = sz.cx - max(isz.cx, Zx(16)) - Zx(1); if(!IsEmpty(keydesc)) { isz = GetTextSize(keydesc, StdFont()); UPP::DrawMenuText(w, x - isz.cx - Zx(2), (sz.cy - isz.cy) / 2, keydesc, font, isenabled, hl, 0, SColorMenuMark(), style->itemtext, false); } }