Example #1
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);
}
Example #2
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;
}
Example #3
0
CH_STYLE(MenuBar, Style, StyleDefault)
{
	topitem[0] = Null;
	topitem[1] = topitem[2] = item = SColorHighlight();
	topitemtext[0] = menutext = SColorMenuText();
	topitemtext[1] = topitemtext[2] = itemtext = SColorHighlightText();
	topbar = SColorFace();
	maxiconsize = Size(16, 16);
	arealook = Null;
	look = SColorFace();
	separator = breaksep = SeparatorCtrl::StyleDefault();
	ImageBuffer ib(7, 7);
	Fill(ib, SColorShadow(), 7 * 7);
	for(int i = 0; i < 5; i++)
		Fill(ib[i + 1] + 1, SColorMenu(), 5);
	ib.SetHotSpot(Point(3, 3));
	ib.Set2ndSpot(Point(3, 3));
	popupframe = Image(ib);
	popupbody = SColorMenu();
	popupiconbar = Null;
	leftgap = DPI(16) + Zx(4);
	textgap = Zx(3);
	lsepm = rsepm = Zx(2);
	pullshift.x = 0;
	pullshift.y = -1;
}
Example #4
0
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);
	}
}
Example #5
0
void MultiButton::Paint(Draw& w)
{
	Size sz = GetSize();
	int border, lx, rx;
	bool frm = Metrics(border, lx, rx);
	int mst = ChState(MAIN);
	if(frm && !nobg)
		ChPaint(w, sz, style->edge[style->activeedge ? mst : 0]);
	bool left = false;
	bool right = false;
	for(int i = 0; i < button.GetCount(); i++) {
		SubButton& b = button[i];
		int st = ChState(i);
		int x = 0, cx = 0;
		GetPos(b, lx, rx, x, cx);
		bool dopaint = true;
		Value v = b.left ? left ? style->lmiddle[st] : style->left[st]
		                 : right ? style->rmiddle[st] : style->right[st];
		if(!nobg) {
			if(ComplexFrame())
				ChPaint(w, x, border, cx, sz.cy - 2 * border, style->simple[st]);
			else
			if(frm) {
				if(IsTrivial() && style->usetrivial)
					dopaint = false;
				ChPaint(w, x, border, cx, sz.cy - 2 * border,
				        dopaint ? v : style->trivial[st]);
			}
			else {
				w.Clip(x, 0, cx, sz.cy);
				ChPaint(w, sz, style->look[Frame() ? mst : st]);
				if(IsNull(v) || !Frame()) {
					if((!IsTrivial() || style->trivialsep) && IsEnabled()) {
						if(b.left) {
							if(left)
								ChPaint(w, x, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep1);
							ChPaint(w, x + cx - 1, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep2);
						}
						else {
							ChPaint(w, x, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep1);
							if(right)
								ChPaint(w, x + cx - 1, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep2);
						}
					}
				}
				else
					ChPaint(w, x, 0, cx, sz.cy, v);
				w.End();
			}
		}
		if(dopaint) {
			Size tsz = GetTextSize(b.label, StdFont());
			Image m = tsz.cx > 0 ? b.img : (Image)Nvl(b.img, CtrlsImg::DA());
			Size isz = m.GetSize();
			Point p = (st == CTRL_PRESSED) * style->pressoffset;
			p.x += x + (cx - isz.cx - tsz.cx - (tsz.cx > 0 && isz.cx > 0 ? LB_IMAGE : 0)) / 2;
			p.y += (sz.cy - isz.cy) / 2;
			if(b.left) {
				if(!left) p.x += style->loff;
			}
			else
				if(!right) p.x += style->roff;
			if(b.monoimg || IsNull(b.img))
				w.DrawImage(p.x, p.y, m, frm ? style->fmonocolor[st] : style->monocolor[st]);
			else
				w.DrawImage(p.x, p.y, m);

			if(tsz.cx > 0) {
				if(isz.cx > 0)
					p.x += isz.cx + LB_IMAGE;
				w.DrawText(p.x, (sz.cy - tsz.cy) / 2, b.label);
			}
		}
		(b.left ? left : right) = true;
	}
	Rect r, cr;
	cr = GetSize();
	cr.left = lx;
	cr.right = rx;
	Color text = SColorLabel();
	Color paper = Null;
	if(!nobg) {
		if(ComplexFrame()) {
			r = cr;
			paper = HasFocus() ? SColorHighlight() : SColorPaper();
			if(HasFocus())
				text = SColorHighlightText();
			w.DrawRect(r, paper);
		}
		else
		if(frm) {
			Rect m = GetMargin();
			r = Rect(max(lx, m.left), m.top, min(rx, sz.cx - m.right), sz.cy - m.bottom);
			Color paper;
			if(mst == CTRL_HOT && !IsTrivial())
				paper = Blend(SColorHighlight, SColorPaper, 235);
			else
			if(mst == CTRL_PRESSED && !IsTrivial())
				paper = Blend(SColorHighlight, SColorFace, 235);
			else
			if(HasFocus()) {
				paper = SColorHighlight();
				text = SColorHighlightText();
			}
			else
				paper = SColorPaper();
			w.DrawRect(r, paper);
			cr = r;
		}
		else {
			w.Clip(lx, 0, rx - lx, sz.cy);
			ChPaint(w, sz, style->look[mst]);
			Rect m = style->margin;
			r = Rect(max(lx, m.left), m.top, min(rx, sz.cx - m.right), sz.cy - m.bottom);
			if(!IsTrivial() || style->trivialsep) {
				if(left) {
					r.left++;
					if(IsEnabled())
						ChPaint(w, lx, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep1);
				}
				if(right) {
					if(IsEnabled())
						ChPaint(w, rx - 1, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep2);
					r.right--;
				}
			}
			w.End();
			cr = r;
		}
	}
	cr.left++;
	Rect clr = cr;
	if(!IsNull(valuecy)) {
		cr.top += (cr.GetHeight() - valuecy + 1) / 2;
		cr.bottom = cr.top + valuecy;
	}
	Value v = convert->Format(value);
	bool f = HasFocus() && !push && frm;
	if(cr.left < cr.right && display) {
		w.Clip(clr);
		display->Paint(w, cr, v,
		               IsShowEnabled() ? text : SColorDisabled,
		               paper, f ? Display::CURSOR : Display::FOCUS|Display::CURSOR);
		w.End();
	}
	if(!frm && HasFocus())
		DrawFocus(w, r);
}
Example #6
0
void ProgressIndicator::Paint(Draw& w) {
	Size sz = GetSize();
	Size msz = GetMsz();
	int p0 = 0;
	int p = pxp;
	if(total <= 0) {
		int l = max(msz.cx, msz.cy) & ~7;
		p0 = pxp - l / 4;
		p = min(p - p0, max(msz.cx, msz.cy) - p0);
		if(style->bound && p0 < 0) {
			p += p0;
			p0 = 0;
		}
	}
	if(style->classic || percent || !IsNull(color)) {
		ChPaintEdge(w, sz, EditFieldEdge());
		Rect mg = ChMargins(EditFieldEdge());
		sz -= Size(mg.left + mg.right, mg.top + mg.bottom);
		Rect r1, r2, r3;
		r1 = r2 = r3 = RectC(mg.left, mg.top, sz.cx, sz.cy);
		w.Clip(r1);
		if(sz.cx > sz.cy) {
			r1.right = r2.left = min(p, sz.cx) + mg.left + p0;
			r3.right = mg.left + p0;
			r3.bottom = r1.bottom;
		}
		else {
			r2.bottom = r1.top = sz.cy - min(p, sz.cy) + mg.left + p0;
			r3.bottom = mg.top + p0;
			r3.right = r1.right;
		}
		w.DrawRect(r1, Nvl(color, SColorHighlight()));
		w.DrawRect(r2, SColorPaper);
		w.DrawRect(r3, SColorPaper);
		if(percent) {
			String pt = Format("%d %%", 100 * actual / max(total, 1));
			Size psz = GetTextSize(pt, StdFont());
			int px = (sz.cx - psz.cx) / 2 + 2;
			int py = (sz.cy - psz.cy) / 2 + 2;
			w.Clip(r1);
			w.DrawText(px, py, pt, StdFont(), SColorLight);
			w.End();
			w.Clip(r2);
			w.DrawText(px, py, pt, StdFont(), SColorText);
			w.End();
		}
		w.End();
	}
	else {
		if(sz.cy > sz.cx) {
			ChPaint(w, sz, style->vlook);
			Rect r = ChMargins(style->vlook);
			w.Clip(r.left, r.top, sz.cx - r.left - r.right, sz.cy - r.top - r.bottom);
			ChPaint(w, r.left, sz.cy - r.bottom - p - p0, sz.cx - r.left - r.right, p,
			        style->vchunk);
		}
		else {
			ChPaint(w, sz, style->hlook);
			Rect r = ChMargins(style->hlook);
			w.Clip(r.left, r.top, sz.cx - r.left - r.right, sz.cy - r.top - r.bottom);
			ChPaint(w, r.left + p0, r.top, p, sz.cy - r.top - r.bottom, style->hchunk);
		}
		w.End();
	}
}