win32tree.cpp

来自「这是VCF框架的代码」· C++ 代码 · 共 1,700 行 · 第 1/3 页

CPP
1,700
字号
							tvItem.hItem = it->second;							SendMessage( hwnd_, TVM_SETITEMW, 0, (LPARAM)&tvItem );						}						else {							TVITEMA tvItem;							memset( &tvItem, 0, sizeof(TVITEMA) );							tvItem.mask = TVIF_HANDLE | TVIF_IMAGE ;							tvItem.iImage = item->getImageIndex();							tvItem.mask |= TVIF_STATE;							if ( item->getTextBold() ) {								tvItem.state |= TVIS_BOLD;							}							tvItem.stateMask |= TVIS_BOLD;							if ( item->getStateImageIndex() >= 0 ) {								tvItem.mask |= TVIF_STATE;								tvItem.state |= INDEXTOSTATEIMAGEMASK( item->getStateImageIndex() );								tvItem.stateMask |= TVIS_STATEIMAGEMASK;							}							if ( item->getSelectedImageIndex() >= 0 ) {								tvItem.mask |= TVIF_SELECTEDIMAGE ;								tvItem.iSelectedImage = item->getSelectedImageIndex();							}							tvItem.hItem = it->second;							SendMessage( hwnd_, TVM_SETITEMA, 0, (LPARAM)&tvItem );						}					}				}			}		}	}}void Win32Tree::onItemSelected( ItemEvent* event ){	if ( (NULL != event) && (peerControl_->getComponentState() != Component::csDestroying) ){		Object* source = event->getSource();		if ( NULL != source ){			TreeItem* item = dynamic_cast<TreeItem*>(source);			if ( NULL != item ){				std::map<TreeItem*,HTREEITEM>::iterator it =					treeItems_.find( item );				if ( it != treeItems_.end() ){					if ( item->isSelected() ) {						TreeView_SelectItem( hwnd_, it->second );					}				}			}		}	}}void Win32Tree::onItemAdded( ItemEvent* event ){}void Win32Tree::onItemDeleted( ItemEvent* event ){	Object* source = event->getSource();	if ( NULL != source ){		TreeItem* item = dynamic_cast<TreeItem*>(source);		if ( NULL != item ){			std::map<TreeItem*,HTREEITEM>::iterator found =				treeItems_.find( item );			if ( found != treeItems_.end() ){				HTREEITEM hItem = found->second;				treeItems_.erase( found );				TreeView_DeleteItem( hwnd_, hItem );			}		}	}}void Win32Tree::onImageListImageChanged( ImageListEvent* event ){	ulong32 index = event->getIndexOfImage();	ImageList* imageList = (ImageList*)event->getSource();	setImageList( imageList );	//hacky way for now	/*	switch ( event->getType() ) {		case IMAGELIST_EVENT_WIDTH_CHANGED : {		}		break;		case IMAGELIST_EVENT_HEIGHT_CHANGED : {		}		break;		case IMAGELIST_EVENT_ITEM_ADDED : {			Win32Image* win32Img = (Win32Image*)event->getImage();			HBITMAP hbmImage = win32Img->getBitmap();			int err = ImageList_Add( imageListCtrl_, hbmImage, NULL );			if ( err < 0 ) {				//error condition !			}		}		break;		case IMAGELIST_EVENT_ITEM_DELETED : {		}		break;	}	*/}Rect Win32Tree::getItemImageRect( TreeItem* item ){	Rect result;		return result;}Rect Win32Tree::getItemRect( TreeItem* item ){	Rect result;		if ( NULL != item ){		std::map<TreeItem*,HTREEITEM>::iterator it = treeItems_.find( item );		if ( it != treeItems_.end() ){			if ( item->isSelected() ) {				RECT r = {0};				TreeView_GetItemRect( hwnd_, it->second, &r, TRUE );								result.left_ = r.left;				result.top_ = r.top;				result.right_ = r.right;				result.bottom_ = r.bottom;			}		}	}	return result;}void Win32Tree::onStateImageListImageChanged( ImageListEvent* event ){	ImageList* imageList = (ImageList*)event->getSource();	setStateImageList( imageList );}void Win32Tree::setStateImageList( ImageList* imageList ){	if ( NULL != stateImageListCtrl_ ) {		BOOL err = ImageList_Destroy( stateImageListCtrl_ );	}	stateImageListCtrl_ = NULL;	TreeView_SetImageList( hwnd_, imageListCtrl_, TVSIL_STATE );	if ( imageList != NULL ) {		stateImageListCtrl_ = ImageList_Create( imageList->getImageWidth(), imageList->getImageHeight(),										ILC_COLOR24|ILC_MASK, imageList->getImageCount(), 4 );		Image* masterImage = imageList->getMasterImage();		Win32Image* win32Img = (Win32Image*)masterImage;		SysPixelType* pix = win32Img->getImageBits()->pixels_;		int sz = win32Img->getWidth() * win32Img->getHeight();		unsigned char* oldAlpaVals = new unsigned char[sz];		do {			sz --;			oldAlpaVals[sz] = pix[sz].a;			pix[sz].a = 0;		} while( sz > 0 );		Color* transparentColor = imageList->getTransparentColor();		HBITMAP hBMPcopy = (HBITMAP)CopyImage( win32Img->getBitmap(), IMAGE_BITMAP, 0, 0, NULL );		//flip the bits		int err = ImageList_AddMasked( stateImageListCtrl_, hBMPcopy, transparentColor->getColorRef32() );		if ( err < 0 ) {			//error condition !		}		DeleteObject( hBMPcopy );		sz = win32Img->getWidth() * win32Img->getHeight();		do {			sz --;			pix[sz].a = oldAlpaVals[sz];		} while( sz > 0 );		delete [] oldAlpaVals;		TreeView_SetImageList( hwnd_, stateImageListCtrl_, TVSIL_STATE );		EventHandler* imgListHandler = getEventHandler( "Win32Tree::onStateImageListImageChanged" );		if ( NULL == imgListHandler ) {			imgListHandler =				new ImageListEventHandler<Win32Tree>(this, &Win32Tree::onStateImageListImageChanged, "Win32Tree::onStateImageListImageChanged" );		}		imageList->SizeChanged.addHandler( imgListHandler );		imageList->ImageAdded.addHandler( imgListHandler );		imageList->ImageDeleted.addHandler( imgListHandler );	}}bool Win32Tree::getAllowLabelEditing(){	return ( TVS_EDITLABELS & GetWindowLong( hwnd_, GWL_STYLE ) ) ? true : false;}void Win32Tree::setAllowLabelEditing( const bool& allowLabelEditing ){	int style = GetWindowLong( hwnd_, GWL_STYLE );	if ( allowLabelEditing ) {		style |= TVS_EDITLABELS;	}	else {		style &= ~TVS_EDITLABELS;	}	SetWindowLong( hwnd_, GWL_STYLE, style );	::SetWindowPos( hwnd_, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE );	::UpdateWindow( hwnd_ );}void Win32Tree::onControlModelChanged( Event* e ){	EventHandler* ev = getEventHandler( "Win32Tree::onTreeNodeDeleted" );	if ( NULL == ev ) {		ev = new TreeModelEventHandler<Win32Tree>( this,													&Win32Tree::onTreeNodeDeleted,													"Win32Tree::onTreeNodeDeleted" );	}	treeControl_->getTreeModel()->addTreeNodeDeletedHandler( ev );}void Win32Tree::onTreeNodeDeleted( TreeModelEvent* event ){	TreeItem* item = event->getTreeItem();	if ( NULL != item ){		std::map<TreeItem*,HTREEITEM>::iterator found =			treeItems_.find( item );		if ( found != treeItems_.end() ){			HTREEITEM hItem = found->second;			treeItems_.erase( found );			TreeView_DeleteItem( hwnd_, hItem );		}	}}/***CVS Log info*$Log$*Revision 1.6  2006/04/07 02:35:26  ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.5.2.5  2006/03/18 19:19:37  ddiego*fixed a paint bug in the win32tree ctrl becuase I was passing in*the wrong rect value. also got rid of various debugging trace statements.**Revision 1.5.2.4  2006/03/18 19:04:56  ddiego*minor update to remove dead code for checkFontUpdate function.**Revision 1.5.2.3  2006/03/16 03:23:11  ddiego*fixes some font change notification issues in win32 peers.**Revision 1.5.2.2  2005/11/21 21:28:05  ddiego*updated win32 code a bit due to osx changes.**Revision 1.5.2.1  2005/09/05 14:38:31  ddiego*added pre and post paint delegates to the control class.**Revision 1.5  2005/07/09 23:14:59  ddiego*merging in changes from devmain-0-6-7 branch.**Revision 1.4  2005/01/02 03:04:22  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.3.2.13  2005/06/26 01:31:20  marcelloptr*improvements to the Color class. The default, when packing the components into a single integer, is now cpsARGB instead than cpsABGR.**Revision 1.3.2.12  2005/06/09 06:13:08  marcelloptr*simpler and more useful use of Color class with ctor and getters/setters**Revision 1.3.2.11  2005/05/02 02:31:42  ddiego*minor text updates.**Revision 1.3.2.10  2005/04/26 02:29:40  ddiego*fixes font setting bug brought up by scott and glen_f**Revision 1.3.2.9  2005/04/20 02:26:01  ddiego*fixes for single line text and formatting problems in text window creation.**Revision 1.3.2.8  2005/04/09 17:20:36  marcelloptr*bugfix [ 1179853 ] memory fixes around memset. Documentation. DocumentManager::saveAs and DocumentManager::reload**Revision 1.3.2.7  2005/02/16 05:09:32  ddiego*bunch o bug fixes and enhancements to the property editor and treelist control.**Revision 1.3.2.6  2005/01/28 02:49:02  ddiego*fixed bug 1111096 where the text control was properly handlind*input from the numbpad keys.**Revision 1.3.2.5  2005/01/07 01:13:59  ddiego*fixed a foundation kit but that was cause a crash by releasing the system instance and then making use of a member variable for it. The member variable is now static, which is more appropriate.**Revision 1.3.2.4  2005/01/01 20:31:08  ddiego*made an adjustment to quitting and event loop, and added some changes to the DefaultTabModel.**Revision 1.3.2.3  2004/12/31 17:41:23  ddiego*fixes a drag-drop bug, initially listed under the vcfbuilders*bug list**Revision 1.3.2.2  2004/12/31 17:39:47  ddiego*fixes a drag-drop bug, initially listed under the vcfbuilders*bug list**Revision 1.3.2.1  2004/12/19 04:05:00  ddiego*made modifications to methods that return a handle type. Introduced*a new typedef for handles, that is a pointer, as opposed to a 32bit int,*which was causing a problem for 64bit compiles.**Revision 1.3  2004/12/01 04:31:39  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.2.2.4  2004/09/09 04:42:04  ddiego*fixed some custom draw bugs in win32 tree control. updated*advanced ui example.**Revision 1.2.2.3  2004/09/08 03:49:05  ddiego*minor win32 tree mods**Revision 1.2.2.2  2004/09/07 03:57:04  ddiego*misc tree control update**Revision 1.2.2.1  2004/09/06 18:33:43  ddiego*fixed some more transparent drawing issues**Revision 1.2  2004/08/07 02:49:11  ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.13  2004/07/30 17:27:14  kiklop74*Added first release of Borland midifications for VCF**Revision 1.1.2.12  2004/07/26 03:40:31  ddiego*minor changes**Revision 1.1.2.11  2004/07/23 04:20:56  ddiego*more checkins**Revision 1.1.2.10  2004/07/16 05:07:18  ddiego*added support for editing labels on a tree control**Revision 1.1.2.9  2004/07/16 04:01:46  ddiego*fixed the last of border redraw issues, I hope.**Revision 1.1.2.8  2004/07/15 18:53:00  ddiego*more updates**Revision 1.1.2.7  2004/07/14 18:18:14  ddiego*fixed problem with edit control. Turns out we were using the wrong*subclassed wndproc. This is now fixed.**Revision 1.1.2.6  2004/07/14 04:56:02  ddiego*fixed Win32 bugs. Got rid of flicker in the common control*wrappers and toolbar. tracking down combo box display bugs.**Revision 1.1.2.5  2004/06/06 07:05:31  marcelloptr*changed macros, text reformatting, copyright sections**Revision 1.1.2.4  2004/05/06 21:18:33  ddiego*some more minor win32 unicode changes**Revision 1.1.2.3  2004/05/04 17:16:07  ddiego*updated some win32 stuff for unicode compliance**Revision 1.1.2.2  2004/04/29 03:43:16  marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1  2004/04/28 00:28:21  ddiego*migration towards new directory structure**Revision 1.33  2004/04/03 15:48:48  ddiego*Merged over code from the 0-6-3 branch.**Revision 1.31.2.4  2004/03/28 00:46:22  ddiego*added VisualFormFiles, fixed some code in the DocumentManager*class, and changed code over to create an Application class on the*heap instead of on the stack. This fixes a problem with static object*destrcutor order when using VC71. Also updated the project wizards*for vc6. Still need to update docs.**Revision 1.31.2.3  2004/03/21 16:03:10  ddiego*minor change to VCFString to properly allocate a buffer*unicode xfrm**Revision 1.31.2.2  2004/03/21 00:39:24  ddiego*merged vc7.1 changes into dev branch**Revision 1.31.2.1  2004/01/16 04:30:47  ddiego*some more minor mods to menus and the Component class. Added some utility*methods for determining the state of a component, and added two new*delegates for firing events when the component is loaded and saved,*as well as value changes for the COmponentState enum so that some of*the values of the component state can be OR'd together.**Revision 1.32  2004/01/20 01:54:56  ddiego*merged some more changes from dev branch, primarily changes to*teh RTTI API so that we now process enum sets correctly (i.e. a long*that is a mask made of enum values).**Revision 1.31.2.1  2004/01/16 04:30:47  ddiego*some more minor mods to menus and the Component class. Added some utility*methods for determining the state of a component, and added two new*delegates for firing events when the component is loaded and saved,*as well as value changes for the COmponentState enum so that some of*the values of the component state can be OR'd together.**Revision 1.31  2003/12/18 05:16:01  ddiego*merge from devmain-0-6-2 branch into the stable branch**Revision 1.30.2.2  2003/09/17 21:23:24  ddiego*added adjustmnents to win32 tree peer and drop target**Revision 1.30.2.1  2003/09/16 21:21:19  ddiego*freed up the DataObject the com DO held onto*added support for dynamically get the caption's of tree items**Revision 1.30  2003/08/09 02:56:46  ddiego*merge over from the devmain-0-6-1 branch*Changes*Features:*-Added additional implementation to better support the MVC architecture in*the VCF**-Added a Document/View architecure that is similar to MFC's or NextSteps's*Doc/View architectures**-Integrated the Anti Grain Graphics library into the GraphicsKit. There is*now basic support for it in terms of drawing vector shapes*(fills and strokes). Image support will come in the next release**-Added several documented graphics tutorials**Bugfixes:**[ 775744 ] wrong buttons on a dialog*[ 585239 ] Painting weirdness in a modal dialog ?*[ 585238 ] Modal dialog which makes a modal Dialog*[ 509004 ] Opening a modal Dialog causes flicker*[ 524878 ] onDropped not called for MLTcontrol**Plus an issue with some focus and getting the right popup window to activate*has also been fixed**Revision 1.29.2.2  2003/07/24 04:10:45  ddiego*added fixes for the following tasks:*Task #82279 ApplicationKit: add static methods to singleton objects*Task #82277 FoundationKit: add static methods to singleton objects*this required a bunch of changes in terms of getting rid of older style code**Revision 1.29.2.1  2003/05/27 04:45:38  ddiego*doing some code cleanup to fix some bugs in the way dialogs and popups*work in Win32 port. Cleaned up the ControlPeer and DialogPeer interfaces*a bit.**Revision 1.29  2003/05/17 20:37:39  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.28.2.2  2003/03/23 03:23:58  marcelloptr*3 empty lines at the end of the files**Revision 1.28.2.1  2003/03/12 03:12:43  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.28  2003/02/26 04:30:52  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.27.2.4  2003/02/24 05:42:19  ddiego*moved the code for the VariantData calss into it's own header*migrated to the new event style using Delegates instead of relying on*the ugly macros that we were using before - same functionality though*made sure everything still works and compiles, including neccessary*changes in the VCF Builder so that it creates code in the new style*This changes to teh new style of using Delegates completes task 58837**Revision 1.27.2.3  2003/01/08 00:19:54  marcelloptr*mispellings and newlines at the end of all source files**Revision 1.27.2.2  2002/12/27 23:04:55  marcelloptr*Improved macros for automatic import/export of libraries. - Warning fixes. - Other Minor Changes.**Revision 1.27.2.1  2002/12/02 00:38:35  ddiego*more fixes to get the ApplicationKit to compile under mingw. Everything now*compiles OK at this point.**Revision 1.27  2002/11/18 00:46:09  ddiego*this is the merge over of all the bug fixes and features (mostly*VCF Builder stuff) from the devmain-0-5-8 branch**Revision 1.26.10.3  2002/11/17 01:20:38  cesarmello*Removed the LR_COPYRETURNORG flag from CopyImage due to inconsistent Win32 behavior under Windows NT 4**Revision 1.26.10.2  2002/11/06 04:27:26  ddiego**** empty log message *****Revision 1.26.10.1  2002/09/12 21:35:53  ddiego*mods to make double clicking on the form in the workspace tree open a*form designer, and clicking on a component instance in the workspace tree*will select the component in the form designer**Revision 1.26  2002/05/09 03:10:45  ddiego*merged over code from development branch devmain-0-5-1a into the main CVS trunk**Revision 1.25.4.2  2002/04/27 15:52:31  ddiego*Changed a bunch of files include and made it a bit faster and added better include*guards in the common headers**Revision 1.25.4.1  2002/04/08 20:55:30  zzack*changed include style**Revision 1.25  2002/02/20 04:07:59  ddiego*consolidated event handling code a bit*introduced a virtual handleEvent() method to Component*clean up some of the event constants, so they are now localized in the*appropriate control classes.**Revision 1.24  2002/01/24 01:46:49  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 + -
显示快捷键?