Exemple #1
0
void DockCont::TabSelected()
{
	int ix = tabbar.GetCursor();
	if (ix >= 0) {
		DockableCtrl *dc = Get0(ix);
		if (!dc) return;
		Ctrl *ctrl = GetCtrl(ix);
		Ctrl *first = &handle;

		for (Ctrl *c = first->GetNext(); c; c = c->GetNext())
			if (c != ctrl) c->Hide();
		ctrl->Show();
		Icon(dc->GetIcon()).Title(dc->GetTitle());

		handle.dc = dc;
		SyncButtons(*dc);

		if (IsTabbed()) {
			DockCont *c = static_cast<DockCont *>(GetParent());
			c->tabbar.SyncRepos();
			c->TabSelected();
			c->RefreshFrame();
		}
		else
			RefreshLayout();
	}
}
Exemple #2
0
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);
	}
}
Exemple #3
0
bool MenuBar::HotKey(dword key)
{
	if(Ctrl::HotKey(key))
		return true;
	if(IsChild()) {
		if((key == (K_ALT_KEY|K_KEYUP) || key == K_F10) && (submenu || HasFocusDeep())) {
			LLOG("CloseMenu()");
			CloseMenu();
			if(restorefocus)
				restorefocus->SetFocus();
			s_doaltkey = false;
			return true;
		}
		if(key == K_ALT_KEY) {
			LLOG("K_ALT_KEY");
			s_doaltkey = true;
			return true;
		}
		if((key == K_F10 || key == (K_ALT_KEY|K_KEYUP) && s_doaltkey)
		   && !submenu && !HasFocusDeep() && GetTopWindow() && GetTopWindow()->IsForeground()) {
			LLOG("Open menu by F10 or ALT-UP");
			SetupRestoreFocus();
			for(Ctrl *q = pane.GetFirstChild(); q; q = q->GetNext())
				if(q->SetFocus()) return true;
		}
	}
	LLOG("MenuBar::HotKey");
	return (key == K_LEFT || key == K_RIGHT) && parentmenu ? parentmenu->Key(key, 1) : false;
}
Exemple #4
0
Ctrl * DockPane::FindCtrl(int ix)
{
	Ctrl *c = GetFirstChild();
	for (int i = 0; i < ix && c; i++)
		c = c->GetNext();
	return c;
}
Exemple #5
0
VisGenDlg::VisGenDlg(LayoutData& layout, const Vector<int>& cursor)
:	layout(layout)
{
	type <<= 0;
	CtrlLayoutOKCancel(*this, "Code generator");
	type <<= THISBACK(Type);

	// needs to be before Refresh to maintain the proper order of action
	toupper1 << [=] { tolower1 <<= false; initcaps1 <<= false; };
	tolower1 << [=] { toupper1 <<= false; initcaps1 <<= false; };
	initcaps1 << [=] { toupper1 <<= false; tolower1 <<= false; };

	toupper2 << [=] { tolower2 <<= false; initcaps2 <<= false; };
	tolower2 << [=] { toupper2 <<= false; initcaps2 <<= false; };
	initcaps2 << [=] { toupper2 <<= false; tolower2 <<= false; };

	for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
		if(dynamic_cast<Option *>(q))
			*q << [=] { Refresh(); };
			
	name << [=] { Refresh(); };
	

	Refresh();
	view.Highlight("cpp");
	view.HideBar();
	view.SetFont(CourierZ(12));
	if(cursor.GetCount())
		sel <<= cursor;
	else
		for(int i = 0; i < layout.item.GetCount(); i++)
			sel.Add(i);
}
Exemple #6
0
void TopWindow::Reject()
{
	for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
		q->Reject();
	if(!backup.IsEmpty())
		Restore();
}
Exemple #7
0
void Ctrl::RemoveFullRefresh()
{
	GuiLock __;
	fullrefresh = false;
	for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
		q->RemoveFullRefresh();
}
Exemple #8
0
void Themed::ReadTheme()
{
	int q = theme.Find(ToLower(GetClass()));
	if(q < 0) return;
	ClassTheme& cm = theme[q];
	ThemeProperties tm(cm.data.property, cm.data.image, true);
	Properties(tm);
	Ctrl *p = dynamic_cast<Ctrl *>(this);
	if(p)
		for(Ctrl *q = p->GetFirstChild(); q; q = q->GetNext()) {
			Themed *t = dynamic_cast<Themed *>(q);
			if(t) {
				int i = cm.child.Find(t->GetClass());
				if(i >= 0) {
					ThemeProperties tm(cm.child[i].property, cm.child[i].image, true);
					t->Properties(tm);
				}
				i = cm.child.Find(t->id);
				if(i >= 0) {
					q->SetPos(cm.child[i].pos);
					ThemeProperties tm(cm.child[i].property, cm.child[i].image, true);
					t->Properties(tm);
				}
			}
		}
}
Exemple #9
0
void Ctrl::RefreshAccessKeys()
{
	GuiLock __;
	if(GetAccessKeys())
		Refresh();
	for(Ctrl *ctrl = GetFirstChild(); ctrl; ctrl = ctrl->GetNext())
		ctrl->RefreshAccessKeys();
}
Exemple #10
0
bool TopWindow::Accept()
{
	Ctrl *q;
	for(q = GetFirstChild(); q; q = q->GetNext())
		if(!q->Accept())
			return false;
	return true;
}
Exemple #11
0
Ctrl * Ctrl::GetIndexChild(int ii) const
{
	GuiLock __;
	Ctrl *c = GetFirstChild();
	for(int i = 0; i < ii && c; i++)
		c = c->GetNext();
	return c;
}
Exemple #12
0
int Ctrl::GetChildCount() const
{
	GuiLock __;
	int n = 0;
	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext())
		n++;
	return n;
}
Exemple #13
0
int DockPane::FindIndex(Ctrl &child)
{
	int ix = 0;
	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext()) {
		if (c == &child) return ix;
		ix++;
	}
	return -1;
}
Exemple #14
0
int Ctrl::GetChildIndex(const Ctrl *child) const
{
	GuiLock __;
	int i = 0;
	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext()) {
		if(c == child) return i;
		i++;
	}
	return -1;
}
Exemple #15
0
int DockPane::GetMinPos(int notix)
{
	int n = 0;
	int msz = 0;
	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext()) {
		if (n != notix) msz += ClientToPos(c->GetMinSize());
		n++;
	}
	return msz;
}
Exemple #16
0
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();
		}
	}
}
Exemple #17
0
void Themed::WriteTheme()
{
	if(IsNull(sWriteDir))
		return;
	RealizeDirectory(sWriteDir);
	String imgdir = AppendFileName(sWriteDir, GetClass() + ".image");
	FileOut out(AppendFileName(sWriteDir, GetClass() + ".class"));
	VectorMap<String, String> prop;
	VectorMap<String, Image> img;
	ThemeProperties tm(prop, img, false);
	Properties(tm);
	RealizeDirectory(imgdir);
	SaveImages(imgdir, NULL, img);
	SaveProp(out, prop, "");
	Ctrl *p = dynamic_cast<Ctrl *>(this);
	if(p)
		for(Ctrl *q = p->GetFirstChild(); q; q = q->GetNext()) {
			Themed *t = dynamic_cast<Themed *>(q);
			if(t && t->id.GetCount()) {
//				prop.Clear();
//				ThemeProperties tm(prop, img, false);
//				t->Properties(tm);
				out << t->id;
				Ctrl::LogPos pos = q->GetPos();
				switch(pos.x.GetAlign()) {
				case Ctrl::LEFT:   out << Format(" left %d, %d", pos.x.GetA(), pos.x.GetB()); break;
				case Ctrl::RIGHT:  out << Format(" right %d, %d", pos.x.GetA(), pos.x.GetB()); break;
				case Ctrl::SIZE:   out << Format(" hsize %d, %d", pos.x.GetA(), pos.x.GetB()); break;
				case Ctrl::CENTER: out << Format(" hcenter %d, %d", pos.x.GetB(), pos.x.GetA()); break;
				}
				switch(pos.y.GetAlign()) {
				case Ctrl::TOP:    out << Format(" top %d, %d", pos.y.GetA(), pos.y.GetB()); break;
				case Ctrl::BOTTOM: out << Format(" bottom %d, %d", pos.y.GetA(), pos.y.GetB()); break;
				case Ctrl::SIZE:   out << Format(" vsize %d, %d", pos.y.GetA(), pos.y.GetB()); break;
				case Ctrl::CENTER: out << Format(" vcenter %d, %d", pos.y.GetB(), pos.y.GetA()); break;
				}
				out << "\r\n";
//				SaveProp(out, prop, "   ");
			}
		}
}
Exemple #18
0
void DockPane::SmartRepos(int ix, int inc)
{
	int cnt = pos.GetCount();
	if (cnt == 1) {
		pos[0] = 10000;
		return;
	}

	for (int i = cnt-1; i > 0; i--)
		pos[i] -= pos[i-1];

	int n = 0;
	int msz = 0;
	int tsz = 0;
	Vector<int>minpos;
	minpos.SetCount(cnt);

	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext()) {
		if (n != ix) {
			minpos[n] = min(ClientToPos(c->GetMinSize()), pos[n]);
			msz += minpos[n];
			tsz += pos[n];
		}
		n++;
	}
	int dif = tsz - inc - msz;
	tsz -= msz;

	pos[ix] += inc;
	if (tsz != 0 && dif != 0) {
		if (tsz <= 0) dif = -dif;
		int isz = pos[ix];
		for (int i = 0; i < cnt; i++) {
			if (i != ix)
				pos[i] = minpos[i] + (dif * (pos[i] - minpos[i])) / tsz;
		}
	}
	for (int i = 1; i < cnt; i++)
		pos[i] += pos[i-1];
}
Exemple #19
0
Ctrl *Ctrl::FindBestOpaque(const Rect& clip)
{
	GuiLock __;
	Ctrl *w = NULL;
	for(Ctrl *q = GetFirstChild(); q; q = q->GetNext()) {
		if(q->IsVisible() && GetScreenView().Contains(q->GetScreenRect())) {
			Rect sw = q->GetScreenView();
			if((q->GetOpaqueRect() + sw.TopLeft()).Contains(clip)) {
				w = q;
				Ctrl *h = q->FindBestOpaque(clip);
				if(h) w = h;
			}
			else
			if(q->GetScreenView().Contains(clip))
				w = q->FindBestOpaque(clip);
			else
			if(q->GetScreenRect().Intersects(clip))
				w = NULL;
		}
	}
	return w;
}
Exemple #20
0
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:;
				}
			}
	}
}
Exemple #21
0
void Ctrl::ApplyLayout()
{
	GuiLock __;
	for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
		q->ApplyLayout();
}
Exemple #22
0
bool MenuBar::Key(dword key, int count)
{
	LLOG("KEY " << GetKeyDesc(key));
	bool horz = IsChild();
	if((horz ? key == K_RIGHT : key == K_DOWN)) {
		Ctrl *ctrl = GetFocusChildDeep();
		LLOG("MenuBar::Key(" << key << ") -> IterateFocusForward for " << UPP::Name(ctrl) << ", pane " << UPP::Name(&pane));
		if(HasMouseDeep())
			GetMouseCtrl()->Refresh();
		if(ctrl && IterateFocusForward(ctrl, &pane, false, false, true))
			return true;
		Ctrl *f = pane.GetFirstChild();
		if(!f) return true;
		if(f->IsEnabled()) {
			f->SetFocus();
			return true;
		}
		if(IterateFocusForward(pane.GetFirstChild(), &pane, false, false, true)) return true;
	}
	else
	if((horz ? key == K_LEFT : key == K_UP)) {
		Ctrl *ctrl = GetFocusChildDeep();
		LLOG("MenuBar::Key(" << key << ") -> IterateFocusBackward for " << UPP::Name(ctrl) << ", pane " << UPP::Name(&pane));
		if(HasMouseDeep())
			GetMouseCtrl()->Refresh();
		if(ctrl && IterateFocusBackward(ctrl, &pane, false, true))
			return true;
		Ctrl *f = pane.GetLastChild();
		if(!f) return true;
		if(f->IsEnabled()) {
			f->SetFocus();
			return true;
		}
		if(IterateFocusBackward(pane.GetLastChild(), &pane, false, true)) return true;
	}
	else
	if(parentmenu && !parentmenu->IsChild() && key == K_LEFT || key == K_ESCAPE) {
		if(HasMouseDeep())
			GetMouseCtrl()->Refresh();
		if(parentmenu && parentmenu->submenu)
			parentmenu->submenuitem->SetFocus();
		else
		if(IsChild() && HasFocusDeep()) {
			if(restorefocus)
				restorefocus->SetFocus();
			doeffect = true;
			return true;
		}
		if(IsPopUp()) {
			SubmenuClose();
			return true;
		}
		doeffect = true;
	}
	if(parentmenu && parentmenu->IsChild() && parentmenu->GetActiveSubmenu() &&
	   parentmenu->pane.GetFirstChild() && parentmenu->submenuitem) {
		Ctrl *smi = parentmenu->submenuitem;
		Ctrl *q = smi;
		q->Refresh();
		if(key == K_RIGHT)
			for(;;) {
				q = q->GetNext();
				if(!q)
					q = parentmenu->pane.GetFirstChild();
				if(q == smi)
					break;
				if(PullMenu(q)) {
					q->Refresh();
					SyncState();
					return true;
				}
			}
		if(key == K_LEFT)
			for(;;) {
				q = q->GetPrev();
				if(!q)
					q = parentmenu->pane.GetLastChild();
				if(q == smi)
					break;
				if(PullMenu(q)) {
					q->Refresh();
					SyncState();
					return true;
				}
			}
	}
	LLOG("MenuBar::Key -> HotKey");
	return HotKey(key);
}