Exemplo n.º 1
0
void NodeRemovedFromDocument(Node* node)
{
	NodeList* childNodes = node->get_childNodes();

	unsigned int length = childNodes->get_length();

	for (unsigned int i = 0; i < length; ++i)
	{
		Node* child = childNodes->item(i);

		NodeRemovedFromDocument(child);
	}

	Document* ownerDocument = node->get_ownerDocument();

	DocumentEvent* ownerDocumentEvent = dynamic_cast<DocumentEvent*>(ownerDocument);
	ASSERT(ownerDocumentEvent != nullptr);

	MutationEvent* event = dynamic_cast<MutationEvent*>(ownerDocumentEvent->createEvent(S("MutationEvent")));

	event->initMutationEvent(S("DOMNodeRemovedFromDocument"), false, false, NULL/*relatedNode*/, nullptr, nullptr, nullptr, CHANGE_UNKNOWN);

	EventTarget* target = dynamic_cast<EventTarget*>(node);

	target->dispatchEvent(event);
}
Exemplo n.º 2
0
void DocumentView::onAddFrame(DocumentEvent& ev)
{
  if (current_editor == m_editor)
    m_editor->setFrame(ev.frame());
  else if (m_editor->getFrame() > ev.frame())
    m_editor->setFrame(m_editor->getFrame().next());
}
Exemplo n.º 3
0
void DocumentView::onAddLayer(DocumentEvent& ev)
{
  if (current_editor == m_editor) {
    ASSERT(ev.layer() != NULL);
    m_editor->setLayer(ev.layer());
  }
}
Exemplo n.º 4
0
void DocumentView::onRemoveLayer(DocumentEvent& ev)
{
  Sprite* sprite = ev.sprite();
  Layer* layer = ev.layer();

  // If the layer that was removed is the selected one
  if (layer == m_editor->getLayer()) {
    LayerFolder* parent = layer->getParent();
    Layer* layer_select = NULL;

    // Select previous layer, or next layer, or the parent (if it is
    // not the main layer of sprite set).
    if (layer->getPrevious())
      layer_select = layer->getPrevious();
    else if (layer->getNext())
      layer_select = layer->getNext();
    else if (parent != sprite->getFolder())
      layer_select = parent;

    m_editor->setLayer(layer_select);
  }
}
Exemplo n.º 5
0
void DocumentView::onRemoveFrame(DocumentEvent& ev)
{
  // Adjust current frame of all editors that are in a frame more
  // advanced that the removed one.
  if (m_editor->getFrame() > ev.frame()) {
    m_editor->setFrame(m_editor->getFrame().previous());
  }
  // If the editor was in the previous "last frame" (current value of
  // getTotalFrames()), we've to adjust it to the new last frame
  // (getLastFrame())
  else if (m_editor->getFrame() >= m_editor->getSprite()->getTotalFrames()) {
    m_editor->setFrame(m_editor->getSprite()->getLastFrame());
  }
}
Exemplo n.º 6
0
void NodeInsertedIntoDocument(Node* node)
{
	NodeList* childNodes = node->get_childNodes();
	long length = childNodes->get_length();

	for (int i = 0; i < length; ++i)
	{
		Node* child = childNodes->item(i);

		NodeInsertedIntoDocument(child);
	}

	Document* ownerDocument = node->get_ownerDocument();

	DocumentEvent* ownerDocumentEvent = dynamic_cast<DocumentEvent*>(ownerDocument);
	ASSERT(ownerDocumentEvent != nullptr);

	MutationEvent* pEvent = dynamic_cast<MutationEvent*>(ownerDocumentEvent->createEvent(S("MutationEvent")));
	pEvent->initMutationEvent(S("DOMNodeInsertedIntoDocument"), false, false, nullptr/*relatedNode*/, nullptr, nullptr, nullptr, CHANGE_UNKNOWN);

	EventTarget* target = dynamic_cast<EventTarget*>(node);

	target->dispatchEvent(pEvent);
}
Exemplo n.º 7
0
 // DocumentObserver impl
 void onCelOpacityChange(DocumentEvent& ev) override {
   if (m_cel == ev.cel())
     updateFromCel();
 }
