Esempio n. 1
0
bool UINode::addFirstFocus ()
{
	bool focus = false;
	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* nodePtr = *i;
		nodePtr->removeFocus();
		if (focus)
			continue;
		focus = nodePtr->addFirstFocus();
		if (focus)
			addFocus(0, 0);
	}

	if (_nodes.empty() && isActive()) {
		addFocus(0, 0);
		return true;
	}
	return focus;
}
Esempio n. 2
0
bool UINode::addLastFocus ()
{
	bool focus = false;
	for (UINodeListRevIter i = _nodes.rbegin(); i != _nodes.rend(); ++i) {
		UINode* nodePtr = *i;
		nodePtr->removeFocus();
		if (!focus) {
			focus = nodePtr->addLastFocus();
			if (focus) {
				addFocus(0, 0);
			}
		}
	}

	if (_nodes.empty() && isActive()) {
		addFocus(0, 0);
		return true;
	}
	return focus;
}
Esempio n. 3
0
bool UINode::checkFocus (int32_t x, int32_t y)
{
	if (x <= -1 || y <= -1 || !isVisible() || !isActive()) {
		if (hasFocus())
			removeFocus();
		return false;
	}

	if (checkBounds(x, y)) {
		if (_nodes.empty()) {
			addFocus(x, y);
			return true;
		}

		const int childX = x - getRenderX();
		const int childY = y - getRenderY();
		bool focusOnChildren = false;
		for (UINodeListRevIter i = _nodes.rbegin(); i != _nodes.rend(); ++i) {
			UINode* nodePtr = *i;
			int focusX = childX;
			int focusY = childY;
			if (focusOnChildren) {
				focusX = focusY = -1;
			}
			const bool focus = nodePtr->checkFocus(focusX, focusY);
			focusOnChildren |= focus;
		}

		if (focusOnChildren) {
			addFocus(x, y);
			return true;
		}
	}

	if (hasFocus()) {
		removeFocus();
	}
	return false;
}
Esempio n. 4
0
bool UINode::nextFocus ()
{
	if (_nodes.empty()) {
		if (!isActive())
			return false;
		if (hasFocus())
			return false;
		addFocus(0, 0);
		return true;
	}

	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* nodePtr = *i;
		// search the node that currently has the focus
		if (!nodePtr->hasFocus())
			continue;

		if (nodePtr->nextFocus()) {
			addFocus(0, 0);
			return true;
		}

		nodePtr->removeFocus();
		for (++i; i != _nodes.end(); ++i) {
			UINode* focusNodePtr = *i;
			if (focusNodePtr->addFirstFocus()) {
				addFocus(0, 0);
				return true;
			}
		}
		break;
	}

	removeFocus();

	return false;
}
Esempio n. 5
0
void UrlBar::handleEvent(const XEvent& event)
{
    switch (event.type) {
    case Expose:
        drawUrlBar();
        break;
    case ButtonRelease:
        addFocus();
        updateCursorPosition(event.xbutton.x);
        break;
    case SelectionRequest:
        respondClipboardRequest(event.xselectionrequest);
        break;
    case SelectionNotify:
        pasteClipboardText(event);
        break;
    }
}