[GME-commit] GMESRC/GME/GMEActiveBrowser ActiveBrowserPropertyPage.cpp,1.38,1.39 ActiveBrowserPropertyPage.h,1.11,1.12 GMEActiveBrowserCtl.cpp,1.12,1.13 InheritanceTreeCtrl.cpp,1.2,1.3 InheritanceTreeCtrl.h,1.1,1.2

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Wed Jan 19 13:45:36 CST 2005


Update of /var/lib/gme/GMESRC/GME/GMEActiveBrowser
In directory braindrain:/tmp/cvs-serv7682

Modified Files:
	ActiveBrowserPropertyPage.cpp ActiveBrowserPropertyPage.h 
	GMEActiveBrowserCtl.cpp InheritanceTreeCtrl.cpp 
	InheritanceTreeCtrl.h 
Log Message:
modifications for bug: GME-37 in JIRA (Inheritance tree gets notifications, displays icons)


CVS User: zolmol

Index: ActiveBrowserPropertyPage.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/GMEActiveBrowser/ActiveBrowserPropertyPage.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** ActiveBrowserPropertyPage.cpp	12 Jan 2005 17:54:00 -0000	1.38
--- ActiveBrowserPropertyPage.cpp	19 Jan 2005 19:45:32 -0000	1.39
***************
*** 2180,2184 ****
  BOOL CAggregatePropertyPage::OnSetActive() 
  {
! 	GetParent()->SendMessage(DM_SETDEFID,IDC_SEARCH,0);
  	::SetFocus(GetDlgItem(IDC_SEARCH)->GetSafeHwnd());
  	return CPropertyPageEx::OnSetActive();
--- 2180,2186 ----
  BOOL CAggregatePropertyPage::OnSetActive() 
  {
! 	CActiveBrowserPropertySheet* pParent=(CActiveBrowserPropertySheet*)GetParent();
! 	pParent->m_PageInheritance.ResetRoot();
! 	pParent->SendMessage(DM_SETDEFID,IDC_SEARCH,0);
  	::SetFocus(GetDlgItem(IDC_SEARCH)->GetSafeHwnd());
  	return CPropertyPageEx::OnSetActive();
***************
*** 2231,2245 ****
  
  
! CInheritancePropertyPage::CInheritancePropertyPage() : CPropertyPageEx(CInheritancePropertyPage::IDD),
! 			m_ComboEditCtrl(&m_ComboSearchCtrl), m_ComboSearchCtrl(&m_TreeInheritance)
  {
  	//{{AFX_DATA_INIT(CInheritancePropertyPage)
  	//}}AFX_DATA_INIT
- 
- 	m_pPrevSelectedItem=NULL;
  }
  
  CInheritancePropertyPage::~CInheritancePropertyPage()
  {
  }
  
--- 2233,2251 ----
  
  
! CInheritancePropertyPage::CInheritancePropertyPage() 
! 	: CPropertyPageEx(CInheritancePropertyPage::IDD)
! 	, m_ComboEditCtrl(&m_ComboSearchCtrl)
! 	, m_ComboSearchCtrl(&m_TreeInheritance)
! 	, m_theCurrentRootFCO( NULL)
! 	, m_pPrevSelectedItem( NULL)
  {
  	//{{AFX_DATA_INIT(CInheritancePropertyPage)
  	//}}AFX_DATA_INIT
  }
  
  CInheritancePropertyPage::~CInheritancePropertyPage()
  {
+ 	m_theCurrentRootFCO = NULL;
+ 	m_pPrevSelectedItem = NULL;
  }
  
***************
*** 2260,2263 ****
--- 2266,2270 ----
  	ON_NOTIFY(NM_DBLCLK, IDC_TREE_INHERITANCE, OnDblclkTreeInheritance)
  	ON_NOTIFY(TVN_ITEMEXPANDING, IDC_TREE_INHERITANCE, OnItemExpandingTreeInheritance)
+ 	ON_NOTIFY(TVN_KEYDOWN, IDC_TREE_INHERITANCE, OnKeyDownTreeInheritance)
  	//}}AFX_MSG_MAP
  END_MESSAGE_MAP()
***************
*** 2280,2283 ****
--- 2287,2293 ----
  	m_TreeInheritance.SetImageList(&m_ImageList,TVSIL_NORMAL);
  
+ 	// Creating the state image list
+ 	PrepareStateImageList();
+ 
  	m_TreeInheritance.EnableWindow(FALSE);
  	m_ComboSearchCtrl.EnableWindow(FALSE);
***************
*** 2309,2312 ****
--- 2319,2323 ----
  	m_TreeInheritance.EnableWindow(TRUE);
  	m_ComboSearchCtrl.EnableWindow(TRUE);
+ 	m_theCurrentRootFCO = NULL;
  	m_pPrevSelectedItem=NULL;
  
***************
*** 2321,2328 ****
--- 2332,2487 ----
  	m_ComboSearchCtrl.EnableWindow(FALSE);
  
+ 	m_theCurrentRootFCO = NULL;
  	m_pPrevSelectedItem=NULL;
  
  }
  
+ void CInheritancePropertyPage::PrepareStateImageList()
+ {
+ 	CImageList ImageList;
+ 	ImageList.Create(16,16,ILC_MASK|ILC_COLOR24,0,0);
+ 
+ 	CBitmap bm;
+ 	bm.LoadBitmap(IDB_IMAGELIST_AGGREGATE_STATE);
+ 
+ 	ImageList.Add(&bm,RGB(128, 158, 8));	// Pretty natural transparent color 
+ 											// provided by Tamas Paka
+ 
+ 	CClientDC dcClient(this);
+ 	CDC dcMem;
+ 	CBitmap Bitmap;
+ 
+ 	if (!dcMem.CreateCompatibleDC(&dcClient)) return;
+ 
+ 	if (!Bitmap.CreateCompatibleBitmap(&dcClient,256,16)) return;
+ 
+ 	CBitmap *pOldMemDCBitmap = dcMem.SelectObject(&Bitmap);
+ 
+ 	COLORREF cMaskColor=RGB(128,58,8);
+ 	dcMem.FillSolidRect(0, 0, 256, 16, cMaskColor);
+ 
+ 	// Paint each Image in the DC
+ 	for(BYTE i=0;i<=15;i++)
+ 	{
+ 		if(i&0x0001) // Access
+ 		{
+ 			ImageList.Draw(&dcMem, 1, CPoint(i*16,0), ILD_TRANSPARENT);
+ 		}
+ 
+ 		if(i&0x0002) // LibObject
+ 		{
+ 			ImageList.Draw(&dcMem, 0, CPoint(i*16,0), ILD_TRANSPARENT);
+ 		}
+ 		if(i&0x0004) // Instance
+ 		{
+ 			ImageList.Draw(&dcMem, 5, CPoint(i*16,0), ILD_TRANSPARENT);
+ 		}
+ 
+ 		if(i&0x0008)	// Derived (subtype)
+ 		{
+ 			ImageList.Draw(&dcMem, 4, CPoint(i*16,0), ILD_TRANSPARENT);
+ 		}
+ 	}
+ 	dcMem.SelectObject(pOldMemDCBitmap);
+ 
+ 	m_StateImageList.Create(16,16, ILC_COLOR | ILC_MASK, 0, 1);
+ 
+ 	// Green is used as mask color
+ 	m_StateImageList.Add(&Bitmap, cMaskColor); 
+ 
+ 	Bitmap.DeleteObject();
+ 
+ 	m_TreeInheritance.SetImageList(&m_StateImageList,TVSIL_STATE);
+ }
+ 
+ // This function is indirectly initiated by MGA, 
+ // so we do not need transaction handling
+ void CInheritancePropertyPage::OnMgaEvent(CComPtr<IMgaObject> ccpMgaObject, unsigned long lEventMask)
+ {
+ 	EVENT_TRACE("\n__________ MGA Event Handling Begin _________\n");
+ 
+ 	// Handling Object Events
+ 
+ 	if(lEventMask&OBJEVENT_CREATED)
+ 	{
+ 		EVENT_TRACE("OBJEVENT_CREATED handled.\n");
+ 
+ 		m_TreeInheritance.StoreState();
+ 		m_TreeInheritance.CleanUp();
+ 		SetupTree2();
+ 		m_TreeInheritance.RestoreState();
+ 	}
+ 
+ 	if(lEventMask&OBJEVENT_DESTROYED)
+ 	{
+ 		EVENT_TRACE("OBJEVENT_DESTROYED handled.\n");
+ 
+ 		m_TreeInheritance.StoreState();
+ 		m_TreeInheritance.CleanUp();
+ 		SetupTree2();
+ 		m_TreeInheritance.RestoreState();
+ 	}
+ 
+ 	if(lEventMask&OBJEVENT_PROPERTIES)
+ 	{
+ 		EVENT_TRACE("OBJEVENT_PROPERTIES handled.\n");
+ 
+ 		// Finding the object in the tree
+ 		HTREEITEM hItem;
+ 		if(m_TreeInheritance.m_MgaMap.LookupTreeItem(ccpMgaObject,hItem)) // The changed object is in the tree
+ 		{
+ 			// Change name
+ 			m_TreeInheritance.SetItemText(hItem,GetDisplayedName(ccpMgaObject));
+ 
+ 			// Setting the state icons
+ 			//m_TreeInheritance.SetItemProperties(hItem);
+ 		}
+ 	}
+ 
+ 	if(lEventMask&OBJEVENT_REGISTRY)
+ 	{
+ 		EVENT_TRACE("OBJEVENT_REGISTRY is partially  handled.\n");
+ 
+ 		// PETER: We need this, because of Library names
+ 
+ 		// Finding the object in the tree
+ 		HTREEITEM hItem;
+ 		if(m_TreeInheritance.m_MgaMap.LookupTreeItem(ccpMgaObject,hItem)) // The changed object is in the tree
+ 		{
+ 			// Change name
+ 			m_TreeInheritance.SetItemText(hItem,GetDisplayedName(ccpMgaObject));
+ 
+ 			// Setting the state icons
+ 			//m_TreeInheritance.SetItemProperties(hItem);
+ 		}
+ 	}
+ }
+ 
+ void CInheritancePropertyPage::OnKeyDownTreeInheritance(NMHDR* pNMHDR, LRESULT* pResult) 
+ {
+ 	TV_KEYDOWN* pTVKeyDown = (TV_KEYDOWN*)pNMHDR;
+ 	switch(pTVKeyDown->wVKey)
+ 	{
+ 	case VK_RETURN: // Display the first selected item in GME editor
+ 		{
+ 				HTREEITEM hItem=m_TreeInheritance.GetSelectedItem();
+ 				LPUNKNOWN pUnknown=NULL;
+ 
+ 				if(m_TreeInheritance.m_MgaMap.LookupObjectUnknown(hItem,pUnknown))
+ 				{
+ 					TRACE(m_TreeInheritance.GetItemText(hItem));
+ 
+ 					// Firing the event
+ 					CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp();
+ 					pApp->GetCtrl()->FireDblClickMgaObject(pUnknown);
+ 					m_TreeInheritance.SetFocus();
+ 				}
+ 		}break;
+ 	}
+ 
+ 	
+ 	*pResult = 0;
+ }
+ 
  
  void CInheritancePropertyPage::OnItemExpandingTreeInheritance(NMHDR* pNMHDR, LRESULT* pResult) 
***************
*** 2437,2440 ****
--- 2596,2602 ----
  		reqFindInheritanceRoot(ccpMgaRootFCO);
  
+ 		// Storing it in a member
+ 		m_theCurrentRootFCO = ccpMgaRootFCO;
+ 
  		// Building inheritance tree
  		reqBuildInheritanceTree(NULL,ccpMgaRootFCO,-1);
***************
*** 2454,2457 ****
--- 2616,2694 ----
  }
  
