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

📄 control.cpp

📁 这是VCF框架的代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	pt.x_ = rect->right_;	pt.y_ = rect->bottom_;	peer_->translateFromScreenCoords( &pt );	rect->right_ = pt.x_;	rect->bottom_ = pt.y_;}void Control::setContainer( Container* container ){	Container* oldContainer = container_;	container_ = container;		if ( NULL != container_ ) {				if ( NULL == container_->getOwner() ) {			addComponent(container_) ;		}		container_->setContainerControl( this );	}	//transfer over container controls!	if ( NULL != container_ && NULL != oldContainer ) {		container_->clear();		int count = oldContainer->getChildCount();		for ( int i=0;i<count;i++ ) {			Control* control = oldContainer->getControlAtIndex( 0 );			oldContainer->remove( control );			container_->add( control );		}		oldContainer->clear();	}}void Control::buildTabList( Control* control, std::vector<Control*>& tabList ){	tabList.push_back( control );	Container* container = control->getContainer();	if ( NULL != container ) {		container->getTabList( tabList );	}}Frame* Control::getParentFrame(){	Control* result = NULL;	Control* parent = getParent();	while ( parent != NULL ) {		result = parent;		parent = result->getParent();	}	if ( NULL == result ) {		result = this;	}	return (Frame*)result;}bool Control::canAcceptFocus(){	bool result = true;	if ( isEnabled() ) {		Control* parent = getParent();		while ( parent != NULL ) {			if ( !parent->isEnabled() ) {				result = false;				break;			}			parent = parent->getParent();		}	}	else {		result = false;	}	return result;}void Control::adjustViewableBoundsAndOriginForScrollable( GraphicsContext* context, Rect& viewBounds, Point& origin ){	Scrollable* scrollable = getScrollable();	if ( NULL != scrollable ) {		Rect innerBounds = getClientBounds(true);		//account for any children that overlap		if ( NULL != container_ ) {			Enumerator<Control*>* children = container_->getChildren();			Rect childBounds;			while ( children->hasMoreElements() ) {				Control* child = children->nextElement();								if ( child->getAlignment() != AlignNone && child->getVisible() ) {					childBounds = child->getBounds();					switch( child->getAlignment() ) {						case AlignLeft : {							innerBounds.left_ += childBounds.getWidth();						}						break;						case AlignRight : {							innerBounds.right_ -= childBounds.getWidth();						}						break;						case AlignTop : {							innerBounds.top_ += childBounds.getHeight();						}						break;						case AlignBottom : {							innerBounds.bottom_ -= childBounds.getHeight();						}						break;					}				}			}		}		Point scrollPos;		scrollPos.x_ = scrollable->getHorizontalPosition();		scrollPos.y_ = scrollable->getVerticalPosition();		//clip for border		viewBounds.left_ = maxVal<>( innerBounds.left_+1,viewBounds.left_ );		viewBounds.top_ = maxVal<>( innerBounds.top_+1,viewBounds.top_ );		viewBounds.right_ = minVal<>( innerBounds.right_-1.0,viewBounds.right_ );		viewBounds.bottom_ = minVal<>( innerBounds.bottom_-1.0,viewBounds.bottom_ );		UIMetricsManager* mgr = UIToolkit::getUIMetricsManager();		double dx = scrollable->getVirtualViewWidth() - innerBounds.getWidth();		double dy = scrollable->getVirtualViewHeight() - innerBounds.getHeight();				/* 		* we need to do a comparison of virtualViewWidth and virtualViewHeight with bounds that have		* accounted for the presence of scrollbars if they exist. We need to do this so that origin and		* viewable bounds offset are calculated correctly so that when we are scrolled all the way to bottom		* and right, the very bottom and right of bounds defined by virtualViewWidth and virtualViewHeight 		* are visible. These 'adjusted' bounds are initially set to innerBounds dimensions, and then modified		* if scrollbars present. (We alternatively could have increased virtualViewWidth/Height if scrollbars		* were present, and compared these to actual innerBounds.)		* NOTE: These adjusted values go hand-in-hand with adjustment to SCROLLINFO::nMax in scrollPeer when		* both scrollbars present. 		*/		double scrollAdjustedWidth  = innerBounds.getWidth();		double scrollAdjustedHeight = innerBounds.getHeight();					// can't use hasVerticalScrollbar here, we need to know if they are actually visible.		bool isVertScrollbarVisible = scrollable->isVerticalScrollbarVisible();		bool isHorzScrollbarVisible = scrollable->isHorizontalScrollbarVisible();						/*		* since we are no longer adjusting virtualViewWidth and Height for presence of both scrollbars,		* we need to tack on the extra to dx and dy here.		*/		if ( isHorzScrollbarVisible ) {			dy += scrollable->getHorizontalScrollbarHeight();			scrollAdjustedHeight -= scrollable->getHorizontalScrollbarHeight();		}		if ( isVertScrollbarVisible ) {			dx += scrollable->getVerticalScrollbarWidth();			scrollAdjustedWidth -= scrollable->getVerticalScrollbarWidth();		}					/*		Just a note: this assumes the scroll position units are same as GraphicsContext units (I think).		When we implement a user-defined scroll increment, such as by the height of a line of text based		on current Context, you may need a conversion here depending on how you implement that technique.		*/		origin.x_ -= scrollPos.x_;		origin.y_ -= scrollPos.y_;		//offset the viewBounds by the scrollable's offset		viewBounds.offset( scrollPos.x_, scrollPos.y_ );		if ( isHorzScrollbarVisible && ( scrollable->getVirtualViewWidth() > scrollAdjustedWidth ) ) {					Size horzSize = mgr->getDefaultHorizontalScrollButtonDimensions();			//viewBounds.bottom_ = minVal<>( viewBounds.bottom_-horzSize.height_,viewBounds.bottom_ );									if ( dx < scrollPos.x_ ) {							origin.x_ -= ( dx - scrollPos.x_ );				viewBounds.offset( dx - scrollPos.x_, 0 );			}		}		else {			Size horzSize = mgr->getDefaultHorizontalScrollButtonDimensions();			//viewBounds.bottom_ = minVal<>( viewBounds.bottom_-horzSize.height_,viewBounds.bottom_ );			origin.x_ += scrollPos.x_;			viewBounds.offset( scrollPos.x_, 0 );			if ( scrollPos.x_ > 0 ) {				scrollable->setHorizontalPosition( 0 );			}		}				if ( isVertScrollbarVisible && ( scrollable->getVirtualViewHeight() > scrollAdjustedHeight ) ) {			Size vertSize = mgr->getDefaultVerticalScrollButtonDimensions();			//viewBounds.right_ = minVal<>( viewBounds.right_-vertSize.width_,viewBounds.right_ );			if ( dy < scrollPos.y_ ) {				origin.y_ -= ( dy - scrollPos.y_ );				viewBounds.offset( 0, dy - scrollPos.y_ );			}		}		else {			Size vertSize = mgr->getDefaultVerticalScrollButtonDimensions();			//viewBounds.right_ = minVal<>( viewBounds.right_-vertSize.width_,viewBounds.right_ );			origin.y_ += scrollPos.y_;			viewBounds.offset( 0, scrollPos.y_ );			if ( scrollPos.y_ > 0 ) {				scrollable->setVerticalPosition( 0 );			}		}	}}bool Control::isActive(){	Frame* parentFrame = getParentFrame();	//printf( "parentFrame: %p, Frame::getActiveFrame(): %p\n",	//			parentFrame, Frame::getActiveFrame() );	return (parentFrame == Frame::getActiveFrame()) && (parentFrame->isActiveFrame());}void Control::setViewModel( Model* viewModel ){	bool modelChanged = (viewModel != getViewModel()) ? true : false;		/**	NOTE!!	Control's will assume that the model is added as a component	some where along the line. Failure to do this will result in	a memory leak. It will also result in the model NOT being written	out for storage	*/	AbstractView::setViewModel( viewModel );		if ( modelChanged ) {		ControlEvent event( this, Control::CONTROL_MODELCHANGED );		ControlModelChanged.fireEvent(&event);	}}void Control::paintBorder( GraphicsContext * context ){	Border* border = getBorder();	if ( NULL != border ) {		border->paint( this, context );	}}bool Control::hasChildren(){	bool result = false;	Container* container = getContainer();	if ( NULL != container ) {		result = container->getChildCount() > 0;	}	return result;}bool Control::isChild(){	return getParent() != NULL;}void Control::internal_beforePaint( GraphicsContext* context ){	if ( getAllowPaintNotification() ) {		ControlEvent e(this,Control::BEFORE_CONTROL_PAINTED,context);		BeforeControlPainted.fireEvent( &e );	}	}void Control::internal_afterPaint( GraphicsContext* context ){	if ( getAllowPaintNotification() ) {		ControlEvent e(this,Control::AFTER_CONTROL_PAINTED,context);		AfterControlPainted.fireEvent( &e );	}}/***CVS Log info*$Log$*Revision 1.9  2006/04/07 02:35:22  ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.8.2.16  2006/03/18 23:03:11  ddiego*added several new virtual methods to control class to make it*easier to write custom controls and respond to events.**Revision 1.8.2.15  2006/03/10 21:49:32  ddiego*updates to color example and some documentation.**Revision 1.8.2.14  2006/02/23 05:54:23  ddiego*some html help integration fixes and new features. context sensitive help is finished now.**Revision 1.8.2.13  2006/02/17 05:23:05  ddiego*fixed some bugs, and added support for minmax in window resizing, as well as some fancier control over tooltips.**Revision 1.8.2.12  2006/02/14 05:13:08  ddiego*more browser updates.**Revision 1.8.2.11  2005/10/07 04:38:47  ddiego*scroll fixes.**Revision 1.8.2.10  2005/10/07 04:37:44  ddiego*another scroll fix.**Revision 1.8.2.9  2005/10/07 04:06:24  ddiego*minor adjustment to control state variables**Revision 1.8.2.8  2005/10/04 01:57:03  ddiego*fixed some miscellaneous issues, especially with model ownership.**Revision 1.8.2.7  2005/09/16 01:12:01  ddiego*fixed bug in component loaded function.**Revision 1.8.2.6  2005/09/14 01:50:07  ddiego*minor adjustment to control for enable setting. and registered*more proeprty editors.**Revision 1.8.2.5  2005/09/12 03:47:04  ddiego*more prop editor updates.**Revision 1.8.2.4  2005/09/05 14:38:31  ddiego*added pre and post paint delegates to the control class.**Revision 1.8.2.3  2005/08/27 04:49:35  ddiego*menu fixes.**Revision 1.8.2.2  2005/08/08 03:18:40  ddiego*minor updates**Revision 1.8.2.1  2005/08/05 01:11:37  ddiego*splitter fixes finished.**Revision 1.8  2005/07/09 23:14:52  ddiego*merging in changes from devmain-0-6-7 branch.**Revision 1.7  2005/02/26 14:47:38  ddiego*fixed bug 1152064 with repaint issue on set enabled state.**Revision 1.6  2005/01/02 03:04:20  ddiego*merged over some of the changes from the dev branch because they're important resoource loading bug fixes. Also fixes a few other bugs as well.**Revision 1.5  2004/12/10 03:32:51  ddiego*fixed a heap overwrite error in the delegate-event handler code.**Revision 1.4.2.3  2005/01/01 20:31:07  ddiego*made an adjustment to quitting and event loop, and added some changes to the DefaultTabModel.**Revision 1.4.2.2  2004/12/31 17:41:23  ddiego*fixes a drag-drop bug, initially listed under the vcfbuilders*bug list**Revision 1.4.2.1  2004/12/31 17:39:47  ddiego*fixes a drag-drop bug, initially listed under the vcfbuilders*bug list**Revision 1.4.2.18  2005/06/29 20:30:15  marcelloptr*second step to remove flickering when dragging a splitter**Revision 1.4.2.17  2005/05/15 23:17:37  ddiego*fixes for better accelerator handling, and various fixes in hwo the text model works.**Revision 1.4.2.16  2005/05/06 20:33:37  marcelloptr*Error message improved.**Revision 1.4.2.14  2005/04/26 04:05:22  ddiego*the first half of [ 1184432 ] Tables cell edit box follows scroll movement, is fixed. Still need to get the scrollbars to update.**Revision 1.4.2.13  2005/04/20 02:25:59  ddiego*fixes for single line text and formatting problems in text window creation.**Revision 1.4.2.12  2005/03/29 05:00:16  ddiego*fixed an issue in drawing borders when the controls render buffer is turned on.**Revision 1.4.2.11  2005/03/29 04:25:37  ddiego*fixed an issue in drawing borders when the controls render buffer is turned on.**Revision 1.4.2.10  2005/03/20 04:29:21  ddiego*added ability to set image lists for list box control.**Revision 1.4.2.9  2005/03/15 05:29:00  ddiego*makes the accelerator check logic a bit smarter and also changes*teh way menu items test to check whether or not they are enabled.**Revision 1.4.2.8  2005/03/14 04:17:22  ddiego*adds a fix plus better handling of accelerator keys, ands auto menu title for the accelerator key data.**Revision 1.4.2.7  2005/03/06 22:50:58  ddiego*overhaul of RTTI macros. this includes changes to various examples to accommadate the new changes.**Revision 1.4.2.6  2005/02/28 04:51:55  ddiego*fixed issue in handling componenent state and events when in design mode**Revision 1.4.2.5  2005/02/27 01:45:33  ddiego*fixed bug in testing whether a path should be loaded as a bundle.*added some additional rtti info for certain classes in app kit.**Revision 1.4.2.4  2005/02/16 05:09:31  ddiego*bunch o bug fixes and enhancements to the property editor and treelist control.**Revision 1.4.2.3  2005/01/01 20:31:07  ddiego*made an adjustment to quitting and event loop, and added some changes to the DefaultTabModel.**Revision 1.4.2.2  2004/12/31 17:41:23  ddiego*fixes a drag-drop bug, initially listed under the vcfbuilders*bug list**Revision 1.4.2.1  2004/12/31 17:39:47  ddiego*fixes a drag-drop bug, initially listed under the vcfbuilders*bug list*Revision 1.4  2004/12/01 04:31:20  ddiego*merged over devmain-0-6-6 code. Marcello did a kick ass job*of fixing a nasty bug (1074768VCF application slows down modal dialogs.)*that he found. Many, many thanks for this Marcello.**Revision 1.3  2004/08/19 02:24:54  ddiego*fixed bug [ 1007039 ] lightweight controls do not paint correctly.**Revision 1.2.2.10  2004/11/18 15:24:26  pallindo*Fixed a line where there was a comment about a Font cast fix for some vc6 compilers, but the fix wasn't actually there.  So I just put it in.**Revision 1.2.2.9  2004/11/03 05:10:45  ddiego*osx open file now 95% functional - woot**Revision 1.2.2.8  2004/10/23 18:10:41  ddiego

⌨️ 快捷键说明

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