Esempio n. 1
0
void Container::_insertAfter(const Ref & child,const Ref & after){
	if (child.isNull() || child==after) return;

	if(child->getParent()!=this){
		++contentsCount;
		if(child->hasParent())
			child->getParent()->_removeChild(child);
		child->_setParent(this);
		child->invalidateAbsPosition();
	}
	if(after==getLastChild())
		lastChild=child;
	if(firstChild==child)
		firstChild=child->getNext();
//    child->insertAfter(after);
	child->_updateNeighbors(after,after.isNull() ? nullptr : after->getNext());
	if(firstChild==nullptr)
		firstChild=child;
	if(lastChild==nullptr)
		lastChild=child;

	if(getFirstChild()->getPrev()!=nullptr){
		firstChild=getFirstChild()->getPrev();
	}
	if(getLastChild()->getNext()!=nullptr){
		lastChild=getLastChild()->getNext();
	}

	childRectChanged(child.get());
	invalidateLayout();
}
Esempio n. 2
0
//! ---|> Component
void Connector::doLayout(){

	Geometry::Vec2 parentsAbsPos=hasParent()?getParent()->getAbsPosition():Geometry::Vec2();

	Geometry::Rect r;
	r.invalidate();
//	std::cout << r.getX();

	if( getFirstComponent() )
		r.include( getFirstComponent()->getAbsRect().getCenter()-parentsAbsPos );
//	std::cout << (getFirstComponent()->getAbsRect().getCenter()-parentsAbsPos).getX();

	if( getSecondComponent() )
		r.include( getSecondComponent()->getAbsRect().getCenter()-parentsAbsPos );

	if(getContentsCount()>2){
		// TODO!!!!!
	}
	setPosition(Geometry::Vec2(r.getX(),r.getY()));
	setSize(r.getWidth(),r.getHeight());
	Geometry::Vec2 myAbsPos=getAbsPosition();

	if(getFirstChild() && getFirstComponent()){
		getFirstChild()->setPosition( getFirstComponent()->getAbsRect().getCenter()-myAbsPos );
	}
	if(getLastChild() && getSecondComponent()){
		getLastChild()->setPosition( getSecondComponent()->getAbsRect().getCenter()-myAbsPos );
//		getLastChild()->setPosition(Vec2(r.getWidth(),r.getHeight()));
	}

	if(getContentsCount()>2){
		// TODO!!!!!
	}
}
Esempio n. 3
0
void Container::_insertBefore(const Ref & child,const Ref & before){
	if (child.isNull() || child==before) return;

	if(child->getParent()!=this){
		++contentsCount;
		if(child->hasParent()){
			child->getParent()->_removeChild(child);
		}
		child->_setParent(this);
		childRectChanged(child.get());
		child->invalidateAbsPosition();
	}
	if(before==getFirstChild())
		firstChild=child;
//    child->insertBefore(before);
	child->_updateNeighbors(before.isNull() ? nullptr : before->getPrev(),before);

	if(firstChild==nullptr)
		firstChild=child;
	if(lastChild==nullptr)
		lastChild=child;

	if(getFirstChild()->getPrev()!=nullptr){
		firstChild=getFirstChild()->getPrev();
	}
	if(getLastChild()->getNext()!=nullptr){
		lastChild=getLastChild()->getNext();
	}
	childRectChanged(child.get());
	invalidateLayout();
}
Esempio n. 4
0
void CPetControl::addToInventory(CGameObject *item) {
	item->detach();

	if (item->getName() == "CarryParcel") {
		CCarry *child = dynamic_cast<CCarry *>(getLastChild());
		if (child)
			child->detach();

		item->petMoveToHiddenRoom();
		if (!child)
			return;

		item = child;
	}

	item->addUnder(this);
	_inventory.itemsChanged();

	setArea(PET_INVENTORY);
	if (_currentArea == PET_INVENTORY)
		_inventory.highlightItem(item);

	makeDirty();
	CPETGainedObjectMsg msg;
	msg.execute(item);
}
Esempio n. 5
0
DOM_Node TreeWalkerImpl::previousNode () {
	
    DOM_Node result;

    if (fCurrentNode.isNull()) return result;

    // get sibling
    result = getPreviousSibling(fCurrentNode);
    if (result.isNull()) {
        result = getParentNode(fCurrentNode);
        if (! result.isNull()) {
            fCurrentNode = result;
            return fCurrentNode;
        }
        return result;
    }

    // get the lastChild of result.
    DOM_Node lastChild  = getLastChild(result);

    // if there is a lastChild which passes filters return it.
    if (! lastChild.isNull()) {
        fCurrentNode = lastChild;
        return fCurrentNode;
    }

    // otherwise return the previous sibling.
    if (! result.isNull()) {
        fCurrentNode = result;
        return fCurrentNode;
    }

    // otherwise return null.
    return result;
}
Esempio n. 6
0
DOMNode* DOMTreeWalkerImpl::getPreviousSibling (DOMNode* node) {
		
    if (!node || node == fRoot) return 0;

    DOMNode* newNode = node->getPreviousSibling();
    if (!newNode) {

        newNode = node->getParentNode();
        if (!newNode || node == fRoot)  return 0;

        short parentAccept = acceptNode(newNode);

        if (parentAccept == DOMNodeFilter::FILTER_SKIP) {
            return getPreviousSibling(newNode);
        }

        return 0;
    }

    short accept = acceptNode(newNode);

    if (accept == DOMNodeFilter::FILTER_ACCEPT)
        return newNode;
    else
    if (accept == DOMNodeFilter::FILTER_SKIP) {
        DOMNode* fChild =  getLastChild(newNode);
        if (!fChild && !newNode->hasChildNodes()) {
            return getPreviousSibling(newNode);
        }
        return fChild;
    }
    return getPreviousSibling(newNode);

}
Esempio n. 7
0
DOMNode* DOMTreeWalkerImpl::previousNode () {
	
    if (!fCurrentNode) return 0;

    // get sibling
    DOMNode* node = getPreviousSibling(fCurrentNode);
    if (node == 0) {
        node = getParentNode(fCurrentNode);
        if ( node != 0) {
            fCurrentNode = node;
        }
        return node;
    }
    else {

        // get the lastChild of result.
        DOMNode* lastChild  = getLastChild(node);

        // if there is a lastChild which passes filters return it.
        if (lastChild != 0) {
            fCurrentNode = lastChild;
        }
        else {
            fCurrentNode = node;
        }
        return fCurrentNode;
    }
}
Esempio n. 8
0
Test::TestGroup* Test::TestGroup::getLastLeaf()
{
	TestGroup* lastChild = getLastChild();
	if (!lastChild)
		return this;

	return lastChild->getLastLeaf();
}
Esempio n. 9
0
void
ActionListViewItem::loadGroup( ananasListViewItem * parent, aCfgItem child )
{
	ActionListViewItem * gparent;
	QString				oclass;
	aCfgItem			cobj;

	gparent = new ActionListViewItem( parent, getLastChild(), md, child, QString::null );
	gparent->setPixmap(0, rcIcon("action_g.png"));
	cobj = md->firstChild ( gparent->obj );
	while ( !cobj.isNull() )
	{
		oclass = md->objClass ( cobj );
		if ( oclass == md_actiongroup )
			loadGroup ( gparent, cobj );
		oclass = md->objClass ( cobj );
		if ( oclass == md_action )
			new ActionListViewItem( gparent, getLastChild(), md, cobj, QString::null );
		cobj = md->nextSibling ( cobj );
	}
};
Esempio n. 10
0
    ElementPtr Node::getLastChildElement() const
    {
      NodePtr found = getLastChild();
      while (found)
      {
        if (found->isElement())
          return found->toElement();

        found = found->getPreviousSibling();
      }
      return ElementPtr();
    }