+ void CInheritancePropertyPage::ResetRoot()
+ {
+ 	m_theCurrentRootFCO = 0;
+ }
+ 
+ void CInheritancePropertyPage::SetupTree2()
+ {
+ 	CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp();
+ 	CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext;
+ 	
+ 	// No open poject - error
+ 	if(pApp->m_CurrentProject.GetCurrentProjectState()!=CURRENT_PROJECT_OPEN) return;
+ 
+ 	CActiveBrowserPropertySheet* pParent=(CActiveBrowserPropertySheet*)GetParent();
+ 	
+ 	m_TreeInheritance.EnableWindow(TRUE);
+ 	m_ComboSearchCtrl.EnableWindow(TRUE);
+ 
+ 	// Cleaning up
+ 	m_TreeInheritance.CleanUp();
+ 	m_ComboSearchCtrl.ResetContent();
+ 	
+ 	MSGTRY{
+ 		// Starting transaction
+ 		pMgaContext->BeginTransaction();
+ 
+ 		if( !m_theCurrentRootFCO) return; // if root not set then return
+ 
+ 		long status;
+ 		COMTHROW(m_theCurrentRootFCO->get_Status(&status));
+ 		if (status != OBJECT_EXISTS) { // if zombie then return
+ 			return;
+ 		}
+ 
+ 		// Getting the root
+ 		CComPtr<IMgaFCO> ccpMgaRootFCO;
+ 		ccpMgaRootFCO = m_theCurrentRootFCO;
+ 
+ 		// Building inheritance tree
+ 		reqBuildInheritanceTree(NULL,ccpMgaRootFCO,-1);
+ 	
+ 		// Ending transaction
+ 		pMgaContext->CommitTransaction();
+ 
+ 	}MSGCATCH("Error retrieving data for inheritance tab",pMgaContext->AbortTransaction();)	
+ 
+ 
+ 	// Select the current item
+ 	//HTREEITEM hSelectedItem;
+ 	//m_TreeInheritance.m_MgaMap.LookupTreeItem(ccpMgaFCO,hSelectedItem);
+ 	//m_TreeInheritance.SelectItem(hSelectedItem);
+ 	//m_TreeInheritance.EnsureVisible(hSelectedItem);
+ 
+ }
+ 
+ void CInheritancePropertyPage::Refresh()
+ {
+ 	CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp();
+ 	CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext;
+ 	
+ 	MSGTRY{
+ 		// Starting transaction
+ 		pMgaContext->BeginTransaction();
+ 
+ 		m_ComboSearchCtrl.ResetContent();
+ 
+ 		m_TreeInheritance.StoreState();
+ 		m_TreeInheritance.CleanUp();
+ 		SetupTree2();
+ 		m_TreeInheritance.RestoreState();
+ 
+ 	}MSGCATCH("Error refreshing tree browser data",pMgaContext->AbortTransaction();)	
+ 	// Ending transaction
+ 	pMgaContext->CommitTransaction();
+ }
  
  void CInheritancePropertyPage::reqBuildInheritanceTree(HTREEITEM hParent, IMgaFCO* pIMgaFCO, int nDepthLevel)
