Beispiel #1
0
void Ctrl::GetWorkArea(Array<Rect>& rc)
{
	GuiLock __;
	GdkScreen *s = gdk_screen_get_default();
	int n = gdk_screen_get_n_monitors(s);
	rc.Clear();
	Vector<int> netwa;
	for(int i = 0; i < n; i++) {
		GdkRectangle rr;
		Rect r;
#if GTK_CHECK_VERSION (3, 3, 5) // U++ does not work with gtk3 yet, but be prepared
		gdk_screen_get_monitor_workarea(s, i, &rr);
		r = RectC(r.x, r.y, r.width, r.height);
#else
		gdk_screen_get_monitor_geometry (s, i, &rr);
		r = RectC(rr.x, rr.y, rr.width, rr.height);
	#ifdef GDK_WINDOWING_X11
		if(i == 0)
			netwa = GetPropertyInts(gdk_screen_get_root_window(gdk_screen_get_default()),
			                        "_NET_WORKAREA");
		if(netwa.GetCount())
			r = r & RectC(netwa[0], netwa[1], netwa[2], netwa[3]);
	#endif
#endif
		rc.Add(r);
	}
}
Beispiel #2
0
void  Ctrl::ScrollRefresh(const Rect& r, int dx, int dy)
{
	GuiLock __;
	if(!IsOpen() || !IsVisible() || r.IsEmpty()) return;
	int tdx = tabs(dx), tdy = tabs(dy);
	if(dx) WndInvalidateRect(RectC(dx >= 0 ? r.left : r.right - tdx, r.top - tdy, tdx, r.Height()));
	if(dy) WndInvalidateRect(RectC(r.left - tdx, dy >= 0 ? r.top : r.bottom - tdy, r.Width(), tdy));
}
Beispiel #3
0
void  Ctrl::ScrollRefresh(const Rect& r, int dx, int dy)
{
	sCheckGuiLock();
	GuiLock __; // Beware: Even if we have ThreadHasGuiLock ASSERT, we still can be the main thread!
	LLOG("ScrollRefresh " << r << " " << dx << " " << dy);
	if(!IsOpen() || !IsVisible() || r.IsEmpty()) return;
	int tdx = tabs(dx), tdy = tabs(dy);
	if(dx) WndInvalidateRect(RectC(dx >= 0 ? r.left : r.right - tdx, r.top - tdy, tdx, r.Height()));
	if(dy) WndInvalidateRect(RectC(r.left - tdx, dy >= 0 ? r.top : r.bottom - tdy, r.Width(), tdy));
}
Beispiel #4
0
void TopWindow::CenterRect(Ctrl *owner)
{
	GuiLock __;
	SetupRect(owner);
	if((owner && center == 1) || center == 2) {
		Rect r, wr;
		wr = Ctrl::GetWorkArea();
		Size sz = GetRect().Size();
		Rect fm = windowFrameMargin;
		if((fm.left|fm.right|fm.top|fm.bottom) == 0)
			fm = Rect(8, 32, 8, 8);
		if(owner && center == 1)
			r = owner->GetRect();
		else
			r = wr;
		Point p = r.CenterPos(sz);
		
		if (GetVirtualScreenArea().Contains(p)) {
			r = RectC(p.x, p.y, sz.cx, sz.cy);
			wr.left += fm.left;
			wr.right -= fm.right;
			wr.top += fm.top;
			wr.bottom -= fm.bottom;
			if(r.top < wr.top) {
				r.bottom += wr.top - r.top;
				r.top = wr.top;
			}
			if(r.bottom > wr.bottom)
				r.bottom = wr.bottom;
			minsize.cx = min(minsize.cx, r.GetWidth());
			minsize.cy = min(minsize.cy, r.GetHeight());
			SetRect(r);
		}	
	}
}
Beispiel #5
0
void DrawImageBandRLE(Draw& w, int x, int y, const Image& m, int minp)
{
	int xi = 0;
	int cx = m.GetWidth();
	int ccy = m.GetHeight();
	Buffer<bool> todo(cx, true);
#ifdef BENCHMARK_RLE
	sTotal += cx;
#endif
	while(xi < cx) {
		int xi0 = xi;
		while(w.Dots() && IsWhiteColumn(m, xi) && xi < cx)
			xi++;
		if(xi - xi0 >= 16) {
#ifdef BENCHMARK_RLE
			sRle += xi - xi0;
#endif
			w.DrawRect(x + xi0, y, xi - xi0, ccy, White);
			Fill(~todo + xi0, ~todo + xi, false);
		}
		xi++;
	}
	
	xi = 0;
	while(xi < cx)
		if(todo[xi]) {
			int xi0 = xi;
			while(xi < cx && todo[xi] && xi - xi0 < 2000)
				xi++;
			w.DrawImage(x + xi0, y, m, RectC(xi0, 0, xi - xi0, ccy));
		}
		else
			xi++;
}
Beispiel #6
0
Rect Ctrl::GetVirtualScreenArea()
{
	GuiLock __;
	return RectC(GetSystemMetrics(SM_XVIRTUALSCREEN),
		GetSystemMetrics(SM_YVIRTUALSCREEN),
		GetSystemMetrics(SM_CXVIRTUALSCREEN),
		GetSystemMetrics(SM_CYVIRTUALSCREEN));
}
Beispiel #7
0
Rect LineEdit::DropCaret()
{
	if(IsNull(dropcaret))
		return Rect(0, 0, 0, 0);
	Size fsz = GetFontSize();
	Point p = dropcaret - sb;
	p = Point(p.x * fsz.cx, p.y * fsz.cy);
	return RectC(p.x, p.y, 1, fsz.cy);
}
Beispiel #8
0
	graphic::SpriteDesc Player::getDesc()
	{
		graphic::SpriteDesc ret;
		ret.setPos(RectC(0, 0, abs(width()), abs(height())));
		ret.setUV(getUVRect());
		ret.setColor(Color32(255, 255, 255));
		ret.setHilight(Color32(0, 0, 0));
		return ret;
	}
