GME
13
|
00001 // MgaMappedTreeCtrl.h: interface for the CMgaMappedTreeCtrl class. 00002 // 00004 00005 #if !defined(AFX_MGAMAPPEDTREECTRL_H__01ABA150_667F_4191_95BC_DA45058B98C9__INCLUDED_) 00006 #define AFX_MGAMAPPEDTREECTRL_H__01ABA150_667F_4191_95BC_DA45058B98C9__INCLUDED_ 00007 00008 #if _MSC_VER > 1000 00009 #pragma once 00010 #endif // _MSC_VER > 1000 00011 00012 #include "TreeCtrlEx.h" 00013 #include "MgaMap.h" // Added by ClassView 00014 #include "GMEActiveBrowserDropTarget.h" // Added by ClassView 00015 00016 #define MGATREECTRL_LOGEVENT(eventstring) \ 00017 { \ 00018 if(m_EventLogger != NULL) \ 00019 { \ 00020 CComBSTR eventBSTR = eventstring; \ 00021 m_EventLogger->LogEvent(eventBSTR); \ 00022 } \ 00023 } \ 00024 00025 class CMgaMappedTreeCtrlBase : public CTreeCtrlEx 00026 { 00027 public: 00028 CMgaMappedTreeCtrlBase() : m_DropTarget(this) {}; 00029 virtual BOOL DoDrop(eDragOperation, COleDataObject*,CPoint); 00030 void RegisterDropTarget(); 00031 virtual BOOL IsRelevantDropTarget(CPoint point,CImageList*); 00032 void ExpandAllChildren(HTREEITEM hParent,UINT nCode); 00033 void DeleteAllChildren(HTREEITEM hParent); 00034 BOOL SetItemState(HTREEITEM hItem, UINT nState); 00035 virtual BOOL DeleteItem(HTREEITEM hItem) = 0; 00036 virtual void CleanUp() = 0; 00037 virtual BOOL LookupObjectUnknown(HTREEITEM hTreeItem, IUnknown*& out) = 0; 00038 00039 protected: 00040 CGMEActiveBrowserDropTarget m_DropTarget; 00041 00042 CComPtr<IMgaEventLogger> m_EventLogger; 00043 }; 00044 00045 00046 template<class ObjectProxy> 00047 class CMgaMappedTreeCtrl : public CMgaMappedTreeCtrlBase 00048 { 00049 public: 00050 CMgaMappedTreeCtrl() { 00051 m_EventLogger.CoCreateInstance(L"Mga.MgaEventLogger"); 00052 } 00053 00054 BOOL GetSelectedItemProxy(ObjectProxy& rMgaObjectProxy) { 00055 HTREEITEM hTreeItem = __super::GetSelectedItem(); 00056 00057 if (hTreeItem == NULL) 00058 return FALSE; // No selected item 00059 00060 return m_MgaMap.LookupObjectProxy(hTreeItem, rMgaObjectProxy); 00061 } 00062 00063 virtual ~CMgaMappedTreeCtrl() {} 00064 00065 virtual BOOL DeleteItem(HTREEITEM hItem) { 00066 m_MgaMap.RemoveTreeItem(hItem); 00067 return CTreeCtrl::DeleteItem(hItem); 00068 } 00069 00070 virtual void CleanUp() { 00071 CTreeCtrlEx::DeleteAllItems(); 00072 m_MgaMap.DestroyMap(); 00073 } 00074 00075 virtual BOOL LookupObjectUnknown(HTREEITEM hTreeItem, IUnknown*& out) { 00076 return m_MgaMap.LookupObjectUnknown(hTreeItem, out); 00077 } 00078 00079 CMgaMap<ObjectProxy> m_MgaMap; 00080 }; 00081 00082 #endif // !defined(AFX_MGAMAPPEDTREECTRL_H__01ABA150_667F_4191_95BC_DA45058B98C9__INCLUDED_)