***************
*** 2508,2512 ****
  BOOL CInheritancePropertyPage::OnSetActive() 
  {
! 
  	SetupTree();	
  	return CPropertyPageEx::OnSetActive();
--- 2745,2749 ----
  BOOL CInheritancePropertyPage::OnSetActive() 
  {
! 	ResetRoot();
  	SetupTree();	
  	return CPropertyPageEx::OnSetActive();

Index: ActiveBrowserPropertyPage.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/GMEActiveBrowser/ActiveBrowserPropertyPage.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** ActiveBrowserPropertyPage.h	12 Jan 2005 17:54:00 -0000	1.11
--- ActiveBrowserPropertyPage.h	19 Jan 2005 19:45:32 -0000	1.12
***************
*** 37,41 ****
  	CComboEdit m_ComboEditCtrl;
  
!     int GetSourceControlStateOffset(IMgaObject * obj);
  
  	BOOL HasDisplayedChild(HTREEITEM hItem);
--- 37,41 ----
  	CComboEdit m_ComboEditCtrl;
  
! 	int GetSourceControlStateOffset(IMgaObject * obj);
  
  	BOOL HasDisplayedChild(HTREEITEM hItem);
***************
*** 142,145 ****
--- 142,151 ----
  	~CInheritancePropertyPage();
  	
+ 	// Resets the last root object, used by the CAggregatePropertyPage also
+ 	void ResetRoot();
+ 	void Refresh();
+ 	void OnMgaEvent(CComPtr<IMgaObject> ccpMgaObject, unsigned long lEventMask);
+ 	void PrepareStateImageList();
+ 
  // Dialog Data
  	//{{AFX_DATA(CInheritancePropertyPage)
***************
*** 168,176 ****
--- 174,186 ----
  	afx_msg void OnDblclkTreeInheritance(NMHDR* pNMHDR, LRESULT* pResult);
  	afx_msg void OnItemExpandingTreeInheritance(NMHDR* pNMHDR, LRESULT* pResult);
+ 	afx_msg void OnKeyDownTreeInheritance(NMHDR* pNMHDR, LRESULT* pResult);
  	//}}AFX_MSG
  	DECLARE_MESSAGE_MAP()
  	CImageList m_ImageList;
+ 	CImageList m_StateImageList;
  
  private:
+ 	// Remembering the current root object (in the inheritance tree)
+ 	CComPtr<IMgaFCO> m_theCurrentRootFCO;
  	// Remembering the previously selected item in the aggregation window
  	LPUNKNOWN m_pPrevSelectedItem; 
***************
*** 179,182 ****
--- 189,194 ----
  	// Creates the tree
  	void SetupTree();
+ 	// Creates the tree using the m_theCurrentRootFCO var as root / used for refresh
+ 	void SetupTree2();
  	// Recursively build up the tree traversing the inheritance hierarchy
  	void reqBuildInheritanceTree(HTREEITEM hParent, IMgaFCO* pIMgaFCO, int nDepthLevel);

Index: GMEActiveBrowserCtl.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/GMEActiveBrowser/GMEActiveBrowserCtl.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** GMEActiveBrowserCtl.cpp	12 Jan 2005 17:54:00 -0000	1.12
--- GMEActiveBrowserCtl.cpp	19 Jan 2005 19:45:32 -0000	1.13
***************
*** 374,378 ****
  	CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext;
  
! 	CAggregateTreeCtrl* pTreeCtrl=&m_pPropFrame->m_pModelessPropSheet->m_PageAggregate.m_TreeAggregate;
  
  	CComPtr<IMgaObjects> ccpSelectedObjects;
--- 374,382 ----
  	CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext;
  
! 	CMgaMappedTreeCtrl* pTreeCtrl = &m_pPropFrame->m_pModelessPropSheet->m_PageAggregate.m_TreeAggregate;
! 
! 	if( 1 == m_pPropFrame->m_pModelessPropSheet->GetActiveIndex()) // if the INHER tree is active use that tree
! 		pTreeCtrl = &m_pPropFrame->m_pModelessPropSheet->m_PageInheritance.m_TreeInheritance;
! 	
  
  	CComPtr<IMgaObjects> ccpSelectedObjects;
***************
*** 582,586 ****
  		m_MgaObjectEventList.RemoveAll();
  
!         m_pPropFrame->m_pModelessPropSheet->m_PageAggregate.Refresh();
  	}
  	else if(event==GLOBALEVENT_UNDO)
--- 586,591 ----
  		m_MgaObjectEventList.RemoveAll();
  
! 		m_pPropFrame->m_pModelessPropSheet->m_PageAggregate.Refresh();
! 		m_pPropFrame->m_pModelessPropSheet->m_PageInheritance.Refresh();
  	}
  	else if(event==GLOBALEVENT_UNDO)
