PieDraw::PieDraw(): backColor(White), titleFont(StdFont(16)), titleColor(Black), titlePos(TOP), titleGap(2), showPercent(true), percentBack(Null), legendFont(StdFont()), legendTextColor(Black), legendBackColor(Null), showLegend(true), legendLeft(10), legendTop(Null), legendWidth(60), legendHeight(120), pieAngle(0), pieMarginLeft(40), pieMarginTop(40), pieMarginRight(40), pieMarginBottom(40) {}
void EscDraw::DrawText(EscEscape& e) { if(e.GetCount() < 3 || e.GetCount() > 6) e.ThrowError("wrong number of arguments in call to 'DrawText'"); int x = e.Int(0); int y = e.Int(1); Font font = StdFont(); Color color = SColorText; if(e[2].IsInt()) { int z = e.Int(2); e.CheckArray(3); WString text = e[3]; if(e.GetCount() > 4) font = FontEsc(e[4]); if(e.GetCount() > 5) color = ColorEsc(e[5]); w.DrawText(x, y, z, text, Nvl(font, StdFont()), color); } else { e.CheckArray(2); WString text = e[2]; if(e.GetCount() > 3) font = FontEsc(e[3]); if(e.GetCount() > 4) color = ColorEsc(e[4]); w.DrawText(x, y, text, Nvl(font, StdFont()), color); } }
void SIC_StdFont(EscEscape& e) { if(e.GetCount() == 1) e = EscFont(StdFont()(Zy(e.Int(0)))); else e = EscFont(StdFont()); }
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()); }
SelectPackageDlg::SelectPackageDlg(const char *title, bool selectvars_, bool main) : selectvars(selectvars_) { CtrlLayoutOKCancel(*this, title); Sizeable().Zoomable(); Icon(IdeImg::MainPackage(), IdeImg::PackageLarge()); base.AutoHideSb(); base.NoGrid(); base.AddColumn("Assembly"); base.WhenCursor = THISBACK(OnBase); base.WhenBar = THISBACK(ToolBase); base.WhenLeftDouble = THISBACK(OnBaseEdit); ok.WhenAction = clist.WhenLeftDouble = alist.WhenLeftDouble = THISBACK(OnOK); cancel.WhenAction = WhenClose = THISBACK(OnCancel); clist.Columns(4); clist.WhenEnterItem = clist.WhenKillCursor = THISBACK(ListCursor); alist.AddColumn("Package").Add(3); alist.AddColumn("Nest"); alist.AddColumn("Description"); alist.AddIndex(); alist.ColumnWidths("108 79 317"); alist.WhenCursor = THISBACK(ListCursor); alist.EvenRowColor(); alist.SetLineCy(max(Zy(16), Draw::GetStdFontCy())); list.Add(clist.SizePos()); list.Add(alist.SizePos()); splitter.Horz(base, list); splitter.SetPos(2000); splitter.Zoom(selectvars ? -1 : 1); newu <<= THISBACK(OnNew); filter <<= THISBACK(OnFilter); filter.Add(MAIN|FIRST, "Main packages of first nest"); filter.Add(MAIN, "All main packages"); filter.Add(FIRST, "All packages of first nest"); filter.Add(0, "All packages"); filter <<= main ? MAIN|FIRST : 0; progress.Hide(); brief <<= THISBACK(SyncBrief); search.NullText("Search (Ctrl+K)", StdFont().Italic(), SColorDisabled()); search <<= THISBACK(SyncList); search.SetFilter(CharFilterDefaultToUpperAscii); SyncBrief(); description.NullText("Package description (Alt+Enter)", StdFont().Italic(), SColorDisabled()); description <<= THISBACK(ChangeDescription); ActiveFocus(brief ? (Ctrl&)clist : (Ctrl&)alist); clist.BackPaintHint(); alist.BackPaintHint(); base.BackPaintHint(); loadi = 0; loading = false; clist.WhenBar = alist.WhenBar = THISBACK(PackageMenu); }
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); }
int GetRichTextScreenStdFontHeight() { static int gh = 67; ONCELOCK { for(int i = 0; i < 1000; i++) { int h = GetRichTextStdScreenZoom() * i; if(h > 0 && StdFont(h).GetCy() == StdFont().GetCy()) { gh = i; break; } } } return gh; }
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 DropGrid::Paint(Draw& w) { Size sz = GetSize(); Size isz = clear.GetStdSize(); if(clear_button && !notnull && IsEnabled() && IsSelected()) { clear.Show(); clear.RightPos(3, isz.cx).TopPos((sz.cy - isz.cy) / 2, isz.cy); } else clear.Hide(); GridDisplay &disp = display ? *display : list.GetDisplay(); bool hf = HasFocus(); bool isnull = rowid < 0; Color fg = hf ? SColorHighlightText() : IsEnabled() ? SColorText() : SColorDisabled(); Color bg = !IsEnabled() || !IsEditable() ? EditField::StyleDefault().disabled : notnull && isnull ? Blend(SColorPaper, Color(255, 0, 0), 32) : hf ? SColorHighlight() : SColorPaper(); const int d = 0; if(isnull) w.DrawRect(d, d, sz.cx - d * 2, sz.cy - d * 2, bg); else { Font fnt(StdFont()); Paint0(w, 1, 1, d, d, sz.cx - d * 2, sz.cy - d * 2, Format0(Null, rowid), 0, fg, bg, fnt); } if(hf) DrawFocus(w, d - 0, d - 0, sz.cx - (d - 0) * 2, sz.cy - (d - 0) * 2); }
CH_STYLE(DockCtrlChStyle, Style, StyleDefault) { font = StdFont(); barmargins = Rect(2,2,2,2); barheight = font.Info().GetHeight() + 8; tabheight = font.Info().GetHeight() + 8; tabmargin = 2; tabsel = Rect(2, 2, 2, 2); tabedge = Rect(6, 6, 6, 6); tabextendleft = 0; const TabCtrl::Style* defguistyle = &TabCtrl::StyleDefault(); barbackground[0] = defguistyle->normal[0]; DockCtrlImgsLook(barshut, DockCtrlImages::I_DClose, 3); DockCtrlImgsLook(barhide, DockCtrlImages::I_DHide, 3); DockCtrlImgsLook(barmenu, DockCtrlImages::I_DMenu, 3); CtrlsImageLook(tabnormal, CtrlsImg::I_TAB, 4); CtrlsImageLook(tabfirst, CtrlsImg::I_FTAB, 4); CtrlsImageLook(tablast, CtrlsImg::I_LTAB, 4); CtrlsImageLook(tabboth, CtrlsImg::I_BTAB, 4); stdhighlight = StandardHighlight(Blend(SColorHighlight, SColorPaper, 90), SColorHighlight); tabhighlight = AlphaHighlight(stdhighlight, 80); }
void Ide::MakeIcon() { #ifdef PLATFORM_WIN32 String mp = main; Image li = IdeImg::PackageLarge(); if(!IsNull(mp)) { Size isz = li.GetSize(); ImageDraw idraw(isz); Draw& mdraw = idraw.Alpha(); idraw.DrawImage(0, 0, li); mdraw.DrawImage(0, 0, li, White); Font font = StdFont(9); Size sz = GetTextSize(mp, font); sz.cx = min(sz.cx + 4, isz.cx); sz.cy += 2; int x = (isz.cx - sz.cx) / 2; int y = isz.cy - sz.cy; idraw.DrawRect(x, y, sz.cx, sz.cy, White); mdraw.DrawRect(x, y, sz.cx, sz.cy, White); idraw.DrawText(x + 2, y + 1, mp, font, Black); DrawFrame(idraw, x, y, sz.cx, sz.cy, LtBlue); li = idraw; } LargeIcon(li); #endif }
void EscDraw::DrawSmartText(EscEscape& e) { if(e.GetCount() < 3 || e.GetCount() > 7) e.ThrowError("wrong number of arguments in call to 'DrawSmartText'"); int x = e.Int(0); int y = e.Int(1); int ii = 2; String text; if(ii < e.GetCount() && e[ii].IsArray()) text = ToUtf8((WString)e[ii++]); int accesskey = ExtractAccessKey(text, text); Font font = StdFont().Height(11); if(ii < e.GetCount()) font = FontEsc(e[ii++]); if(font.GetHeight() == 0) #ifdef GUI_X11 font.Height(12); #else font.Height(11); #endif Color color = SColorText; if(ii < e.GetCount()) color = ColorEsc(e[ii++]); int cx = INT_MAX; if(ii < e.GetCount()) cx = e.Int(ii++); ::DrawSmartText(w, x, y, cx, text, font, color, accesskey); }
int GetEditWidth(const String str) { Font font = StdFont(); int ret = 0; for (int i = 0; i < str.GetCount(); ++i) ret += font.GetWidth(str[i]); return ret; }
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 AttrText::Init() { ink = Null; normalink = Null; normalpaper = Null; paper = Null; font = StdFont(); align = Null; imgspc = 0; }
void SIC_GetTextSize(EscEscape& e) { if(e.GetCount() < 1 || e.GetCount() > 2) e.ThrowError("wrong number of arguments in call to 'GetTextSize'"); e.CheckArray(0); WString text = e[0]; Font font = StdFont(); if(e.GetCount() > 1) font = FontEsc(e[1]); e = EscSize(GetTextSize(text, font)); }
void IconDes::SingleMode() { single_mode = true; ilist.Ctrl::Remove(); rgbactrl.SubCtrl(&single); Size fsz = GetTextSize("Resize", StdFont()); single.Add(info.HSizePos().TopPos(0, fsz.cy)); resize.SetLabel("Resize"); single.Add(resize.LeftPos(0, fsz.cx + 2 * fsz.cy).TopPos(4 * fsz.cy / 3, 4 * fsz.cy / 3)); resize <<= THISBACK(EditImage); }
DrawLabel::DrawLabel() { push = focus = disabled = false; lspc = rspc = 0; limg_never_hide = false; rimg_never_hide = false; ink = disabledink = Null; align = valign = ALIGN_CENTER; accesskey = 0; accesspos = -1; font = StdFont(); }
void SIC_GetSmartTextSize(EscEscape& e) { if(e.GetCount() < 1 || e.GetCount() > 2) e.ThrowError("wrong number of arguments in call to 'GetTextSize'"); e.CheckArray(0); String text = ToUtf8((WString)(e[0])); ExtractAccessKey(text, text); Font font = StdFont(); if(e.GetCount() > 1) font = FontEsc(e[1]); e = EscSize(GetSmartTextSize(text, font)); }
void MenuItemBase::PaintTopItem(Draw& w, int state) { Size sz = GetSize(); if(GUI_GlobalStyle() >= GUISTYLE_XP) { bool opaque = InOpaqueBar(); bool opaque2 = opaque || state; Color bg = SColorFace(); if(opaque2) ChPaint(w, 0, 0, sz.cx, sz.cy, style->topitem[state]); else if(opaque) w.DrawRect(0, 0, sz.cx, sz.cy, bg); String text = GetText(); Size isz = GetTextSize(text, StdFont()); Color txt = opaque ? style->topitemtext[0] : GetLabelTextColor(this); Color hltxt = opaque2 ? style->topitemtext[state] : GetLabelTextColor(this); if(!opaque && state != 2) { // Fix issues when text color is not compatible with transparent background (e.g. Ubuntu Ambience)] Color c = state == 1 ? SColorHighlight() : bg; int g = Grayscale(c); bool dark = IsDark(c); if(abs(g - Grayscale(txt)) < 70) txt = dark ? White() : Black(); if(abs(g - Grayscale(hltxt)) < 70) hltxt = dark ? White() : Black(); } DrawMenuText(w, 6, (sz.cy - isz.cy) / 2, text, GetFont(), IsItemEnabled(), state, txt, hltxt); } else { w.DrawRect(sz, SColorFace); static const ColorF b0[] = { (ColorF)1, SColorLight, SColorLight, SColorShadow, SColorShadow, }; static const ColorF b1[] = { (ColorF)1, SColorShadow, SColorShadow, SColorLight, SColorLight, }; String text = GetText(); Size isz = GetTextSize(text, StdFont()); DrawMenuText(w, 6, (sz.cy - isz.cy) / 2, text, GetFont(), IsItemEnabled(), false, SColorMenuText, SColorHighlightText); if(state) DrawBorder(w, 0, 0, sz.cx, sz.cy, state == 2 ? b1 : b0); } }
void EscDraw::DrawQtf(EscEscape& e) { if(e.GetCount() < 5 || e.GetCount() > 6) e.ThrowError("wrong number of arguments in call to 'DrawQtf'"); // int zoom = e.Int(0); int x = e.Int(1); int y = e.Int(2); e.CheckArray(3); WString text = e[3]; int cx = e.Int(4); String txt = '\1' + ToUtf8(text); ::DrawSmartText(w, x, y, cx, txt, StdFont(), SColorText, 0); }
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 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 XmlView::LoadDir(const char *d) { files.Clear(); dir = d; Title(dir); #ifdef PLATFORM_WIN32 if(dir.GetLength()) #else if(dir.GetLength() > 1) #endif files.Add("..", CtrlImg::DirUp(), StdFont(), SColorText(), true); ::Load(files, dir, "*.*"); SortByExt(files); }
MenuBar::MenuBar() { LLOG("MenuBar " << Name()); submenu = parentmenu = NULL; submenuitem = NULL; doeffect = true; font = StdFont(); leftgap = Null; lock = 0; SetStyle(StyleDefault()); arealook = -1; maxiconsize = Null; nodarkadjust = false; }
CH_STYLE(ToolButton, Style, StyleDefault) { CtrlsImageLook(look, CtrlsImg::I_TB, 6); font = StdFont(); for(int i = 0; i < 4; i++) textcolor[i] = Button::StyleNormal().textcolor[i]; textcolor[CTRL_CHECKED] = textcolor[CTRL_NORMAL]; textcolor[CTRL_HOTCHECKED] = textcolor[CTRL_HOT]; for(int i = 0; i < 6; i++) { light[i] = false; contrast[i] = 0; } light[CTRL_PRESSED] = light[CTRL_HOT] = light[CTRL_HOTCHECKED] = true; overpaint = 0; }
DocEdit::DocEdit() { updownleave = false; cx = 0; filter = NULL; after = 0; font = StdFont(); AutoHideSb(); SetFrame(ViewFrame()); AddFrame(sb); sb.SetLine(8); sb.WhenScroll = THISBACK(Scroll); InsertLines(0, 1); eofline = true; }
int DrawFileName0(Draw& w, const Rect& r, const String& h, Color ink, int x) { if(h.GetCount() == 0) return 0; int q = h.Find("\xff"); String ns; String fn = h; if(q >= 0) { ns = h.Mid(0, q) + ' '; fn = h.Mid(q + 1); } String s = GetFileName(GetFileFolder(h)) + "/"; x += r.left; if(ns.GetCount()) { PaintTeXt(w, x, r.top, ns, StdFont().Bold(), ink); PaintTeXt(w, x, r.top, "(", StdFont(), ink); } PaintTeXt(w, x, r.top, s, StdFont(), ink); s = GetFileName(h); PaintTeXt(w, x, r.top, s, StdFont().Bold(), ink); if(ns.GetCount()) PaintTeXt(w, x, r.top, ")", StdFont(), ink); return x - r.left; }
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); }