Example #1
0
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;
}
Example #2
0
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;
}
Example #3
0
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;
}
Example #4
0
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(); 
}
Example #5
0
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;
}
Example #6
0
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;
		}
	}
}
Example #7
0
nuiContainer::IteratorPtr nuiContainer::GetChildIterator(nuiWidgetPtr pChild, bool DoRefCounting)
{
  CheckValid();
  IteratorPtr pIt = GetFirstChild(DoRefCounting);
  while (pIt->IsValid() && pIt->GetWidget() != pChild)
    GetNextChild(pIt);
  return pIt;
}
Example #8
0
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;
}
Example #10
0
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;
}
Example #11
0
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;
}
Example #12
0
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;
}
Example #13
0
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;
}
Example #14
0
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();
}
Example #15
0
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;  
}
Example #16
0
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;
}
Example #17
0
void nuiContainer::InternalResetCSSPass()
{
  CheckValid();
  nuiWidget::InternalResetCSSPass();
  
  IteratorPtr pIt = GetFirstChild(false);
  for (; pIt && pIt->IsValid(); GetNextChild(pIt))
  {
    nuiWidgetPtr pItem = pIt->GetWidget();
    pItem->ResetCSSPass();
  }
  delete pIt;
}
Example #18
0
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;
}
Example #19
0
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;
}
Example #20
0
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;
}
Example #21
0
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;
}
Example #22
0
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;
}
Example #23
0
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);
}
Example #24
0
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;
}
Example #25
0
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;

}
Example #26
0
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;
}
Example #27
0
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;
}
Example #28
0
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;
}
Example #29
0
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);
}
Example #30
0
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;
}