***************
*** 588,595 ****
--- 593,602 ----
  		EVENT_TRACE("GLOBALEVENT_UNDO\n");
  		m_pPropFrame->m_pModelessPropSheet->m_PageAggregate.Refresh();
+ 		m_pPropFrame->m_pModelessPropSheet->m_PageInheritance.Refresh();
  	}
  	else if(event==GLOBALEVENT_REDO)
  	{
  		m_pPropFrame->m_pModelessPropSheet->m_PageAggregate.Refresh();
+ 		m_pPropFrame->m_pModelessPropSheet->m_PageInheritance.Refresh();
  		EVENT_TRACE("GLOBALEVENT_REDO\n");
  	}
***************
*** 644,647 ****
--- 651,658 ----
  		// Propagating message to AggregatePropertyPage
  		m_pPropFrame->m_pModelessPropSheet->m_PageAggregate.OnMgaEvent\
+ 						(pEventWrapper->m_ccpMgaObject,pEventWrapper->m_eventmask);
+ 
+ 		// ... and to the InheritancePropertyPage as well
+ 		m_pPropFrame->m_pModelessPropSheet->m_PageInheritance.OnMgaEvent\
  						(pEventWrapper->m_ccpMgaObject,pEventWrapper->m_eventmask);
  

Index: InheritanceTreeCtrl.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/GMEActiveBrowser/InheritanceTreeCtrl.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** InheritanceTreeCtrl.cpp	29 Jun 2004 17:49:11 -0000	1.2
--- InheritanceTreeCtrl.cpp	19 Jan 2005 19:45:32 -0000	1.3
***************
*** 6,9 ****
--- 6,10 ----
  #include "gmeactivebrowser.h"
  #include "InheritanceTreeCtrl.h"