Exemplo n.º 8
0
void Attr::set_value(StringIn newVal)
{
	String prevValue = nullptr;
	if (false)
	{
		prevValue = get_value();
	}

	m_valueIsValid = true;

// Optimize if there is one single textnode already there
	Text* textNode;
#if 0
	CComQIPtr<ILDOMText, &IID_ILDOMText> textNode;
	if ((m_childNodes->m_items.GetSize() == 1) && (textNode = m_childNodes->m_items[0]))
	{
		textNode->set_data(newVal);
	}
	else
#endif
	{
		for (int i = m_childNodes->m_items.GetSize()-1; i >= 0; i--)
		{
			removeChild(m_childNodes->m_items[i]);
		}

		textNode = m_ownerDocument->createTextNode(newVal);
		appendChild(textNode);
	}

#if 0
	ASSERT(m_callbacks);
	(m_ownerElement->*m_callbacks->SetBaseValString)();
#endif
	if (m_owner)
	{
		m_owner->UpdateBaseValString();
	}

//	m_callbacks->SetBaseValString(m_ownerElement);
//	m_notify->OnSetBaseValString();

	/*
	if (m_pListener)
	{
		m_pListener->OnAttrValueChanged(m_nodeName, this);
	}
	*/

	if (false)
	{
		EventTarget* eventTarget = dynamic_cast<EventTarget*>(m_ownerElement);
		if (eventTarget)
		{
			DocumentEvent* ownerDocumentEvent = dynamic_cast<DocumentEvent*>(m_ownerDocument);
			if (ownerDocumentEvent)
			{
				MutationEvent* evt;
				
				evt = dynamic_cast<MutationEvent*>(ownerDocumentEvent->createEvent(WSTR("MutationEvent")));

				if (evt)
				{
				// Create an attr modification event
					evt->initMutationEvent(WSTR("DOMAttrModified"), true, false, this, prevValue, newVal, m_nodeName, CHANGE_MODIFICATION);

					eventTarget->dispatchEvent(evt);
				}
			}
		}
	}
}
Exemplo n.º 9
0
void DocumentView::onLayerMergedDown(DocumentEvent& ev)
{
  m_editor->setLayer(ev.targetLayer());
}
Exemplo n.º 10
0
void DocumentView::onSpritePixelsModified(DocumentEvent& ev)
{
  if (m_editor->isVisible())
    m_editor->drawSpriteClipped(ev.region());
}
Exemplo n.º 11
0
Node* Node::removeChild(Node *oldChild)
{
	//ASSERT(0);
#if 0
	// Do this first?
	{
		CComQIPtr<INotifySend> cp = thisNode;
		if (cp)
		{
			cp->FireOnChanged(NOTIFY_REMOVE, oldChild, DISPID_UNKNOWN);
		}
	}
#endif

	Document* ownerDocument = oldChild->get_ownerDocument();

	if (ownerDocument)
	{
		ASSERT(ownerDocument != NULL);

		DocumentEvent* ownerDocumentEvent = dynamic_cast<DocumentEvent*>(ownerDocument);
		ASSERT(ownerDocumentEvent != NULL);

		MutationEvent* evt = dynamic_cast<MutationEvent*>(ownerDocumentEvent->createEvent(S("MutationEvent")));

	// Create a DOMNodeRemoved event
		evt->initMutationEvent(S("DOMNodeRemoved"), true, false, this, nullptr, nullptr, nullptr, CHANGE_UNKNOWN);

		EventTarget* target = dynamic_cast<EventTarget*>(oldChild);
		target->dispatchEvent(evt);

		NodeRemovedFromDocument(oldChild);
	}

// Do the work
	ChildNode* previous = oldChild->get_previousSibling();

	ChildNode* next = oldChild->get_nextSibling();

	if (previous != NULL)
		previous->set_nextSibling(next);
	else
		m_firstChild = next;

	if (next != NULL)
		next->set_previousSibling(previous);
	else
		m_lastChild = previous;

	oldChild->set_previousSibling(nullptr);
	oldChild->set_nextSibling(nullptr);

	for (int i = 0; i < m_childNodes->m_items.GetSize(); ++i)
	{
		if (m_childNodes->m_items[i] == oldChild)
		{
#if 0
			ASSERT(0);
			/////////
			CComQIPtr<INotifySend, &IID_INotifySend> cp = (IUnknown*)oldChild;
			if (cp)
			{
				CComQIPtr<INotifyGet, &IID_INotifyGet> get = (IUnknown*)thisNode;
				if (get)
				{
					cp->Unadvise(get);
				}
			}
#endif
			/////////

		//	m_childNodes->m_items.erase(&m_childNodes->m_items[i]);
			m_childNodes->m_items.RemoveAt(i);
			break;
		}
	}

	oldChild->set_parentNode(NULL);

	return oldChild;
}
Exemplo n.º 12
0
Node* Node::insertNode(Node* _newChild, Node* _pBefore)
{
	ChildNode* newChild = dynamic_cast<ChildNode*>(_newChild);
	ChildNode* pBefore = dynamic_cast<ChildNode*>(_pBefore);

	Node* pPrevParent = newChild->get_parentNode();
	if (pPrevParent)
	{
		pPrevParent->removeChild(newChild);
	}

	ChildNode* pAfter;

	if (pBefore)
		pAfter = pBefore->get_previousSibling();
	else
		pAfter = m_lastChild;

	newChild->set_nextSibling(pBefore);
	newChild->set_previousSibling(pAfter);

	if (pAfter == NULL)
		m_firstChild = newChild;
	else
		pAfter->set_nextSibling(newChild);

	if (pBefore == NULL)
		m_lastChild = newChild;
	else
		pBefore->set_previousSibling(newChild);

	if (pBefore)
	{
		for (int i = 0; i < m_childNodes->m_items.GetSize(); i++)
		{
			if (m_childNodes->m_items[i] == pBefore)
			{
				m_childNodes->m_items.InsertAt(i, newChild);
			//	m_childNodes->m_items.insert(&m_childNodes->m_items[i], newChild);
				break;
			}
		}
	}
	else
	{
		m_childNodes->m_items.Add(newChild);
	}

// Set new child node's parent to this element
	newChild->set_parentNode(this);

//	TRACE("TODO\n");
#if 0
// Update computed xmlspace for inserted child(ren)
	CComQIPtr<ILDOMElement> newElement((IUnknown*)newChild);
	if (newElement)
	{
		CComBSTR xmlspace;
		newElement->getAttribute(OLESTR("xml:space"), &xmlspace);
		if (xmlspace.Length()==0)	// inherit from parent
		{
			CComQIPtr<CLDOMElementImplImpl>((IUnknown*)newChild)->m_xmlspace = m_xmlspace;
		}
		else	// explicitly set
		{
			CComQIPtr<CLDOMElementImplImpl>((IUnknown*)newChild)->m_xmlspace = cmpbstr(xmlspace, OLESTR("preserve")) == 0;
		}
	// TODO, update recursively for newChild
	}
#endif
	// SMIL Animation (TODO, not very well thought trough)
#if 0
	{
		CLDOMDocument* pDocument = static_cast<CLDOMDocument*>(static_cast<CLDOMDocumentImpl<ILDOMDocument>*>(m_ownerDocument));

		if (pDocument)
		{
			CComQIPtr<ILDOMElement> newElement = newChild;

			if (newElement)
			{
			// SMIL Animation (connect animate/set etc. elements to the elements they target)
				pDocument->BuildAnimationListForAllElements(newElement, pDocument->m_documentElement);

			// Set baseVal/animVal from attributes and parse 'style' attributes
				pDocument->UpdateAnimationElements(newElement);
			}
		}
	}
#endif

//	TRACE("TODO\n");
#if 0
	// Timing stuff (TODO)
	{
		ElementTimeImplImpl* elementTimeImpl((IUnknown*)newChild);
		if (elementTimeImpl)
		{
			elementTimeImpl->CalculateTimeBeforeParent();

			CComPtr<ILElementTimeContainer> parentTimeContainer;
			elementTimeImpl->get_parentTimeContainer(&parentTimeContainer);
			CComQIPtr<CLElementTimeContainerImplImpl> parentTimeContainerImpl((IUnknown*)parentTimeContainer);
			if (parentTimeContainerImpl)
			{
				parentTimeContainerImpl->RecalculateTime();
			}

			elementTimeImpl->CalculateTimeAfterParent();
		}
	}

	CComQIPtr<ILAnimationElement, &IID_ILAnimationElement> animation = (IUnknown*)newChild;
	if (animation)
	{
		CComQIPtr<CLAnimationElementImplImpl> pAnimation((IUnknown*)animation);

		pAnimation->SetValuesFromAttributes();
	}
#endif

	{
#if 0	// TODO
		for (int i = 0; i < m_pNodes.GetSize(); i++)
		{
			ASSERT(0);
			m_pNodes[i]->OnInsertedChild(newChild);
		}
#endif

#if 0
		if (TRUE)	// TODO, probably remove this (use above loop only)
		{
			CComQIPtr<INotifySend, &IID_INotifySend> cp = newChild;
			if (cp)
			{
				CComQIPtr<INotifyGet, &IID_INotifyGet> get = (IUnknown*)thisNode;
				if (get)
				{
					DWORD cookie;
					cp->Advise(get, &cookie);
				}

				cp->FireOnChanged(NOTIFY_ADD, newChild, DISPID_UNKNOWN);
			}
		}
#endif
	}

//	CComPtr<ILDOMDocument> ownerDocument;
//	newChild->get_ownerDocument(&ownerDocument);
//	if (ownerDocument)
	{
////////////////////////////////
// create an event notification

		DocumentEvent* ownerDocumentEvent = dynamic_cast<DocumentEvent*>(m_ownerDocument);

		if (ownerDocumentEvent == NULL)
			ownerDocumentEvent = dynamic_cast<DocumentEvent*>(this);

		if (ownerDocumentEvent)
		{
			MutationEvent* event = dynamic_cast<MutationEvent*>(ownerDocumentEvent->createEvent(S("MutationEvent")));

			EventTarget* eventTarget = dynamic_cast<EventTarget*>(newChild);

		//
			event->initMutationEvent(S("DOMNodeInserted"), true, false, this, nullptr, nullptr, nullptr, CHANGE_UNKNOWN);

			bool doDefault = eventTarget->dispatchEvent(event);

			if (IsDocumentOrPartOfDocument(this))
			{
			// Send "DOMNodeInsertedIntoDocument" to the node and it's children
				NodeInsertedIntoDocument(newChild);
			}
		}

		{
			Node* p = this;
			while (p)
			{
				if (p->m_pNode)
				{
					p->m_pNode->m_bArrangeValid = false;
				}

				p = p->get_parentNode();
			}
		}

#if 0
	//
		event->initMutationEvent(OLESTR("DOMSubtreeModified"), VARIANT_TRUE, VARIANT_FALSE, thisNode, NULL, NULL, NULL, CHANGE_UNKNOWN);
		eventTarget->dispatchEvent(event, &doDefault);
#endif
	}

	return newChild;
}