Ejemplo n.º 1
0
void RGBACtrl::Paint(Draw& w)
{
	w.DrawRect(GetSize(), SColorFace);
	if(alpha.IsMask())
		return;
	for(int x = 0; x <= 18; x++)
		w.DrawRect(x * cbox.cx + cs.x, cs.y, 1, cbox.cy * 14, SColorText());
	int i = 0;
	int my = cs.y + 1;
	w.DrawRect(cs.x, cs.y + 14 * cbox.cy, cbox.cx * 18 + 1, 1, SColorText());
	Point pp = Null;
	for(int y = 0; y < 14; y++) {
		w.DrawRect(cs.x, my - 1, cbox.cx * 18 + 1, 1, SColorText());
		int mx = cs.x + 1;
		for(int x = 0; x < 18; x++) {
			Color c = GetColor(i++);
			w.DrawRect(mx, my, cbox.cx - 1, cbox.cy - 1, c);
			if(c == color)
				pp = Point(mx, my);
			mx += cbox.cx;
		}
		my += cbox.cy;
	}
	if(!IsNull(pp)) {
		Size isz = CtrlImg::wheel_cursor().GetSize();
		pp = pp + (cbox - isz) / 2;
		w.DrawImage(pp.x, pp.y, CtrlImg::wheel_cursor(),
		            Grayscale(color) < 120 ? White() : Black());
	}
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
NAMESPACE_UPP

CH_STYLE(MultiButton, Style, StyleDefault)
{
	for(int i = 0; i < 4; i++) {
		simple[i] = left[i] = right[i] = lmiddle[i] = rmiddle[i]
			= Button::StyleEdge().look[i];
		monocolor[i] = Button::StyleEdge().monocolor[i];
		fmonocolor[i] = i == 3 ? SColorDisabled() : SColorText();
		look[i] = trivial[i] = ChLookWith(simple[i], CtrlsImg::DA(), monocolor[i]);
		edge[i] = EditFieldEdge();
	}
	activeedge = false;
	trivialborder = 1;
	border = 1;
	pressoffset = Button::StyleEdge().pressoffset;
	sep1 = SColorHighlight();
	sep2 = SColorLight();
	sepm = 2;
	stdwidth = FrameButtonWidth();
	trivialsep = false;
	margin = Rect(2, 2, 2, 2);
	usetrivial = false;
	overpaint = loff = roff = 0;
}
Ejemplo n.º 4
0
void HeaderCtrl::LeftDrag(Point p, dword keyflags)
{
	if(li < 0 || !moving) return;
	int n = 0;
	for(int i = 0; i < col.GetCount(); i++)
		if(col[i].visible)
			n++;
	if(n < 2)
		return;
	push = false;
	ti = li;
	pushi = -1;
	Refresh();
	Rect r = GetTabRect(li).OffsetedHorz(-sb);
	Size sz = r.GetSize();
	ImageDraw iw(sz.cx, sz.cy);
	bool first = true;
	col[li].Paint(first, iw, 0, 0, sz.cx, sz.cy, false, false, false);
	DrawFrame(iw, sz, SColorText());
	dragtab = iw;
	dragx = p.x;
	dragd = r.left - p.x;
	ImageBuffer ib(dragtab);
	Unmultiply(ib);
	RGBA *s = ~ib;
	RGBA *e = s + ib.GetLength();
	while(s < e) {
		s->a >>= 1;
		s++;
	}
	Premultiply(ib);
	dragtab = ib;
	isdrag = true;
}
Ejemplo n.º 5
0
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);
}
Ejemplo n.º 6
0
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());
}
Ejemplo n.º 7
0
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);
}
Ejemplo n.º 8
0
Color GetLabelTextColor(const Ctrl *ctrl)
{
	if(!IsLabelTextColorMismatch())
		return SColorLabel();
	while(ctrl) {
		if(!ctrl->IsTransparent()) {
			if(dynamic_cast<const TopWindow *>(ctrl) || dynamic_cast<const TabCtrl *>(ctrl) ||
			   dynamic_cast<const ToolBar *>(ctrl) || dynamic_cast<const MenuBar *>(ctrl) ||
			   dynamic_cast<const StaticRect *>(ctrl) || dynamic_cast<const StaticBarArea *>(ctrl))
				break;
			return SColorText();
		}
		ctrl = ctrl->GetParent();
	}
	return SColorLabel();
}
Ejemplo n.º 9
0
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);
}
Ejemplo n.º 10
0
void WorkspaceWork::ScanWorkspace() {
	Workspace wspc;
	if(main.GetCount())
		wspc.Scan(main);
	actualpackage.Clear();
	actualfileindex = -1;
	filelist.Clear();
	package.Clear();
	Vector<String> pks;
	speed.Clear();
	for(int i = 0; i < wspc.package.GetCount(); i++) {
		pks.Add(wspc.package.GetKey(i));
		speed.Add(wspc.GetPackage(i).optimize_speed);
	}
	if(sort && wspc.GetCount()) {
		PackageOrder po;
		po.mainpath = PackagePath(pks[0]);
		IndexSort(pks.Begin() + 1, pks.End(), speed.Begin() + 1, po);
	}
	for(int i = 0; i < wspc.package.GetCount(); i++) {
		String pk = pks[i];
		Font fnt = ListFont();
		if(i == 0)
			fnt.Bold();
		PackageInfo pi = GetPackageInfo(pk);
		if(pi.bold)
			fnt.Bold();
		if(pi.italic)
			fnt.Italic();
		package.Add(pk, Null, fnt, Nvl(pi.ink, SColorText()), false, 0, Null, SColorMark);
	}
	if(!organizer) {
		if(main.GetCount())
			package.Add(prjaux, IdeImg::PrjAux(), ListFont(), Magenta);
		package.Add(ideaux, IdeImg::IdeAux(), ListFont(), Magenta);
		package.Add(tempaux, IdeImg::TempAux(), ListFont(), Magenta);
		if(main.GetCount())
			package.Add(METAPACKAGE, IdeImg::Meta(), ListFont(), Red);
	}
	package.SetCursor(0);
	
	SyncErrorPackages();
}
Ejemplo n.º 11
0
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();
	}
}