splitter.cpp
来自「这是VCF框架的代码」· C++ 代码 · 共 661 行 · 第 1/2 页
CPP
661 行
case AlignBottom : { //delta_ = dragPoint_.y_ - pt.y_; delta = -(pt.y_ - dragPoint_.y_); if ( 0 < delta && controlLast->getHeight() < minimumWidth_ ) { //too complicated and it does not work right: delta -= ( minimumWidth_ - controlLast->getHeight() ); shouldResize = false; } if ( NULL != attachedControl_ ) { Rect attachedCtrlBounds = attachedControl_->getBounds(); width = attachedCtrlBounds.getHeight(); widthMax = attachedCtrlBounds.getBottom() - minimumWidth_ - this->getHeight(); //2ch newWidth = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, width + delta ) ); if ( width != newWidth ) { if ( !shiftAll && NULL != attachedControlAlt_ ) { delta = ( newWidth - width ); Rect attachedCtrlAltBounds = attachedControlAlt_->getBounds(); widthAlt = attachedCtrlAltBounds.getHeight(); widthMax = parentHeight - attachedCtrlAltBounds.getTop() - minimumWidth_ - this->getHeight(); //2ch newWidthAlt = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, widthAlt - delta ) ); deltaAlt = ( newWidthAlt - widthAlt ); if ( !shouldResize && minimumWidth_ < newWidthAlt ) { shouldResize = true; // let the splitter to resize even if the last control is already at the minimum size } if ( shouldResize ) { Rect boundsAlt = attachedCtrlAltBounds; boundsAlt.setBottom( attachedCtrlAltBounds.getBottom() - deltaAlt ); //2ch boundsAlt.setHeight( newWidthAlt ); attachedControlAlt_->setBounds( &boundsAlt ); //StringUtils::traceWithArgs( "updateAttachedControl newHeightAlt: %3.1f deltaAlt: [%.3f]\r\n" ,newWidthAlt, deltaAlt ); } } if ( shouldResize ) { Rect bounds = attachedControl_->getBounds(); bounds.setHeight( newWidth ); attachedControl_->setBounds( &bounds ); //StringUtils::traceWithArgs( "updateAttachedControl newHeight: %3.1f delta: [%.3f]\r\n" ,newWidth, delta ); } } } } break; } //StringUtils::trace( Format( "Splitter: calling resizeChildren( NULL )\n" ) ); if ( NULL != attachedControlAlt_ ) { attachedControlAlt_->repaintNow(); } if ( NULL != attachedControl_ ) { attachedControl_->repaintNow(); } container->resizeChildren( NULL ); getParent()->repaintNow();}void Splitter::updateAttachedControlJump( Point& pt, const bool& shiftAll ){ //if ( !dblClickEnabled_ ) { // return; //} Rect parentBounds = getParent()->getBounds(); double parentWidth = parentBounds.getWidth()-1; double parentHeight = parentBounds.getHeight()-1; double width, widthMax; double newWidth = 0.0; switch ( this->getAlignment() ) { case AlignLeft : { if ( shiftAll ) { if ( NULL != attachedControl_ ) { Rect attachedCtrlBounds = attachedControl_->getBounds(); width = attachedCtrlBounds.getWidth();// - minimumWidth_ - this->getWidth(); widthMax = parentWidth - attachedCtrlBounds.getLeft() - minimumWidth_ - this->getWidth(); newWidth = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, width ) ); if ( newWidth == minimumWidth_ ) { pt.x_ += deltaRestore_; } else { pt.x_ -= newWidth - minimumWidth_; deltaRestore_ = newWidth - minimumWidth_; } } } else { if ( NULL != attachedControlAlt_ ) { Rect attachedCtrlAltBounds = attachedControlAlt_->getBounds(); width = attachedCtrlAltBounds.getWidth() - minimumWidth_ - this->getWidth(); widthMax = attachedCtrlAltBounds.getRight() - minimumWidth_ - this->getWidth(); newWidth = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, width ) ); if ( newWidth == minimumWidth_ ) { pt.x_ -= deltaRestore_; } else { pt.x_ += newWidth; deltaRestore_ = newWidth /*+ minimumWidth_ + this->getWidth()*/; } } } //StringUtils::traceWithArgs( "mouseDblClick delta_: %3.1f\r\n" ,delta_ ); } break; case AlignTop : { if ( shiftAll ) { if ( NULL != attachedControl_ ) { Rect attachedCtrlBounds = attachedControl_->getBounds(); width = attachedCtrlBounds.getHeight(); widthMax = parentHeight - attachedCtrlBounds.getTop();// - minimumWidth_ - this->getHeight(); newWidth = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, width ) ); if ( newWidth == minimumWidth_ ) { pt.y_ += deltaRestore_; } else { pt.y_ -= newWidth - minimumWidth_; deltaRestore_ = newWidth - minimumWidth_; } } } else { if ( NULL != attachedControlAlt_ ) { Rect attachedCtrlAltBounds = attachedControlAlt_->getBounds(); width = attachedCtrlAltBounds.getHeight() - minimumWidth_ - this->getHeight(); widthMax = attachedCtrlAltBounds.getBottom() - minimumWidth_ - this->getHeight(); newWidth = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, width ) ); if ( newWidth == minimumWidth_ ) { pt.y_ -= deltaRestore_; } else { pt.y_ += newWidth; deltaRestore_ = newWidth /*+ minimumWidth_ + this->getWidth()*/; } } } } break; case AlignRight : { if ( shiftAll ) { if ( NULL != attachedControl_ ) { Rect attachedCtrlBounds = attachedControl_->getBounds(); width = attachedCtrlBounds.getWidth();// - minimumWidth_ - this->getWidth(); widthMax = attachedCtrlBounds.getRight() - minimumWidth_ - this->getWidth(); newWidth = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, width ) ); if ( newWidth == minimumWidth_ ) { pt.x_ -= deltaRestore_; } else { pt.x_ += newWidth - minimumWidth_; deltaRestore_ = newWidth - minimumWidth_; } } } else { if ( NULL != attachedControlAlt_ ) { Rect attachedCtrlAltBounds = attachedControlAlt_->getBounds(); width = attachedCtrlAltBounds.getWidth() - minimumWidth_ - this->getWidth(); widthMax = parentWidth - attachedCtrlAltBounds.getLeft() - minimumWidth_ - this->getWidth(); newWidth = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, width ) ); if ( newWidth == minimumWidth_ ) { pt.x_ += deltaRestore_; } else { pt.x_ -= newWidth; deltaRestore_ = newWidth; } } } } break; case AlignBottom : { if ( shiftAll ) { if ( NULL != attachedControl_ ) { Rect attachedCtrlBounds = attachedControl_->getBounds(); width = attachedCtrlBounds.getHeight();// - minimumWidth_ - this->getHeight(); //2ch widthMax = attachedCtrlBounds.getBottom() - minimumWidth_ - this->getHeight(); //2ch newWidth = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, width ) ); if ( newWidth == minimumWidth_ ) { pt.y_ -= deltaRestore_; } else { pt.y_ += newWidth - minimumWidth_; deltaRestore_ = newWidth - minimumWidth_; } } } else { if ( NULL != attachedControlAlt_ ) { Rect attachedCtrlAltBounds = attachedControlAlt_->getBounds(); width = attachedCtrlAltBounds.getHeight() - minimumWidth_ - this->getHeight(); //2ch widthMax = parentWidth - attachedCtrlAltBounds.getTop() - minimumWidth_ - this->getHeight(); //2ch newWidth = VCF::minVal<double>( widthMax, VCF::maxVal<double>( minimumWidth_, width ) ); if ( newWidth == minimumWidth_ ) { pt.y_ += deltaRestore_; } else { pt.y_ -= newWidth; deltaRestore_ = newWidth; } } } } break; } updateAttachedControl( pt, shiftAll );}void Splitter::paint( GraphicsContext* ctx ){ CustomControl::paint( ctx ); Rect r( 0, 0, getWidth(), getHeight() ); bdr_.paint( &r, ctx );}double Splitter::getPreferredHeight(){ return UIToolkit::getUIMetricsManager()->getDefaultHeightFor( UIMetricsManager::htSeparatorHeight ) * 3;}double Splitter::getPreferredWidth(){ return UIToolkit::getUIMetricsManager()->getDefaultHeightFor( UIMetricsManager::htSeparatorHeight ) * 3;}/***CVS Log info*$Log$*Revision 1.4 2006/04/07 02:35:25 ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.3.2.2 2005/08/08 03:18:40 ddiego*minor updates**Revision 1.3.2.1 2005/08/05 01:11:38 ddiego*splitter fixes finished.**Revision 1.3 2005/07/09 23:14:55 ddiego*merging in changes from devmain-0-6-7 branch.**Revision 1.2.4.3 2005/06/29 21:18:16 marcelloptr*minor bug fixed**Revision 1.2.4.2 2005/06/29 20:30:16 marcelloptr*second step to remove flickering when dragging a splitter**Revision 1.2.4.1 2005/06/28 20:14:11 marcelloptr*first step to remove flickering when dragging a splitter**Revision 1.2 2004/08/07 02:49:09 ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.3 2004/07/11 18:45:34 ddiego*some toolbar fixes, plus some other minor glithches fixed**Revision 1.1.2.2 2004/04/29 03:43:14 marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1 2004/04/28 00:28:19 ddiego*migration towards new directory structure**Revision 1.13 2003/12/18 05:16:00 ddiego*merge from devmain-0-6-2 branch into the stable branch**Revision 1.12.4.4 2003/12/02 05:50:06 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.12.4.3 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.12.4.2 2003/08/26 21:41:17 ddiego*miscellanesous stuff, minor bugs**Revision 1.12.4.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.**Revision 1.12 2003/05/17 20:37:49 ddiego*this is the checkin for the 0.6.1 release - represents the merge over from*the devmain-0-6-0 branch plus a few minor bug fixes**Revision 1.11.2.1 2003/03/12 03:13:21 ddiego*switched all member variable that used the "m_"<name> prefix to* <name>"_" suffix nameing standard.*Also changed all vcf builder files to accomadate this.*Changes were made to the Stream classes to NOT multiple inheritance and to*be a little more correct. Changes include breaking the FileStream into two*distinct classes, one for input and one for output.**Revision 1.11 2003/02/26 04:30:57 ddiego*merge of code in the devmain-0-5-9 branch into the current tree.*most additions are in the area of the current linux port, but the major*addition to this release is the addition of a Condition class (currently*still under development) and the change over to using the Delegate class*exclusively from the older event handler macros.**Revision 1.10.14.1 2003/01/08 00:20:01 marcelloptr*mispellings and newlines at the end of all source files**Revision 1.10 2002/05/09 03:10:46 ddiego*merged over code from development branch devmain-0-5-1a into the main CVS trunk**Revision 1.9.4.2 2002/04/27 15:52:51 ddiego*Changed a bunch of files include and made it a bit faster and added better include*guards in the common headers**Revision 1.9.4.1 2002/04/08 20:55:31 zzack*changed include style**Revision 1.9 2002/01/24 01:46:50 ddiego*added a cvs "log" comment to the top of all files in vcf/src and vcf/include*to facilitate change tracking**/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?