NAMESPACE_UPP void DrawTextEllipsis(Draw& w, int x, int y, int cx, const wchar *text, const char *ellipsis, Font font, Color ink, int n) { if(n < 0) n = wstrlen(text); FontInfo f = font.Info(); const char *s; int dtl = 0; int el = 0; for(s = ellipsis; *s; s++) { dtl += f[(byte)*s]; el++; } int l = 0; int i; for(i = 0; i < n; i++) { l += f[(byte) text[i]]; if(l > cx) { while(l + dtl > cx && i > 0) { l -= f[(byte) text[i]]; i--; } i++; break; } } w.DrawText(x, y, text, font, ink, i); if(i < n) w.DrawText(x + l, y, ellipsis, font, ink, el); }
virtual void Paint(Draw& w) { w.DrawRect(GetSize(), White); w.DrawText(10, 10, "ultimate++是一个性能优良的C++GUI库"); w.DrawText(10, 100, "X\357\274\214X"); WString h("x\357\274\214X"); w.DrawText(10, 150, h); DDUMP(h.GetLength()); }
void DndTest::Paint(Draw &w) { w.DrawRect(GetSize(), SColorPaper()); if(files.GetCount()) for(int i = 0; i < files.GetCount(); i++) w.DrawText(2, 2 + i * Draw::GetStdFontCy(), files[i]); else w.DrawText(2, 2, "None"); }
void MyApp::Paint(Draw& w) { w.DrawRect(GetSize(), SColorPaper()); for(int i = 0; i < MyImages::GetCount(); i++) { w.DrawImage(50, 80 + 20 * i, MyImages::Get(i)); w.DrawText(80, 80 + 20 * i, MyImages::GetId(i)); } w.DrawImage(20, 0, 50, 50, MyImages::Get(MyImages::I_Circle)); w.DrawText(80, 0, AsString(MyImages::Find("Circle"))); }
void DocEdit::Paint(Draw& w) { Size sz = GetSize(); Color bg = color[IsShowEnabled() && !IsReadOnly() ? PAPER_NORMAL : PAPER_READONLY]; if(nobg) bg = Null; int y = -sb + 1; int pos = 0; int sell, selh; GetSelection(sell, selh); for(int i = 0; i < para.GetCount() && y < sz.cy; i++) { int h = GetHeight(i); if(y + h >= 0) { WString text = line[i]; Fmt fmt = Format(text); int p = pos; for(int i = 0; i < fmt.line.GetCount(); i++) { int n = fmt.LineEnd(i) - fmt.line[i]; int a = minmax(sell - p, 0, n); int b = minmax(selh - p, 0, n) - a; int c = n - a - b; int *wa = fmt.width + fmt.line[i]; int *wb = fmt.width + fmt.line[i] + a; int *wc = fmt.width + fmt.line[i] + a + b; int acx = sSum(wa, a); int bcx = sSum(wb, b); int ccx = sSum(wc, c); w.DrawRect(1, y, acx, fmt.fi.GetHeight(), bg); w.DrawText(1, y, ~fmt.text + fmt.line[i], font, IsShowEnabled() ? color[INK_NORMAL] : color[INK_DISABLED], a, wa); w.DrawRect(1 + acx, y, bcx, fmt.fi.GetHeight(), color[PAPER_SELECTED]); w.DrawText(1 + acx, y, ~fmt.text + fmt.line[i] + a, font, color[INK_SELECTED], b, wb); w.DrawRect(1 + acx + bcx, y, ccx, fmt.fi.GetHeight(), bg); w.DrawText(1 + acx + bcx, y, ~fmt.text + fmt.line[i] + a + b, font, color[INK_NORMAL], c, wc); p += n; w.DrawRect(1 + acx + bcx + ccx, y, cx - (acx + bcx + ccx), fmt.fi.GetHeight(), p >= sell && p < selh ? color[PAPER_SELECTED] : bg); y += fmt.fi.GetHeight(); } w.DrawRect(1, y, cx, after, color[PAPER_NORMAL]); y += after; } else y += h; pos += line[i].GetLength() + 1; } w.DrawRect(0, -sb, sz.cx, 1, bg); w.DrawRect(0, 0, 1, sz.cy, bg); w.DrawRect(sz.cx - 1, 0, 1, sz.cy, bg); if(eofline) w.DrawRect(1, y++, cx, 1, SColorShadow); if(y < sz.cy) w.DrawRect(1, y, cx, sz.cy - y, bg); DrawTiles(w, DropCaret(), CtrlImg::checkers()); }
void MyApp::Paint(Draw& w) { w.DrawRect(GetSize(), White()); Font fnt = StdFont(10); w.DrawText(100, 200, "Quick brown 1234567890", fnt); w.DrawText(100, 200, 900, "Quick brown 1234567890", fnt); fnt = Arial(10); w.DrawText(300, 200, "Quick brown 1234567890", fnt); w.DrawText(300, 200, 900, "Quick brown 1234567890", fnt); }
int Navigator::NavigatorDisplay::DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { int ii = q; if(ii < 0 || ii >= item.GetCount()) return 0; const NavItem& m = *item[ii]; bool focuscursor = (style & (FOCUS|CURSOR)) == (FOCUS|CURSOR) || (style & SELECT); int x = r.left; int ry = r.top + r.GetHeight() / 2; int y = ry - Draw::GetStdFontCy() / 2; if(findarg(m.kind, KIND_FILE, KIND_NEST) >= 0) { w.DrawRect(r, focuscursor ? paper : m.kind == KIND_NEST ? Blend(SColorMark, SColorPaper, 220) : SColorFace); if(m.kind == KIND_FILE) return PaintFileName(w, r, m.type, ink); String h = FormatNest(m.type); w.DrawText(x, y, h, StdFont().Bold(), ink); return GetTextSize(h, StdFont().Bold()).cx; } w.DrawRect(r, paper); if(m.kind == KIND_LINE) { w.DrawText(x, y, m.type, StdFont().Bold(), ink); return GetTextSize(m.type, StdFont().Bold()).cx; } PaintCppItemImage(w, x, ry, m.access, m.kind, focuscursor); x += Zx(15); Vector<ItemTextPart> n = ParseItemNatural(m.name, m.natural, m.ptype, m.pname, m.type, m.tname, m.ctname, ~m.natural + m.at); int starti = 0; for(int i = 0; i < n.GetCount(); i++) if(n[i].type == ITEM_NAME) { starti = i; break; } PaintText(w, x, y, m.natural, n, starti, n.GetCount(), focuscursor, ink, false); if(starti) { const char *h = " : "; w.DrawText(x, y, h, BrowserFont(), SColorText); x += GetTextSize(h, BrowserFont()).cx; } PaintText(w, x, y, m.natural, n, 0, starti, focuscursor, ink, false); return x; }
void ValueSlider::Paint(Draw &w) { Size sz = GetSize(); /*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);*/ int t = (int) (((pos - minValue) * sz.cx) / (maxValue - minValue)); if(t < 1) t = 1; if(t > sz.cx - 1) t = sz.cx - 1; if(shaded) { for(int i = 1; i < t; i++) w.DrawRect(i, 1, 1, sz.cy - 2, Blend(src, dst, 256 * i / (sz.cx - 1))); } else { w.DrawRect(Rect(1, 1, t, sz.cy - 1), dst); } if(t < sz.cx - 1) w.DrawRect(Rect(t, 1, sz.cx - 1, sz.cy - 1), Color(245, 245, 255)); String s = Format("%s : %.2f", text, pos); Size tsz = GetTextSize(s, StdFont()); w.DrawText((sz.cx - tsz.cx) / 2, (sz.cy - tsz.cy) / 2, s); }
void MyList::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { if(style & CURSOR) w.DrawRect(r,SLtGray()); else w.DrawRect(r,SWhite()); w.DrawText(r.left,r.top,q.ToString()); }
void MyApp::Paint(Draw& w) { w.DrawRect(GetSize(), SColorPaper()); w.DrawText(pos.x, pos.y, data.text, StdFont(), data.color); if(!IsNull(dragpos)) w.DrawRect(RectC(dragpos.x - 1, dragpos.y - 1, 3, 3), LtBlue); }
int Navigator::ScopeDisplay::DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { w.DrawRect(r, paper); if(IsNull(q)) { const char *txt = "All"; w.DrawText(r.left, r.top, txt, StdFont().Bold().Italic(), style & CURSOR ? ink : HighlightSetup::GetHlStyle(HighlightSetup::INK_KEYWORD).color); return GetTextSize(txt, StdFont().Bold().Italic()).cx; } String h = q; if(*h == '\xff') return PaintFileName(w, r, h, ink); else h = FormatNest(h); w.DrawText(r.left, r.top, h, StdFont().Bold(), ink); return GetTextSize(h, StdFont().Bold()).cx; }
void ExGridCtrl::Paint(Draw &w) { GridCtrl::Paint(w); if (GetCount() == 0) w.DrawText(GetSize().cx / 2 - _X, GetSize().cy / 2 - _Y - _Offset, _Info, _Font, _Ink); }
//============================================================================================== /*virtual*/ void TightFontDisplayForArrayCtrl::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { Font fnt(FontZ(Font::COURIER, 9)); String txt = q; w.DrawRect(r, paper); w.DrawText(r.left + 2, r.top + (r.Height() - GetTextSize(txt, fnt).cy) / 2, txt, fnt, ink); // <- Change is here - "w." no more needed }
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { Font fnt = Font(q, r.Height() - 2); String txt = Font::GetFaceName(q); w.DrawRect(r, paper); w.DrawText(r.left + 2, r.top + (r.Height() - GetTextSize(txt, fnt).cy) / 2, txt, fnt, ink); }
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { ValueArray va = q; String txt = va[0]; Image icon = va[1]; w.DrawRect(r, paper); w.DrawImage(r.left, r.top + (r.Height() - 16) / 2, IsNull(icon) ? IdeImg::Package() : icon); w.DrawText(r.left + 20, r.top + (r.Height() - Draw::GetStdFontCy()) / 2, txt, fnt, ink); }
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { w.DrawRect(r, paper); w.DrawText(r.left, r.top, AsString(q), StdFont(), ink); Font fnt; fnt.FaceName("Bitstream Vera Sans Mono"); // fnt.Face(Font::ARIAL); fnt.Height(20); WString txt((int)q, 1); w.DrawText(r.left + 40, r.top, txt, Courier(20), ink); GlyphInfo gi = GetGlyphMetrics(fnt, q); w.DrawRect(r.left + 60, r.top, gi.width, r.GetHeight(), LtCyan()); gi = GetGlyphInfo(fnt, q); if(!gi.IsMissing()) { if(gi.IsNormal()) w.DrawText(r.left + 60, r.top, txt, fnt); else if(gi.IsReplaced()) w.DrawText(r.left + 60, r.top, txt, fnt().Face(gi.lspc), Magenta()); else if(gi.IsComposed()) { ComposedGlyph g; if(Compose(fnt, q, g)) { w.DrawText(r.left + 60, r.top, WString(g.basic_char, 1), fnt, LtBlue()); w.DrawText(r.left + 60 + g.mark_pos.x, r.top + g.mark_pos.y, WString(g.mark_char, 1), g.mark_font, LtRed()); } } } else w.DrawText(r.left + 60, r.top, txt, fnt, ink); w.DrawRect(r.left, r.bottom - 1, r.Width(), 1, Black()); }
void ItemProperty::Paint(Draw& w) { Size sz = GetSize(); w.DrawRect(sz, SColorLtFace); w.DrawRect(0, GetHeight() - 1, sz.cx, 1, SColorText); w.DrawText(2, (EditField::GetStdHeight() + 6 - GetTextSize(name, StdFont()).cy) / 2, name, GetData() == defval ? StdFont()() : StdFont().Bold()); }
virtual void Paint(Draw& w) { w.DrawRect(GetSize(), White()); w.DrawRect(10, 10, 60, 80, Green()); w.DrawLine(100, 10, 160, 80, 0, Black()); w.DrawLine(160, 10, 100, 80, 4, Red()); w.DrawLine(160, 40, 100, 50, PEN_DOT, Red()); w.DrawEllipse(210, 20, 80, 60, Blue()); w.DrawEllipse(310, 20, 80, 60, LtBlue(), 5, Red()); w.DrawArc(RectC(410, 20, 80, 60), Point(10, 10), Point(450, 80), 3, Cyan); Vector<Point> p; p << Point(30, 110) << Point(60, 180) << Point(10, 150) << Point(70, 150); w.DrawPolyline(p, 4, Black); p.Clear(); p << Point(130, 110) << Point(160, 180) << Point(110, 150) << Point(170, 120) << Point(130, 110); w.DrawPolygon(p, Blue); p.Clear(); p << Point(230, 110) << Point(260, 180) << Point(210, 150) << Point(270, 120) << Point(230, 110); w.DrawPolygon(p, Cyan, 5, Magenta); p.Clear(); p << Point(330, 110) << Point(360, 180) << Point(310, 150) << Point(370, 120) << Point(330, 110); w.DrawPolygon(p, Cyan, 5, Magenta, I64(0xaa55aa55aa55aa55)); w.DrawImage(40, 240, CtrlImg::save()); w.DrawImage(110, 210, 80, 80, CtrlImg::save()); w.DrawImage(240, 240, CtrlImg::save(), Blue); w.DrawImage(310, 210, 80, 80, CtrlImg::save(), Blue); w.DrawText(20, 330, "Hello world!"); w.DrawText(120, 330, "Hello world!", Arial(15).Bold()); w.DrawText(220, 330, "Hello world!", Roman(15).Italic(), Red); w.DrawText(320, 380, 400, "Hello world!", Courier(15).Underline()); }
void DrawTLText(Draw& draw, int x, int y, int cx, const wchar *text, Font font, Color ink, int accesskey) { int cy = font.Info().GetHeight(); const wchar *s = text; const wchar *t = s; int apos = HIWORD(accesskey); int akey = LOWORD(accesskey); for(;;) { if(*s == '\n' || *s == '\0') { int a = x; const wchar *q = t; const wchar *start = NULL; while(q < s) { while(q < s && *q < ' ') { if(*q == '\t') a = (a - x + 2 * cy) / (2 * cy) * (2 * cy) + x; q++; } t = q; bool ak = false; start = q; while(q < s && *q >= ' ') { if(akey && ToUpper(ToAscii(*q)) == akey && (apos == 0 || q - start + 1 == apos)) { ak = true; akey = 0; break; } q++; } start = NULL; draw.DrawText(a, y, t, font, ink, (int)(q - t)); a += GetTextSize(t, font, (int)(q - t)).cx; if(ak) { draw.DrawText(a, y, q, font().Underline(), ink, 1); a += GetTextSize(q, font().Underline(), 1).cx; q++; } } t = s + 1; y += cy; } if(*s++ == '\0') break; } }
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { ValueArray va = q; String txt = va[0]; Image icon = va[1]; if(IsNull(icon)) icon = IdeImg::Package(); else icon = DPI(icon, 16); w.DrawRect(r, paper); w.DrawImage(r.left, r.top + (r.Height() - icon.GetHeight()) / 2, icon); w.DrawText(r.left + Zx(20), r.top + (r.Height() - Draw::GetStdFontCy()) / 2, txt, fnt, ink); }
void RichPNG::Paint(const Value& data, Draw& w, Size sz) const { if(IsString(data)) { w.DrawRect(sz, SColorFace()); DrawFrame(w, sz, SColorText()); w.DrawText(2, 2, "plugin/png missing!"); return; } Image x = Image(data); Size outsz(min(sz.cx, 4 * x.GetWidth()), min(sz.cy, 4 * x.GetHeight())); w.DrawImage(0, 0, outsz.cx, outsz.cy, x); }
void InfoPanel::Paint(Draw& w) { Size sz = GetSize(); Size wsz = screenRect.GetSize(); Color frameColor = Color(183, 183, 183); Color bgColor = Color(102, 102, 102); w.DrawRect(sz, bgColor); w.DrawRect(0, 0, 1, sz.cy, frameColor); w.DrawRect(0, 0, sz.cx, 1, frameColor); w.DrawRect(sz.cx - 1, 0, 1, sz.cy, frameColor); String info = Format("FPS: %.2f, Textures: %d (%d), Size: %d, %d", GetFps(), resources.textures.GetCount(), resources.bindedTextures, wsz.cx, wsz.cy); w.DrawText(5, sz.cy - 18, info, StdFont(), White); }
void SlimButton::Paint(Draw &w) { SystemDraw& sw = (SystemDraw&) w; float a = sw.alpha; sw.alpha = alpha; Size sz = GetSize(); if(HasMouseIn(sz)) w.DrawRect(sz, bg); sw.alpha = a; Size tsz = GetTextSize(label, StdFont()); w.DrawText((sz.cx - tsz.cx) / 2, (sz.cy - tsz.cy) / 2, label, StdFont(), fg); }
void ColorPusher::Paint(Draw& w) { Size sz = GetSize(); w.DrawRect(sz, push ? SColorHighlight : SColorPaper); int ty = (sz.cy - StdFont().Info().GetHeight()) / 2; if(withtext) { w.DrawRect(2, 2, sz.cy - 4, sz.cy - 4, color); DrawFrame(w, 1, 1, sz.cy - 2, sz.cy - 2, SColorText); w.DrawText(sz.cy + 2, ty, FormatColor(color), StdFont(), SColorText()); } else { if(!IsNull(color)) { w.DrawRect(2, 2, sz.cx - 4, sz.cy - 4, color); DrawFrame(w, 1, 1, sz.cx - 2, sz.cy - 2, SColorText); } else if(!withtext) w.DrawText(max(2, (sz.cx - GetTextSize(nulltext, StdFont()).cx) / 2), ty, nulltext, StdFont(), SColorText()); } if(HasFocus()) DrawFocus(w, GetSize()); }
void AppPreview::Paint(Draw& w) { Size sz = GetSize(); FontInfo fi = CourierZ(12).Info(); int y = 0; int i = sb; while(y < sz.cy) { bool hdr = i < line.GetCount() && line[i].header; w.DrawRect(0, y, sz.cx, fi.GetHeight(), hdr ? LtCyan : SColorPaper); if(i < line.GetCount()) w.DrawText(0, y, line[i].text, hdr ? ArialZ(12).Bold().Italic() : CourierZ(12), SColorText); y += fi.GetHeight(); i++; } }
void Puzzle::Paint(Draw& w) { w.DrawRect(GetSize(), WhiteGray); for(int y = 0; y < size.cy; y++) for(int x = 0; x < size.cx; x++) { int b = Get(x, y); Point p(x * 32, y * 32); if(b) { w.DrawImage(p.x, p.y, BoxImg()); String txt = AsString(b); Size sz = w.GetTextSize(txt, Arial(20).Bold()); w.DrawText(p.x + (32 - sz.cx) / 2, p.y + (32 - sz.cy) / 2, txt, Arial(20).Bold(), LtBlue); } } }
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); }
void RichRuler::Paint(Draw& w) { Size sz = GetSize(); w.DrawRect(sz, SColorFace); w.DrawRect(0, sz.cy - 1, sz.cx, 1, SColorShadow); int cx = zoom * pgcx; w.DrawRect(x0 - 1, 3, cx + 3, sz.cy - 6, SColorPaper); int i = 0; for(;;) { int x = fround(++i * grid) * zoom; if(x >= cx) break; if(i % marks == 0) w.DrawRect(x0 + x, 8, 1, 5, SColorHighlight); else w.DrawRect(x0 + x, 9, 1, 3, SColorHighlight); } i = 0; for(;;) if(++i % numbers == 0) { int x = fround(i * grid) * zoom; if(x >= cx) break; String n = Format("%d", (int)(i * numbermul + 0.5)); Size tsz = GetTextSize(n, Arial(10)); if(x + tsz.cx - tsz.cx / 2 < cx) { int px = x0 + x - tsz.cx / 2; w.DrawRect(px, 4, tsz.cx, sz.cy - 8, SColorPaper); w.DrawText(x0 + x - tsz.cx / 2, 4, n, Arial(10), SColorText); } } FieldFrame().FramePaint(w, RectC(x0 - 1, 3, cx + 3, sz.cy - 6)); for(i = marker.GetCount() - 1; i >= 0; --i) { const Marker& m = marker[i]; if(!IsNull(m.pos)) HotPaint(w, x0 + m.pos * zoom, m.top ? 1 : sz.cy - 4, m.image); } i = 0; if(tabsize) for(;;) { int xp = ++i * tabsize; int x = xp * zoom; if(x >= cx) break; if(xp > tabpos) w.DrawRect(x0 + x, sz.cy - 4, 1, 3, SColorShadow); } w.DrawImage(4, 6, newtabalign == ALIGN_RIGHT ? RichEditImg::RightTab() : newtabalign == ALIGN_CENTER ? RichEditImg::CenterTab() : RichEditImg::LeftTab()); }
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 IdeImgView::Paint(Draw& w) { Size sz = GetSize(); String t = (img_sz != img.GetSize() ? "Resized from: " : "Image size: "); t << Format("%d x %d", img_sz.cx, img_sz.cy); int tcy = Draw::GetStdFontCy(); w.DrawRect(0, 0, sz.cx, tcy, SColorFace()); w.DrawText(5, 0, t, StdFont(), SColorText()); int ii = 0; for(int x = 0; x < sz.cx; x += 16) { int jj = ii; for(int y = tcy; y < sz.cy; y += 16) w.DrawRect(x, y, 16, 16, jj++ & 1 ? LtGray() : WhiteGray()); ii++; } w.DrawImage(5, 5 + tcy, img); }