示例#1
0
OGRErr OGR_SRSNode::applyRemapper( const char *pszNode, 
                                   char **papszSrcValues, 
                                   char **papszDstValues, 
                                   int nStepSize, int bChildOfHit )

{
    int i;

/* -------------------------------------------------------------------- */
/*      Scan for value, and replace if our parent was a "hit".          */
/* -------------------------------------------------------------------- */
    if( bChildOfHit || pszNode == NULL )
    {
        for( i = 0; papszSrcValues[i] != NULL; i += nStepSize )
        {
            if( EQUAL(papszSrcValues[i],pszValue) && 
                ! EQUAL(papszDstValues[i],"") )
            {
                SetValue( papszDstValues[i] );
                break;
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Are the the target node?                                        */
/* -------------------------------------------------------------------- */
    if( pszNode != NULL )
        bChildOfHit = EQUAL(pszValue,pszNode);

/* -------------------------------------------------------------------- */
/*      Recurse                                                         */
/* -------------------------------------------------------------------- */
    for( i = 0; i < GetChildCount(); i++ )
    {
        GetChild(i)->applyRemapper( pszNode, papszSrcValues, 
                                    papszDstValues, nStepSize, bChildOfHit );
    }

    return OGRERR_NONE;
}
示例#2
0
文件: GeomList.cpp 项目: geomview/gv2
// Write the List in OOGL format.
int GeomList::Save(char *indent, IoDataStream *s)
{
  const char *INDENT = indent ? indent : "";
  s->PrintF("%sLIST", INDENT);
  if (mpName) { s->PrintF("  # %s", mpName); }
  s->PrintF("\n");
  int i, n = GetChildCount();
  char buffer[1024], *NEWINDENT;
  if (indent) {
    sprintf(buffer, "%s  ", indent);
    NEWINDENT = buffer;
  } else {
    NEWINDENT = NULL;
  }
  for (i = 0; i < n; i++) {
    s->PrintF("%s{\n", INDENT);
    mGeomList[i]->Save(NEWINDENT, s);
    s->PrintF("%s}\n", INDENT);
  }
  return !s->error();
}
bool 
StorageCollectionSparePool::BuildYourValueSet(){
	
	U32					i;
	StorageElement		*pElement;
	DesignatorId		id;

	// collect your size
	m_capacity = 0;
	for( i = 0; i < GetChildCount(); i++ ){
		pElement = (StorageElement *)GetChild( i );
		m_capacity += pElement->GetCapacity();
	}
	
	
	StorageCollection::BuildYourValueSet();

	AddGenericValue( (char *)&m_dedicatedHostId, sizeof(m_dedicatedHostId), SSAPI_STORAGE_COLL_SPAREPOOL_FID_HOST_ID );

	return true;
}
JBoolean
JNamedTreeNode::FindNamedChild
	(
	const JCharacter*		name,
	const JNamedTreeNode**	node
	)
	const
{
	const JSize count = GetChildCount();
	for (JIndex i=1; i<=count; i++)
		{
		*node = GetNamedChild(i);
		if ((**node).GetName() == name)
			{
			return kJTrue;
			}
		}

	*node = NULL;
	return kJFalse;
}
JBoolean
JFSFileTreeNodeBase::Update
	(
	const JBoolean			force,
	JFSFileTreeNodeBase**	updateNode
	)
{
	JBoolean changed = kJFalse;

	const JSize count = GetChildCount();
	for (JIndex i=1; i<=count; i++)
		{
		JFSFileTreeNodeBase* node = dynamic_cast<JFSFileTreeNodeBase*>(GetChild(i));
		assert (node != NULL);
		if (node->Update(force, updateNode))
			{
			changed = kJTrue;
			}
		}

	return changed;
}
示例#6
0
std::ostream &
	TKTry::
	Release(std::ostream & s) const
{
	DoLabel(s);
	// try must have braces
	switch (GetChildCount())
	{
		case 2:
		{
			// try-finally
			s << "try";
			Token &
				what = GetFirstChild();
			// Add braces
			if (what.GetType() == TokenType::TO_BRACE_O)
			{
				what.Release(s);
			}
			else
			{
				s << '{';
				what.Release(s);
				s << '}';
			}
			s << "finally";
			Token &
				final = GetChild(1);
			// Add braces
			if (final.GetType() == TokenType::TO_BRACE_O)
			{
				final.Release(s);
			}
			else
			{
				s << '{';
				final.Release(s);
				s << '}';
			}
ECode ShortcutAndWidgetContainer::OnLayout(
    /* [in] */ Boolean changed,
    /* [in] */ Int32 l,
    /* [in] */ Int32 t,
    /* [in] */ Int32 r,
    /* [in] */ Int32 b)
{
    Int32 count;
    GetChildCount(&count);
    for (Int32 i = 0; i < count; i++) {
        AutoPtr<IView> child;
        ViewGroup::GetChildAt(i, (IView**)&child);
        Int32 visibility;
        child->GetVisibility(&visibility);
        if (visibility != GONE) {
            AutoPtr<IViewGroupLayoutParams> params;
            child->GetLayoutParams((IViewGroupLayoutParams**)&params);
            AutoPtr<CellLayout::LayoutParams> lp =
                    (CellLayout::LayoutParams*)IObject::Probe(params);
            Int32 childLeft = lp->mX;
            Int32 childTop = lp->mY;
            child->Layout(childLeft, childTop, childLeft + lp->mWidth, childTop + lp->mHeight);
            if (lp->mDropped) {
                lp->mDropped = FALSE;

                AutoPtr<ArrayOf<Int32> > cellXY = mTmpCellXY;
                GetLocationOnScreen(cellXY);
                AutoPtr<IBinder> token;
                GetWindowToken((IBinder**)&token);
                mWallpaperManager->SendWallpaperCommand(token,
                        IWallpaperManager::COMMAND_DROP,
                        (*cellXY)[0] + childLeft + lp->mWidth / 2,
                        (*cellXY)[1] + childTop + lp->mHeight / 2, 0, NULL);
            }
        }
    }
    return NOERROR;
}
示例#8
0
void QuadTreeNode::AddMesh(QuadTreeMesh *new_mesh, int depth)
{
    size_t meshes_size = meshes.size();

    // If we have reached the last level of the quad tree, add the mesh and return
    if(depth == 0)
    {
        meshes.push_back(new_mesh);
        return;
    }

    // If this node has no meshes or children, go ahead and add the mesh to it
    if(GetChildCount() == 0 && meshes_size < QUADTREE_TARGET_LEAF_SIZE)
    {
        meshes.push_back(new_mesh);
        return;
    }

    // If there are already meshes at this node, add it anyway if it's close enough to the first one
    if(meshes_size > 0)
    {
        D3DXVECTOR3 diff = new_mesh->sphere.center - meshes[0]->sphere.center;
        if(D3DXVec3Length(&diff) <= QUADTREE_MIN_DIST)
        {
            meshes.push_back(new_mesh);
            return;
        }
    }

    // Push down the new mesh and the existing ones
    PushDown(new_mesh, depth);

    for (size_t i = 0; i != meshes_size; ++i)
        PushDown(meshes[i], depth);

    // Clear mesh list
    meshes.clear();
}
void IconMerger::CheckOverflow(
    /* [in] */ Int32 width)
{
    if (mMoreView == NULL) return;

        Int32 N = GetChildCount();
        Int32 visibleChildren = 0, visibility;
        for (Int32 i = 0; i < N; i++) {
            AutoPtr<IView> childView = GetChildAt(i);
            childView->GetVisibility(&visibility);
            if (visibility != IView::GONE) visibleChildren++;
        }

        mMoreView->GetVisibility(&visibility);
        Boolean overflowShown = (visibility == IView::VISIBLE);
        // let's assume we have one more slot if the more icon is already showing
        if (overflowShown) visibleChildren--;
        Boolean moreRequired = visibleChildren * mIconSize > width;
        if (moreRequired != overflowShown) {
            AutoPtr<IRunnable> runnable = new SetVisibilityRunnable(moreRequired, this);
            Post(runnable);
        }
}
示例#10
0
int OGR_SRSNode::NeedsQuoting() const

{
    // non-terminals are never quoted.
    if( GetChildCount() != 0 )
        return FALSE;

    // As per bugzilla bug 201, the OGC spec says the authority code
    // needs to be quoted even though it appears well behaved.
    if( poParent != NULL && EQUAL(poParent->GetValue(),"AUTHORITY") )
        return TRUE;
    
    // As per bugzilla bug 294, the OGC spec says the direction
    // values for the AXIS keywords should *not* be quoted.
    if( poParent != NULL && EQUAL(poParent->GetValue(),"AXIS") 
        && this != poParent->GetChild(0) )
        return FALSE;

    // Strings starting with e or E are not valid numeric values, so they
    // need quoting, like in AXIS["E",EAST] 
    if( (pszValue[0] == 'e' || pszValue[0] == 'E') )
        return TRUE;

    // Non-numeric tokens are generally quoted while clean numeric values
    // are generally not. 
    for( int i = 0; pszValue[i] != '\0'; i++ )
    {
        if( (pszValue[i] < '0' || pszValue[i] > '9')
            && pszValue[i] != '.'
            && pszValue[i] != '-' && pszValue[i] != '+'
            && pszValue[i] != 'e' && pszValue[i] != 'E' )
            return TRUE;
    }

    return FALSE;
}
示例#11
0
void 
StorageElementArray::ReportYourUnderlyingDevices( Container &devices ){

	SList			tempContainer;
	StorageElement	*pElement;
	U32				index;
	DesignatorId	*pId;

	devices.RemoveAll();

	for( index = 0 ; index < GetChildCount(); index++ ){

		// request a list for every child
		pElement = (StorageElement *)GetChild( index );
		pElement->ReportYourUnderlyingDevices( tempContainer );

		// move ids into the main vector
		while( tempContainer.Count() ){
			tempContainer.GetAt( (CONTAINER_ELEMENT &)pId, 0 );
			tempContainer.RemoveAt( 0 );
			devices.Add( (CONTAINER_ELEMENT) pId );
		}
	}
}
示例#12
0
void CCWidget::MultiplySize(float byIDLWidth, float byIDLHeight, float byCurrWidth, float byCurrHeight){
	if(GetIDLRect().w>0 && GetIDLRect().h>0)	
	{
		m_Rect.x = int(m_IDLRect.x * byIDLWidth +0.5f);
		m_Rect.w = int(m_IDLRect.w * byIDLWidth +0.5f);
		m_Rect.y = int(m_IDLRect.y * byIDLHeight +0.5f);
		m_Rect.h = int(m_IDLRect.h * byIDLHeight +0.5f);
	}
	else 
	{
		m_Rect.x = int(m_Rect.x * byCurrWidth +0.5f);
		m_Rect.w = int(m_Rect.w * byCurrWidth +0.5f);
		m_Rect.y = int(m_Rect.y * byCurrHeight +0.5f);
		m_Rect.h = int(m_Rect.h * byCurrHeight +0.5f);
	}

	SetBoundsAlignment( GetBoundsAlignment(), -1, -1);

	int n = GetChildCount();
	for( int i = 0; i < n; ++i)
	{
		GetChild(i)->MultiplySize(byIDLWidth, byIDLHeight, byCurrWidth, byCurrHeight);
	}
}
示例#13
0
bool QuadTreeNode::Optimize()
{
    //Call this function on each child
    for(size_t i = 0; i < 4; ++i)
    {
        QuadTreeNode *old_child = children[i];
        if(old_child && old_child->Optimize())
        {
            //This child has only one child of its own so it should be removed
            //First get the child
            QuadTreeNode *new_child = 0;
            for(size_t j = 0; j < 4; ++j)
            {
                new_child = old_child->children[j];
                if(new_child)
                {
                    old_child->children[j] = 0;
                    break;
                }
            }

            // Replace this child with its child
            children[i] = new_child;
            // old_child dealloc handled when MemoryPool is flushed
        }
    }

    // Report number of children remaining in this node to calling function after optimization is complete
    if(GetChildCount() == 1)
    {
        // This node should be removed
        return true;
    }

    return false;
}
示例#14
0
文件: xmlutil.cpp 项目: cw2018/xtpui
long CXmlUtil::FindElement(XMLDOMElementPtr& outEle,
                           const XMLDOMElementPtr& parent,
                           const wchar_t* pszElement,
                           const wchar_t* pszField,
                           const wchar_t* value)
{
    NL(value);
    XMLDOMElementPtr ele;
    long nCount = GetChildCount(parent, pszElement);
    long i;

    outEle = NULL;
    for (i = nCount - 1; i >= 0; i--)
    {
        if (GetChild(ele, parent, pszElement, i)
            && _wcsicmp(GetField(ele, pszField).c_str(), value) == 0)
        {
            outEle = ele;
            break;
        }
    }

    return i;
}
//-----------------------------------------------------------------------------
// Purpose: Removes all instances of a given object from this node.
// Input  : pObject - 
//-----------------------------------------------------------------------------
CCullTreeNode *CCullTreeNode::FindCullTreeObjectRecurse(CMapClass *pObject)
{
	for (int i = 0; i < m_Objects.Count(); i++)
	{
		CMapClass *pCurrent = m_Objects[i];
		if (pCurrent == pObject)
		{
			return(this);
		}
	}

	int nChildCount = GetChildCount();
	for (int nChild = 0; nChild < nChildCount; nChild++)
	{
		CCullTreeNode *pChild = GetCullTreeChild(nChild);
		CCullTreeNode *pFound = pChild->FindCullTreeObjectRecurse(pObject);
		if (pFound != NULL)
		{
			return(pFound);
		}
	}

	return(NULL);
}
ECode ShortcutAndWidgetContainer::DispatchDraw(
    /* [in] */ ICanvas* canvas)
{
    //@SuppressWarnings("all") // suppress dead code warning
    const Boolean debug = FALSE;
    if (debug) {
        // Debug drawing for hit space
        AutoPtr<IPaint> p;
        CPaint::New((IPaint**)&p);
        p->SetColor(0x6600FF00);
        Int32 count;
        GetChildCount(&count);
        for (Int32 i = count - 1; i >= 0; i--) {
            AutoPtr<IView> child;
            ViewGroup::GetChildAt(i, (IView**)&child);
            AutoPtr<IViewGroupLayoutParams> params;
            child->GetLayoutParams((IViewGroupLayoutParams**)&params);
            AutoPtr<CellLayout::LayoutParams> lp =
                    (CellLayout::LayoutParams*)IObject::Probe(params);
            canvas->DrawRect(lp->mX, lp->mY, lp->mX + lp->mWidth, lp->mY + lp->mHeight, p);
        }
    }
    return ViewGroup::DispatchDraw(canvas);
}
示例#17
0
void CHudChatFilterPanel::SetVisible(bool state)
{
	if ( state == true )
	{
		for (int i = 0; i < GetChildCount(); i++)
		{
			CHudChatFilterCheckButton *pButton = dynamic_cast < CHudChatFilterCheckButton * > ( GetChild(i) );

			if ( pButton )
			{
				if ( cl_chatfilters.GetInt() & pButton->GetFilterFlag() )
				{
					pButton->SetSelected( true );
				}
				else
				{
					pButton->SetSelected( false );
				}
			}
		}
	}

	BaseClass::SetVisible( state );
}
示例#18
0
bool
nsLineBox::CachedIsEmpty()
{
  if (mFlags.mDirty) {
    return IsEmpty();
  }
  
  if (mFlags.mEmptyCacheValid) {
    return mFlags.mEmptyCacheState;
  }

  bool result;
  if (IsBlock()) {
    result = mFirstChild->CachedIsEmpty();
  } else {
    PRInt32 n;
    nsIFrame *kid;
    result = true;
    for (n = GetChildCount(), kid = mFirstChild;
         n > 0;
         --n, kid = kid->GetNextSibling())
      {
        if (!kid->CachedIsEmpty()) {
          result = false;
          break;
        }
      }
    if (HasBullet()) {
      result = false;
    }
  }

  mFlags.mEmptyCacheValid = true;
  mFlags.mEmptyCacheState = result;
  return result;
}
示例#19
0
wxObject* wxsGridBagSizer::OnBuildPreview(wxWindow* Parent,long Flags)
{
	wxWindow* NewParent = Parent;

	if ( !(Flags & pfExact) )
	{
		NewParent = new wxsSizerPreview(Parent);
	}

	wxGridBagSizer* Sizer = OnBuildSizerPreview(NewParent);
	int Count = GetChildCount();
	for ( int i=0; i<Count; i++ )
	{
		wxsItem* Child = GetChild(i);
		wxsGridBagSizerExtra* _Extra = (wxsGridBagSizerExtra*)GetChildExtra(i);

		// Reset span in case of wrong values
		if (_Extra->colspan < 1) _Extra->colspan = 1;
		if (_Extra->rowspan < 1) _Extra->rowspan = 1;

		// How many rows / cols ?
		int nbRows = 0;
		int nbCols = 0;
		for (int j = 0 ; j < Count ; j++)
		{
			wxsGridBagSizerExtra* ExtraRows = (wxsGridBagSizerExtra*)GetChildExtra(j);

			if (nbRows < ExtraRows->row + ExtraRows->rowspan)
				nbRows = ExtraRows->row + ExtraRows->rowspan;

			if (nbCols < ExtraRows->col + ExtraRows->colspan)
				nbCols = ExtraRows->col + ExtraRows->colspan;
		}

		// Set the position in the sizer in case of wrong values
		if (_Extra->col < 0 && _Extra->row < 0)
		{
			_Extra->col = 0;
			_Extra->row = nbRows;
		}
		if (_Extra->col < 0) _Extra->col = nbCols;
		if (_Extra->row < 0) _Extra->row = nbRows;

		// We pass either Parent passed to current BuildPreview function
		// or pointer to additional parent currently created
		wxObject* ChildPreview = Child->BuildPreview(NewParent,Flags);
		if ( !ChildPreview ) continue;

		wxSizer* ChildAsSizer = wxDynamicCast(ChildPreview,wxSizer);
		wxWindow* ChildAsWindow = wxDynamicCast(ChildPreview,wxWindow);
		wxGBSizerItem* ChildAsItem = wxDynamicCast(ChildPreview,wxGBSizerItem);
		if ( ChildAsSizer )
		{
			Sizer->Add(ChildAsSizer,
			wxGBPosition(_Extra->row, _Extra->col), wxGBSpan(_Extra->rowspan, _Extra->colspan),
			wxsSizerFlagsProperty::GetWxFlags(_Extra->Flags),
			_Extra->Border.GetPixels(Parent));
		}
		else if ( ChildAsWindow )
		{
			Sizer->Add(ChildAsWindow,
			wxGBPosition(_Extra->row, _Extra->col), wxGBSpan(_Extra->rowspan, _Extra->colspan),
			wxsSizerFlagsProperty::GetWxFlags(_Extra->Flags),
			_Extra->Border.GetPixels(Parent));
		}
		else if ( ChildAsItem )
		{
			ChildAsItem->SetProportion(_Extra->Proportion);
			ChildAsItem->SetFlag(wxsSizerFlagsProperty::GetWxFlags(_Extra->Flags));
			ChildAsItem->SetBorder(_Extra->Border.GetPixels(Parent));
			ChildAsItem->SetSpan(wxGBSpan(_Extra->rowspan, _Extra->colspan));
			ChildAsItem->SetPos(wxGBPosition(_Extra->row, _Extra->col));
			Sizer->Add(ChildAsItem);
		}
	}

	if ( !(Flags & pfExact) )
	{
		NewParent->SetSizer(Sizer);
		if ( !GetChildCount() )
		{
			// Setting custom size for childless sizer to prevent
			// zero-size items
			NewParent->SetInitialSize(wxSize(20,20));
			NewParent->SetSizeHints(20,20);
			NewParent->SetSize(wxSize(20,20));
		}
		else
		{
			Sizer->Fit(NewParent);
			Sizer->SetSizeHints(NewParent);
		}
		return NewParent;
	}
	return Sizer;
}
示例#20
0
void Control::MeasureChildren(Size availableSize) const
{
    for (size_t i = 0; i < GetChildCount(); i++) {
        GetChild(i)->Measure(availableSize);
    }
}
示例#21
0
/* readonly attribute long anchors; */
NS_IMETHODIMP nsHTMLImageMapAccessible::GetAnchors(PRInt32 *aAnchors)
{
  return GetChildCount(aAnchors);
}
示例#22
0
bool MFrame::OnShow()
{
	if(GetChildCount()>0) GetChild(0)->SetFocus();
	return true;
}
示例#23
0
wxObject* wxsDialog::OnBuildPreview(wxWindow* Parent,long Flags)
{
    wxWindow* NewItem = 0;
    wxDialog* Dlg = 0;

    // In case of frame and dialog when in "Exact" mode, we do not create
    // new object, but use Parent and call Create for it.
    if ( Flags & pfExact )
    {
        Dlg = wxDynamicCast(Parent,wxDialog);
        if ( Dlg )
        {
            Dlg->Create(0,GetId(),Title,wxDefaultPosition,wxDefaultSize,Style());
            Dlg->SetClientSize(Size(wxTheApp->GetTopWindow()));
            Dlg->Move(Pos(wxTheApp->GetTopWindow()));
        }
        NewItem = Dlg;
        SetupWindow(NewItem,Flags);
        AddChildrenPreview(NewItem,Flags);
        if ( Centered )
        {
            Dlg->Centre();
        }
    }
    else
    {
        NewItem = new wxsGridPanel(Parent,GetId(),wxPoint(0,0),Size(Parent),0);
        NewItem->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
        SetupWindow(NewItem,Flags);
        AddChildrenPreview(NewItem,Flags);

        // wxPanel tends to behave very strange when it has children and no sizer,
        // we have to manually resize it's content
        if ( !GetChildCount() || GetChild(0)->GetType()!=wxsTSizer )
        {
            wxSize NewSize = Size(Parent);
            if ( !NewSize.IsFullySpecified() )
            {
                NewSize.SetDefaults(wxSize(400,450));
                NewItem->SetSize(NewSize);
                #if wxCHECK_VERSION(2,8,0)
                    NewItem->SetInitialSize(NewSize);
                #else
                    NewItem->SetBestFittingSize(NewSize);
                #endif
                if ( GetChildCount() == 1 )
                {
                    // If there's only one child it's size gets dialog's size
                    wxWindow* ChildPreview = wxDynamicCast(GetChild(0)->GetLastPreview(),wxWindow);
                    if ( ChildPreview )
                    {
                        ChildPreview->SetSize(0,0,NewItem->GetClientSize().GetWidth(),NewItem->GetClientSize().GetHeight());
                    }
                }
            }
            else
            {
                NewItem->SetSize(NewSize);
                #if wxCHECK_VERSION(2,8,0)
                    NewItem->SetInitialSize(NewSize);
                #else
                    NewItem->SetBestFittingSize(NewSize);
                #endif
            }
        }
    }

    return NewItem;
}
PRUint32
nsHTMLImageMapAccessible::AnchorCount()
{
  return GetChildCount();
}
示例#25
0
void GUIcontrol::Process()
{
	if(visible)
	{
		if(GetChildCount() == 0)
		{
			if(PointInBox(mouseX, mouseY, GetPosX(), GetPosY(), GetPatternWidth(), GetPatternHeight()))
			{
				GUIMessage temp_message;
							
				if(GetPatternCount() > 1)
					SetCurrentPattern(1);

				//temp_message.from = GetGID();
				//temp_message.a1 = MOUSE_OVER;
				//temp_message.a2 = 0;

				if(mouse[0])
				{
					_pressed = true;
					//mouse[0] = false;

					
					if(GetPatternCount() > 1)
					{
						SetCurrentPattern(2);
						_pos_dx = 1;
						_pos_dy = 1;
						if(_caption)
						{
							_caption_dx = 1;
							_caption_dy = 1;
						}
					}
				}
				else
				{
					_pos_dx = 0;
					_pos_dy = 0;
					if(_caption)
					{
						_caption_dx = 0;
						_caption_dy = 0;
					}

					if(_pressed)
					{
						_pressed = false;

						temp_message.from = GetGID();
						temp_message.a1 = MOUSE_LEFT_CLICKED;
						temp_message.a2 = 0;
						temp_message.solved = false;

						SendMessage(temp_message);

					}

				}

			}

			else
			{
				if(GetCurrentPattern() != 0) SetCurrentPattern(0);
			}
		}
	}

}
示例#26
0
void CFormulaNode::Recalculate_VerticalCenter( const SizeFde &sz )
{
	RealFde vc = sz.height() / 2.0;

	switch( getAlignmentType() )
	{
	case FBtnChildPos::Child:
		if( getAlignmentValue() >= 1 && (getAlignmentValue() - 1) < getGraphPrimNumber() )
		{
			const RectFde& _t = getGraphPrimitivePositionRect( getAlignmentValue() - 1 );
			vc = (_t.top() + _t.bottom()) / 2.0;
		}
		break;
	case FBtnChildPos::Child_Average:
		if( getAlignmentValue() >= 1 && (getAlignmentValue() - 1) < getGraphPrimNumber() )
		{
			vc = 0.0;
			for( long i = 0; i <= getAlignmentValue() - 1; i++ )
			{
				const RectFde& _t = getGraphPrimitivePositionRect( i );
				vc += _t.top() + _t.bottom();
			}
			vc = vc / (getAlignmentValue() * 2.0);
		}
		break;
	case FBtnChildPos::MSPACE_Exact_HeightDepth:
	case FBtnChildPos::Frame:
		if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() )
		{
			CNode *pNode = GetChild( getAlignmentValue() - 1 );
			if( pNode )
				vc = pNode->GetPosition().y() + pNode->GetVerticalCenter();
		}
		break;
	case FBtnChildPos::Frame_Blank_Average:
		{
			CNode *pNodeFirst = GetFirstChild();
			CNode *pNodeLast  = GetLastChild();
			if( pNodeFirst != NULL && pNodeLast != NULL )
			{
				vc = (pNodeFirst->GetPosition().y() + pNodeFirst->GetSize().height() + pNodeLast->GetPosition().y()) / 2.0;
			}
		}
		break;
	case FBtnChildPos::Half:
		break;

	case FBtnChildPos::TableAxis:
		if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() )
		{
			CNode *pNode = GetChild( getAlignmentValue() - 1 );
			if( pNode )
				vc = pNode->GetPosition().y() + pNode->GetSize().height() / 2.0;
		}
		break;

	case FBtnChildPos::TableCenter2Baseline:
	case FBtnChildPos::TableTop2Baseline:
	case FBtnChildPos::TableBottom2Baseline:
		{
			RealFde asc = ::getCurrentDefaultAscent( GetLevel() );
			RealFde h = ::getCurrentDefaultSize( GetLevel() ).height();
			vc = getAscent( sz ) - asc + h - asc / 2.0;
		}
		break;

	default:
		break;
	}

	SetVerticalCenter( vc );
}
示例#27
0
OGRErr OGR_SRSNode::FixupOrdering()

{
    int    i;

/* -------------------------------------------------------------------- */
/*      Recurse ordering children.                                      */
/* -------------------------------------------------------------------- */
    for( i = 0; i < GetChildCount(); i++ )
        GetChild(i)->FixupOrdering();

    if( GetChildCount() < 3 )
        return OGRERR_NONE;

/* -------------------------------------------------------------------- */
/*      Is this a node for which an ordering rule exists?               */
/* -------------------------------------------------------------------- */
    const char * const * papszRule = NULL;

    for( i = 0; apszOrderingRules[i] != NULL; i++ )
    {
        if( EQUAL(apszOrderingRules[i][0],pszValue) )
        {
            papszRule = apszOrderingRules[i] + 1;
            break;
        }
    }

    if( papszRule == NULL )
        return OGRERR_NONE;

/* -------------------------------------------------------------------- */
/*      If we have a rule, apply it.  We create an array                */
/*      (panChildPr) with the priority code for each child (derived     */
/*      from the rule) and we then bubble sort based on this.           */
/* -------------------------------------------------------------------- */
    int  *panChildKey = (int *) CPLCalloc(sizeof(int),GetChildCount());

    for( i = 1; i < GetChildCount(); i++ )
    {
        panChildKey[i] = CSLFindString( (char**) papszRule, 
                                        GetChild(i)->GetValue() );
        if( panChildKey[i] == -1 )
        {
            CPLDebug( "OGRSpatialReference", 
                      "Found unexpected key %s when trying to order SRS nodes.",
                      GetChild(i)->GetValue() );
        }
    }

/* -------------------------------------------------------------------- */
/*      Sort - Note we don't try to do anything with the first child    */
/*      which we assume is a name string.                               */
/* -------------------------------------------------------------------- */
    int j, bChange = TRUE;

    for( i = 1; bChange && i < GetChildCount()-1; i++ )
    {
        bChange = FALSE;
        for( j = 1; j < GetChildCount()-i; j++ )
        {
            if( panChildKey[j] == -1 || panChildKey[j+1] == -1 )
                continue;

            if( panChildKey[j] > panChildKey[j+1] )
            {
                OGR_SRSNode *poTemp = papoChildNodes[j];
                int          nKeyTemp = panChildKey[j];

                papoChildNodes[j] = papoChildNodes[j+1];
                papoChildNodes[j+1] = poTemp;

                nKeyTemp = panChildKey[j];
                panChildKey[j] = panChildKey[j+1];
                panChildKey[j+1] = nKeyTemp;

                bChange = TRUE;
            }
        }
    }

    CPLFree( panChildKey );

    return OGRERR_NONE;
}
示例#28
0
void CParentNode::iterateNodeTree_ToWidth( NODE_TREE_ITERATOR call_back, void *arg )
{
	call_back( this, arg );
	for( long i = 0; i < GetChildCount(); i++ )
		GetChild( i )->iterateNodeTree_ToWidth( call_back, arg );
}
示例#29
0
int CFormulaNode::RunCalc()
{
	if( !getCalc() )
	{
		if( getCalcButtonID().length() )
			setMissButton();
		return 0;
	}
	if( !getCalc()->isPositionRunExist() ) return 0;

	QVector<RealFde> frames_ltrb;
	frames_ltrb.fill( 0.0, 4 * GetChildCount() );
	QVector<RealFde> frames_margin_ltrb;
	frames_margin_ltrb.fill( 0.0, 4 * GetChildCount() );
	QVector<RealFde> primitive_ltrb;
	primitive_ltrb.fill( 0.0, 4 * GetChildCount() );

	long i;
	CNode *pCurNode = GetFirstChild();
	if( pCurNode->GetType() != NODE_FRAME ) return 0;
	for( i = 0; i < GetChildCount() && pCurNode; pCurNode = pCurNode->GetNext(), i++ )
	{
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] = pCurNode->GetPosition().x();
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] = pCurNode->GetPosition().y();
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] = pCurNode->GetPosition().x() + pCurNode->GetSize().width();
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] = pCurNode->GetPosition().y() + pCurNode->GetSize().height();

		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] = ((CFrameNode*) pCurNode)->getLeftIndent();
		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] = ((CFrameNode*) pCurNode)->getTopIndent();
		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] = ((CFrameNode*) pCurNode)->getRightIndent();
		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] = ((CFrameNode*) pCurNode)->getBottomIndent();
	}

	for( i = 0; i < getGraphPrimNumber(); i++ )
	{
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 0 ) );
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 1 ) );
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 2 ) );
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 3 ) );
	}

	UseBtnCalc_InitByThisSize( *getCalc() );
	int ret = getCalc()->PositionRun( frames_ltrb, frames_margin_ltrb, primitive_ltrb );

	// reset parent margins
	UseBtnCalc_ChangeThisMargin( *getCalc() );

	for( i = 0; i < getGraphPrimNumber(); i++ )
	{
		if( getCalc()->isFormulaTypeGraphics( i ) )
		{
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Left,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] );
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Top,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] );
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Right,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] );
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Bottom,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] );
		}
	}

	if( ret )
	{
		pCurNode = GetFirstChild();
		i = 0;
		while( pCurNode )
		{
			((CFrameNode*) pCurNode)->setLeftIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] );
			((CFrameNode*) pCurNode)->setTopIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] );
			((CFrameNode*) pCurNode)->setRightIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] );
			((CFrameNode*) pCurNode)->setBottomIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] );
			pCurNode = pCurNode->GetNext();
			i++;
		}
		RecalculateSizeChild();
	}

	return ret;
}
示例#30
0
void CParentNode::cleanSpareAutodetect()
{
	for( long no = 0; no < GetChildCount(); no++ )
		GetChild( no )->cleanSpareAutodetect();
}