virtual void Paint(Draw& w) { w.DrawRect(GetSize(), White()); DoPainting(w); w.Offset(30, 50); DoPainting(w); w.End(); w.Offset(20, 100); w.Clip(5, 5, 40, 20); DoPainting(w); w.End(); w.End(); w.Clipoff(10, 150, 60, 20); DoPainting(w); w.End(); }
void RichTextView::Paint(Draw& w) { Size sz = GetSize(); w.DrawRect(sz, background); sz.cx -= margin.left + margin.right; sz.cy -= margin.top + margin.bottom; w.Clipoff(margin.left, margin.top, sz.cx, sz.cy); PaintInfo pi; if(!hldec) pi.hyperlink = Null; if(sell < selh) { pi.sell = sell; pi.selh = selh; } pi.indexentry = Null; pi.highlightpara = highlight; pi.zoom = GetZoom(); int q = sb * pi.zoom; scroller.Set(q); w.Offset(0, -q); SimplePageDraw pw(w); pi.top = PageY(0, sb); pi.bottom = PageY(0, sb + sz.cy / pi.zoom); pi.usecache = true; pi.sizetracking = sizetracking; pi.shrink_oversized_objects = shrink_oversized_objects; Color c = SColorPaper(); if(Grayscale(c) < 100) pi.coloroverride = true; text.Paint(pw, GetPage(), pi); w.End(); w.End(); }
void Print(Draw& w, const RichText& text, const Rect& page, const Vector<int>& pg) { LLOG("Print"); int lpage = text.GetHeight(page).page; PrintPageDraw pw(w); Size sz = w.GetPageMMs(); Size pgsz = page.Size(); int x = (6000 * sz.cx / 254 - pgsz.cx) / 2; int y = (6000 * sz.cy / 254 - pgsz.cy) / 2; for(int pi = 0; pi < pg.GetCount(); pi++) { int i = pg[pi]; w.StartPage(); w.Offset(x, y); pw.SetPage(i); PaintInfo paintinfo; paintinfo.top = PageY(i, 0); paintinfo.bottom = PageY(i + 1, 0); paintinfo.indexentry = Null; if(text.IsPrintNoLinks()) paintinfo.hyperlink = Null; text.Paint(pw, page, paintinfo); w.End(); String footer = text.GetFooter(); if(!IsNull(footer) && lpage) { String n = Format(footer, i + 1, lpage + 1); Size nsz = GetTextSize(n, Arial(90).Italic()); pw.Page(i).DrawText( x + pgsz.cx - nsz.cx, y + pgsz.cy + 100, n, Arial(90).Italic()); } w.EndPage(); } }
void Picture::Paint(Draw& w) { Size sz = GetSize(); w.DrawRect(0, 0, sz.cx, sz.cy, background); if(!picture) return; int dx = 0; int dy = 0; Size rz = sz; if(ratio) { Size sr = picture.GetSize(); if(sr.cy * sz.cx < sz.cy * sr.cx) { if(sr.cx) { rz.cy = sr.cy * sz.cx / sr.cx; dy = (sz.cy - rz.cy) / 2; } } else { if(sr.cy) { rz.cx = sr.cx * sz.cy / sr.cy; dx = (sz.cx - rz.cx) / 2; } } } w.Clipoff(dx, dy, rz.cx, rz.cy); w.DrawDrawing(0, 0, rz.cx, rz.cy, picture); w.End(); }
void HeaderCtrl::Column::Paint(bool& first, Draw& w, int x, int y, int cx, int cy, bool disabled, bool push, bool hl) { const HeaderCtrl::Style *style = header ? header->style : &HeaderCtrl::StyleDefault();; if(first) { if(cx >= -style->gridadjustment) { cx -= style->gridadjustment; if(cx < 0) cx = 0; first = false; } } else x -= style->gridadjustment; bool p = push && style->pressoffset; int q = CTRL_NORMAL; if(hl) q = CTRL_HOT; if(push) q = CTRL_PRESSED; if(disabled) q = CTRL_DISABLED; ChPaint(w, x, y, cx, cy, IsNull(paper) ? style->look[q] : paper.operator Value()); x += margin; cx -= 2 * margin; w.Clip(x + 2, y, cx - 4, cy); PaintLabel(w, x + 2, y + 1, cx - 4, cy - 4, disabled, p); w.End(); }
void Ctrl::DrawCtrl(Draw& w, int x, int y) { GuiLock __; w.Offset(x, y); SystemDraw *ws = dynamic_cast<SystemDraw *>(&w); if(ws) UpdateArea(*ws, GetRect().GetSize()); w.End(); }
void QTFDisplayCls::Paint(Draw& draw, const Rect& r, const Value& v, Color ink, Color paper, dword style) const { String s; s << "[@(" << ink.GetR() << "." << ink.GetG() << "." << ink.GetB() << ") " << v; RichText rtext = ParseQTF(s); rtext.ApplyZoom(GetRichTextStdScreenZoom()); draw.DrawRect(r, paper); draw.Clipoff(r); rtext.Paint(Zoom(1, 1), draw, 0, 0, r.Width()); draw.End(); }
void DrawFocus(Draw& w, int x, int y, int cx, int cy, Color c) { w.Clipoff(x, y, cx, cy); for(int a = 0; a < cx; a += CtrlImg::focus_h().GetWidth()) { w.DrawImage(a, 0, CtrlImg::focus_h(), c); w.DrawImage(a, cy - 1, CtrlImg::focus_h(), c); } for(int a = 0; a < cy; a += CtrlImg::focus_v().GetHeight()) { w.DrawImage(0, a, CtrlImg::focus_v(), c); w.DrawImage(cx - 1, a, CtrlImg::focus_v(), c); } w.End(); }
void RichText::Paint(Draw& w, int x, int y, int cx, const PaintInfo& pinit) const { Mutex::Lock __(mutex); SimplePageDraw pw(w); PaintInfo pi(pinit); pi.top = PageY(0, 0); pi.bottom = PageY(0, INT_MAX); pi.usecache = true; pi.sizetracking = false; pi.highlight = Null; w.Offset(x, y); Paint(pw, Size(cx / pi.zoom, INT_MAX), pi); w.End(); }
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); }
virtual void Paint(Draw& w) { Size sz = GetSize(); w.DrawRect(sz, LtGray); w.DrawRect(sz / 2, LtBlue); w.DrawText(10, 10, "Hello", Arial(12)); w.DrawImage(50, 50, CtrlImg::exclamation()); w.DrawImage(100, 50, CtrlImg::exclamation(), Blue); w.DrawImage(50, 150, CtrlsImg::O1h()); w.DrawImage(150, 150, CtrlsImg::O1h()); w.Clipoff(50, 180, 40, 40); w.DrawImage(0, 0, 50, 50, CtrlsImg::O1h()); w.End(); w.DrawImage(100, 100, ball); w.DrawImage(200, 200, 40, 40, ball); }
void Ctrl::DrawCtrlWithParent(Draw& w, int x, int y) { GuiLock __; if(parent) { Rect r = GetRect(); Ctrl *top = parent->GetTopRect(r, inframe); w.Clip(x, y, r.Width(), r.Height()); w.Offset(x - r.left, y - r.top); SystemDraw *ws = dynamic_cast<SystemDraw *>(&w); if(ws) top->UpdateArea(*ws, r); w.End(); w.End(); } else DrawCtrl(w, x, y); }
void DockCont::Handle::Paint(Draw& w) { if (IsShown() && dc) { const DockableCtrl::Style &s = dc->GetStyle(); Rect r = GetSize(); const Rect &m = s.handle_margins; Point p; if (s.handle_vert) p = Point(r.left-1 + m.left, r.bottom - m.bottom); else p = Point(r.left + m.left, r.top + m.top); ChPaint(w, r, s.handle[focus]); Image img = dc->GetIcon(); if (!img.IsEmpty()) { if (s.handle_vert) { int isz = r.GetWidth(); p.y -= isz; isz -= (m.left + m.right); ChPaint(w, max(p.x+m.left, r.left), p.y, isz, isz, img); p.y -= 2; } else { int isz = r.GetHeight(); isz -= (m.top + m.bottom); ChPaint(w, p.x, max(p.y, r.top), isz, isz, img); p.x += isz + 2; } } if (!s.title_font.IsNull()) { Ctrl *c = GetLastChild(); while (c && !c->IsShown() && c->GetParent()) c = c->GetNext(); if (s.handle_vert) r.top = c ? c->GetRect().bottom + m.top : m.top; else r.right = c ? c->GetRect().left + m.right : m.right; w.Clip(r); WString text = IsNull(dc->GetGroup()) ? dc->GetTitle() : (WString)Format("%s (%s)", dc->GetTitle(), dc->GetGroup()); w.DrawText(p.x, p.y, s.handle_vert ? 900 : 0, text, s.title_font, s.title_ink[focus]); w.End(); } } }
void ScrollBar::Paint(Draw& w) { w.DrawRect(GetSize(), SColorPaper()); int cc; Size sz = style->through ? GetSize() : Slider(cc).GetSize(); light = GetMousePart(); int p = push; if(!HasCapture()) p = -1; const Value *hl[] = { style->hlower, style->hupper, style->hthumb }; const Value *vl[] = { style->vupper, style->vlower, style->vthumb }; const Value **l = IsHorz() ? hl : vl; if(prev.IsShowEnabled()) { for(int i = 0; i < 3; i++) { Rect pr = GetPartRect(i); if(i != 2) { w.Clip(pr); pr = style->through ? GetSize() : Slider(); } if(i != 2 || thumbsize >= style->thumbmin) ChPaint(w, pr, l[i][p == i ? CTRL_PRESSED : light == i ? CTRL_HOT : CTRL_NORMAL]); if(i != 2) w.End(); } } else if(style->through) ChPaint(w, sz, l[0][CTRL_DISABLED]); else if(IsHorz()) { ChPaint(w, cc, 0, sz.cx / 2, sz.cy, l[0][CTRL_DISABLED]); ChPaint(w, cc + sz.cx / 2, 0, sz.cx - sz.cx / 2, sz.cy, l[1][CTRL_DISABLED]); } else { ChPaint(w, 0, cc, sz.cx, sz.cy / 2, l[0][CTRL_DISABLED]); ChPaint(w, 0, cc + sz.cy / 2, sz.cx, sz.cy - sz.cy / 2, l[1][CTRL_DISABLED]); // w.DrawRect(0, cc, sz.cx, sz.cy / 2, Red()); _DBG_ // w.DrawRect(0, cc + sz.cy / 2, sz.cx, sz.cy - sz.cy / 2, Green()); _DBG_ } }
void GridDisplay::PaintFixed(Draw &w, bool firstx, bool firsty, int x, int y, int cx, int cy, const Value &val, dword style, Font &fnt, bool indicator, bool moved, int sortmode, int sortcol, int sortcnt, bool horizontal) { real_size.cx = 0; real_size.cy = 0; bool chameleon = style & GD::CHAMELEON; bool highlight = style & GD::HIGHLIGHT; bool readonly = style & GD::READONLY; if(chameleon) { int ncx = cx; int nx = x; int ht = HeaderCtrl::StyleDefault().gridadjustment; if(firstx) { if(ncx >= -ht) { ncx -= ht; if(ncx < 0) ncx = 0; } } else nx -= ht; int q = CTRL_NORMAL; if(highlight) q = CTRL_HOT; if(readonly) q = CTRL_DISABLED; ChPaint(w, nx, y, ncx, cy, HeaderCtrl::StyleDefault().look[q]); } else { if(theme < 0) w.DrawRect(x, y, cx, cy, highlight ? Blend(SColorFace(), White, 128) : SColorFace()); else { int sx = cx > 1 ? cx : 1; int sy = cy - 1; if(sx > 0 && sy > 0) w.DrawImage(x, y, sx, sy, highlight ? hdrhigh : vhdr[theme]()); } //Color dark(76, 83, 92); Color dark(155, 154, 153); //Color dark(155, 154, 153); Color bright(White); if(!firstx) w.DrawRect(x, y, 1, cy, bright); if(!firsty) w.DrawRect(x, y, cx, 1, bright); if(firstx) w.DrawRect(x, y, 1, cy, dark); if(firsty) w.DrawRect(x, y, cx, 1, dark); w.DrawRect(x + cx - 1, y, 1, cy, dark); w.DrawRect(x, y + cy - 1, cx, 1, dark); } int tx = x + lm; if(firsty) { if(!leftImg.IsEmpty()) { Size isz = leftImg.GetSize(); w.DrawImage(tx, y + (cy - isz.cy) / 2, leftImg); tx += isz.cx + 3; } if(!rightImg.IsEmpty()) { Size isz = rightImg.GetSize(); w.DrawImage(x + cx - isz.cx - 3, y + (cy - isz.cy) / 2, rightImg); } if(!centerImg.IsEmpty()) { Size isz = centerImg.GetSize(); w.DrawImage(x + (cx - isz.cx) / 2, y + (cy - isz.cy) / 2, centerImg); } } if(moved) DrawBorder(w, x, y, cx, cy, BlackBorder); Color col = style & GD::READONLY ? Gray : Black; if(sortmode > 0) { Size isz = GridImg::SortAsc().GetSize(); int yf = y + (cy - isz.cy) / 2; int xf = tx + 2; tx = xf + isz.cx + 1; if(sortcol > 0 && sortcnt > 1) { String tcol = AsString(sortcol); Size tsz = GetTextSize(tcol, fnt); w.DrawText(tx, y + (cy - tsz.cy) / 2, tcol, fnt); tx += tsz.cx; } bool asc = sortmode == 1; if(reverse_sort_icon) asc = !asc; w.DrawImage(xf, yf, asc ? GridImg::SortAsc() : GridImg::SortDsc(), col); tx += 3; } if(indicator) { w.Clip(x, y, cx, cy); Image img; if((style & GD::CURSOR) && (style & GD::SELECT)) { img = GridImg::FocSel(); } else if(style & GD::CURSOR) { img = GridImg::Focused(); } else if(style & GD::SELECT) { img = GridImg::Selected(); } if(!img.IsEmpty()) { Size isz = img.GetSize(); int xp = IsNull(val) ? x + (cx - isz.cx) / 2 : tx; w.DrawImage(xp, y + (cy - isz.cy) / 2, img, col); if(!IsNull(val)) tx += isz.cx + 3; } w.End(); } if(cx > lm + rm && cy > tm + bm) { int nx = x + lm; int ny = y + tm; int ncx = cx - lm - rm; int ncy = cy - tm - bm; w.Clip(nx, ny, ncx, ncy); int al = style & GD::ALIGN ? style & GD::ALIGN : align; Color fg = style & GD::READONLY ? SColorDisabled() : SColorText(); DrawText(w, tx, nx, ny, ncx, ncy, al, GetStdConvertedValue(val), fnt, fg, SColorPaper, 0, 0, 0, style & GD::WRAP); w.End(); } }
void GridDisplay::DrawText(Draw &w, int mx, int x, int y, int cx, int cy, int align, const wchar *s, const Font &font, const Color &fg, const Color &bg, bool found, int fs, int fe, bool wrap) { if(*s == 0) return; int tcy = font.Info().GetHeight(); const wchar *p = s; const wchar *t = s; int lines = 0; // int enters = 0; int ty = y; Size tsz; if((align & GD::VCENTER) || (align & GD::BOTTOM)) { lines = GetLinesCount(cx, s, font, wrap); if(align & GD::VCENTER) ty = max(ty, y + (cy - tcy * lines) / 2); else ty = y + cy - tcy * lines; } //w.DrawText(x, y, Format("lines: %d, cx:%d, cy%d", lines, cx, cy)); Size isz = GridImg::Dots2().GetSize(); int gcx = cx - (wrap ? 0 : isz.cx); real_size.cy = lines > 1 ? lines * tcy : 0; while(true) { bool nextline = *p == '\n'; bool caret = *p == '\r'; bool endtext = *p == '\0'; const wchar * pp = p; bool textbreak = false; if(nextline || endtext) { /*int kk = p - t; if(p - t <= 1) { //break; kk = 0; }*/ int tx = x; tsz = GetTextSize(t, font, int(p - t)); if(tsz.cx > gcx) { int size = 0; const wchar *e = t; while(e < p) { int tcx = GetTextSize(e, font, 1).cx; size += tcx; if(size > gcx) break; e++; } p = e; if(wrap) { textbreak = true; if(p == t) p = t + 1; } } if(align & GD::RIGHT) tx = x + cx - tsz.cx; else if(align & GD::HCENTER) tx = x + (cx - tsz.cx) / 2; Color tfg = fg; if(found) { int chs = int(t - s); int che = int(p - s - 1); if(fs <= che && fe >= chs) { int scx = GetTextSize(t, font, max(chs, fs) - chs).cx; int ecx = GetTextSize(t, font, min(che, fe) - chs + 1).cx; Color nbg(255 - fg.GetR(), 255 - fg.GetG(), 255 - fg.GetB()); w.DrawRect(max(mx, tx) + scx, ty, ecx - scx, tcy, Blend(nbg, bg, 100)); } } bool dots = !wrap && tsz.cx > gcx; if(dots) { real_size.cx = max(real_size.cx, tsz.cx); w.Clip(x, y, cx, cy); w.DrawImage(x + cx - isz.cx, ty + font.Info().GetAscent() - isz.cy, GridImg::Dots2, tfg); w.End(); if(p > t) { w.Clip(x, y, cx - isz.cx , cy); w.DrawText(max(mx, tx), ty, t, font, tfg, int(p - t)); w.End(); } } else w.DrawText(max(mx, tx), ty, t, font, tfg, int(p - t)); ty += tcy; t = textbreak ? p : (p = pp + 1); } if(caret) *(char *) p = ' '; if(!textbreak) { if(endtext) break; else p++; } } }
void GridDisplay::Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, dword style, Color &fg, Color &bg, Font &fnt, bool found, int fs, int fe) { real_size.cx = 0; real_size.cy = 0; if(cx == 0 || cy == 0) return; Color mg = bg; int al = style & GD::ALIGN ? style & GD::ALIGN : align; if(cx > lm + rm && cy > tm + bm) { int nx = x + lm; int ny = y + tm; int ncx = cx - lm - rm; int ncy = cy - tm - bm; if(IsNull(bgImg)) { if(lm > 0) w.DrawRect(x, y, lm, cy, mg); if(rm > 0) w.DrawRect(x + cx - rm, y, rm, cy, mg); if(tm > 0) w.DrawRect(x, y, cx, tm, mg); if(bm > 0) w.DrawRect(x, y + cy - bm, cx, bm, mg); w.DrawRect(nx, ny, ncx, ncy, bg); } else w.DrawImage(x, y, cx, cy, bgImg); w.Clip(nx, ny, ncx, ncy); if(!leftImg.IsEmpty()) { 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()) { Size isz = rightImg.GetSize(); w.DrawImage(nx + ncx - isz.cx, y + (cy - isz.cy) / 2, style & GD::READONLY ? Grayscale(rightImg) : rightImg); } if(!centerImg.IsEmpty()) { Size isz = centerImg.GetSize(); w.DrawImage(x + (cx - isz.cx) / 2, y + (cy - isz.cy) / 2, style & GD::READONLY ? Grayscale(centerImg) : centerImg); } if(!(style & GD::NOTEXT)) { DrawText(w, nx, nx, ny, ncx, ncy, al, GetStdConvertedValue(val), fnt, fg, bg, found, fs, fe, style & GD::WRAP); } w.End(); } else w.DrawRect(x, y, cx, cy, bg); }
void MultiButton::Paint(Draw& w) { Size sz = GetSize(); int border, lx, rx; bool frm = Metrics(border, lx, rx); int mst = ChState(MAIN); if(frm && !nobg) ChPaint(w, sz, style->edge[style->activeedge ? mst : 0]); bool left = false; bool right = false; for(int i = 0; i < button.GetCount(); i++) { SubButton& b = button[i]; int st = ChState(i); int x = 0, cx = 0; GetPos(b, lx, rx, x, cx); bool dopaint = true; Value v = b.left ? left ? style->lmiddle[st] : style->left[st] : right ? style->rmiddle[st] : style->right[st]; if(!nobg) { if(ComplexFrame()) ChPaint(w, x, border, cx, sz.cy - 2 * border, style->simple[st]); else if(frm) { if(IsTrivial() && style->usetrivial) dopaint = false; ChPaint(w, x, border, cx, sz.cy - 2 * border, dopaint ? v : style->trivial[st]); } else { w.Clip(x, 0, cx, sz.cy); ChPaint(w, sz, style->look[Frame() ? mst : st]); if(IsNull(v) || !Frame()) { if((!IsTrivial() || style->trivialsep) && IsEnabled()) { if(b.left) { if(left) ChPaint(w, x, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep1); ChPaint(w, x + cx - 1, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep2); } else { ChPaint(w, x, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep1); if(right) ChPaint(w, x + cx - 1, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep2); } } } else ChPaint(w, x, 0, cx, sz.cy, v); w.End(); } } if(dopaint) { Size tsz = GetTextSize(b.label, StdFont()); Image m = tsz.cx > 0 ? b.img : (Image)Nvl(b.img, CtrlsImg::DA()); Size isz = m.GetSize(); Point p = (st == CTRL_PRESSED) * style->pressoffset; p.x += x + (cx - isz.cx - tsz.cx - (tsz.cx > 0 && isz.cx > 0 ? LB_IMAGE : 0)) / 2; p.y += (sz.cy - isz.cy) / 2; if(b.left) { if(!left) p.x += style->loff; } else if(!right) p.x += style->roff; if(b.monoimg || IsNull(b.img)) w.DrawImage(p.x, p.y, m, frm ? style->fmonocolor[st] : style->monocolor[st]); else w.DrawImage(p.x, p.y, m); if(tsz.cx > 0) { if(isz.cx > 0) p.x += isz.cx + LB_IMAGE; w.DrawText(p.x, (sz.cy - tsz.cy) / 2, b.label); } } (b.left ? left : right) = true; } Rect r, cr; cr = GetSize(); cr.left = lx; cr.right = rx; Color text = SColorLabel(); Color paper = Null; if(!nobg) { if(ComplexFrame()) { r = cr; paper = HasFocus() ? SColorHighlight() : SColorPaper(); if(HasFocus()) text = SColorHighlightText(); w.DrawRect(r, paper); } else if(frm) { Rect m = GetMargin(); r = Rect(max(lx, m.left), m.top, min(rx, sz.cx - m.right), sz.cy - m.bottom); Color paper; if(mst == CTRL_HOT && !IsTrivial()) paper = Blend(SColorHighlight, SColorPaper, 235); else if(mst == CTRL_PRESSED && !IsTrivial()) paper = Blend(SColorHighlight, SColorFace, 235); else if(HasFocus()) { paper = SColorHighlight(); text = SColorHighlightText(); } else paper = SColorPaper(); w.DrawRect(r, paper); cr = r; } else { w.Clip(lx, 0, rx - lx, sz.cy); ChPaint(w, sz, style->look[mst]); Rect m = style->margin; r = Rect(max(lx, m.left), m.top, min(rx, sz.cx - m.right), sz.cy - m.bottom); if(!IsTrivial() || style->trivialsep) { if(left) { r.left++; if(IsEnabled()) ChPaint(w, lx, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep1); } if(right) { if(IsEnabled()) ChPaint(w, rx - 1, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep2); r.right--; } } w.End(); cr = r; } } cr.left++; Rect clr = cr; if(!IsNull(valuecy)) { cr.top += (cr.GetHeight() - valuecy + 1) / 2; cr.bottom = cr.top + valuecy; } Value v = convert->Format(value); bool f = HasFocus() && !push && frm; if(cr.left < cr.right && display) { w.Clip(clr); display->Paint(w, cr, v, IsShowEnabled() ? text : SColorDisabled, paper, f ? Display::CURSOR : Display::FOCUS|Display::CURSOR); w.End(); } if(!frm && HasFocus()) DrawFocus(w, r); }
bool TableCell::Paint(int zoom, Draw& w, int x, int y, int cx, int cy, int pcy, Color color, PaintInfo& pi) const { if(pcy > cy) pcy = cy; w.DrawRect(x, y, cx, cy, style.paper); int lw = DocZoom(zoom, style.leftwidth); int tw = DocZoom(zoom, style.topwidth); int rw = DocZoomLn(zoom, style.rightwidth); int bw = DocZoomLn(zoom, style.bottomwidth); int ls = DocZoom(zoom, style.leftspace); int ts = DocZoom(zoom, style.topspace); int rs = DocZoom(zoom, style.rightspace); int bs = DocZoom(zoom, style.bottomspace); Rect r(x + lw + ls, y + tw + ts, x + cx - rw - rs, y + cy - bw - bs); if(paintrect) { w.Clip(r); paintrect.Paint(w, r, color, style.paper); w.End(); } w.DrawRect(x, y, lw, cy, color); w.DrawRect(x, y, cx, tw, color); w.DrawRect(x + cx - rw, y, rw, cy, color); w.DrawRect(x, y + cy - bw, cx, bw, color); x = r.left; cx = r.Width(); switch(style.align) { case ALIGN_TOP: y = y + tw + ts; break; case ALIGN_CENTER: y = y + (cy - pcy) / 2 + tw + ts; break; case ALIGN_BOTTOM: y = y + cy - pcy - bw - bs; break; } int ymax = y + cy - bw - bs; int ypos = 0; for(int i = 0; i < par.GetCount(); i++) { const Paragraph& p = par[i]; int bef = DocZoom(zoom, p.GetBefore()); int aft = DocZoom(zoom, p.GetAfter()); if(ypos + bef - pi.yl + y > ymax) { pi.yl = ypos; return true; } ypos += bef; Paragraph::PaintInfo ppi; if(ypos >= pi.yl) { int py = y + ypos - pi.yl; if(p.Paint(zoom, w, x, py, cx, ymax, ppi, style.paper)) { pi.yl = ypos + ppi.yl; return true; } ypos += ppi.ypos - py; } else { int h = ypos < pi.yl ? p.GetHeight(zoom, cx) : 0; if(ypos + h > pi.yl) { ppi.yl = pi.yl - ypos; if(p.Paint(zoom, w, x, y, cx, ymax, ppi, style.paper)) { pi.yl = ypos + ppi.yl; return true; } } ypos += h; } ypos += aft; if(ypos - pi.yl + y > ymax) { pi.yl = ypos; return true; } } pi.yl = ypos; return false; }
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(); } }
void StreamCtrl::Paint(Draw &w) { Size sz = GetSize(); Color fill = Color(245, 245, 255); int width = sz.cx - info_width; int height = sz.cy - progress_height; /* black border */ w.DrawRect(0, 0, sz.cx, 1, Black); w.DrawRect(0, sz.cy - 1, sz.cx, 1, Black); w.DrawRect(0, 0, 1, sz.cy, Black); w.DrawRect(sz.cx - 1, 0, 1, sz.cy, Black); /* progress separator */ w.DrawRect(1, progress_height, width - 1, 1, Gray); /* info separator */ w.DrawRect(width, 1, 1, sz.cy - 2, Gray); int t = max(1, fceil((pos * width) / 100.0f)); //if(t < 1) t = 1; //if(t > width) t = width; if(shaded) { for(int i = 1; i < t; i++) w.DrawRect(i, 1, 1, progress_height - 1, Blend(src, dst, 256 * i / (width - 1))); } else { w.DrawRect(Rect(1, 1, t, progress_height), dst); } w.DrawRect(Rect(t, 1, width, progress_height), fill); String s = Format("%s : %d %%", postext, (int) pos); Size psz = GetTextSize(s, StdFont()); w.DrawText((width - psz.cx) / 2, 1 + (progress_height - psz.cy) / 2, s); /* Title */ //WString text = name; Font fnt = Arial(18); Size nsz = GetTextSize(name, fnt); w.DrawRect(1, progress_height + 1, width - 1, height - 2, fill); w.Clip(5, progress_height, width - 10, height); w.DrawText(noname ? (width - nsz.cx) / 2 : 5, progress_height + (height - nsz.cy) / 2 + 1, name, fnt); w.End(); /* Time */ w.DrawRect(width + 1, 1, info_width - 2, sz.cy - 2, fill); String ts; if(time_direction > 0) { int tms = time_total - time; int min = tms / 1000 / 60; int sec = tms / 1000 % 60; if(min == 0 && sec == 0) ts = "00:00"; else ts = ::Format("-%02d:%02d", min, sec); } else { int tms = time; ts = ::Format("%02d:%02d", tms / 1000 / 60, tms / 1000 % 60); } Size tsz = GetTextSize(ts, fnt); w.DrawText(width + (info_width - tsz.cx) / 2, sz.cy - (sz.cy - progress_height + tsz.cy) / 2, ts, fnt); /* Bitrate */ fnt = Arial(11); String inf = bitrate + " / stereo"; Size isz = GetTextSize(inf, fnt); w.DrawText(width + (info_width - isz.cx) / 2, 3, inf, fnt); //w.DrawText(width + 5, 3, bitrate, fnt); //w.DrawText(width + 5 + bsz.cx + 5, 3, "stereo", fnt); }
void LabelBox::Paint(Draw& w) { Size sz = GetSize(); if(!IsTransparent()) w.DrawRect(sz, SColorFace); Size lsz = GetLabelSize(); int d = lsz.cy >> 1; bool hline = sz.cy < 2 * Draw::GetStdFontCy(); bool vline = sz.cx < 2 * Draw::GetStdFontCy(); int ty = hline ? (sz.cy - lsz.cy) / 2 : 0; Size ts = PaintLabel(w, d + 2, ty, sz.cx, lsz.cy, !IsShowEnabled(), false, false, VisibleAccessKeys()); w.Begin(); w.ExcludeClip(d, ty, ts.cx + 4, ts.cy); if(GUI_GlobalStyle() >= GUISTYLE_XP || !IsNull(color)) { if(hline) { d = sz.cy / 2; w.DrawRect(0, d - 1, sz.cx, 1, SColorLight); w.DrawRect(0, d, sz.cx, 1, SColorShadow); w.DrawRect(0, d + 1, sz.cx, 1, SColorLight); } else if(vline) { d = sz.cx / 2; w.DrawRect(d - 1, 0, 1, sz.cy, SColorLight); w.DrawRect(d, 0, 1, sz.cy, SColorShadow); w.DrawRect(d + 1, 0, 1, sz.cy, SColorLight); } else { Color c = Nvl(color, LabelBoxColor); w.DrawRect(0, d + 2, 1, sz.cy - d - 4, c); w.DrawRect(sz.cx - 1, d + 2, 1, sz.cy - d - 4, c); w.DrawRect(2, sz.cy - 1, sz.cx - 4, 1, c); w.DrawRect(2, d, sz.cx - 4, 1, c); w.DrawRect(1, d + 1, 2, 1, c); w.DrawRect(1, d + 2, 1, 1, c); w.DrawRect(sz.cx - 3, d + 1, 2, 1, c); w.DrawRect(sz.cx - 2, d + 2, 1, 1, c); w.DrawRect(1, sz.cy - 2, 2, 1, c); w.DrawRect(1, sz.cy - 3, 1, 1, c); w.DrawRect(sz.cx - 3, sz.cy - 2, 2, 1, c); w.DrawRect(sz.cx - 2, sz.cy - 3, 1, 1, c); } } else { if(hline) { d = sz.cy / 2; w.DrawRect(0, d, sz.cx, 1, SColorShadow); w.DrawRect(0, d + 1, sz.cx, 1, SColorLight); } else if(vline) { d = sz.cx / 2; w.DrawRect(d, 0, 1, sz.cy, SColorShadow); w.DrawRect(d - 1, 1, 0, sz.cy, SColorLight); } else { w.DrawRect(1, d, sz.cx - 2, 1, SColorShadow); w.DrawRect(1, d + 1, sz.cx - 2, 1, SColorLight); w.DrawRect(0, d, 1, sz.cy - d - 1, SColorShadow); w.DrawRect(1, d + 1, 1, sz.cy - d - 2, SColorLight); w.DrawRect(sz.cx - 2, d, 1, sz.cy - d, SColorShadow); w.DrawRect(sz.cx - 1, d, 1, sz.cy - d, SColorLight); w.DrawRect(1, sz.cy - 2, sz.cx - 2, 1, SColorShadow); w.DrawRect(1, sz.cy - 1, sz.cx - 2, 1, SColorLight); } } w.End(); }