コード例 #1
0
ファイル: CtrlDraw.cpp プロジェクト: dreamsxin/ultimatepp
void Ctrl::GatherTransparentAreas(Vector<Rect>& area, SystemDraw& w, Rect r, const Rect& clip)
{
	GuiLock __;
	LTIMING("GatherTransparentAreas");
	Point off = r.TopLeft();
	Point viewpos = off + GetView().TopLeft();
	r.Inflate(overpaint);
	Rect notr = GetVoidRect();
	if(notr.IsEmpty())
		notr = GetOpaqueRect();
	notr += viewpos;
	if(!IsShown() || r.IsEmpty() || !clip.Intersects(r) || !w.IsPainting(r))
		return;
	if(notr.IsEmpty())
		CombineArea(area, r & clip);
	else {
		if(notr != r) {
			CombineArea(area, clip & Rect(r.left, r.top, notr.left, r.bottom));
			CombineArea(area, clip & Rect(notr.right, r.top, r.right, r.bottom));
			CombineArea(area, clip & Rect(notr.left, r.top, notr.right, notr.top));
			CombineArea(area, clip & Rect(notr.left, notr.bottom, notr.right, r.bottom));
		}
		for(Ctrl *q = firstchild; q; q = q->next) {
			Point qoff = q->InView() ? viewpos : off;
			Rect qr = q->GetRect() + qoff;
			if(clip.Intersects(qr))
				q->GatherTransparentAreas(area, w, qr, clip);
		}
	}
}
コード例 #2
0
ファイル: Win32Wnd.cpp プロジェクト: koz4k/soccer
void Ctrl::WndUpdate(const Rect& r)
{
	GuiLock __;
	LLOG("WndUpdate " << UPP::Name(this));
	Ctrl *top = GetTopCtrl();
	if(top->IsOpen()) {
		HWND hwnd = top->GetHWND();
		HDC hdc = GetDC(hwnd);
		HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
		if(GetUpdateRgn(hwnd, hrgn, FALSE) != NULLREGION) {
			SelectClipRgn(hdc, hrgn);
			SystemDraw draw(hdc);
			bool hcr = focusCtrl && focusCtrl->GetTopCtrl() == top &&
			           caretRect.Intersects(r + top->GetRect().TopLeft());
			if(hcr) ::HideCaret(hwnd);
			draw.Clip(r);
			top->UpdateArea(draw, r);
			ValidateRect(hwnd, r);
			SelectClipRgn(hdc, NULL);
			if(hcr) ::ShowCaret(hwnd);
		}
		ReleaseDC(hwnd, hdc);
		DeleteObject(hrgn);
	}
}
コード例 #3
0
ファイル: CtrlDraw.cpp プロジェクト: pedia/raidget
void  Ctrl::ScrollView(const Rect& _r, int dx, int dy)
{
	GuiLock __;
	LLOG("ScrollView " << _r << " " << dx << " " << dy);
	if(IsFullRefresh() || !IsVisible())
		return;
	Size vsz = GetSize();
	dx = sgn(dx) * min(abs(dx), vsz.cx);
	dy = sgn(dy) * min(abs(dy), vsz.cy);
	Rect r = _r & vsz;
	LLOG("ScrollView2 " << r << " " << dx << " " << dy);
	Ctrl *w;
	for(w = this; w->parent; w = w->parent)
		if(w->InFrame()) {
			Refresh();
			return;
		}
	if(!w || !w->top) return;
	Rect view = InFrame() ? GetView() : GetClippedView();
	Rect sr = (r + view.TopLeft()) & view;
	sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft();
	if(w->AddScroll(sr, dx, dy))
		Refresh();
	else {
		LTIMING("ScrollCtrls1");
		Top *top = GetTopCtrl()->top;
		for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
			if(q->InView())
				ScrollCtrl(top, q, r, q->GetRect(), dx, dy);
		if(parent)
			for(Ctrl *q = parent->GetFirstChild(); q; q = q->GetNext())
				if(q->InView() && q != this)
					ScrollCtrl(top, q, r, q->GetScreenRect() - GetScreenView().TopLeft(), dx, dy);
	}
}
コード例 #4
0
ファイル: DockCont.cpp プロジェクト: dreamsxin/ultimatepp
Image DockCont::GetHighlightImage()
{
	Ctrl *ctrl = GetCtrl(GetCursor());
	ImageDraw img(ctrl->GetRect().GetSize());
	ctrl->DrawCtrlWithParent(img);
	return img;
}
コード例 #5
0
ファイル: Options.cpp プロジェクト: dreamsxin/ultimatepp
// get user options, process and save.
void
Options::onbtnSave()
{
	int dontsplash = optSplash.Get();    // get the value from option control
	int savewinpos = optSaveWinPos.Get();// get the value from option control

	Ctrl* owner = GetOwner(); // get a handle to the Options dislog owner which is MyUppApp main window.
	Rect rc;                  // create a struct to store window position and size

	if ( savewinpos != 1 ) {  // if Save Window option is not checked.
		rc.left = 0;          // set window position x to 0
		rc.top = 0;           // set window position y to 0
	} else {
		rc = owner->GetRect(); // get the position and size of MyUppApp main window
	}

	String cfg;  // create a string to store config data
	cfg << "Splash="     << dontsplash << "\n"    // save user's choice
	       "SaveWinPos=" << savewinpos << "\n"    // save user's choice
	       "PosX="       << rc.left    << "\n"    // save window x position
	       "PosY="       << rc.top     << "\n";   // save window y position

	if( !SaveFile(cfgfile, cfg) )  // save the config file
		Exclamation("Error saving configuration!"); // if failed show error dialog
	else
	    PromptOK("Options saved!");  // show success dialog

	Break(IDOK); // close this dialog
}
コード例 #6
0
ファイル: DockCont.cpp プロジェクト: dreamsxin/ultimatepp
void DockCont::Handle::Paint(Draw& w)
{
	if (IsShown() && dc) {
		const DockableCtrl::Style &s = dc->GetStyle();
		Rect r = GetSize();
		const Rect &m = s.handle_margins;
		Point p;

		if (s.handle_vert)
			p = Point(r.left-1 + m.left, r.bottom - m.bottom);
		else
			p = Point(r.left + m.left, r.top + m.top);
		ChPaint(w, r, s.handle[focus]);

		Image img = dc->GetIcon();
		if (!img.IsEmpty()) {
			if (s.handle_vert) {
				int isz = r.GetWidth();
				p.y -= isz;
				isz -= (m.left + m.right);
				ChPaint(w, max(p.x+m.left, r.left), p.y, isz, isz, img);
				p.y -= 2;
			}
			else {
				int isz = r.GetHeight();
				isz -= (m.top + m.bottom);
				ChPaint(w, p.x, max(p.y, r.top), isz, isz, img);
				p.x += isz + 2;
			}
		}
		if (!s.title_font.IsNull()) {
			Ctrl *c = GetLastChild();
			while (c && !c->IsShown() && c->GetParent())
				c = c->GetNext();
			if (s.handle_vert)
				r.top = c ? c->GetRect().bottom + m.top : m.top;
			else
				r.right = c ? c->GetRect().left + m.right : m.right;
			w.Clip(r);
			WString text = IsNull(dc->GetGroup()) ? dc->GetTitle() : (WString)Format("%s (%s)", dc->GetTitle(), dc->GetGroup());
			w.DrawText(p.x, p.y, s.handle_vert ? 900 : 0, text, s.title_font, s.title_ink[focus]);
			w.End();
		}
	}
}
コード例 #7
0
ファイル: Event.cpp プロジェクト: AbdelghaniDr/mirror
Ctrl *Ctrl::FindMouseTopCtrl()
{
	for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
		Ctrl *t = topctrl[i];
		if(t->GetRect().Contains(MousePos))
			return t->IsEnabled() ? t : NULL;
	}
	return desktop->IsEnabled() ? desktop : NULL;
}
コード例 #8
0
ファイル: CtrlDraw.cpp プロジェクト: dreamsxin/ultimatepp
bool Ctrl::PaintOpaqueAreas(SystemDraw& w, const Rect& r, const Rect& clip, bool nochild)
{
	GuiLock __;
	LTIMING("PaintOpaqueAreas");
	if(!IsShown() || r.IsEmpty() || !r.Intersects(clip) || !w.IsPainting(r))
		return true;
	Point off = r.TopLeft();
	Point viewpos = off + GetView().TopLeft();
	if(backpaint == EXCLUDEPAINT)
		return w.ExcludeClip(r);
	Rect cview = clip & (GetView() + off);
	for(Ctrl *q = lastchild; q; q = q->prev)
		if(!q->PaintOpaqueAreas(w, q->GetRect() + (q->InView() ? viewpos : off),
		                        q->InView() ? cview : clip))
			return false;
	if(nochild && (lastchild || GetNext()))
		return true;
	Rect opaque = (GetOpaqueRect() + viewpos) & clip;
	if(opaque.IsEmpty())
		return true;
#ifdef SYSTEMDRAW
	if(backpaint == FULLBACKPAINT && !dynamic_cast<BackDraw *>(&w))
#else
	if(backpaint == FULLBACKPAINT && !w.IsBack())
#endif
	{
		ShowRepaintRect(w, opaque, LtRed());
		BackDraw bw;
		bw.Create(w, opaque.GetSize());
		bw.Offset(viewpos - opaque.TopLeft());
		bw.SetPaintingDraw(w, opaque.TopLeft());
		{
			LEVELCHECK(bw, this);
			Paint(bw);
			PaintCaret(bw);
		}
		bw.Put(w, opaque.TopLeft());
	}
	else {
		w.Clip(opaque);
		ShowRepaintRect(w, opaque, Green());
		w.Offset(viewpos);
		{
			LEVELCHECK(w, this);
			Paint(w);
			PaintCaret(w);
		}
		w.End();
		w.End();
	}
	LLOG("Exclude " << opaque);
	return w.ExcludeClip(opaque);
}
コード例 #9
0
ファイル: ToolTip.cpp プロジェクト: pedia/raidget
void PerformDescription()
{
	Ctrl *top = Ctrl::GetActiveWindow();
	if(!top) return;
	Vector<Image> vi;
	vi.Add(CtrlImg::HelpCursor0());
	vi.Add(CtrlImg::HelpCursor1());
	if(PointLoop(*top, vi, 300)) {
		Point p = GetMousePos();
		Ctrl *ctrl = Ctrl::GetVisibleChild(top, p - top->GetRect().TopLeft(), true);
		while(ctrl) {
			String desc = ctrl->GetDescription();
			if(!IsEmpty(desc)) {
				static QTFPopUp qtf;
				qtf.SetQTF(desc);
				qtf.PopUp(top);
				return;
			}
			ctrl = ctrl->GetParent();
		}
	}
}
コード例 #10
0
ファイル: CtrlDraw.cpp プロジェクト: dreamsxin/ultimatepp
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
	GuiLock __;
	LEVELCHECK(w, this);
	LTIMING("CtrlPaint");
	Rect rect = GetRect().GetSize();
	Rect orect = rect.Inflated(overpaint);
	if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect))
		return;
	Ctrl *q;
	Rect view = rect;
	for(int i = 0; i < frame.GetCount(); i++) {
		LEVELCHECK(w, NULL);
		frame[i].frame->FramePaint(w, view);
		view = frame[i].view;
	}
	Rect oview = view.Inflated(overpaint);
	bool hasviewctrls = false;
	bool viewexcluded = false;
	for(q = firstchild; q; q = q->next)
		if(q->IsShown())
			if(q->InFrame()) {
				if(!viewexcluded && IsTransparent() && q->GetRect().Intersects(view)) {
					w.Begin();
					w.ExcludeClip(view);
					viewexcluded = true;
				}
				LEVELCHECK(w, q);
				Point off = q->GetRect().TopLeft();
				w.Offset(off);
				q->CtrlPaint(w, clip - off);
				w.End();
			}
			else
				hasviewctrls = true;
	if(viewexcluded)
		w.End();
	DOLEVELCHECK;
	if(!oview.IsEmpty()) {
		if(oview.Intersects(clip) && w.IsPainting(oview)) {
			LEVELCHECK(w, this);
			if(overpaint) {
				w.Clip(oview);
				w.Offset(view.left, view.top);
				Paint(w);
				PaintCaret(w);
				w.End();
				w.End();
			}
			else {
				w.Clipoff(view);
				Paint(w);
				PaintCaret(w);
				w.End();
			}
		}
	}
	if(hasviewctrls && !view.IsEmpty()) {
		Rect cl = clip & view;
		w.Clip(cl);
		for(q = firstchild; q; q = q->next)
			if(q->IsShown() && q->InView()) {
				LEVELCHECK(w, q);
				Rect qr = q->GetRect();
				Point off = qr.TopLeft() + view.TopLeft();
				Rect ocl = cl - off;
				if(ocl.Intersects(Rect(qr.GetSize()).Inflated(overpaint))) {
					w.Offset(off);
					q->CtrlPaint(w, cl - off);
					w.End();
				}
			}
		w.End();
	}
}
コード例 #11
0
ファイル: CtrlDraw.cpp プロジェクト: dreamsxin/ultimatepp
void  Ctrl::ScrollView(const Rect& _r, int dx, int dy)
{
	GuiLock __;
	if(IsFullRefresh() || !IsVisible())
		return;
	Size vsz = GetSize();
	dx = sgn(dx) * min(abs(dx), vsz.cx);
	dy = sgn(dy) * min(abs(dy), vsz.cy);
	Rect r = _r & vsz;
	Ctrl *w;
	for(w = this; w->parent; w = w->parent)
		if(w->InFrame()) {
			Refresh();
			return;
		}
	if(!w || !w->top) return;
	Rect view = InFrame() ? GetView() : GetClippedView();
	Rect sr = (r + view.TopLeft()) & view;
	sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft();
	if(w->AddScroll(sr, dx, dy))
		Refresh();
	else {
		LTIMING("ScrollCtrls1");
		Top *top = GetTopCtrl()->top;
		for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
			if(q->InView()) {
				Rect cr = q->GetRect();
				if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs
					Rect to = cr;
					GetTopRect(to, false);
					if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
						Rect from = cr.Offseted(-dx, -dy);
						GetTopRect(from, false);
						MoveCtrl *m = FindMoveCtrlPtr(top->move, q);
						if(m && m->from == from && m->to == to) {
							LLOG("ScrollView Matched " << from << " -> " << to);
							m->ctrl = NULL;
							goto done;
						}
					}

					if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
						Rect from = to;
						to = cr.Offseted(dx, dy);
						GetTopRect(to, false);
						MoveCtrl& m = top->scroll_move.Add(q);
						m.from = from;
						m.to = to;
						m.ctrl = q;
						LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to);
						goto done;
					}
					cr &= r;
					if(!cr.IsEmpty()) {
						Refresh(cr);
						Refresh(cr + Point(dx, dy));
					}
				done:;
				}
			}
	}
}
コード例 #12
0
ファイル: DockPane.cpp プロジェクト: dreamsxin/ultimatepp
void DockPane::Swap(Ctrl &child, Ctrl &newctrl)
{
	newctrl.SetRect(child.GetRect());
	Ctrl::AddChildBefore(&newctrl, &child);
	Ctrl::RemoveChild(&child);
}
コード例 #13
0
ファイル: CtrlDraw.cpp プロジェクト: dreamsxin/ultimatepp
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
	GuiLock __;
	LEVELCHECK(w, this);
	LTIMING("CtrlPaint");
	
	Rect rect = GetRect().GetSize();
	Rect orect = rect.Inflated(overpaint);
	if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect))
		return;
	
	w.PushContext();
	//glPushMatrix();
	ApplyTransform(TS_BEFORE_CTRL_PAINT);
		
	Ctrl *q;
	Rect view = rect;
	for(int i = 0; i < frame.GetCount(); i++) {
		LEVELCHECK(w, NULL);
		frame[i].frame->FramePaint(w, view);
		view = frame[i].view;
	}
	Rect oview = view.Inflated(overpaint);
	bool hasviewctrls = false;
	bool viewexcluded = false;
	
	for(q = firstchild; q; q = q->next)
		if(q->IsShown())
			if(q->InFrame()) {
				if(!viewexcluded && IsTransparent() && q->GetRect().Intersects(view)) {
					w.Begin();
					w.ExcludeClip(view);
					viewexcluded = true;
				}
				LEVELCHECK(w, q);
				Point off = q->GetRect().TopLeft();
				w.Offset(off);
				q->CtrlPaint(w, clip - off);
				w.End();
			}
			else
				hasviewctrls = true;

	if(viewexcluded)
		w.End();
	//DOLEVELCHECK;

	if(!oview.IsEmpty() && oview.Intersects(clip)) {
		LEVELCHECK(w, this);
		if(cliptobounds)
			w.Clip(overpaint ? oview : view);
		w.Offset(view.left, view.top);
		Paint(w);
		PaintCaret(w);		
		w.End();
		
		if(hasviewctrls && !view.IsEmpty()) {
			Rect cl = clip & view;
			for(q = firstchild; q; q = q->next)
				if(q->IsShown() && q->InView()) {
					Rect rr(q->popup ? clip : cl);
					LEVELCHECK(w, q);
					Rect qr = q->GetRect();
					Point off = qr.TopLeft() + view.TopLeft();
					Rect ocl = cl - off;
					if(ocl.Intersects(Rect(qr.GetSize()).Inflated(overpaint))) {
						w.Offset(off);
						q->CtrlPaint(w, rr - off);
						w.End();
					}
				}
		}

		if(cliptobounds)
			w.End();
	}
	
	ApplyTransform(TS_AFTER_CTRL_PAINT);
	//glPopMatrix();
	w.PopContext();
}