+ #include "ActiveBrowserPropertyPage.h"
  
  #ifdef _DEBUG
***************
*** 45,48 ****
--- 46,52 ----
  		m_MgaMap.AddEntry(hItem,ObjectProxy);
  		SetItemData(hItem,(DWORD)0);
+ 
+ 		SetItemProperties(hItem);
+ 
  		return hItem;
  	}
***************
*** 50,51 ****
--- 54,260 ----
  }
  
+ void CInheritanceTreeCtrl::SetItemProperties(HTREEITEM hItem)
+ {
+ 	CMgaObjectProxy ObjectProxy;
+ 
+ 	if(!m_MgaMap.LookupObjectProxy(hItem, ObjectProxy))return;
+ 
+ 	CComQIPtr<IMgaObject> ccpObject(ObjectProxy.m_pMgaObject);
+ 
+ 	if(!ccpObject)return; // Not an MgaObject
+ 	
+ 	BYTE cState=0;
+ 
+ 	CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp();
+ 	CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext;
+ 
+ 	pMgaContext->BeginTransaction();
+ 
+ 
+ 	// Checking access rights
+ 	VARIANT_BOOL vtbIsWritable=VARIANT_FALSE;
+ 	COMTHROW( ccpObject->get_IsWritable(&vtbIsWritable));
+ 
+ 	if (vtbIsWritable != VARIANT_TRUE)
+ 	{
+ 		cState|=0x0001;// Read only object
+ 	} // If the object is writable then nothing
+ 
+ 
+ 	VARIANT_BOOL vtbIsLibObject=VARIANT_FALSE;;
+ 	COMTHROW(ccpObject->get_IsLibObject(&vtbIsLibObject));
+ 	
+ 	if(vtbIsLibObject!=VARIANT_TRUE)
+ 	{ } // Not a LibObject
+ 	else
+ 	{		
+ 		cState|=0x0002;// LibObject
+ 	}
+ 
+ 	pMgaContext->CommitTransaction();
+ 
+ 	/////////////// If it is an FCO cast it //////////////
+ 	// If not an FCO
+ 	if(ObjectProxy.m_TypeInfo==OBJTYPE_FOLDER)return;
+ 
+ 	CComQIPtr<IMgaFCO> ccpMgaFCO(ObjectProxy.m_pMgaObject);
+ 	if(!ccpMgaFCO)return; // Not an FCO
+ 
+ 	pMgaContext->BeginTransaction();
+ 	// Is it instance?
+ 	VARIANT_BOOL vtbIsInstance=VARIANT_FALSE;
+ 	COMTHROW(ccpMgaFCO->get_IsInstance(&vtbIsInstance));
+ 
+ 	if(vtbIsInstance!=VARIANT_TRUE)
+ 	{
+ 		CComPtr<IMgaFCO> ccpBaseType;
+ 		COMTHROW(ccpMgaFCO->get_BaseType(&ccpBaseType));
+ 
+ 		if(!ccpBaseType)
+ 		{ } // Not derived
+ 		else
+ 		{
+ 			cState|=0x0008;// Derived
+ 		}
+ 	}
+ 	else
+ 	{
+ 		cState|=0x0004;// Instance
+ 	}
+ 
+ 	pMgaContext->CommitTransaction();	
+ 	
+ 
+ 	if(cState)
+ 	{
+ 		CTreeCtrl::SetItemState( hItem,INDEXTOSTATEIMAGEMASK(cState), TVIS_STATEIMAGEMASK );
+ 	}
+ 	else
+ 	{		
+ 		CTreeCtrl::SetItemState( hItem,0, TVIS_STATEIMAGEMASK );
+ 	}
+ }
+ 
+ void CInheritanceTreeCtrl::StoreState()
+ {
+ 
+ 	m_StateBuffer.RemoveAll();
+ 
+ 	// Traverse all items in tree control
+ 	HTREEITEM hItem= GetRootItem();
+ 
+ 	while ( hItem )
+ 	{
+ 		/* Saving the items to the state buffer		*/
+ 		// Getting item state
+ 		UINT nItemState=CTreeCtrlEx::GetItemState(hItem,0x000000ff);
+ 		CString strItemState;
+ 		strItemState.Format("%ul",nItemState);
+ 
+ 		// Searching the map for the Mga pointer
+ 		LPUNKNOWN pUnknown;
+ 		if(m_MgaMap.LookupObjectUnknown(hItem,pUnknown))
+ 		{
+ 			CComQIPtr<IMgaObject>ccpMgaObject(pUnknown);
+ 			if(ccpMgaObject) // succesful conversion
+ 			{
+ 				CComBSTR IDObj;
+ 				ccpMgaObject->get_ID(&IDObj);
+ 
+ 				// Put Object id and item state in the buffer
+ 				CString strID(IDObj);
+ 				m_StateBuffer.SetAt(strID,strItemState);
+ 				
+ 			}
+ 		}
+ 
+ 		// Get first child node
+ 		HTREEITEM hNextItem = GetChildItem( hItem );
+ 
+ 		if ( !hNextItem )
+ 		{
+ 			// Get next sibling child
+ 			hNextItem = GetNextSiblingItem( hItem );
+ 
+ 			if ( !hNextItem )
+ 			{
+ 				HTREEITEM hParentItem=hItem;
+ 				while ( !hNextItem && hParentItem )
+ 				{
+ 					// No more children: Get next sibling to parent
+ 					hParentItem = GetParentItem( hParentItem );
+ 					hNextItem = GetNextSiblingItem( hParentItem );
+ 				}
+ 			}
+ 		}
+ 
+ 		hItem = hNextItem;
+ 	}
+ 
+ 	m_bIsStateStored=TRUE;
+ 	return;
+ 
+ }
+ 
+ 
+ 
+ void CInheritanceTreeCtrl::RestoreState()
+ {
+ 	if(!m_bIsStateStored)return;
+ 
+ 	// Traverse all items in tree control
+ 	HTREEITEM hItem= GetRootItem();
+ 
+ 	while ( hItem )
+ 	{
+ 		/* Getting the item from the map		*/
+ 		
+ 		// Searching the map for the Mga pointer
+ 		LPUNKNOWN pUnknown;
+ 		if(m_MgaMap.LookupObjectUnknown(hItem,pUnknown))
+ 		{
+ 			CComQIPtr<IMgaObject>ccpMgaObject(pUnknown);
+ 			if(ccpMgaObject) // succesful conversion
+ 			{
+ 				CComBSTR IDObj;
+ 				ccpMgaObject->get_ID(&IDObj);
+ 
+ 				// Get Object id and item state from the map
+ 				CString strID(IDObj);
+ 				CString strItemState;
+ 				if(m_StateBuffer.Lookup(strID,strItemState))
+ 				{
+ 					char* pszEndPtr=NULL;
+ 					UINT nItemState=strtoul(strItemState,&pszEndPtr,10);														
+ 					CMgaMappedTreeCtrl::SetItemState(hItem,nItemState);
+ 				}
+ 			}
+ 		}
+ 		
+ 		// Get first child node
+ 		HTREEITEM hNextItem = GetChildItem( hItem );
+ 
+ 		if ( !hNextItem )
+ 		{
+ 			// Get next sibling child
+ 			hNextItem = GetNextSiblingItem( hItem );
+ 
+ 			if ( !hNextItem )
+ 			{
+ 				HTREEITEM hParentItem=hItem;
+ 				while ( !hNextItem && hParentItem )
+ 				{
+ 					// No more children: Get next sibling to parent
+ 					hParentItem = GetParentItem( hParentItem );
+ 					hNextItem = GetNextSiblingItem( hParentItem );
+ 				}
+ 			}
+ 		}
+ 
+ 		hItem = hNextItem;
+ 	}
+ 
+ 	m_StateBuffer.RemoveAll();
+ 	m_bIsStateStored=FALSE;
+ 	return;
+ }

Index: InheritanceTreeCtrl.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/GMEActiveBrowser/InheritanceTreeCtrl.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** InheritanceTreeCtrl.h	1 Mar 2002 21:53:00 -0000	1.1
--- InheritanceTreeCtrl.h	19 Jan 2005 19:45:32 -0000	1.2
***************
*** 20,23 ****
--- 20,28 ----
  	HTREEITEM InsertItem(HTREEITEM hParent, CString strObjectName, LPUNKNOWN pUnknown, objtype_enum otObjectType);
  
+ 	void SetItemProperties(HTREEITEM hItem);
+ 	CMapStringToString m_StateBuffer;
+ 	BOOL m_bIsStateStored;
+ 	void RestoreState();
+ 	void StoreState();
  
  };



More information about the GME-commit mailing list