Exemplo n.º 1
0
reg_t ScrollWindow::modify(const reg_t id, const Common::String &text, const GuiResourceId fontId, const int16 foreColor, const TextAlign alignment, const bool scrollTo) {

	EntriesList::iterator it = _entries.begin();
	uint firstCharLocation = 0;
	for ( ; it != _entries.end(); ++it) {
		if (it->id == id) {
			break;
		}
		firstCharLocation += it->text.size();
	}

	if (it == _entries.end()) {
		return make_reg(0, 0);
	}

	ScrollWindowEntry &entry = *it;

	uint oldTextLength = entry.text.size();

	fillEntry(entry, text, fontId, foreColor, alignment);
	_text.replace(firstCharLocation, oldTextLength, entry.text);

	if (scrollTo) {
		_firstVisibleChar = firstCharLocation;
	}

	computeLineIndices();
	update(true);

	return entry.id;
}
Exemplo n.º 2
0
UA_StatusCode
UA_NodeStore_replace(UA_NodeStore *ns, UA_Node *oldNode,
                     UA_Node *node, UA_Node **inserted) {
    UA_NodeStoreEntry *slot;
    if(!containsNodeId(ns, &node->nodeId, &slot))
        return UA_STATUSCODE_BADNODEIDUNKNOWN;
    /* that is not the node you are looking for */
    if(&slot->node.node != oldNode)
        return UA_STATUSCODE_BADINTERNALERROR;
    deleteEntry(slot);
    fillEntry(slot, node);
    if(inserted)
        *inserted = &slot->node.node;
    return UA_STATUSCODE_GOOD;
}
Exemplo n.º 3
0
reg_t ScrollWindow::add(const Common::String &text, const GuiResourceId fontId, const int16 foreColor, const TextAlign alignment, const bool scrollTo) {
	if (_entries.size() == _maxNumEntries) {
		ScrollWindowEntry removedEntry = _entries.remove_at(0);
		_text.erase(0, removedEntry.text.size());
		// `_firstVisibleChar` will be reset shortly if
		// `scrollTo` is true, so there is no reason to
		// update it
		if (!scrollTo) {
			_firstVisibleChar -= removedEntry.text.size();
		}
	}

	_entries.push_back(ScrollWindowEntry());
	ScrollWindowEntry &entry = _entries.back();

	// NOTE: In SSCI the line ID was a memory handle for the
	// string of this line. We use a numeric ID instead.
	entry.id = make_reg(0, _nextEntryId++);

	if (_nextEntryId > _maxNumEntries) {
		_nextEntryId = 1;
	}

	// NOTE: In SSCI this was updated after _text was
	// updated, which meant there was an extra unnecessary
	// subtraction operation (subtracting `entry.text` size)
	if (scrollTo) {
		_firstVisibleChar = _text.size();
	}

	fillEntry(entry, text, fontId, foreColor, alignment);
	_text += entry.text;

	computeLineIndices();
	update(true);

	return entry.id;
}
Exemplo n.º 4
0
UA_StatusCode UA_NodeStore_insert(UA_NodeStore *ns, UA_Node *node, UA_Node **inserted) {
    if(ns->size * 3 <= ns->count * 4) {
        if(expand(ns) != UA_STATUSCODE_GOOD)
            return UA_STATUSCODE_BADINTERNALERROR;
    }

    UA_NodeStoreEntry *entry;
    UA_NodeId tempNodeid;
    tempNodeid = node->nodeId;
    tempNodeid.namespaceIndex = 0;
    if(UA_NodeId_isNull(&tempNodeid)) {
        /* find a free nodeid */
        if(node->nodeId.namespaceIndex == 0) //original request for ns=0 should yield ns=1
            node->nodeId.namespaceIndex = 1;
        UA_Int32 identifier = ns->count+1; // start value
        UA_Int32 size = ns->size;
        hash_t increase = mod2(identifier, size);
        while(UA_TRUE) {
            node->nodeId.identifier.numeric = identifier;
            if(!containsNodeId(ns, &node->nodeId, &entry))
                break;
            identifier += increase;
            if(identifier >= size)
                identifier -= size;
        }
    } else {
        if(containsNodeId(ns, &node->nodeId, &entry))
            return UA_STATUSCODE_BADNODEIDEXISTS;
    }

    fillEntry(entry, node);
    ns->count++;
    if(inserted)
        *inserted = &entry->node.node;
    return UA_STATUSCODE_GOOD;
}