NAMESPACE_UPP CH_STYLE(MultiButton, Style, StyleDefault) { for(int i = 0; i < 4; i++) { simple[i] = left[i] = right[i] = lmiddle[i] = rmiddle[i] = Button::StyleEdge().look[i]; monocolor[i] = Button::StyleEdge().monocolor[i]; fmonocolor[i] = i == 3 ? SColorDisabled() : SColorText(); look[i] = trivial[i] = ChLookWith(simple[i], CtrlsImg::DA(), monocolor[i]); edge[i] = EditFieldEdge(); } activeedge = false; trivialborder = 1; border = 1; pressoffset = Button::StyleEdge().pressoffset; sep1 = SColorHighlight(); sep2 = SColorLight(); sepm = 2; stdwidth = FrameButtonWidth(); trivialsep = false; margin = Rect(2, 2, 2, 2); usetrivial = false; overpaint = loff = roff = 0; }
Size ProgressIndicator::GetMsz() { Size sz = GetSize(); Rect mg = ChMargins(style->classic || percent || !IsNull(color) ? EditFieldEdge() : sz.cx > sz.cy ? style->hlook : style->vlook); sz.cx -= mg.left + mg.right; sz.cy -= mg.top + mg.bottom; return sz; }
void ProgressIndicator::Paint(Draw& w) { Size sz = GetSize(); Size msz = GetMsz(); int p0 = 0; int p = pxp; if(total <= 0) { int l = max(msz.cx, msz.cy) & ~7; p0 = pxp - l / 4; p = min(p - p0, max(msz.cx, msz.cy) - p0); if(style->bound && p0 < 0) { p += p0; p0 = 0; } } if(style->classic || percent || !IsNull(color)) { ChPaintEdge(w, sz, EditFieldEdge()); Rect mg = ChMargins(EditFieldEdge()); sz -= Size(mg.left + mg.right, mg.top + mg.bottom); Rect r1, r2, r3; r1 = r2 = r3 = RectC(mg.left, mg.top, sz.cx, sz.cy); w.Clip(r1); if(sz.cx > sz.cy) { r1.right = r2.left = min(p, sz.cx) + mg.left + p0; r3.right = mg.left + p0; r3.bottom = r1.bottom; } else { r2.bottom = r1.top = sz.cy - min(p, sz.cy) + mg.left + p0; r3.bottom = mg.top + p0; r3.right = r1.right; } w.DrawRect(r1, Nvl(color, SColorHighlight())); w.DrawRect(r2, SColorPaper); w.DrawRect(r3, SColorPaper); if(percent) { String pt = Format("%d %%", 100 * actual / max(total, 1)); Size psz = GetTextSize(pt, StdFont()); int px = (sz.cx - psz.cx) / 2 + 2; int py = (sz.cy - psz.cy) / 2 + 2; w.Clip(r1); w.DrawText(px, py, pt, StdFont(), SColorLight); w.End(); w.Clip(r2); w.DrawText(px, py, pt, StdFont(), SColorText); w.End(); } w.End(); } else { if(sz.cy > sz.cx) { ChPaint(w, sz, style->vlook); Rect r = ChMargins(style->vlook); w.Clip(r.left, r.top, sz.cx - r.left - r.right, sz.cy - r.top - r.bottom); ChPaint(w, r.left, sz.cy - r.bottom - p - p0, sz.cx - r.left - r.right, p, style->vchunk); } else { ChPaint(w, sz, style->hlook); Rect r = ChMargins(style->hlook); w.Clip(r.left, r.top, sz.cx - r.left - r.right, sz.cy - r.top - r.bottom); ChPaint(w, r.left + p0, r.top, p, sz.cy - r.top - r.bottom, style->hchunk); } w.End(); } }