nuiRect nuiZoomView::CalcIdealSize() { nuiRect rect; nuiSize HorizontalZoomLevel = mHorizontalZoomLevel; nuiSize VerticalZoomLevel = mVerticalZoomLevel; if (mpVerticalSlider) VerticalZoomLevel = mpVerticalSlider->GetRange().GetValue(); if (mpHorizontalSlider) HorizontalZoomLevel = mpHorizontalSlider->GetRange().GetValue(); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); nuiRect itemRect = pItem->GetIdealRect(); itemRect.SetSize(itemRect.GetWidth() * HorizontalZoomLevel, itemRect.GetHeight() * VerticalZoomLevel); rect.Union(rect, itemRect); } delete pIt; rect.mLeft = 0; rect.mTop = 0; mIdealRect = rect; return mIdealRect; }
bool nuiScrollView::Draw(nuiDrawContext* pContext) { nuiSize scrollv = (mpVertical->IsVisible() && !mForceNoVertical && !mVerticalIsExternal)?mBarSize:0; nuiSize scrollh = (mpHorizontal->IsVisible() && !mForceNoHorizontal && !mHorizontalIsExternal)?mBarSize:0; nuiRect rect(0.0f,0.0f,mRect.GetWidth()-scrollv, mRect.GetHeight()-scrollh); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); nuiRect intersect; if (intersect.Intersect(rect, pItem->GetOverDrawRect(true, true))) { DrawChild(pContext, pItem); } } delete pIt; if (GetDebug()) { pContext->SetStrokeColor(nuiColor("red")); pContext->DrawRect(GetRect().Size(), eStrokeShape); pContext->SetStrokeColor(nuiColor("blue")); pContext->DrawRect(GetIdealRect().Size(), eStrokeShape); pContext->SetStrokeColor("yellow"); float h = GetRect().GetHeight() - scrollh - 1; pContext->DrawLine(0, h, GetRect().GetWidth(), h); } return true; }
void nuiContainer::SilentInvalidateChildren(bool Recurse) { CheckValid(); IteratorPtr pIt; if (Recurse) { for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); nuiContainerPtr pCont = dynamic_cast<nuiContainerPtr>(pItem); if (pCont) pCont->SilentInvalidateChildren(Recurse); pItem->SilentInvalidate(); } } else { for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); pItem->SilentInvalidate(); } } delete pIt; }
void nuiToggleButton::SetDisplayAsFrameBox(bool set) { if (set) { mDisplayAsCheckBox = false; } mDisplayAsFrameBox = set; IteratorPtr pIt = GetFirstChild(); nuiLabel* pItem = dynamic_cast<nuiLabel*>(pIt->GetWidget()); if (pItem) { if (mDisplayAsCheckBox) { pItem->SetPosition(nuiLeft); } else { pItem->SetPosition(nuiCenter); } } delete pIt; InvalidateLayout(); }
bool nuiContainer::DrawChildren(nuiDrawContext* pContext) { CheckValid(); IteratorPtr pIt; if (mReverseRender) { for (pIt = GetLastChild(); pIt && pIt->IsValid(); GetPreviousChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem) DrawChild(pContext, pItem); } delete pIt; } else { for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem) DrawChild(pContext, pItem); } delete pIt; } return true; }
void Document::CreateKeys() { IteratorPtr<Symbol<double>*> iter = _calculator->GetSymbols(); float min = MIN(_size.GetWidth(),_size.GetHeight()); float edgeLength = (int)((float)min/((float)COL)); float xStart = 0,yStart = 0; wxPoint pos(xStart,yStart); int colCount = 1; for(iter->First();!iter->IsDone();iter->Next()) { Key *key = new Key(pos,edgeLength,iter->Current()); _keys.push_back(key); if(colCount>=COL) { pos.x = xStart; pos.y += edgeLength; colCount = 1; } else { colCount++; pos.x += edgeLength; } } }
nuiContainer::IteratorPtr nuiContainer::GetChildIterator(nuiWidgetPtr pChild, bool DoRefCounting) { CheckValid(); IteratorPtr pIt = GetFirstChild(DoRefCounting); while (pIt->IsValid() && pIt->GetWidget() != pChild) GetNextChild(pIt); return pIt; }
bool nuiContainer::DispatchMouseUnclick(const nglMouseInfo& rInfo) { CheckValid(); nuiAutoRef; if (!mMouseEventEnabled || mTrashed) return false; bool hasgrab = HasGrab(rInfo.TouchId); if (IsDisabled() && !hasgrab) return false; nglMouseInfo info(rInfo); GlobalToLocal(info.X, info.Y); // Get a chance to preempt the mouse event before the children get it: if (PreMouseUnclicked(info)) { Ungrab(); return true; } if (IsInsideFromRoot(rInfo.X, rInfo.Y) || hasgrab) { if (!hasgrab) { IteratorPtr pIt; for (pIt = GetLastChild(false); pIt && pIt->IsValid(); GetPreviousChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem) { if (IsEnabled()) { if ((pItem)->DispatchMouseUnclick(rInfo)) { delete pIt; return true; } } } } delete pIt; } bool res = PreUnclicked(info); if (!res) { res = MouseUnclicked(info); res |= Unclicked(info); } res = res | (!mClickThru); if (res) Ungrab(); return res; } return false; }
void SearchSpaceTimerEvaluatorImpl<T>::releaseResultIter(IteratorPtr<LookupResult<T> >& pFindResultIter) { while(pFindResultIter != NullPtr && !pFindResultIter->isDone()) { T element = pFindResultIter->getObj().m_resultElement; pFindResultIter->next(); _destroy(element); } _destroy(pFindResultIter); pFindResultIter = NullPtr; }
nuiContainer::Iterator* nuiSimpleContainer::GetFirstChild(bool DoRefCounting) { CheckValid(); IteratorPtr pIt; pIt = new nuiSimpleContainerIterator(this, DoRefCounting); bool valid = !mpChildren.empty(); pIt->SetValid(valid); if (valid) ((nuiSimpleContainerIterator*)pIt)->SetIndex(0); return pIt; }
void nuiContainer::CallDisconnectTopLevel(nuiTopLevel* pTopLevel) { CheckValid(); nuiWidget::CallDisconnectTopLevel(pTopLevel); IteratorPtr pIt; for (pIt = GetFirstChild(true); pIt && pIt->IsValid(); GetNextChild(pIt)) { pIt->GetWidget()->CallDisconnectTopLevel(pTopLevel); } delete pIt; }
void nuiContainer::SetChildrenLayoutAnimationDuration(float duration) { CheckValid(); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); pItem->SetLayoutAnimationDuration(duration); } delete pIt; }
void nuiContainer::SetChildrenLayoutAnimationEasing(const nuiEasingMethod& rMethod) { CheckValid(); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); pItem->SetLayoutAnimationEasing(rMethod); } delete pIt; }
uint nuiList::GetUnselected(nuiWidgetList& unselitems) { IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (!pItem->IsSelected()) unselitems.push_back(pItem); } delete pIt; return unselitems.size(); }
void nuiContainer::ChildrenCallOnTrash() { CheckValid(); IteratorPtr pIt; for (pIt = GetFirstChild(false); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem) pItem->CallOnTrash(); } delete pIt; }
nuiWidgetPtr nuiContainer::GetChild(const nglString& rName, bool ResolveNameAsPath) { CheckValid(); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem->GetObjectName() == rName) { delete pIt; return pItem; } } delete pIt; if (!ResolveNameAsPath) // Are we allowed to search the complete tree? return NULL; nuiWidgetPtr pNode = this; nglString name = rName; if (name[0] == '/') { // Get the root of the tree: pNode = GetRoot(); name.DeleteLeft(1); // Remove the '/' } // Get all the nodes and remove the slashes: std::vector<nglString> tokens; name.Tokenize(tokens, _T('/')); size_t i; size_t count = tokens.size(); for (i = 0; i < count; i++) { nglString& rTok = tokens[i]; //Node* pOld = pNode; if (rTok == _T("..")) pNode = pNode->GetParent(); else pNode = pNode->GetChild(rTok, false); if (!pNode) { //NUI_OUT("Tried to find %s on %s", rTok.GetChars(), pOld->GetParamCString(ParamIds::Name)); return NULL; } } return pNode; }
void nuiContainer::InternalResetCSSPass() { CheckValid(); nuiWidget::InternalResetCSSPass(); IteratorPtr pIt = GetFirstChild(false); for (; pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); pItem->ResetCSSPass(); } delete pIt; }
bool nuiContainer::DrawChildren(nuiDrawContext* pContext) { CheckValid(); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem) DrawChild(pContext, pItem); } delete pIt; return true; }
nuiRect nuiFixed::CalcIdealSize() { mIdealRect = nuiRect(); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); mIdealRect.Union(mIdealRect,pItem->GetIdealRect()); } delete pIt; mIdealRect.mLeft = 0; mIdealRect.mTop = 0; return mIdealRect; }
nuiWidgetPtr nuiList::GetItem(nuiSize X,nuiSize Y) { IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem->GetRect().IsInside(X,Y)) { delete pIt; return pItem; } } delete pIt; return NULL; }
bool nuiButton::SetRect(const nuiRect& rRect) { nuiWidget::SetRect(rRect); nuiRect Rect = rRect.Size(); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem) pItem->SetLayout(Rect); } delete pIt; return true; }
nuiWidget* nuiList::GetSelected () { IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem->IsSelected()) { delete pIt; return pItem; } } delete pIt; return NULL; }
void nuiList::SelectItemSilent(uint ItemNumber) { nuiWidgetPtr pItem = NULL; int32 i = 0; IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid() && i <= ItemNumber; GetNextChild(pIt)) { pItem = pIt->GetWidget(); i++; } delete pIt; if (pItem && i == ItemNumber+1) SelectItemSilent(pItem); }
bool nuiWindowManager::DispatchMouseClick(const nglMouseInfo& rInfo) { if (!IsEnabled()) return false; if (IsInsideFromRoot(rInfo.X, rInfo.Y)) { if (!mWindows.empty()) { std::list<nuiWindow*>::iterator it; std::list<nuiWindow*>::iterator begin = mWindows.begin(); it = mWindows.end(); do { it--; nuiWindow* win = *it; if (win->IsInsideFromRoot(rInfo.X, rInfo.Y)) { if (GetActiveWindow() != win) ActivateWindow(win); break; } } while (it!=begin); } IteratorPtr pIt; for (pIt = GetLastChild(); pIt && pIt->IsValid(); GetPreviousChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem && pItem->IsVisible() && pItem->IsEnabled()) { if (pItem->DispatchMouseClick(rInfo)) { delete pIt; return true; } } } delete pIt; nglMouseInfo info(rInfo); GlobalToLocal(info.X, info.Y); bool ret = MouseClicked(info); ret |= Clicked(info); return ret; } return false; }
bool nuiFixed::SetRect(const nuiRect& rRect) { nuiWidget::SetRect(rRect); IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); nuiRect rect = pItem->GetIdealRect(); pItem->SetLayout(rect); } delete pIt; return true; }
nuiTokenBase* nuiList::GetSelectedToken () { IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem->IsSelected()) { nuiTokenBase* token = pItem->GetToken(); delete pIt; return token; } } delete pIt; return NULL; }
nuiWindow* nuiWindowManager::GetWindow(nuiSize X, nuiSize Y, bool ClientAreaOnly) { IteratorPtr pIt; for (pIt = GetLastChild(); pIt && pIt->IsValid(); GetPreviousChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem && pItem->IsInsideFromParent(X,Y)) { delete pIt; return (nuiWindow*)pItem; } } delete pIt; return NULL; }
nuiContainer::Iterator* nuiSimpleContainer::GetLastChild(bool DoRefCounting) { CheckValid(); IteratorPtr pIt; pIt = new nuiSimpleContainerIterator(this, DoRefCounting); if (!mpChildren.empty()) { ((nuiSimpleContainerIterator*)pIt)->SetIndex(mpChildren.size() - 1); pIt->SetValid(true); } else { pIt->SetValid(false); } return pIt; }
bool nuiWindowManager::DispatchMouseUnclick(const nglMouseInfo& rInfo) { //OUT("OnMouseUnclick\n"); IteratorPtr pIt; for (pIt = GetLastChild(); pIt && pIt->IsValid(); GetPreviousChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem && pItem->IsVisible() && pItem->IsEnabled()) { if (pItem->DispatchMouseUnclick(rInfo)) return true; } } delete pIt; return nuiSimpleContainer::DispatchMouseUnclick(rInfo); }
nuiSimpleContainer::~nuiSimpleContainer() { CheckValid(); // Delete all children: IteratorPtr pIt; for (pIt = GetFirstChild(false); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem) { if (!pItem->IsTrashed(false)) pItem->SetParent(NULL); pItem->Release(); } } delete pIt; }