nsresult nsTransactionItem::GetChild(PRInt32 aIndex, nsTransactionItem **aChild) { if (!aChild) return NS_ERROR_NULL_POINTER; *aChild = 0; PRInt32 numItems = 0; nsresult result = GetNumberOfChildren(&numItems); if (NS_FAILED(result)) return result; if (aIndex < 0 || aIndex >= numItems) return NS_ERROR_FAILURE; // Children are expected to be in the order they were added, // so the child first added would be at the bottom of the undo // stack, or if there are no items on the undo stack, it would // be at the top of the redo stack. result = GetNumberOfUndoItems(&numItems); if (NS_FAILED(result)) return result; if (numItems > 0 && aIndex < numItems) { if (!mUndoStack) return NS_ERROR_FAILURE; return mUndoStack->GetItem(aIndex, aChild); } // Adjust the index for the redo stack: aIndex -= numItems; result = GetNumberOfRedoItems(&numItems); if (NS_FAILED(result)) return result; if (!mRedoStack || numItems == 0 || aIndex >= numItems) return NS_ERROR_FAILURE; return mRedoStack->GetItem(numItems - aIndex - 1, aChild); }
void Tile::UpdateSprite(unsigned int aVariant) { //Safety check the variant index if(aVariant > GetVariantCount()) { return; } //Cycle through and remove all the children from the tile for (unsigned int i = 0; i < GetNumberOfChildren(); i++) { RemoveChild(GetChildAtIndex(i)); } //Get the atlas key for the sprite string atlasKey; GetAtlasKeyForVariant(aVariant, atlasKey); //Add the Sprite object as a child AddChild(new Sprite("MainAtlas", atlasKey), true); }
bool DelayAtomicSequence::Prepare (const PrepareMode mode) { bool b=true; double delay = 0.; ATTRIBUTE("Delay" , m_await_time); ATTRIBUTE("ADCs" , m_adc ); ATTRIBUTE("PhaseLock", m_phase_lock); ATTRIBUTE("StartSeq" , m_start ); ATTRIBUTE("StopSeq" , m_stop ); ATTRIBUTE("DelayType", m_delay_type); //insert pulse and module-attributes for observation only once if (mode == PREP_INIT) { //insert empty pulse if (GetNumberOfChildren()==0) b =InsertChild("EmptyPulse"); //add attributes to link with durations of other modules for (int i=0;i<20;i++) { char modules[10]; sprintf( modules, "Module%02d", i ) ; HIDDEN_ATTRIBUTE(modules, m_durations[i] ); } } //set delaytype for a quick later check in PREP_UPDATE if (mode != PREP_UPDATE) { if (m_delay_type == "B2E") m_dt = DELAY_B2E; if (m_delay_type == "C2E") m_dt = DELAY_C2E; if (m_delay_type == "B2C") m_dt = DELAY_B2C; if (m_delay_type == "C2C") m_dt = DELAY_C2C; } b = ( SearchStartStopSeq() && b); delay = GetDelay(mode); //std::cout << b << "+" << delay << "-" << std::endl; b = (delay >= 0.0 && b); if (GetNumberOfChildren()>0) { ((Pulse*) GetChild(0))->SetNADC(m_adc); //pass my ADCs to the EmptyPulse ((Pulse*) GetChild(0))->SetPhaseLock(m_phase_lock); ((Pulse*) GetChild(0))->SetDuration(delay); if (mode != PREP_UPDATE) ((Pulse*) GetChild(0))->SetName("eP_"+GetName()); } b = ( AtomicSequence::Prepare(mode) && b); // Hide XML attributes which were set by AtomicSequence::Prepare() // delay atoms don't need a rot-matrix. if (mode != PREP_UPDATE) { HideAttribute("RotAngle",false); HideAttribute("Inclination",false); HideAttribute("Azimut",false); } if (!b && mode == PREP_VERBOSE) cout << "Preparation of DelayAtomicSequence '" << GetName() << "' not succesful. Delay = " << delay << " ms" << endl; return b; }