/*---------------------------------------------------------------------- Set the value of a string attribute ----------------------------------------------------------------------*/ void SetAttributeStringValue (Element el, int att, const char* value) { #ifdef TEMPLATES Document doc = TtaGetDocument(el); AttributeType attType; Attribute attribute; if (doc == 0 || !TtaGetDocumentAccessMode(doc)) return; attType.AttrSSchema = TtaGetElementType(el).ElSSchema; attType.AttrTypeNum = att; attribute = TtaGetAttribute(el, attType); if (attribute == NULL) { attribute = TtaNewAttribute (attType); TtaAttachAttribute(el, attribute, doc); } TtaSetAttributeText(attribute, value, el, doc); #endif /* TEMPLATES */ }
/*---------------------------------------------------------------------- Set the value of a int attribute and registering it in undo sequence if wanted ----------------------------------------------------------------------*/ void SetAttributeIntValue (Element el, int att, int value, ThotBool undo) { #ifdef TEMPLATES Document doc = TtaGetDocument(el); AttributeType attType; Attribute attribute; if (doc == 0 || !TtaGetDocumentAccessMode(doc)) return; attType.AttrSSchema = TtaGetElementType(el).ElSSchema; attType.AttrTypeNum = att; attribute = TtaGetAttribute(el, attType); if (attribute == NULL) { attribute = TtaNewAttribute (attType); TtaAttachAttribute(el, attribute, doc); if (undo) TtaRegisterAttributeCreate(attribute, el, doc); } TtaSetAttributeValue(attribute, value, el, doc); if (undo) TtaRegisterAttributeReplace(attribute, el, doc); #endif /* TEMPLATES */ }
/*---------------------------------------------------------------------- RemoveCurrentAttribut params: returns: ----------------------------------------------------------------------*/ void AmayaAttributeToolPanel::RemoveCurrentAttribute() { PtrElement pEl; Attribute attr; AttributeType attrType; NotifyAttribute notifyAttr; int kind; Document doc = TtaGetDocument((Element)m_firstSel); DisplayMode mode = TtaGetDisplayMode(doc); DesactivatePanel(); if (m_currentPane != wxATTR_PANEID_NONE && m_firstSel && m_currentAttElem && m_currentAttElem->val) { TtaSetDisplayMode(doc, DeferredDisplay); TtaOpenUndoSequence(doc, (Element)m_firstSel, (Element)m_lastSel, m_firstChar, m_lastChar); /* first selected element */ pEl = (PtrElement)m_firstSel; attr = (Attribute)m_currentAttElem->val; TtaGiveAttributeType (attr, &attrType, &kind); /* prepare event AttrDelete to be sent to the application */ notifyAttr.event = TteAttrDelete; notifyAttr.document = doc; notifyAttr.info = 0; /* not sent by undo */ notifyAttr.attributeType = attrType; while (pEl != NULL) { if (attr) { notifyAttr.element = (Element) pEl; notifyAttr.attribute = attr; if (!CallEventAttribute (¬ifyAttr, TRUE)) /* application accepts */ { TtaRegisterAttributeDelete(attr, (Element)pEl, doc); TtaRemoveAttribute((Element)pEl, attr, doc); TtaSetDocumentModified(doc); /* send event Attribute deleted */ notifyAttr.attribute = NULL; CallEventAttribute (¬ifyAttr, FALSE); } } /* next element in the selection */ pEl = NextInSelection (pEl, (PtrElement)m_lastSel); attr = TtaGetAttribute ((Element)pEl, attrType); } TtaCloseUndoSequence(doc); TtaSetDisplayMode(doc, mode); ForceAttributeUpdate(); } ActivePanel(); /* try to redirect focus to canvas */ TtaRedirectFocus(); }