Beispiel #1
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;
}
Beispiel #2
0
// 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
}
Beispiel #3
0
void ShowToolTip()
{
	LLOG("ShowToolTip");
	CloseToolTip();
	if(tipctrl) {
		String text = tipctrl->GetTip();
		LLOG("-> showing tip: " << text << " tipctrl: " << UPP::Name(tipctrl));
		Ctrl *top = tipctrl->GetTopCtrl();
		if(!text.IsEmpty() && top && (top->IsForeground() || top->IsPopUp())) {
			LLOG("-> foreground");
			ToolTip& q = AppToolTip();
			q.Set(text);
			Size sz = q.GetMinSize();
			Rect r = top->GetWorkArea();
			Point p = GetMousePos() + Size(0, 22);
			if(p.y + sz.cy > r.bottom)
				p = GetMousePos() - Size(0, 22);
			q.PopUp(top, p, !showmode);
			showmode = true;
			KillTimeCallback((void *)EndShowMode);
			return;
		}
		LLOG("-> background / empty text, top = " << UPP::Name(top));
	}
	SetTimeCallback(200, callback(EndShowMode), (void *)EndShowMode);
}
Beispiel #4
0
void Ctrl::RemoveFullRefresh()
{
	GuiLock __;
	fullrefresh = false;
	for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
		q->RemoveFullRefresh();
}
Beispiel #5
0
Ctrl * DockPane::FindCtrl(int ix)
{
	Ctrl *c = GetFirstChild();
	for (int i = 0; i < ix && c; i++)
		c = c->GetNext();
	return c;
}
Beispiel #6
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);
				}
			}
		}
}
Beispiel #7
0
void DisplayPopup::Sync()
{
	if(display && ctrl && !ctrl->IsDragAndDropTarget() && !IsDragAndDropTarget()) {
		Ctrl *top = ctrl->GetTopCtrl();
		if(top && top->HasFocusDeep()) {
			Size sz = display->GetStdSize(value);
			if(sz.cx + 2 * margin > item.GetWidth() || sz.cy > item.GetHeight()) {
				slim = item + ctrl->GetScreenView().TopLeft();
				if(slim.Contains(GetMousePos())) {
//					Rect wa = GetWorkArea();
					Rect r = item;
					r.right = max(r.right, r.left + sz.cx + 2 * margin);
					r.bottom = max(r.bottom, r.top + sz.cy);
					r.Inflate(1, 1);
					r.Offset(ctrl->GetScreenView().TopLeft());
					SetRect(r);
					if(!IsOpen())
						Ctrl::PopUp(ctrl, true, false, false);
					Refresh();
					return;
				}
			}
		}
	}
	if(IsOpen())
		Close();
}
Beispiel #8
0
void DockWindow::Undock(DockCont &c)
{
	if (!c.IsFloating() && !c.IsHidden()) {
		if (c.IsAutoHide()) {
			for (int i = 0; i < 4; i++) {
				int ix = hideframe[i].FindCtrl(c);
				if (ix >= 0) {
					hideframe[i].RemoveCtrl(ix);
					hideframe[i].RefreshFrame();
					break;
				}
			}
		}
		else {
			int dock = GetDockAlign(c);
			if (dock >= 0 && dock < 4) {
				Ctrl *p = &c;
				while (p && p->GetParent() != &dockpane[dock]) p = p->GetParent();
				ASSERT(p);
				bool v = !IsTB(dock);
				c.SyncUserSize(v, !v);
			}
			Undock0(c);
		}
		c.StateNotDocked();
	}
}
Beispiel #9
0
void TopWindow::Reject()
{
	for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
		q->Reject();
	if(!backup.IsEmpty())
		Restore();
}
Beispiel #10
0
PasteClip Ctrl::GtkDnd(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
                       guint time, gpointer user_data, bool paste)
{
	DndTargets(context);
	g_object_ref(context); // make sure these always survive the action...
	g_object_ref(widget);
	dnd_context = context;
	dnd_widget = widget;
	dnd_time = time;
	PasteClip clip;
	clip.type = 1;
	clip.paste = paste;
	clip.accepted = false;
	clip.allowed = DND_MOVE|DND_COPY;
	gint dummy;
	GdkModifierType mod;
	gdk_window_get_pointer(gdk_get_default_root_window(), &dummy, &dummy, &mod);
	clip.action = mod & GDK_CONTROL_MASK ? DND_COPY : DND_MOVE;
	Ctrl *w = DragWnd(user_data);
	if(w) {
		gint mx, my;
		GdkModifierType mod;
		gdk_window_get_pointer(gdk_get_default_root_window(), &mx, &my, &mod);
		CurrentState = mod;
		CurrentMousePos = Point(x, y) + w->GetScreenRect().TopLeft();	
		w->DnD(CurrentMousePos, clip);
	}
	gdk_drag_status(context, clip.IsAccepted() ? clip.GetAction() == DND_MOVE ? GDK_ACTION_MOVE
	                                                                          : GDK_ACTION_COPY
	                                           : GdkDragAction(0), time);
	return clip;
}
Beispiel #11
0
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);
	}
}
Beispiel #12
0
void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool dropshadow, bool topmost)
{
	popup = false;
	Ctrl *q = owner ? owner->GetTopCtrl() : GetActiveCtrl();
	PopUpHWND(q ? q->GetHWND() : NULL, savebits, activate, dropshadow, topmost);
	if(top) top->owner = owner;
}
Beispiel #13
0
ViewDraw::ViewDraw(Ctrl *ctrl)
{
	EnterGuiMutex();
	Ctrl *top = ctrl->GetTopCtrl();
	cr = gdk_cairo_create(top->gdk());
	Clipoff(ctrl->GetScreenView() - top->GetScreenRect().TopLeft());
}
Beispiel #14
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);
}
Beispiel #15
0
Image DockCont::GetHighlightImage()
{
	Ctrl *ctrl = GetCtrl(GetCursor());
	ImageDraw img(ctrl->GetRect().GetSize());
	ctrl->DrawCtrlWithParent(img);
	return img;
}
Beispiel #16
0
void DockCont::AddRemoveButton(Ctrl &c, bool state)
{
	if (state && !c.GetParent())
		Add(c);
	else if (!state)
		c.Remove();
}
Beispiel #17
0
bool TopWindow::Key(dword key, int count)
{
	if(Ctrl::Key(key, count))
		return true;
	if(IsChild()) return false;
	if(key == K_DOWN || key == K_RIGHT || key == K_TAB) {
		Ctrl *ctrl = GetFocusChildDeep();
		if(ctrl && IterateFocusForward(ctrl, this))
			return true;
		ctrl = GetFirstChild();
		if(ctrl) {
			if(ctrl->SetWantFocus()) return true;
			return IterateFocusForward(ctrl, this);
		}
	}
	if(key == K_UP || key == K_LEFT || key == K_SHIFT_TAB) {
		Ctrl *ctrl = GetFocusChildDeep();
		if(ctrl && IterateFocusBackward(ctrl, this))
			return true;
		ctrl = GetLastChild();
		if(ctrl) {
			if(ctrl->SetWantFocus()) return true;
			return IterateFocusBackward(ctrl, this);
		}
	}
	return false;
}
Beispiel #18
0
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);
		}
	}
}
Beispiel #19
0
void Ctrl::DoMouseFB(int event, Point p, int zdelta, CParser& cp)
{
	ReadKeyMods(cp);
	MousePos = p;
	int a = event & ACTION;
	if(a == UP && Ctrl::ignoreclick) {
		EndIgnore();
		return;
	}
	else
	if(a == DOWN && ignoreclick)
		return;
	LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl));
	if(captureCtrl)
		MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta);
	else
		for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
			Ptr<Ctrl> t = topctrl[i];
			Rect rr = t->GetRect();
			if(rr.Contains(p)) {
				MouseEventFB(t, event, p, zdelta);
				return;
			}
		}
	Ctrl *desktop = GetDesktop();
	if(desktop) {
		desktop->DispatchMouse(event, p, zdelta);
		desktop->PostInput();
	}
}
Beispiel #20
0
int DockWindow::GetDockAlign(const Ctrl &c) const
{
	Ctrl *p = c.GetParent();
	while (p && p->GetParent() != this) p = p->GetParent();
	for (int i = 0; i < 4; i++)
		if (dockpane[i].GetParent() == p) return i;
	return DOCK_NONE;
}
Beispiel #21
0
void PaintBarArea(Draw& w, Ctrl *x, const Value& look, int bottom)
{
	Ctrl *tc = x->GetTopCtrl();
	Rect sr = tc->GetScreenRect();
	sr.bottom = Nvl(bottom, tc->GetScreenView().top);
	sr.Offset(-x->GetScreenRect().TopLeft());
	ChPaint(w, sr, look);
}
Beispiel #22
0
Ctrl * Ctrl::GetIndexChild(int ii) const
{
	GuiLock __;
	Ctrl *c = GetFirstChild();
	for(int i = 0; i < ii && c; i++)
		c = c->GetNext();
	return c;
}
Beispiel #23
0
void Ctrl::RefreshAccessKeys()
{
	GuiLock __;
	if(GetAccessKeys())
		Refresh();
	for(Ctrl *ctrl = GetFirstChild(); ctrl; ctrl = ctrl->GetNext())
		ctrl->RefreshAccessKeys();
}
Beispiel #24
0
bool TopWindow::Accept()
{
	Ctrl *q;
	for(q = GetFirstChild(); q; q = q->GetNext())
		if(!q->Accept())
			return false;
	return true;
}
Beispiel #25
0
int Ctrl::GetChildCount() const
{
	GuiLock __;
	int n = 0;
	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext())
		n++;
	return n;
}
Beispiel #26
0
ViewDraw::ViewDraw(Ctrl *ctrl)
{
	EnterGuiMutex();
	Ctrl *top = ctrl->GetTopCtrl();
	hwnd = top->GetHWND();
	ASSERT(hwnd);
	Attach(GetDC(hwnd));
	Clipoff(ctrl->GetScreenView() - top->GetScreenRect().TopLeft());
}
Beispiel #27
0
bool  Ctrl::HasFocusDeep() const
{
	GuiLock __;
	if(HasFocus() || HasChildDeep(FocusCtrl())) return true;
	Ctrl *a = GetActiveCtrl();
	if(!a || !a->IsPopUp()) return false;
	a = a->GetOwnerCtrl();
	return a && HasChildDeep(a);
}
Beispiel #28
0
Size DockWindow::CtrlBestSize(const Ctrl &c, bool restrict) const
{
	Size mn = c.GetMinSize();
	Size mx = c.GetMaxSize();
	Size std = c.GetStdSize();
	if (restrict)
		mx = minmax(GetSize()/2, mn, mx);
	return minmax(std, mn, mx);
}
Beispiel #29
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;
}
Beispiel #30
0
void  Ctrl::DoSync(Ctrl *q, Rect r, bool inframe)
{
	GuiLock __;
	ASSERT(q);
	LLOG("DoSync " << UPP::Name(q) << " " << r);
	Ctrl *top = q->GetTopRect(r, inframe);
	top->SyncScroll();
	top->WndUpdate(r);
}