Beispiel #9
0
void IconDes::RefreshPixel(int x, int y, int cx, int cy)
{
	Point p = sb;
	x -= p.x;
	y -= p.y;
	if(magnify == 1) {
		if(IsNull(m1refresh))
			m1refresh = RectC(x, y, cx, cx);
		else {
			if(m1refresh.Contains(x, y))
				return;
			m1refresh = m1refresh | RectC(x, y, 1, 1);
		}
		Refresh(m1refresh);
	}
	else
		Refresh(x * magnify - 4, y * magnify - 4, cx * magnify + 10, cy * magnify + 10);
}
Beispiel #10
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);
	}
}
Beispiel #11
0
inline
void Paragraph::ParaRect::Put(int x, int y, Part *ip, Part **ibeg, Part **i, const char *text) {
	if(!ip) return;
	const Paragraph::Part *p = (const Paragraph::Part *) ip->voidptr;
	if(IsNull(p->value)) return;
	ValueRect& r = vr.Add();
	r.value = p->value;
	r.rect = RectC(px + x, y, p->pr ? ip->width
				              : GetTextSize(text + (ibeg - info), ip->font, i - ibeg).cx,
			       ascent + descent + external);
}
Beispiel #12
0
Rect Ctrl::GetVirtualScreenArea()
{
	GuiLock __;
	static Rect r;
	if(r.right == 0) {
		gint x, y, width, height;
		gdk_window_get_geometry(gdk_screen_get_root_window(gdk_screen_get_default()),
	    	                    &x, &y, &width, &height, NULL);
	    r = RectC(x, y, width, height);
	}
	return r;
}
Beispiel #13
0
Rect ScrollBar::Slider(int& cc) const
{
	Size sz = GetSize();
	Rect r;
	if(IsHorz()) {
		cc = sz.cx > (3 + style->isleft2 + style->isright2) * style->arrowsize ? style->arrowsize : 0;
		r = RectC(cc, 0, sz.cx - 2 * cc, sz.cy);
		if(style->isleft2)
			r.right -= cc;
		if(style->isright2)
			r.left += cc;
	}
	else {
		cc = sz.cy > (3 + style->isup2 + style->isdown2) * style->arrowsize ? style->arrowsize : 0;
		r = RectC(0, cc, sz.cx, sz.cy - 2 * cc);
		if(style->isup2)
			r.bottom -= cc;
		if(style->isdown2)
			r.top += cc;
	}
	return r;
}
Beispiel #14
0
void SDraw::DrawRectOp(int x, int y, int cx, int cy, Color color)
{
	if(IsNull(color))
		return;
	Rect r = RectC(x, y, cx, cy);
	r += cloff.Top().offset;
	const Vector<Rect>& clip = cloff.Top().clip;
	for(int i = 0; i < clip.GetCount(); i++) {
		Rect cr = clip[i] & r;
		if(!cr.IsEmpty())
			PutRect(cr, color);
	}
}
Beispiel #15
0
Rect Ctrl::GetDefaultWindowRect()
{
	GuiLock __; 
	Rect r  = GetPrimaryWorkArea();
	Size sz = r.GetSize();
	
	static int pos = min(sz.cx / 10, 50);
	pos += 10;
	int cx = sz.cx * 2 / 3;
	int cy = sz.cy * 2 / 3;
	if(pos + cx + 50 > sz.cx || pos + cy + 50 > sz.cy)
		pos = 0;
	return RectC(r.left + pos + 20, r.top + pos + 20, cx, cy);
}
Beispiel #16
0
void SystemDraw::DrawRectOp(int x, int y, int cx, int cy, Color color)
{
    GuiLock __;
    LTIMING("DrawRect");
    LLOG("DrawRect " << RectC(x, y, cx, cy) << ": " << color);
    if(IsNull(color)) return;
    if(cx <= 0 || cy <= 0) return;
    if(color == InvertColor)
        ::PatBlt(handle, x, y, cx, cy, DSTINVERT);
    else {
        SetColor(color);
        ::PatBlt(handle, x, y, cx, cy, PATCOPY);
    }
}
Beispiel #17
0
void RichRuler::Paint(Draw& w)
{
	Size sz = GetSize();
	w.DrawRect(sz, SColorFace);
	w.DrawRect(0, sz.cy - 1, sz.cx, 1, SColorShadow);
	int cx = zoom * pgcx;
	w.DrawRect(x0 - 1, 3, cx + 3, sz.cy - 6, SColorPaper);
	int i = 0;
	for(;;) {
		int x = fround(++i * grid) * zoom;
		if(x >= cx) break;
		if(i % marks == 0)
			w.DrawRect(x0 + x, 8, 1, 5, SColorHighlight);
		else
			w.DrawRect(x0 + x, 9, 1, 3, SColorHighlight);
	}
	i = 0;
	for(;;)
		if(++i % numbers == 0) {
			int x = fround(i * grid) * zoom;
			if(x >= cx) break;
			String n = Format("%d", (int)(i * numbermul + 0.5));
			Size tsz = GetTextSize(n, Arial(10));
			if(x + tsz.cx - tsz.cx / 2 < cx) {
				int px = x0 + x - tsz.cx / 2;
				w.DrawRect(px, 4, tsz.cx, sz.cy - 8, SColorPaper);
				w.DrawText(x0 + x - tsz.cx / 2, 4, n, Arial(10), SColorText);
			}
		}
	FieldFrame().FramePaint(w, RectC(x0 - 1, 3, cx + 3, sz.cy - 6));
	for(i = marker.GetCount() - 1; i >= 0; --i) {
		const Marker& m = marker[i];
		if(!IsNull(m.pos))
			HotPaint(w, x0 + m.pos * zoom, m.top ? 1 : sz.cy - 4, m.image);
	}
	i = 0;
	if(tabsize)
		for(;;) {
			int xp = ++i * tabsize;
			int x = xp * zoom;
			if(x >= cx) break;
			if(xp > tabpos)
				w.DrawRect(x0 + x, sz.cy - 4, 1, 3, SColorShadow);
		}
	w.DrawImage(4, 6, newtabalign == ALIGN_RIGHT  ? RichEditImg::RightTab() :
	                  newtabalign == ALIGN_CENTER ? RichEditImg::CenterTab() :
	                                                RichEditImg::LeftTab());
}
Beispiel #18
0
void Ctrl::DrawLine(const Vector<Rect>& clip, int x, int y, int cx, int cy, bool horz, const byte *pattern, int animation)
{
	if(cx <= 0 || cy <= 0)
		return;
	Vector<Rect> rr = Intersection(clip, RectC(x, y, cx, cy));
	for(int i = 0; i < rr.GetCount(); i++) {
		Rect r = rr[i];
		AddUpdate(r);
		if(horz)
			for(int y = r.top; y < r.bottom; y++)
				DDRect(framebuffer[y] + r.left, 1, pattern, r.left + animation, r.GetWidth());
		else
			for(int x = r.left; x < r.right; x++)
				DDRect(framebuffer[r.top] + x, framebuffer.GetWidth(), pattern, r.top + animation, r.GetHeight());
	}
}
Beispiel #19
0
void Ctrl::SetCaret(int x, int y, int cx, int cy)
{
	GuiLock __;
	LLOG("SetCaret " << Name() << " " << RectC(x, y, cx, cy));
	if(this == caretCtrl)
		RefreshCaret();
	caretx = x;
	carety = y;
	caretcx = cx;
	caretcy = cy;
	if(this == caretCtrl) {
		WndCaretTime = GetTickCount();
		RefreshCaret();
		AnimateCaret();
	}
}
Beispiel #20
0
void  DrawRectBASE(PixelBlock& w, int x, int y, int cx, int cy, Color c)
{
	RTIMING("DrawRect");
	Rect r = RectC(x, y, cx, cy);
	r.Intersect(w.GetSize());
	if(r.IsEmpty())
		return;
	dword color = c.GetRaw();
	dword *a = w.PointAdr(r.left, r.top);
	int d = w.LineDelta();
	cy = r.Height();
	cx = r.Width();
	while(cy--) {
		memsetd(a, color, cx);
		a += d;
	}
}
Beispiel #21
0
Rect Ctrl::GetDefaultWindowRect() {
#ifdef PLATFORM_WINCE
	return Rect(0, 0, 100, 100);
#else
	HWND hwnd = ::CreateWindow("UPP-CLASS-A", "", WS_OVERLAPPED,
		                       CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
							   NULL, NULL, NULL, NULL);
	Rect sr;
	if(hwnd) {
		::ShowWindow(hwnd, SW_HIDE);
		sr = GetScreenClient(hwnd);
		::DestroyWindow(hwnd);
	}
	else
		sr = RectC(20, 20, 500, 350);
	return sr;
#endif
}
Beispiel #22
0
void ImageDraw::Init()
{
	GuiLock __;
	dw = XCreatePixmap(Xdisplay, Xroot, max(size.cx, 1), max(size.cy, 1), Xdepth);
	gc = XCreateGC(Xdisplay, dw, 0, 0);
	xftdraw = XftDrawCreate(Xdisplay, (Drawable) dw, DefaultVisual(Xdisplay, Xscreenno), Xcolormap);

	alpha.dw = XCreatePixmap(Xdisplay, Xroot, max(size.cx, 1), max(size.cy, 1), Xdepth);
	alpha.gc = XCreateGC(Xdisplay, alpha.dw, 0, 0);
	alpha.xftdraw = XftDrawCreate(Xdisplay, (Drawable) alpha.dw, DefaultVisual(Xdisplay, Xscreenno), Xcolormap);

	Vector<Rect> clip;
	clip.Add(RectC(0, 0, size.cx, size.cy));
	SystemDraw::Init(clip, Point(0, 0));
	alpha.Init(clip, Point(0, 0));

	has_alpha = false;
}
Beispiel #23
0
void TopWindow::SerializePlacement(Stream& s, bool reminimize)
{
	GuiLock __;
	int version = 0;
	s / version;
	Rect rect = GetRect();
	s % overlapped % rect;
	bool mn = state == MINIMIZED;
	bool mx = state == MAXIMIZED;
	s.Pack(mn, mx);
	LLOG("TopWindow::SerializePlacement / " << (s.IsStoring() ? "write" : "read"));
	LLOG("minimized = " << mn << ", maximized = " << mx);
	LLOG("rect = " << rect << ", overlapped = " << overlapped);
	if(s.IsLoading()) {
		if(mn) rect = overlapped;
		Rect limit = GetVirtualWorkArea();
		Rect fm = windowFrameMargin;
		if((fm.left|fm.right|fm.top|fm.bottom) == 0)
			fm = Rect(8, 32, 8, 8);
		limit.left += fm.left;
		limit.right -= fm.right;
		limit.top += fm.top;
		limit.bottom -= fm.bottom;
		Size sz = min(rect.Size(), limit.Size());
		rect = RectC(
			minmax(rect.left, limit.left, limit.right - sz.cx),
			minmax(rect.top,  limit.top,  limit.bottom - sz.cy),
			sz.cx, sz.cy);
		state = OVERLAPPED;
		if(mn && reminimize)
			state = MINIMIZED;
		if(mx)
			state = MAXIMIZED;
		if(state == OVERLAPPED)
			SetRect(rect);
		if(IsOpen()) {
			if(state == MINIMIZED)
				Minimize(false);
			if(state == MAXIMIZED)
				Maximize(false);
		}
	}
}
Beispiel #24
0
void Threads::picbox_LeftDown(Point p, dword keyflags )
{
		if (keyflags & K_CTRL)
		{
			RectTracker tr(picbox);
			Rect s_xy = RectC(p.x, p.y, 0, 0);
			tr.Solid().Animation();
			s_xy = tr.Track(s_xy, ALIGN_RIGHT, ALIGN_BOTTOM);
			area = Rect_<double>( area.left + (double)s_xy.left * area.Width() / picbox.GetSize().cx
									, area.top + (double)s_xy.top * area.Height() / picbox.GetSize().cy
									, area.left + (double)s_xy.right * area.Width() / picbox.GetSize().cx 
									, area.top + (double)s_xy.bottom * area.Height() / picbox.GetSize().cy );
			DoJob();
		}
		else
			moving = true;
		
	posOnClick = p;
}
Beispiel #25
0
void MultiButton::LeftDown(Point p, dword flags)
{
	push = true;
	Refresh();
	if(IsNull(hl))
		pushrect = Null;
	else {
		if(hl == MAIN)
			pushrect = GetScreenRect();
		else {
			int x, cx;
			int border = IsTrivial() ? style->trivialborder : style->border;
			GetPos(hl, x, cx);
			pushrect = RectC(x, border, cx, GetSize().cy - 2 * border)
			           .Offseted(GetScreenView().TopLeft());
		}
		Sync();
		if(hl >= 0)
			button[hl].WhenPush();
		else
			WhenPush();
	}
}
Beispiel #26
0
Size LabelBase::PaintLabel(Draw& w, int x, int y, int cx, int cy, bool disabled, bool push, bool focus, bool vak)
{
	return PaintLabel(w, RectC(x, y, cx, cy), disabled, push, focus, vak);
}
Beispiel #27
0
Size DrawLabel::Paint(Draw& w, int x, int y, int cx, int cy, bool vak) const
{
	return Paint(w, RectC(x, y, cx, cy), vak);
}
Beispiel #28
0
Size DrawLabel::Paint(Ctrl *ctrl, Draw& w, int x, int y, int cx, int cy, bool visibleaccesskey) const
{
	return Paint(ctrl, w, RectC(x, y, cx, cy), visibleaccesskey);
}
Beispiel #29
0
void Ctrl::RefreshFrame(int x, int y, int cx, int cy) {
	RefreshFrame(RectC(x, y, cx, cy));
}
Beispiel #30
-5
Rect Ctrl::GetWndScreenRect() const
{
	GuiLock __;
	if(IsOpen()) {
		gint x, y;
		gdk_window_get_position(gdk(), &x, &y);
	#if GTK_CHECK_VERSION(2, 24, 0)
		gint width = gdk_window_get_width(gdk());
		gint height = gdk_window_get_height(gdk());
	#else
		gint width, height;
		gdk_drawable_get_size(gdk(), &width, &height);
	#endif
		return RectC(x, y, width, height);
	}
	return Null;
}