#include "IconDes.h" String IconDes::FormatImageName(const Slot& c) { Size sz = c.image.GetSize(); String r; r << c.name << " " << sz.cx << " x " << sz.cy; if(c.flags & IML_IMAGE_FLAG_FIXED) r << " Fxd"; else { if(c.flags & IML_IMAGE_FLAG_FIXED_COLORS) r << " Clr"; if(c.flags & IML_IMAGE_FLAG_FIXED_SIZE) r << " Sz"; } int scale = ImlFlagsToDPIScale(c.flags); r << decode(scale, DPI_100, " 100%", DPI_150, " 150%", DPI_200, " 200%", DPI_300, " 300%", ""); if(c.exp) r << " X"; return r; } void IconDes::SyncList() { if(syncinglist) return; syncinglist++; int sc = ilist.GetScroll(); int q = ilist.GetKey(); ilist.Clear(); String s = ToUpper((String)~search); for(int i = 0; i < slot.GetCount(); i++) { Slot& c = slot[i]; if(ToUpper(c.name).Find(s) >= 0) ilist.Add(i, FormatImageName(c), RawToValue(MakeTuple(c.image, c.flags))); } ilist.ScrollTo(sc); ilist.FindSetCursor(q); syncinglist--; } void IconDes::Search() { SyncList(); } void IconDes::GoTo(int q) { ilist.FindSetCursor(q); if(ilist.IsCursor()) return; search <<= Null; SyncList(); ilist.FindSetCursor(q); } static int sCharFilterCid(int c) { return IsAlNum(c) || c == '_' ? c : 0; } void IconDes::PlaceDlg(TopWindow& dlg) { Rect r = ilist.GetScreenRect(); Size sz = dlg.GetSize(); dlg.NoCenter().SetRect(max(0, r.left + (r.Width() - sz.cx) / 2), r.bottom + 32, sz.cx, sz.cy); } void IconDes::PrepareImageDlg(WithImageLayout& dlg) { CtrlLayoutOKCancel(dlg, "New image"); dlg.cx <<= 16; dlg.cy <<= 16; if(IsCurrent()) { Size sz = GetImageSize(); dlg.cx <<= sz.cx; dlg.cy <<= sz.cy; dword flags = IsCurrent() ? Current().flags : 0; dlg.fixed <<= !!(flags & IML_IMAGE_FLAG_FIXED); dlg.fixed_colors <<= !!(flags & IML_IMAGE_FLAG_FIXED_COLORS); dlg.fixed_size <<= !!(flags & IML_IMAGE_FLAG_FIXED_SIZE); dlg.dark <<= !!(flags & IML_IMAGE_FLAG_DARK); int scale = ImlFlagsToDPIScale(flags); dlg.scale = decode(scale, DPI_100, 1, DPI_150, 2, DPI_200, 3, DPI_300, 4, 0); for(Ctrl& q : dlg) if(dynamic_cast