Example #1
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 #2
0
// frame painting
void XMLDragFrame::FramePaint(Draw& w, const Rect& r)
{
	w.DrawRect(r, SColorFace());
	int x1 = r.left + 1;
	int x2 = r.right - 1;
	int y1 = r.top + 1;
	int y2 = r.bottom -1;
	w.DrawLine(x1, y1, x2, y1, 1, SColorLight());
	w.DrawLine(x2, y1, x2, y2, 1, SColorShadow());
	w.DrawLine(x2, y2, x1, y2, 1, SColorShadow());
	w.DrawLine(x1, y2, x1, y1, 1, SColorLight());
	if(align == ToolBar::BAR_LEFT || align == ToolBar::BAR_RIGHT)
	{
		x1 = r.left + 5;
		x2 = r.right - 5;
		y1 = r.top + 4;
		y2 = r.top + 9;
		w.DrawLine(x1, y1, x2, y1, 2, SColorShadow());
		w.DrawLine(x1, y2, x2, y2, 2, SColorShadow());
	}
	else
	{
		x1 = r.left + 4;
		x2 = r.left + 9;
		y1 = r.top + 5;
		y2 = r.bottom - 5;
		w.DrawLine(x1, y1, x1, y2, 2, SColorShadow());
		w.DrawLine(x2, y1, x2, y2, 2, SColorShadow());
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////
// paint routine
void PixRasterBaseCtrl::Paint(Draw &d)
{
	// clears background
	d.DrawRect(GetSize(), SColorFace());

	// if no associated PixRaster, does nothing
	if(!pixRasterCtrl->GetPixBase())
		return;

	// paints image inside cache, if needed
	PaintCache();
	
	// paints image cache inside control
	if(imageCache.GetWidth() >= GetSize().cx)
		imageCache.Paint(d, Point(0, 0));
	else
		imageCache.Paint(d, Point((GetSize().cx - imageCache.GetWidth()) / 2, 0));
	
	// paints markers inside control
	PaintMarkers(d);
	
	// if dragging, paints rubber banded polygon
	if(selectedMarker && dragPolygon.GetCount())
	{
		d.DrawPolygon(dragPolygon, dragPolygon.GetCount(),
		selectedMarker->GetFillColor(),
		selectedMarker->GetBorderThickness(),
		selectedMarker->GetBorderColor(),
		PEN_DOT,
		White);
	}

} // END LeptonicaBaseCtrl::Paint()
Example #4
0
ScrollBars& ScrollBars::WithSizeGrip()
{
	box_bg.Color(SColorFace());
	the_box.Add(box_bg.SizePos());
	the_box.Add(grip);
	return *this;
}
Example #5
0
FileTabs::FileTabs() :
stackedicons(false), 
greyedicons(true),
filecolor(SColorLabel),
extcolor(IsDark(SColorFace()) ? Blend(White, LtBlue) : LtBlue)
{

}
Example #6
0
CH_STYLE(ToolBar, Style, StyleDefault)
{
	buttonstyle = ToolButton::StyleDefault();
	buttonminsize = Size(16, 16);
	maxiconsize = Size(INT_MAX, INT_MAX);
	arealook = Null;
	look = SColorFace();
	breaksep = separator = SeparatorCtrl::StyleDefault();
}
Example #7
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);
}
Example #8
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);
}
Example #9
0
void HeaderCtrl::Paint(Draw& w) {
	RefreshDistribution();
	Size sz = GetSize();
	w.DrawRect(sz, SColorFace());
	bool ds = !IsShowEnabled();
	double rs = Denominator();
	double rr = 0;
	int x = -sb;
	light = -1;
	bool first = true;
	int dx = Null;
	for(int i = 0; i < col.GetCount(); i++) {
		if(col[i].visible) {
			Rect r;
			if(mode == SCROLL) {
				int cx = (int)col[i].ratio;
				r = RectC(x, 0, cx, sz.cy);
				x += cx;
			}
			else {
				rr += rs ? col[i].ratio : 1;
				int xx = int(rr * sz.cx / (rs ? rs : col.GetCount()));
				r = RectC(x, 0, i == col.GetCount() - 1 ? sz.cx - x : xx - x, sz.cy);
				x = xx;
			}
			bool mousein = HasMouseIn(r.Deflated(1, 0)) && col[i].WhenAction && pushi < 0 &&
			               !isdrag;
			if(mousein)
				light = i;
			col[i].Paint(first, w,
			             r.left, r.top, r.Width(), r.Height(), ds, push && i == pushi, mousein);
			if(isdrag && ti == i)
				dx = r.left;
		}
		if(x >= sz.cx) break;
	}
	Column h;
	h.header = this;
	h.Paint(first, w, x, 0, 999, sz.cy, false, false, false);
	if(isdrag) {
		w.DrawImage(dragx + dragd, 0, dragtab);
		DrawVertDrop(w, IsNull(dx) ? sz.cx - 2 : dx - (dx > 0), 0, sz.cy);
	}
}
Example #10
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 #11
0
StaticRect::StaticRect() {
	bg = SColorFace();
	NoWantFocus();
}
Example #12
0
		if(!next->GetAccessKeysDeep()) {
			lbl.accesskey = ChooseAccessKey(GetText(), used);
			if(lbl.accesskey) Refresh();
			used |= AccessKeyBit(lbl.accesskey);
		}
	}
	Ctrl::AssignAccessKeys(used);
}

Label::Label() {
	noac = false;
}

Label::~Label() {}

CH_COLOR(LabelBoxTextColor, IsDark(SColorFace()) ? Blend(LtBlue(), White) : LtBlue());
CH_COLOR(LabelBoxDisabledTextColor, SColorDisabled());
CH_COLOR(LabelBoxColor, SColorShadow());

LabelBox::LabelBox()
{
	color = Null;
	LabelBase::SetInk(LabelBoxTextColor, LabelBoxDisabledTextColor);
	SetVAlign(ALIGN_TOP);
	#if defined(flagWINGL) || defined(flagLINUXGL)
	ClipToBounds(false);
	#endif
}

void  LabelBox::AssignAccessKeys(dword used)
{
Example #13
0
	void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
	{
		w.DrawRect(r, SColorFace());
	}
Example #14
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();
	}
}