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); }
void DrawSmartText(Draw& draw, int x, int y, int cx, const char *text, Font font, Color ink, int accesskey) { if(*text == '\1') { RichText txt = ParseQTF(text + 1, accesskey); txt.ApplyZoom(GetRichTextStdScreenZoom()); txt.Paint(Zoom(1, 1), draw, x, y, cx); return; } DrawTLText(draw, x, y, cx, ToUnicode(text, CHARSET_DEFAULT), font, ink, accesskey); }
void LineEdit::LeftDrag(Point p, dword flags) { int c = GetMousePos(p); int l, h; if(!HasCapture() && GetSelection(l, h) && c >= l && c < h) { WString sample = GetW(l, min(h - l, 3000)); Size sz = StdSampleSize(); ImageDraw iw(sz); iw.DrawRect(sz, Black()); iw.Alpha().DrawRect(sz, Black()); DrawTLText(iw.Alpha(), 0, 0, 9999, sample, font, White()); NextUndo(); if(DoDragAndDrop(ClipFmtsText(), iw) == DND_MOVE) { RemoveSelection(); Action(); } } }