void UIList::AddCellAtPos(UIListCell *cell, int32 pos, int32 size, int32 index) { DVASSERT(cell); DVASSERT(cell->cellStore == NULL || cell->cellStore == this); DVASSERT(index >= 0); if(!cell->cellStore) { cell->cellStore = this; cell->AddEvent(EVENT_TOUCH_UP_INSIDE, Message(this, &UIList::OnSelectEvent)); Vector<UIListCell*> *store = GetStoreVector(cell->identifier); if(!store) { store = new Vector<UIListCell*>; cellStore[cell->identifier] = store; } store->push_back(cell); } cell->currentIndex = index; Rect r = cell->GetRect(); if(orientation == ORIENTATION_HORIZONTAL) { r.dx = (float32)size; r.x = (float32)pos; } else { r.dy = (float32)size; r.y = (float32)pos; } cell->SetRect(r); scrollContainer->AddControl(cell); }
void UIHierarchy::AddCellAtPos(UIHierarchyCell *cell, int32 pos, int32 size, UIHierarchyNode *node) { DVASSERT(cell); DVASSERT(cell->cellStore == NULL || cell->cellStore == this); if(!cell->cellStore) { cell->cellStore = this; cell->AddEvent(EVENT_TOUCH_UP_INSIDE, Message(this, &UIHierarchy::OnSelectEvent)); cell->openButton->AddEvent(EVENT_TOUCH_UP_INSIDE, Message(this, &UIHierarchy::OnOpenPressedEvent)); Vector<UIHierarchyCell*> *store = GetStoreVector(cell->identifier); if(!store) { store = new Vector<UIHierarchyCell*>; cellStore[cell->identifier] = store; } store->push_back(cell); } cell->node = node; cell->RemoveControl(cell->openButton); if (node->hasChildren) { cell->AddControl(cell->openButton); } cell->size.y = (float32)size; cell->relativePosition.y = (float32)pos; cell->relativePosition.x = (float32)cell->node->nodeLevel * shiftWidth; scrollContainer->AddControl(cell); }
UIListCell* UIList::GetReusableCell(const String &cellIdentifier) { Vector<UIListCell*> *store = GetStoreVector(cellIdentifier); if(!store) { return NULL; } for(Vector<UIListCell*>::iterator it = store->begin(); it != store->end(); it++) { if((*it)->GetIndex() == -1) { return (*it); } } return NULL; }
UIHierarchyCell* UIHierarchy::GetReusableCell(const String &cellIdentifier) { Vector<UIHierarchyCell*> *store = GetStoreVector(cellIdentifier); if(!store) { return NULL; } for(Vector<UIHierarchyCell*>::iterator it = store->begin(); it != store->end(); it++) { if((*it)->node == NULL) { return (*it); } } return NULL; }