Esempio n. 11
0
/** Return the last child Node from the current node,
 *  after applying filter, whatToshow.
 *  If result is not null, set the current Node.
 */
DOM_Node TreeWalkerImpl::lastChild () {

    DOM_Node result;

    if (fCurrentNode.isNull()) return result;

    DOM_Node node = getLastChild(fCurrentNode);
    if (! node.isNull()) {
        fCurrentNode = node;
    }
    return node;
}
Esempio n. 12
0
/** Return the last child Node from the current node,
 *  after applying filter, whatToshow.
 *  If result is not null, set the current Node.
 */
DOMNode* DOMTreeWalkerImpl::lastChild () {

    if (!fCurrentNode) return 0;

    if(!fExpandEntityReferences && fCurrentNode->getNodeType()==DOMNode::ENTITY_REFERENCE_NODE)
        return 0;

    DOMNode* node = getLastChild(fCurrentNode);
    if (node != 0) {
        fCurrentNode = node;
    }
    return node;
}
Esempio n. 13
0
//-----------------------------------------------------------------------------
// 
// VTrack::getPreviousEvent();
// 
// Returns the Event that the Track was last intergrating.
// 
//-----------------------------------------------------------------------------
VEvent *VTrack::getPreviousEvent( void )
{
    if ( mNextEvent )
    {
        return mNextEvent->getPreviousEvent();
    }

    if ( !isControllerPlayingForward() )
    {
        return dynamic_cast<VEvent*>( getChild() );
    }

    return dynamic_cast<VEvent*>( getLastChild() );
}
Esempio n. 14
0
Bool testlist::Parent::pushBackChild(const Child & child) const  {
    if(!child.isExists() || child.getParent().isValid())
        return false;
    Child last_child = getLastChild();
    child.setPrevParentChild(last_child);
    if(last_child.isValid())
        last_child.setNextParentChild(child);
    else
        setFirstChild(child);
    child.setNextParentChild(Child());
    setLastChild(child);
    setNumChilds(getNumChilds() + 1);
    child.setParent(*this);
    child.setupParentHandler();
    return true;
}
Esempio n. 15
0
void
ActionListViewItem::newAction ()
{
	aCfgItem			newobj;
	ActionListViewItem 	*newitem;
	QString 			oclass = md->objClass( obj );

	if ( oclass == md_actiongroup || oclass == md_actions )
	{
		setSelected( FALSE );
		setOpen( TRUE );
		newobj = md->insert( obj, md_action, QObject::tr("New Action") );
		newitem = new ActionListViewItem( this, getLastChild(), md, newobj );
		newitem->setSelected( TRUE );
		newitem->edit();
	};
}
Esempio n. 16
0
testlist::Child testlist::Parent::popBackChild() const  {
    Child result = getLastChild();
    if(result.isValid())
    {
        result.removeParentHandler();
        Child prev = result.getPrevParentChild();
        result.setPrevParentChild(Child());
        result.setNextParentChild(Child());
        setLastChild(prev);
        if(!prev.isValid())
            setFirstChild(Child());
        else
            prev.setNextParentChild(Child());
        setNumChilds(getNumChilds() - 1);
        result.setParent(Parent());
    }
    return result;
}
Esempio n. 17
0
void Container::_removeChild(const Ref & child) {
	if (child.isNull() || (child->getParent()!=this) ) {
		if(!child.isNull()){
			std::cout << "Container::_removeChild: Component is not a child. this:" <<this->getTypeName()<<" component:"<<child->getTypeName()<<"\n";
		}
		return;
	}
	if(child==getFirstChild()){
		firstChild = child->getNext();
	}
	if(child==getLastChild()){
		lastChild = child->getPrev();
	}

	child->_updateNeighbors(nullptr,nullptr);
	child->_setParent(nullptr);

	--contentsCount;
	childRectChanged(child.get());
	invalidateLayout();
}
Esempio n. 18
0
DOMElement * DOMElementImpl::getLastElementChild() const
{
    DOMNode* n = getLastChild();
    while (n != NULL) {
        switch (n->getNodeType()) {
            case DOMNode::ELEMENT_NODE:
                return (DOMElement*) n;
            case DOMNode::ENTITY_REFERENCE_NODE:
                {
                    DOMElement* e = getLastElementChild(n);
                    if (e != NULL)
                        return e;
                }
                break;
            default:
                break;
        }
        n = n->getPreviousSibling();
    }
    return NULL;
}
Esempio n. 19
0
void UIWidget::addChild(const UIWidgetPtr& child)
{
    if(!child) {
        g_logger.traceWarning("attempt to add a null child into a UIWidget");
        return;
    }

    if(child->isDestroyed()) {
        g_logger.traceWarning("attemp to add a destroyed child into a UIWidget");
        return;
    }

    if(hasChild(child)) {
        g_logger.traceWarning("attempt to add a child again into a UIWidget");
        return;
    }

    UIWidgetPtr oldLastChild = getLastChild();

    m_children.push_back(child);
    child->setParent(static_self_cast<UIWidget>());

    // create default layout
    if(!m_layout)
        m_layout = UIAnchorLayoutPtr(new UIAnchorLayout(static_self_cast<UIWidget>()));

    // add to layout and updates it
    m_layout->addWidget(child);

    // update new child states
    child->updateStates();

    // update old child index states
    if(oldLastChild) {
        oldLastChild->updateState(Fw::MiddleState);
        oldLastChild->updateState(Fw::LastState);
    }

    g_ui.onWidgetAppear(child);
}
Esempio n. 20
0
void
ActionListViewItem::loadTree()
{
	QString				oclass;
	aCfgItem			cobj;

	// clear tree
	clearTree();
	if ( !md ) return;
	setPixmap(0, rcIcon("actions.png"));
	cobj = md->firstChild ( obj );
	while ( !cobj.isNull() )
	{
		oclass = md->objClass ( cobj );
		if ( oclass == md_actiongroup )
			loadGroup ( this, cobj );
		oclass = md->objClass ( cobj );
		if ( oclass == md_action )
			new ActionListViewItem( this, getLastChild(), md, cobj, QString::null );
		cobj = md->nextSibling ( cobj );
	}
};
Esempio n. 21
0
DOMNode* DOMTreeWalkerImpl::getLastChild (DOMNode* node) {
	
    if (!node) return 0;

    if(!fExpandEntityReferences && node->getNodeType()==DOMNode::ENTITY_REFERENCE_NODE)
        return 0;

    DOMNode* newNode = node->getLastChild();
    if (!newNode)  return 0;

    short accept = acceptNode(newNode);

    if (accept == DOMNodeFilter::FILTER_ACCEPT)
        return newNode;
    else
    if (accept == DOMNodeFilter::FILTER_SKIP
        && newNode->hasChildNodes())
    {
        return getLastChild(newNode);
    }
    return getPreviousSibling(newNode);

}
Esempio n. 22
0
DOM_Node TreeWalkerImpl::getLastChild (DOM_Node node) {
	
	DOM_Node result;

    if (node.isNull()) return result;

    DOM_Node newNode = node.getLastChild();
    if (newNode.isNull())  return result;

    short accept = acceptNode(newNode);

    if (accept == DOM_NodeFilter::FILTER_ACCEPT)
        return newNode;
    else
    if (accept == DOM_NodeFilter::FILTER_SKIP
        && newNode.hasChildNodes())
    {
        return getLastChild(newNode);
    }
    return getPreviousSibling(newNode);


}
Esempio n. 23
0
Bool testlist::Parent::removeChild(const Child & child) const  {
    if( !child.isExists() || child.getParent() != *this)
        return false;
    child.removeParentHandler();
    Child next = child.getNextParentChild(), prev = child.getPrevParentChild();
    if(next.isValid())
        next.setPrevParentChild(prev);
    else if (getLastChild() == child)
        setLastChild(prev);
    else
        return false;
    if(prev.isValid())
        prev.setNextParentChild(next);
    else if (getFirstChild() == child)
        setFirstChild(next);
    else
        return false;
    child.setNextParentChild(Child());
    child.setPrevParentChild(Child());
    child.setParent(Parent());
    setNumChilds(getNumChilds() - 1);
    return true;
}
Esempio n. 24
0
DOM_Node TreeWalkerImpl::getPreviousSibling (DOM_Node node) {
		
	DOM_Node result;

    if (node.isNull() || node == fRoot) return result;

    DOM_Node newNode = node.getPreviousSibling();
    if (newNode.isNull()) {

        newNode = node.getParentNode();
        if (newNode.isNull() || node == fRoot)  return result;

        short parentAccept = acceptNode(newNode);

        if (parentAccept == DOM_NodeFilter::FILTER_SKIP) {
            return getPreviousSibling(newNode);
        }

        return result;
    }

    short accept = acceptNode(newNode);

    if (accept == DOM_NodeFilter::FILTER_ACCEPT)
        return newNode;
    else
    if (accept == DOM_NodeFilter::FILTER_SKIP) {
        DOM_Node fChild =  getLastChild(newNode);
        if (fChild.isNull()) {
            return getPreviousSibling(newNode);
        }
        return fChild;
    }
    return getPreviousSibling(newNode);

}
Esempio n. 25
0
 NodePtr Node::getLastChildChecked() const throw(Exceptions::CheckFailed)
 {
   NodePtr result = getLastChild();
   ZS_THROW_CUSTOM_IF(Exceptions::CheckFailed, !result)
   return result;
 }