⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 containers.cpp

📁 这是VCF框架的代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	return result;}void StandardContainer::doAnchors( Control* initialControl, const bool& controlJustAdded, Rect* bounds ){	Rect tmpBounds = controlContainer_->getClientBounds();	std::vector<Control*>::iterator it = controls_.begin();	while ( it != controls_.end() ) {		Control* child = *it;		if ( child->isIgnoredForLayout() ) {			it ++;			continue;		}		if ( AnchorNone != child->getAnchor() ) {			long anchorType = child->getAnchor();			Rect anchorBounds = child->getBounds();			double h = anchorBounds.getHeight();			double w = anchorBounds.getWidth();			float* anchorDeltas = child->getAnchorDeltas();			if ( (anchorType & AnchorRight) != 0 ) {				if ( anchorBounds.left_ < tmpBounds.right_ ) {					anchorBounds.right_ = tmpBounds.getWidth() - anchorDeltas[Control::ANCHOR_DRIGHT];				}				else {					anchorBounds.right_ = tmpBounds.getWidth() - anchorDeltas[Control::ANCHOR_DRIGHT];				}				anchorBounds.left_ = anchorBounds.right_ - w;			}			if ( (anchorType & AnchorLeft) != 0 ) {				anchorBounds.left_ = anchorDeltas[Control::ANCHOR_DLEFT];			}			if ( (anchorType & AnchorBottom) != 0 ) {				if ( anchorBounds.top_ < tmpBounds.bottom_ ) {					anchorBounds.bottom_ = tmpBounds.getHeight() - anchorDeltas[Control::ANCHOR_DBOTTOM];				}				else {					anchorBounds.bottom_ = tmpBounds.getHeight() - anchorDeltas[Control::ANCHOR_DBOTTOM];				}				anchorBounds.top_ = anchorBounds.bottom_ - h;			}			if ( (anchorType & AnchorTop) != 0 ) {				anchorBounds.top_ = anchorDeltas[Control::ANCHOR_DTOP];			}			child->setBounds( &anchorBounds, false );		}		it ++;	}}void StandardContainer::calcAlignmentList( const AlignmentType& alignment, std::vector< Control* >& alignmentList ){	//std::vector< Control* > alignmentList;	Control* initialControl = NULL;	const bool controlJustAdded = false;	Rect* rect = NULL;	alignmentList.clear();	if ( NULL != initialControl ) {		if ( (initialControl->getVisible()) && (initialControl->getAlignment() == alignment) && !initialControl->isIgnoredForLayout() ) {			alignmentList.push_back( initialControl );		}	}	std::vector< Control* >::iterator it = controls_.begin();	ulong32 index=0;	while ( it != controls_.end() ){		Control* child = *it;		if ( (child->getAlignment() == alignment) && (child->getVisible()) && !child->isIgnoredForLayout() ){			ulong32 insertIndex = 0;			if ( NULL != initialControl && initialControl == child ) {				it ++;				index ++;				continue;			}			while ( (insertIndex < alignmentList.size()) &&					!insertBefore( initialControl, controlJustAdded, child,									alignmentList[insertIndex], alignment, rect ) ){				insertIndex++;			}			alignmentList.insert( alignmentList.begin() + insertIndex, child );		}		it ++;		index ++;	}}Control* StandardContainer::getControlWithAlignment( const AlignmentType& alignment, const bool& first/*=true*/ ){	Control* control = NULL;	std::vector<Control*>::iterator it = controls_.begin();	while ( it != controls_.end() ) {		if ( (*it)->getAlignment() == alignment ){			control = (*it);			if ( first ) {				break;			}		}		it ++;	}	return control;}Control* StandardContainer::getControlInAlignmentList( const AlignmentType& alignment, const bool& first/*=true*/ ){	Control* control = NULL;	control = getControlWithAlignment( AlignClient, first );	if ( NULL == control ) {		std::vector< Control* > alignmentList;		calcAlignmentList( alignment, alignmentList );		if ( 0 != alignmentList.size() ) {			if ( first ) {				control = alignmentList[0];			}			else {				control = alignmentList[alignmentList.size()-1];			}		}	}	return control;}void StandardContainer::setBottomBorderHeight( const double& bottomBorderHeight ){	bottomBorderHeight_ = bottomBorderHeight;	if ( NULL != controlContainer_ ) {		resizeChildren(NULL);	}}void StandardContainer::setTopBorderHeight( const double& topBorderHeight ){	topBorderHeight_ = topBorderHeight;	if ( NULL != controlContainer_ ) {		resizeChildren(NULL);	}}void StandardContainer::setRightBorderWidth( const double& rightBorderWidth ){	rightBorderWidth_ = rightBorderWidth;	if ( NULL != controlContainer_ ) {		resizeChildren(NULL);	}}void StandardContainer::setLeftBorderWidth( const double& leftBorderWidth ){	leftBorderWidth_ = leftBorderWidth;	if ( NULL != controlContainer_ ) {		resizeChildren(NULL);	}}void StandardContainer::setBorderWidth ( const double& borderWidth ){	leftBorderWidth_ = borderWidth;	topBorderHeight_ = borderWidth;	rightBorderWidth_ = borderWidth;	bottomBorderHeight_ = borderWidth;	if ( NULL != controlContainer_ ) {		resizeChildren(NULL);	}}/**DesignTimeContainer class impl*/void DesignTimeContainer::resizeChildren( Control* control ){	//if ( controlContainer_->getVisible() ) {		Rect bounds = controlContainer_->getClientBounds();		if ( bounds.isEmpty() ) {			//return;		}		Rect rect ( bounds.left_ + leftBorderWidth_,						bounds.top_ + topBorderHeight_,						bounds.right_ - rightBorderWidth_,						bounds.bottom_ - bottomBorderHeight_ );		resizeChildrenUsingBounds( control, &rect );	//}}void DesignTimeContainer::resizeChildrenUsingBounds( Control* control, Rect* bounds ){	if ( NULL == controlContainer_ ){		throw InvalidPointerException(MAKE_ERROR_MSG_2(INVALID_POINTER_ERROR));	};	bool controlJustAdded = false;	if ( NULL != control ) {		std::vector<Control*>::iterator found = std::find( controls_.begin(), controls_.end(), control );		controlJustAdded = ( found == controls_.end() );	}	bool needAnchorWork = anchorWork() ||		(controlJustAdded && (control->getAlignment() == AlignNone) && (control->getAnchor() != 0));	bool needAlignWork = alignWork()||		(controlJustAdded && (control->getAlignment() != AlignNone));	if ( (true == needAnchorWork) || (true == needAlignWork) ) {		controlContainer_->getPeer()->beginSetBounds( controls_.size() );	}	if ( true == needAlignWork ){		doAlign( control, controlJustAdded, AlignTop, bounds );		doAlign( control, controlJustAdded, AlignBottom, bounds );		doAlign( control, controlJustAdded, AlignLeft, bounds );		doAlign( control, controlJustAdded, AlignRight, bounds );		doAlign( control, controlJustAdded, AlignClient, bounds );	}	if ( true == needAnchorWork ) {		doAnchors( control, controlJustAdded, bounds );	}	if ( (true == needAnchorWork) || (true == needAlignWork) ) {		controlContainer_->getPeer()->endSetBounds();	}}/***CVS Log info*$Log$*Revision 1.5  2006/04/07 02:35:22  ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.3.2.3  2006/03/16 05:51:53  ddiego*fixed glitch in achor sizing code, per fraggles req.**Revision 1.3.2.2  2005/08/15 03:10:51  ddiego*minor updates to vff in out streaming.**Revision 1.3.2.1  2005/07/29 03:04:25  ddiego*rolled back a few conatainer changes.**Revision 1.3  2005/07/09 23:14:52  ddiego*merging in changes from devmain-0-6-7 branch.**Revision 1.2.4.3  2005/06/25 22:47:20  marcelloptr*[bugfix 1227549] HorizontalLayoutContainer set the heights in the wrong rows.*AbstractContainer::add() needs to resizeChildren *after* the child control has been added.**Revision 1.2.4.2  2005/03/20 04:29:21  ddiego*added ability to set image lists for list box control.**Revision 1.2.4.1  2005/03/06 22:50:58  ddiego*overhaul of RTTI macros. this includes changes to various examples to accommadate the new changes.**Revision 1.2  2004/08/07 02:49:06  ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.3  2004/07/08 15:08:05  ddiego*made the change to the StandardContainer name - the*old StandardContainer is now called DesignTimeContainer and*the old FixedStandardContainer is now renamed to StandardContainer.**Revision 1.1.2.2  2004/04/29 03:43:13  marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1  2004/04/28 00:28:15  ddiego*migration towards new directory structure**Revision 1.2.4.1  2004/04/24 02:14:06  ddiego*fixed incorrect calculation of anchor bounds in certain cases**Revision 1.2  2003/12/18 05:16:00  ddiego*merge from devmain-0-6-2 branch into the stable branch**Revision 1.1.2.10  2003/12/02 05:50:05  ddiego*added preliminary support for teh Action class. This will make it easier*to hook up complimentary UI elements (such as a "copy" menu item, and a*"copy" toolbar item) and have tehm respond to update and actions via a*single source.*Got rid of the old toolbar button and separator class. Merged in Marcellos*new fixes for the Container and Splitter classes.*Some misc fixes to the Toolbar, groups and checks now work correctly.**Revision 1.1.2.9  2003/12/01 21:58:25  marcelloptr*minor fixes**Revision 1.1.2.8  2003/10/15 04:01:29  ddiego*added some more support for persisting the dependency info**Revision 1.1.2.7  2003/10/14 04:31:07  ddiego*some more adjustments to hack on getting the alignments to wrok better**Revision 1.1.2.6  2003/10/13 21:27:57  ddiego*fiddles with the containers a bit - didn't fix anything :(**Revision 1.1.2.5  2003/10/12 19:38:35  ddiego*added a fix in the combbox control due to changes in the container*layout*fixed a glitch in the StandardContainer::resizeChildrenUsingBounds*method os that it correctly checks the passed in control for alignment*or anchor  changes if neccessary**Revision 1.1.2.4  2003/10/12 06:34:13  ddiego*added some fixes to standard container layout algorithms - thisstill needs*to be tested, but it looks like it may fix some outstanding issues*with the layout logic**Revision 1.1.2.3  2003/08/20 19:05:20  ddiego*some minor changes to container logic**Revision 1.1.2.2  2003/08/19 04:43:40  ddiego*further code to support lightweight container implementation. Not quite*finished**Revision 1.1.2.1  2003/08/18 19:52:37  ddiego*changed the Container from being a class you derive from to a separate*intance that is created and assigned dynamically to any Control.**/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -