[GME-commit] GMESRC/GME/PartBrowser MgaObjectEventList.cpp, NONE, 1.1 MgaObjectEventList.h, NONE, 1.1 ObjectEventWrapper.cpp, NONE, 1.1 ObjectEventWrapper.h, NONE, 1.1 PartBrowser.cpp, NONE, 1.1 PartBrowser.def, NONE, 1.1 PartBrowser.h, NONE, 1.1 PartBrowser.ico, NONE, 1.1 PartBrowser.idl, NONE, 1.1 PartBrowser.rc, NONE, 1.1 PartBrowser.vcproj, NONE, 1.1 PartBrowserCtrl.bmp, NONE, 1.1 PartBrowserCtrl.cpp, NONE, 1.1 PartBrowserCtrl.h, NONE, 1.1 PartBrowserDlg.cpp, NONE, 1.1 PartBrowserDlg.h, NONE, 1.1 PartBrowseridl.h, NONE, 1.1 PartBrowserOLEData.cpp, NONE, 1.1 PartBrowserOLEData.h, NONE, 1.1 PartBrowserPane.cpp, NONE, 1.1 PartBrowserPane.h, NONE, 1.1 PartBrowserPaneFrame.cpp, NONE, 1.1 PartBrowserPaneFrame.h, NONE, 1.1 PartBrowserPropPage.cpp, NONE, 1.1 PartBrowserPropPage.h, NONE, 1.1 ReadMe.txt, NONE, 1.1 resource.h, NONE, 1.1 stdafx.cpp, NONE, 1.1 stdafx.h, NONE, 1.1

Log messages of CVS commits gme-commit at list.isis.vanderbilt.edu
Wed Feb 13 15:24:00 CST 2008


Update of /project/gme-repository/GMESRC/GME/PartBrowser
In directory escher:/tmp/cvs-serv7992/GME/PartBrowser

Added Files:
	MgaObjectEventList.cpp MgaObjectEventList.h 
	ObjectEventWrapper.cpp ObjectEventWrapper.h PartBrowser.cpp 
	PartBrowser.def PartBrowser.h PartBrowser.ico PartBrowser.idl 
	PartBrowser.rc PartBrowser.vcproj PartBrowserCtrl.bmp 
	PartBrowserCtrl.cpp PartBrowserCtrl.h PartBrowserDlg.cpp 
	PartBrowserDlg.h PartBrowseridl.h PartBrowserOLEData.cpp 
	PartBrowserOLEData.h PartBrowserPane.cpp PartBrowserPane.h 
	PartBrowserPaneFrame.cpp PartBrowserPaneFrame.h 
	PartBrowserPropPage.cpp PartBrowserPropPage.h ReadMe.txt 
	resource.h stdafx.cpp stdafx.h 
Log Message:
1. PartBrowser ActiveX control
2. Drag-drop support PartBrowserbol kozvetlenul a treeview-ba (AggregateTreeCtrl.cpp)
3. Java-s kodok az Eclipse-es kiserletezesi prototipushoz


CVS User:  (csaba)

--- NEW FILE: PartBrowserDlg.h ---
#if !defined(AFX_PARTBROWSERDLG_H__6BE75806_C869_11D3_91EA_00104B98EAD9__INCLUDED_)
#define AFX_PARTBROWSERDLG_H__6BE75806_C869_11D3_91EA_00104B98EAD9__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PartBrowserDlg.h : header file
//

#include "PartBrowserPaneFrame.h"

/////////////////////////////////////////////////////////////////////////////
// CPartBrowserDlg dialog

class CPartBrowserCtrl;

class CPartBrowserDlg : public CDialog
{
// Construction
public:
	CPartBrowserDlg(CWnd* pParent = NULL);   // standard constructor

public:
// Dialog Data
	//{{AFX_DATA(CPartBrowserDlg)
	enum { IDD = IDD_PARTBROWSER_DIALOG };
	CTabCtrl		tab;
	//}}AFX_DATA
	CPartBrowserPaneFrame	partFrame;

	CComPtr<IMgaMetaModel>	mgaMetaModel;
	CComPtr<IMgaProject>	mgaProject;

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPartBrowserDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

public:
	void SetCurrentProject(CComPtr<IMgaProject> project);
	void SetMetaModel(CComPtr<IMgaMetaModel> meta);
	void SetBgColor(COLORREF bgColor);
	void ChangeAspect(long ind);
	void CycleAspect();
	void SetTabs();
	void Resize();
// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CPartBrowserDlg)
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	virtual void OnCancel();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnSelchangeAspectTab(NMHDR* pNMHDR, LRESULT* pResult);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	void SendAspectChange(long index);
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PARTBROWSERDLG_H__6BE75806_C869_11D3_91EA_00104B98EAD9__INCLUDED_)

--- NEW FILE: PartBrowserPane.h ---
#if !defined(AFX_PARTBROWSERPANE_H__B9443F67_C8F4_11D3_91EB_00104B98EAD9__INCLUDED_)
#define AFX_PARTBROWSERPANE_H__B9443F67_C8F4_11D3_91EB_00104B98EAD9__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PartBrowserPane.h : header file
//

#include <vector>

/////////////////////////////////////////////////////////////////////////////
// CPartBrowserPane window

class CPartBrowserPane : public CWnd
{
// Construction
public:
	struct PartWithDecorator {
		CComPtr<IMgaMetaPart>	part;
		CComPtr<IMgaDecorator>	decorator;
	};

	CPartBrowserPane();
	virtual ~CPartBrowserPane();

private:
// Operations
	CComBSTR	GetDecoratorProgId(CComPtr<IMgaMetaFCO> metaFCO);
	bool		IsPartDisplayable(CComPtr<IMgaMetaPart> metaPart, bool debugPrint = false);
	bool		FindObject(CPoint &pt, PartWithDecorator& pdt);
	void		CreateDecorators(CComPtr<IMgaMetaParts> metaParts);
	void		DestroyDecorators(void);

// Attributes
protected:
	CComPtr<IMgaProject>	mgaProject;
	CComPtr<IMgaMetaModel>	mgaMetaModel;
	COLORREF				backgroundColor;
	std::vector<std::vector<PartWithDecorator> >	pdts;
	int						currenAspectIndex;
	CSize					maxSize;
	bool					omitPaintMessages;
	CFont					txtMetricFont;
	// To avoid GdiplusShutdown by BoxDecorator (see Mga BoxDecorator constructor/destructor),
	// beause this frees up all memory behind m_mapBitmaps cache (see BitmapUtils.cpp,hpp -> crash
	// TODO: maybe cache flush should be done in BoxDecorator Destructor with the GdiplusShutdown
	CComPtr<IMgaDecorator>	dummyDecorator;

public:
// Operations
	void Resize(CRect r);

// Get/Set methods
	void SetCurrentProject(CComPtr<IMgaProject> project);
	void SetMetaModel(CComPtr<IMgaMetaModel> meta);
	void SetBgColor(COLORREF bgColor);
	void ChangeAspect(int index);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPartBrowserPane)
	//}}AFX_VIRTUAL

// Implementation

	// Generated message map functions
protected:
	//{{AFX_MSG(CPartBrowserPane)
	afx_msg void OnPaint();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PARTBROWSERPANE_H__B9443F67_C8F4_11D3_91EB_00104B98EAD9__INCLUDED_)

--- NEW FILE: PartBrowser.def ---
; PartBrowser.def : Declares the module parameters.

LIBRARY      "PartBrowser.OCX"

EXPORTS
	DllCanUnloadNow     PRIVATE
	DllGetClassObject   PRIVATE
	DllRegisterServer   PRIVATE
	DllUnregisterServer PRIVATE

--- NEW FILE: PartBrowserPaneFrame.h ---
#if !defined(AFX_PARTBROWSERPANEFRAME_H__B9443F66_C8F4_11D3_91EB_00104B98EAD9__INCLUDED_)
#define AFX_PARTBROWSERPANEFRAME_H__B9443F66_C8F4_11D3_91EB_00104B98EAD9__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PartBrowserPaneFrame.h : header file
//

#include "PartBrowserPane.h"
#include "Resource.h"

/////////////////////////////////////////////////////////////////////////////
// CPartBrowserPaneFrame dialog

class CPartBrowserPaneFrame : public CDialog
{
// Construction
public:
	CPartBrowserPaneFrame(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
	//{{AFX_DATA(CPartBrowserPaneFrame)
	enum { IDD = IDD_PARTBROWSERFRAME_DIALOG };
		// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPartBrowserPaneFrame)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	CPartBrowserPane pane;

	int logicalHeight;
	int pageHeight;
	int scrollPos;
	const int vScrollWidth;
	const int lineSize;
	const int pageSize;

public:
	void Resize(RECT r);
	void SetScrollBar();

	// Get/Set methods
	CPartBrowserPane&	GetPane(void);
	void				SetLogicalHeight(int logHeight);
	void				SetPageHeight(int pgHeight);
	int					GetScrollPosition(void);
	void				SetScrollPosition(int scrollPosition);

protected:

	// Generated message map functions
	//{{AFX_MSG(CPartBrowserPaneFrame)
	virtual BOOL OnInitDialog();
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PARTBROWSERPANEFRAME_H__B9443F66_C8F4_11D3_91EB_00104B98EAD9__INCLUDED_)

--- NEW FILE: PartBrowserCtrl.bmp ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: MgaObjectEventList.cpp ---
// MgaObjectEventList.cpp: implementation of the CMgaObjectEventList class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MgaObjectEventList.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMgaObjectEventList::CMgaObjectEventList()
{

}

CMgaObjectEventList::~CMgaObjectEventList()
{

}

void CMgaObjectEventList::Add(IMgaObject *pMgaObject, unsigned long eventmask)
{
 
	AddTail(new CMgaObjectEventWrapper(pMgaObject,eventmask));
}

void CMgaObjectEventList::RemoveAll()
{
 POSITION pos=GetHeadPosition();

 while(pos)
 {
	 CMgaObjectEventWrapper* ptr=(CMgaObjectEventWrapper*)GetNext(pos);
	 delete ptr;
 }

 CPtrList::RemoveAll();
}

void CMgaObjectEventList::RemoveAt(POSITION position)
{
	CMgaObjectEventWrapper* ptr=(CMgaObjectEventWrapper*)GetAt(position);
	CPtrList::RemoveAt(position);

	delete ptr;
}



--- NEW FILE: PartBrowserDlg.cpp ---
// PartBrowserDlg.cpp : implementation file
//

#include "stdafx.h"
//#include "..\Mga\MgaLib_i.c"
#include "PartBrowserDlg.h"
#include "PartBrowserCtrl.h"
#include "..\Common\CommonError.h"
#include "..\Common\CommonSmart.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPartBrowserDlg dialog


CPartBrowserDlg::CPartBrowserDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPartBrowserDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPartBrowserDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	mgaMetaModel = NULL;
	mgaProject = NULL;
}

void CPartBrowserDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPartBrowserDlg)
	DDX_Control(pDX, IDC_ASPECT_TAB, tab);
	//}}AFX_DATA_MAP
}

void CPartBrowserDlg::SetCurrentProject(CComPtr<IMgaProject> project)
{
	mgaProject = project;
	partFrame.GetPane().SetCurrentProject(project);
}

void CPartBrowserDlg::SetMetaModel(CComPtr<IMgaMetaModel> meta)
{
	mgaMetaModel = meta;
	partFrame.GetPane().SetMetaModel(meta);

	SetTabs();
}

void CPartBrowserDlg::SetBgColor(COLORREF bgColor)
{
	partFrame.GetPane().SetBgColor(bgColor);
}

void CPartBrowserDlg::ChangeAspect(long ind)
{
	tab.SetCurSel(ind);
	partFrame.GetPane().ChangeAspect(ind);
	Resize();
}

void CPartBrowserDlg::CycleAspect()
{
	if (!mgaMetaModel)
		return;

	CComPtr<IMgaMetaParts> mgaMetaParts;
	try {
		CComPtr<IMgaMetaAspects> spAspects;
		COMTHROW(mgaMetaModel->get_Aspects(&spAspects));
		ASSERT(spAspects);
		if (spAspects) {
			long nAspects = 0;
			COMTHROW(spAspects->get_Count(&nAspects));
			if (nAspects <= 0)
				return;

			long ind = (tab.GetCurSel() + 1) % nAspects;
			tab.SetCurSel(ind);

			partFrame.GetPane().ChangeAspect(ind);
			SendAspectChange(ind);
		}
	}
	catch (hresult_exception&) {
	}

	Resize();
}

void CPartBrowserDlg::SetTabs()
{
	tab.DeleteAllItems();
	if (mgaMetaModel) {
		try {
			CComPtr<IMgaMetaAspects> spAspects;
			COMTHROW(mgaMetaModel->get_Aspects(&spAspects));
			ASSERT(spAspects);
			if (spAspects) {
				long nAspects = 0;
				COMTHROW(spAspects->get_Count(&nAspects));
				TC_ITEM tcItem;
				for (long ind = 0; ind < nAspects; ind++) {
					CComPtr<IMgaMetaAspect>	spAspect;
					COMTHROW(spAspects->get_Item(ind + 1, &spAspect));
					tcItem.mask = TCIF_TEXT;
					CComBSTR nameBStr;
					COMTHROW(spAspect->get_Name(&nameBStr));
					CString name;
					CopyTo(nameBStr, name);
					tcItem.pszText = name.GetBuffer();
					tcItem.cchTextMax = name.GetLength();
					tab.InsertItem(ind, &tcItem);
				}
			}
		}
		catch (hresult_exception&) {
		}
	}
	Resize();
}

void CPartBrowserDlg::Resize()
{
	RECT r;
	GetClientRect(&r);
	if (::IsWindow(tab.m_hWnd))
		tab.MoveWindow(&r);
	if (::IsWindow(partFrame.m_hWnd)) {
		tab.AdjustRect(FALSE, &r);
		r.bottom -= 2;
		r.top += 2;
		r.left += 2;
		r.right -= 2;
		partFrame.Resize(r);
	}
}

BEGIN_MESSAGE_MAP(CPartBrowserDlg, CDialog)
	//{{AFX_MSG_MAP(CPartBrowserDlg)
	ON_WM_SIZE()
	ON_NOTIFY(TCN_SELCHANGE, IDC_ASPECT_TAB, OnSelchangeAspectTab)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPartBrowserDlg message handlers

BOOL CPartBrowserDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	tab.SetWindowPos(&wndBottom, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
	partFrame.Create(IDD_PARTBROWSERFRAME_DIALOG, this);

	SetTabs();

	return TRUE;	// return TRUE unless you set the focus to a control
					// EXCEPTION: OCX Property Pages should return FALSE
}

void CPartBrowserDlg::OnOK()
{
	// do nothing to avoid getting kick out
}

void CPartBrowserDlg::OnCancel()
{
	// do nothing to avoid getting kick out
}

void CPartBrowserDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);

	Resize();	
}

void CPartBrowserDlg::OnSelchangeAspectTab(NMHDR* /*pNMHDR*/, LRESULT* pResult) 
{
	long s = tab.GetCurSel();
	if (s >= 0) {
		partFrame.GetPane().ChangeAspect(s);
		SendAspectChange(s);
	}
	Resize();
	*pResult = 0;
}

void CPartBrowserDlg::SendAspectChange(long index)
{
	CWnd *wnd = GetParent();
	if (wnd->IsKindOf(RUNTIME_CLASS(CPartBrowserCtrl))) {
		CPartBrowserCtrl *ctrl = STATIC_DOWNCAST(CPartBrowserCtrl, wnd);
		ctrl->SendAspectChanged(index);
	}
}

--- NEW FILE: MgaObjectEventList.h ---
// MgaObjectEventList.h: interface for the CMgaObjectEventList class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MGAOBJECTEVENTLIST_H__887A50FF_BF3A_4ED4_9660_E0B83537533F__INCLUDED_)
#define AFX_MGAOBJECTEVENTLIST_H__887A50FF_BF3A_4ED4_9660_E0B83537533F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ObjectEventWrapper.h"

class CMgaObjectEventList: public CPtrList
{
public:
	void RemoveAt( POSITION position );
	void RemoveAll();
	void Add(IMgaObject* pMgaObject,unsigned long eventmask);		
	CMgaObjectEventList();
	virtual ~CMgaObjectEventList();

};

#endif // !defined(AFX_MGAOBJECTEVENTLIST_H__887A50FF_BF3A_4ED4_9660_E0B83537533F__INCLUDED_)

--- NEW FILE: PartBrowser.h ---
#pragma once

// PartBrowser.h : main header file for PartBrowser.DLL

#if !defined( __AFXCTL_H__ )
#error include 'afxctl.h' before including this file
#endif

#include "resource.h"       // main symbols


// CPartBrowserApp : See PartBrowser.cpp for implementation.

class CPartBrowserApp : public COleControlModule
{
public:
	BOOL InitInstance();
	int ExitInstance();
};

extern const GUID CDECL _tlid;
extern const WORD _wVerMajor;
extern const WORD _wVerMinor;


--- NEW FILE: PartBrowser.vcproj ---
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="7.10"
	Name="PartBrowser"
	ProjectGUID="{EC447287-A21A-4DE2-822A-55F20A5805D4}"
	RootNamespace="PartBrowser"
	Keyword="MFCActiveXProj">
	<Platforms>
		<Platform
			Name="Win32"/>
	</Platforms>
	<Configurations>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory="Debug"
			IntermediateDirectory="Debug"
			ConfigurationType="2"
			UseOfMFC="2"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				AdditionalIncludeDirectories="../Common,../Interfaces"
				PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL"
				MinimalRebuild="TRUE"
				BasicRuntimeChecks="3"
				RuntimeLibrary="3"
				TreatWChar_tAsBuiltInType="TRUE"
				UsePrecompiledHeader="3"
				WarningLevel="3"
				Detect64BitPortabilityProblems="TRUE"
				DebugInformationFormat="4"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLinkerTool"
				OutputFile="$(OutDir)/PartBrowser.ocx"
				LinkIncremental="2"
				AdditionalLibraryDirectories="C:\GME\GMESRC\GME\Gme\Debug"
				ModuleDefinitionFile=".\PartBrowser.def"
				GenerateDebugInformation="TRUE"
				SubSystem="2"
				ImportLibrary="$(OutDir)/PartBrowser.lib"
				TargetMachine="1"/>
			<Tool
				Name="VCMIDLTool"
				PreprocessorDefinitions="_DEBUG"
				MkTypLibCompatible="TRUE"
				TypeLibraryName="$(IntDir)/$(ProjectName).tlb"
				HeaderFileName="$(ProjectName)idl.h"/>
			<Tool
				Name="VCPostBuildEventTool"
				Description="Performing registration"
				CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="_DEBUG"
				Culture="1033"
				AdditionalIncludeDirectories="$(IntDir)"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
			<Tool
				Name="VCXMLDataGeneratorTool"/>
			<Tool
				Name="VCWebDeploymentTool"/>
			<Tool
				Name="VCManagedWrapperGeneratorTool"/>
			<Tool
				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
		</Configuration>
		<Configuration
			Name="Release|Win32"
			OutputDirectory="Release"
			IntermediateDirectory="Release"
			ConfigurationType="2"
			UseOfMFC="2"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL"
				RuntimeLibrary="2"
				TreatWChar_tAsBuiltInType="TRUE"
				UsePrecompiledHeader="3"
				WarningLevel="3"
				Detect64BitPortabilityProblems="TRUE"
				DebugInformationFormat="3"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLinkerTool"
				OutputFile="$(OutDir)/PartBrowser.ocx"
				LinkIncremental="1"
				ModuleDefinitionFile=".\PartBrowser.def"
				GenerateDebugInformation="TRUE"
				SubSystem="2"
				OptimizeReferences="2"
				EnableCOMDATFolding="2"
				ImportLibrary="$(OutDir)/PartBrowser.lib"
				TargetMachine="1"/>
			<Tool
				Name="VCMIDLTool"
				PreprocessorDefinitions="NDEBUG"
				MkTypLibCompatible="FALSE"
				TypeLibraryName="$(IntDir)/$(ProjectName).tlb"
				HeaderFileName="$(ProjectName)idl.h"/>
			<Tool
				Name="VCPostBuildEventTool"
				Description="Performing registration"
				CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="NDEBUG"
				Culture="1033"
				AdditionalIncludeDirectories="$(IntDir)"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
			<Tool
				Name="VCXMLDataGeneratorTool"/>
			<Tool
				Name="VCWebDeploymentTool"/>
			<Tool
				Name="VCManagedWrapperGeneratorTool"/>
			<Tool
				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
		</Configuration>
	</Configurations>
	<References>
		<ProjectReference
			ReferencedProjectIdentifier="{0B16B893-5512-48B8-B764-EE72C522EAD8}"
			Name="Core"/>
		<ProjectReference
			ReferencedProjectIdentifier="{3ED3216E-B64C-4D0B-881F-68BFF2CB3E83}"
			Name="Meta"/>
		<ProjectReference
			ReferencedProjectIdentifier="{86DAEF74-2527-41E5-82CE-52C31C5BBE8E}"
			Name="Mga"/>
		<ProjectReference
			ReferencedProjectIdentifier="{66D5FEC3-17C7-4B20-9A3A-07A1B585314F}"
			Name="MgaDecorators"/>
		<ProjectReference
			ReferencedProjectIdentifier="{CA09AB5C-BFAC-4152-AE0B-D5AFC400A5E7}"
			Name="MgaUtil"/>
		<ProjectReference
			ReferencedProjectIdentifier="{73A7151A-1044-417B-ACC8-88C48F0AFDCC}"
			Name="Parser"/>
	</References>
	<Files>
		<Filter
			Name="Source Files"
			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
			<File
				RelativePath="..\Common\CommonError.cpp">
			</File>
			<File
				RelativePath="..\Common\CommonSmart.cpp">
			</File>
			<File
				RelativePath="..\Gme\GMEOLEData.cpp">
			</File>
			<File
				RelativePath=".\MgaObjectEventList.cpp">
			</File>
			<File
				RelativePath=".\ObjectEventWrapper.cpp">
			</File>
			<File
				RelativePath=".\PartBrowser.cpp">
			</File>
			<File
				RelativePath=".\PartBrowser.def">
			</File>
			<File
				RelativePath=".\PartBrowser.idl">
				<FileConfiguration
					Name="Debug|Win32">
					<Tool
						Name="VCMIDLTool"
						AdditionalIncludeDirectories="..\Interfaces"/>
				</FileConfiguration>
				<FileConfiguration
					Name="Release|Win32">
					<Tool
						Name="VCMIDLTool"
						AdditionalIncludeDirectories="..\Interfaces"/>
				</FileConfiguration>
			</File>
			<File
				RelativePath=".\PartBrowserCtrl.cpp">
			</File>
			<File
				RelativePath=".\PartBrowserDlg.cpp">
			</File>
			<File
				RelativePath=".\PartBrowserPane.cpp">
			</File>
			<File
				RelativePath=".\PartBrowserPaneFrame.cpp">
			</File>
			<File
				RelativePath=".\PartBrowserPropPage.cpp">
			</File>
			<File
				RelativePath=".\stdafx.cpp">
				<FileConfiguration
					Name="Debug|Win32">
					<Tool
						Name="VCCLCompilerTool"
						UsePrecompiledHeader="1"/>
				</FileConfiguration>
				<FileConfiguration
					Name="Release|Win32">
					<Tool
						Name="VCCLCompilerTool"
						UsePrecompiledHeader="1"/>
				</FileConfiguration>
			</File>
		</Filter>
		<Filter
			Name="Header Files"
			Filter="h;hpp;hxx;hm;inl;inc;xsd"
			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
			<File
				RelativePath="..\Gme\GMEOLEData.h">
			</File>
			<File
				RelativePath=".\MgaObjectEventList.h">
			</File>
			<File
				RelativePath=".\ObjectEventWrapper.h">
			</File>
			<File
				RelativePath=".\PartBrowser.h">
			</File>
			<File
				RelativePath=".\PartBrowserCtrl.h">
			</File>
			<File
				RelativePath=".\PartBrowserDlg.h">
			</File>
			<File
				RelativePath=".\PartBrowserPane.h">
			</File>
			<File
				RelativePath=".\PartBrowserPaneFrame.h">
			</File>
			<File
				RelativePath=".\PartBrowserPropPage.h">
			</File>
			<File
				RelativePath=".\Resource.h">
			</File>
			<File
				RelativePath=".\stdafx.h">
			</File>
		</Filter>
		<Filter
			Name="Resource Files"
			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
			<File
				RelativePath=".\PartBrowser.ico">
			</File>
			<File
				RelativePath=".\PartBrowser.rc">
			</File>
			<File
				RelativePath=".\PartBrowserCtrl.bmp">
			</File>
		</Filter>
		<File
			RelativePath=".\ReadMe.txt">
		</File>
	</Files>
	<Globals>
	</Globals>
</VisualStudioProject>

--- NEW FILE: stdafx.h ---
#if !defined(AFX_STDAFX_H__A72BCE1F_468F_4b23_A08F_E29356EF3659__INCLUDED_)
#define AFX_STDAFX_H__A72BCE1F_468F_4b23_A08F_E29356EF3659__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
#endif

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER				// Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT		// Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400	// Change this to the appropriate value to target Windows 2000 or later.
#endif						

#ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE			// Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400	// Change this to the appropriate value to target IE 5.0 or later.
#endif

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS	// some CString constructors will be explicit

#include <afxctl.h>         // MFC support for ActiveX Controls
#include <afxext.h>         // MFC extensions
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Comon Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>			// MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

// Delete the two includes below if you do not wish to use the MFC
//  database classes
#include <afxdb.h>			// MFC database classes
#include <afxdao.h>			// MFC DAO database classes

#include <atlbase.h>
#include <atlcom.h>

#include "..\Interfaces\Meta.h"
#include "..\Interfaces\MgaUtil.h"
#include "..\Interfaces\GME.h"
#include "..\Interfaces\MgaDecorator.h"
#include "..\Common\CommonError.h"
#include "..\Common\CommonSmart.h"
#include "..\Common\CommonMfc.h"
#include "..\Common\CommonMgaTrukk.h"
//#include "..\Mga\MgaLib.h"

// Comment this out if you do not want to see the messages in the debug window
#define DEBUG_EVENTS


#ifdef DEBUG_EVENTS
 #define EVENT_TRACE(x) TRACE(x)
#else
 #define EVENT_TRACE(x)
#endif 


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__A72BCE1F_468F_4b23_A08F_E29356EF3659__INCLUDED_)

--- NEW FILE: stdafx.cpp ---
// stdafx.cpp : source file that includes just the standard includes
//  PartBrowser.pch will be the pre-compiled header
//  stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

--- NEW FILE: resource.h ---
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by PartBrowser.rc
//
#define IDS_PARTBROWSER                 1
#define IDD_ABOUTBOX_PARTBROWSER        1
#define IDB_PARTBROWSER                 1
#define IDI_ABOUTDLL                    1
#define IDS_PARTBROWSER_PPG             2
#define IDD_PARTBROWSER_DIALOG          139
#define IDD_PARTBROWSERFRAME_DIALOG     140
#define IDS_PARTBROWSER_PPG_CAPTION     200
#define IDD_PROPPAGE_PARTBROWSER        200
#define IDC_ASPECT_TAB                  1007
#define IDD_PARTBROWSER_PANE            1008

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        201
#define _APS_NEXT_COMMAND_VALUE         32768
#define _APS_NEXT_CONTROL_VALUE         201
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

--- NEW FILE: PartBrowser.idl ---
// PartBrowser.idl : type library source for ActiveX Control project.

// This file will be processed by the MIDL compiler tool to
// produce the type library (PartBrowser.tlb) that will become a resource in
// PartBrowser.ocx.

#include <olectl.h>
#include <idispids.h>

import "oaidl.idl";
import "ocidl.idl";

import "Core.idl";
#ifndef METAIDL_IMPORTED
import "Meta.idl";
#endif


[ uuid(EA3F7431-913A-421F-9B9C-BEB6A735285A), version(1.0),
  helpfile("PartBrowser.hlp"),
  helpstring("PartBrowser ActiveX Control module"),
  control ]
library PartBrowserLib
{
	importlib(STDOLE_TLB);
	importlib(STDTYPE_TLB);

	//  Primary dispatch interface for CPartBrowserCtrl

	[ uuid(2D05F0EE-EB81-4D1D-A5C6-43146F38BF81),
	  helpstring("Dispatch interface for PartBrowser Control")]
	dispinterface _DPartBrowser
	{
		properties:
			// NOTE - ClassWizard will maintain property information here.
			//    Use extreme caution when editing this section.
			//{{AFX_ODL_PROP(CPartBrowserCtrl)
			//}}AFX_ODL_PROP

		methods:
			// NOTE - ClassWizard will maintain property information here.
			//    Use extreme caution when editing this section.
			//{{AFX_ODL_METHOD(CPartBrowserCtrl)
			[id(1), helpstring("method SetCurrentProject")] void SetCurrentProject([in] IUnknown* project);
			[id(2), helpstring("method SetMetaModel")] void SetMetaModel([in] IUnknown* meta);
			[id(3), helpstring("method SetBgColor")] void SetBgColor([in] OLE_COLOR oleBgColor);
			[id(4), helpstring("method ChangeAspect")] void ChangeAspect([in] LONG index);
			[id(5), helpstring("method CycleAspect")] void CycleAspect(void);
			[id(6), helpstring("method RePaint")] void RePaint(void);
			//}}AFX_ODL_METHOD

			[id(DISPID_ABOUTBOX)] void AboutBox();
	};

	//  Event dispatch interface for CPartBrowserCtrl

	[ uuid(5042C3E4-58A9-4059-A5E4-FD7BFB3AA22B),
	  helpstring("Event interface for PartBrowser Control") ]
	dispinterface _DPartBrowserEvents
	{
		properties:
			//  Event interface has no properties

		methods:
			// NOTE - ClassWizard will maintain event information here.
			//    Use extreme caution when editing this section.
			//{{AFX_ODL_EVENT(CPartBrowserCtrl)
			[id(1), helpstring("method AspectChanged")] void AspectChanged(LONG index);
			//}}AFX_ODL_EVENT
	};

	//  Class information for CPartBrowserCtrl

	[ uuid(1FF57057-D598-4FC2-8F9D-708F59B9C017),
	  helpstring("PartBrowser Control"), control ]
	coclass PartBrowser
	{
		[default] dispinterface _DPartBrowser;
		[default, source] dispinterface _DPartBrowserEvents;
	};

};

--- NEW FILE: ReadMe.txt ---
========================================================================
    ACTIVEX CONTROL DLL : PartBrowser Project Overview
========================================================================

ControlWizard has created this project for your PartBrowser ActiveX Control
DLL, which contains 1 control.

This skeleton project not only demonstrates the basics of writing an
ActiveX Control, but is also a starting point for writing the specific
features of your control.

This file contains a summary of what you will find in each of the files
that make up your PartBrowser ActiveX Control DLL.

PartBrowser.vcproj
    This is the main project file for VC++ projects generated using an 
    Application Wizard. It contains information about the version of 
    Visual C++ that generated the file, and information about the platforms,
    configurations, and project features selected with the Application Wizard.

PartBrowser.h
    This is the main include file for the ActiveX Control DLL.  It
    includes other project-specific includes such as resource.h.

PartBrowser.cpp
    This is the main source file that contains code for DLL initialization,
    termination and other bookkeeping.

PartBrowser.rc
    This is a listing of the Microsoft Windows resources that the project
    uses.  This file can be directly edited with the Visual C++ resource
    editor.

PartBrowser.def
    This file contains information about the ActiveX Control DLL that
    must be provided to run with Microsoft Windows.

PartBrowser.idl
    This file contains the Object Description Language source code for the
    type library of your control.

PartBrowser.ico
    This file contains an icon that will appear in the About box.  This icon
    is included by the main resource file PartBrowser.rc.

/////////////////////////////////////////////////////////////////////////////
CPartBrowserCtrl control:

PartBrowserCtrl.h
    This file contains the declaration of the CPartBrowserCtrl C++ class.

PartBrowserCtrl.cpp
    This file contains the implementation of the CPartBrowserCtrl C++ class.

PartBrowserPropPage.h
    This file contains the declaration of the CPartBrowserPropPage C++ class.

PartBrowserPropPage.cpp
    This file contains the implementation of the CPartBrowserPropPage C++ class.

CPartBrowserCtrl.bmp
    This file contains a bitmap that a container will use to represent the
    CPartBrowserCtrl control when it appears on a tool palette.  This bitmap
    is included by the main resource file PartBrowser.rc.

/////////////////////////////////////////////////////////////////////////////
Other standard files:

stdafx.h, stdafx.cpp
    These files are used to build a precompiled header (PCH) file
    named PartBrowser.pch and a precompiled types (PCT) file named stdafx.obj.

resource.h
    This is the standard header file, which defines new resource IDs.
    The Visual C++ resource editor reads and updates this file.

/////////////////////////////////////////////////////////////////////////////
Other notes:

ControlWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.

/////////////////////////////////////////////////////////////////////////////

--- NEW FILE: PartBrowserPropPage.cpp ---
// PartBrowserPropPage.cpp : Implementation of the CPartBrowserPropPage property page class.

#include "stdafx.h"
#include "PartBrowser.h"
#include "PartBrowserPropPage.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


IMPLEMENT_DYNCREATE(CPartBrowserPropPage, COlePropertyPage)



// Message map

BEGIN_MESSAGE_MAP(CPartBrowserPropPage, COlePropertyPage)
END_MESSAGE_MAP()



// Initialize class factory and guid

IMPLEMENT_OLECREATE_EX(CPartBrowserPropPage, "PARTBROWSER.PartBrowserPropPage.1",
	0x8e82d238, 0xd222, 0x493d, 0x8e, 0xd2, 0x31, 0x75, 0xa5, 0xb1, 0x8, 0x6c)



// CPartBrowserPropPage::CPartBrowserPropPageFactory::UpdateRegistry -
// Adds or removes system registry entries for CPartBrowserPropPage

BOOL CPartBrowserPropPage::CPartBrowserPropPageFactory::UpdateRegistry(BOOL bRegister)
{
	if (bRegister)
		return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(),
			m_clsid, IDS_PARTBROWSER_PPG);
	else
		return AfxOleUnregisterClass(m_clsid, NULL);
}



// CPartBrowserPropPage::CPartBrowserPropPage - Constructor

CPartBrowserPropPage::CPartBrowserPropPage() :
	COlePropertyPage(IDD, IDS_PARTBROWSER_PPG_CAPTION)
{
}



// CPartBrowserPropPage::DoDataExchange - Moves data between page and properties

void CPartBrowserPropPage::DoDataExchange(CDataExchange* pDX)
{
	DDP_PostProcessing(pDX);
}



// CPartBrowserPropPage message handlers

--- NEW FILE: ObjectEventWrapper.h ---
// ObjectEventWrapper.h: interface for the CMgaObjectEventWrapper class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_OBJECTEVENTWRAPPER_H__32D44E31_FC8E_4B22_A2F3_7F15C298B8C0__INCLUDED_)
#define AFX_OBJECTEVENTWRAPPER_H__32D44E31_FC8E_4B22_A2F3_7F15C298B8C0__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CMgaObjectEventWrapper  
{
public:
	CMgaObjectEventWrapper(IMgaObject *pMgaObject, unsigned long eventmask);
	virtual ~CMgaObjectEventWrapper();
	CComPtr<IMgaObject> m_ccpMgaObject;
	unsigned long m_eventmask;
};

#endif // !defined(AFX_OBJECTEVENTWRAPPER_H__32D44E31_FC8E_4B22_A2F3_7F15C298B8C0__INCLUDED_)

--- NEW FILE: PartBrowserOLEData.h ---
#ifndef PartBrowserOLEData_h
#define PartBrowserOLEData_h

#include <afxole.h>
#include "mfcdual.h"
#include "PartBrowseridl.h"

class CPartBrowserDataDescriptor
{
public:
	CPartBrowserDataDescriptor(): pFile(0) {}
	CPartBrowserDataDescriptor(CTypedPtrList<CPtrList, CRect*> &list,
							   CTypedPtrList<CPtrList, CRect*> &annList,
							   CPoint dragPt, CPoint offs);
	~CPartBrowserDataDescriptor() { Reset(); }
public:
	CTypedPtrList<CPtrList, CRect*> rects;	
	CTypedPtrList<CPtrList, CRect*> annRects;	
	CPoint offset;
	CFile* pFile;
public:
	void SimpleDraw(CDC* pDC,CPoint& pt);
	void GetBoundingRect(CRect& rBoundingRect);
	void Reset();
	void Draw(CDC* pDC,CPoint &pt);
	void Serialize(CArchive& ar);
	bool Load(COleDataObject* pDataObject);
	void Clean();
	int GetCount();
public:
	// called externally (from GMEView.cpp and ActiveBrowserPropertyPage.cpp)
	// to destruct certain lists
	static void destructList(CTypedPtrList<CPtrList, CRect*>& pList);//it is a CRectList
};

struct IMgaProject;

class CPartBrowserDataSource : public COleDataSource
{
public:
	CPartBrowserDataSource(IMgaProject *p)
	{
		EnableAutomation();
		ASSERT(p != NULL ); 
		project = p;
		myData++; 
	}

	~CPartBrowserDataSource() { myData--; }

protected:
	CComPtr<IMgaProject> project;
	CComPtr<IUnknown> data;
	CComPtr<IUnknown> folders; // by Zolmol
	CComPtr<IUnknown> regdata;

public:
	static CLIPFORMAT cfGMEDesc;
	static int myData;

public:
	void SetNodes(IMgaFCOs* fcos) { data = fcos; }
	void SetFolders(IMgaFolders* objs) { folders = objs; } // by Zolmol
	void SetMetaRole(IMgaMetaRole* metaRole) { data = metaRole; }
	void SetAnnotations(IMgaRegNodes* regs) { regdata = regs; }

	void CacheDescriptor(CPartBrowserDataDescriptor* desc);
	void DelayXMLDump();

	static bool IsGmeNativeDataAvailable(COleDataObject* pDataObject, IMgaProject* project);
	static bool IsXMLDataAvailable(COleDataObject* pDataObject);
	static bool ParseXMLData(COleDataObject* pDataObject, IMgaObject* target, bool merge);
	static CComPtr<IGMEOLEApp> get_GME(CComObjPtr<IMgaProject> project);

protected:
	HGLOBAL CreateDescriptor(CPartBrowserDataDescriptor* desc);
	virtual BOOL OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile);

// Interface Maps
protected:
	DECLARE_MESSAGE_MAP()
	// OLE dispatch map functions
	afx_msg LPDISPATCH DispGetData();
	afx_msg void DispSetData(LPDISPATCH newValue);
	afx_msg LPDISPATCH DispGetFolders();
	afx_msg void DispSetFolders(LPDISPATCH newValue);
	afx_msg LPDISPATCH DispGetRegistryData();
	afx_msg void DispSetRegistryData(LPDISPATCH newValue);
	afx_msg LPDISPATCH DispGetProject();
	afx_msg void DispSetProject(LPDISPATCH newValue);

	DECLARE_DISPATCH_MAP()
	DECLARE_INTERFACE_MAP()

	BEGIN_DUAL_INTERFACE_PART(PartBrowserDataSource, IPartBrowserDataSource)
		STDMETHOD(get_Data)(IUnknown **p);
		STDMETHOD(get_Folders)(IUnknown **p);
		STDMETHOD(get_RegistryData)(IUnknown **p);
		STDMETHOD(get_Project)(IUnknown **p);
	END_DUAL_INTERFACE_PART(PartBrowserDataSource)

	//     add declaration of ISupportErrorInfo implementation
	//     to indicate we support the OLE Automation error object
	DECLARE_DUAL_ERRORINFO()
};


class CPartBrowserClosureDataSource : public CPartBrowserDataSource // by Zolmol
{
public:
	CPartBrowserClosureDataSource(IMgaProject* p) : CPartBrowserDataSource(p) {}

	~CPartBrowserClosureDataSource() {}

protected:
	CComPtr<IUnknown>	m_topFcos;
	CComPtr<IUnknown>	m_topFolders;
	long				m_options;
	CComBstrObj			m_absPathPart;
	CComBstrObj			m_acceptingKinds;

public:
	void SetTopNodes(IMgaFCOs* objs) { m_topFcos = objs; }
	void SetTopNodes(IMgaFolders* objs) { m_topFolders = objs; }
	void SetOptions(long l) { m_options = l; }
	void SetAbsPathPart(const CComBstrObj& path) { m_absPathPart = path; }
	void SetAcceptingKinds(const CComBstrObj& acceptingkinds) { m_acceptingKinds = acceptingkinds; }

protected:
	virtual BOOL OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile);
};


#endif // whole file
--- NEW FILE: PartBrowseridl.h ---


/* this ALWAYS GENERATED file contains the definitions for the interfaces */


 /* File created by MIDL compiler version 6.00.0361 */
/* at Tue Feb 12 17:15:06 2008
 */
/* Compiler settings for .\PartBrowser.idl:
    Oicf, W1, Zp8, env=Win32 (32b run)
    protocol : dce , ms_ext, c_ext, robust
    error checks: allocation ref bounds_check enum stub_data 
    VC __declspec() decoration level: 
         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
         DECLSPEC_UUID(), MIDL_INTERFACE()
*/
//@@MIDL_FILE_HEADING(  )

#pragma warning( disable: 4049 )  /* more than 64k source lines */


/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif

#include "rpc.h"
#include "rpcndr.h"

#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__


#ifndef __PartBrowseridl_h__
#define __PartBrowseridl_h__

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

/* Forward Declarations */ 

#ifndef ___DPartBrowser_FWD_DEFINED__
#define ___DPartBrowser_FWD_DEFINED__
typedef interface _DPartBrowser _DPartBrowser;
#endif 	/* ___DPartBrowser_FWD_DEFINED__ */


#ifndef ___DPartBrowserEvents_FWD_DEFINED__
#define ___DPartBrowserEvents_FWD_DEFINED__
typedef interface _DPartBrowserEvents _DPartBrowserEvents;
#endif 	/* ___DPartBrowserEvents_FWD_DEFINED__ */


#ifndef __PartBrowser_FWD_DEFINED__
#define __PartBrowser_FWD_DEFINED__

#ifdef __cplusplus
typedef class PartBrowser PartBrowser;
#else
typedef struct PartBrowser PartBrowser;
#endif /* __cplusplus */

#endif 	/* __PartBrowser_FWD_DEFINED__ */


/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
#include "Core.h"
#include "Meta.h"

#ifdef __cplusplus
extern "C"{
#endif 

void * __RPC_USER MIDL_user_allocate(size_t);
void __RPC_USER MIDL_user_free( void * ); 


#ifndef __PartBrowserLib_LIBRARY_DEFINED__
#define __PartBrowserLib_LIBRARY_DEFINED__

/* library PartBrowserLib */
/* [control][helpstring][helpfile][version][uuid] */ 


DEFINE_GUID(LIBID_PartBrowserLib,0xEA3F7431,0x913A,0x421F,0x9B,0x9C,0xBE,0xB6,0xA7,0x35,0x28,0x5A);

#ifndef ___DPartBrowser_DISPINTERFACE_DEFINED__
#define ___DPartBrowser_DISPINTERFACE_DEFINED__

/* dispinterface _DPartBrowser */
/* [helpstring][uuid] */ 


DEFINE_GUID(DIID__DPartBrowser,0x2D05F0EE,0xEB81,0x4D1D,0xA5,0xC6,0x43,0x14,0x6F,0x38,0xBF,0x81);

#if defined(__cplusplus) && !defined(CINTERFACE)

    MIDL_INTERFACE("2D05F0EE-EB81-4D1D-A5C6-43146F38BF81")
    _DPartBrowser : public IDispatch
    {
    };
    
#else 	/* C style interface */

    typedef struct _DPartBrowserVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
            _DPartBrowser * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void **ppvObject);
        
        ULONG ( STDMETHODCALLTYPE *AddRef )( 
            _DPartBrowser * This);
        
        ULONG ( STDMETHODCALLTYPE *Release )( 
            _DPartBrowser * This);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( 
            _DPartBrowser * This,
            /* [out] */ UINT *pctinfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( 
            _DPartBrowser * This,
            /* [in] */ UINT iTInfo,
            /* [in] */ LCID lcid,
            /* [out] */ ITypeInfo **ppTInfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( 
            _DPartBrowser * This,
            /* [in] */ REFIID riid,
            /* [size_is][in] */ LPOLESTR *rgszNames,
            /* [in] */ UINT cNames,
            /* [in] */ LCID lcid,
            /* [size_is][out] */ DISPID *rgDispId);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( 
            _DPartBrowser * This,
            /* [in] */ DISPID dispIdMember,
            /* [in] */ REFIID riid,
            /* [in] */ LCID lcid,
            /* [in] */ WORD wFlags,
            /* [out][in] */ DISPPARAMS *pDispParams,
            /* [out] */ VARIANT *pVarResult,
            /* [out] */ EXCEPINFO *pExcepInfo,
            /* [out] */ UINT *puArgErr);
        
        END_INTERFACE
    } _DPartBrowserVtbl;

    interface _DPartBrowser
    {
        CONST_VTBL struct _DPartBrowserVtbl *lpVtbl;
    };

    

#ifdef COBJMACROS


#define _DPartBrowser_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define _DPartBrowser_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define _DPartBrowser_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define _DPartBrowser_GetTypeInfoCount(This,pctinfo)	\
    (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)

#define _DPartBrowser_GetTypeInfo(This,iTInfo,lcid,ppTInfo)	\
    (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)

#define _DPartBrowser_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)	\
    (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)

#define _DPartBrowser_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)	\
    (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)

#endif /* COBJMACROS */


#endif 	/* C style interface */


#endif 	/* ___DPartBrowser_DISPINTERFACE_DEFINED__ */


#ifndef ___DPartBrowserEvents_DISPINTERFACE_DEFINED__
#define ___DPartBrowserEvents_DISPINTERFACE_DEFINED__

/* dispinterface _DPartBrowserEvents */
/* [helpstring][uuid] */ 


DEFINE_GUID(DIID__DPartBrowserEvents,0x5042C3E4,0x58A9,0x4059,0xA5,0xE4,0xFD,0x7B,0xFB,0x3A,0xA2,0x2B);

#if defined(__cplusplus) && !defined(CINTERFACE)

    MIDL_INTERFACE("5042C3E4-58A9-4059-A5E4-FD7BFB3AA22B")
    _DPartBrowserEvents : public IDispatch
    {
    };
    
#else 	/* C style interface */

    typedef struct _DPartBrowserEventsVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
            _DPartBrowserEvents * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void **ppvObject);
        
        ULONG ( STDMETHODCALLTYPE *AddRef )( 
            _DPartBrowserEvents * This);
        
        ULONG ( STDMETHODCALLTYPE *Release )( 
            _DPartBrowserEvents * This);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( 
            _DPartBrowserEvents * This,
            /* [out] */ UINT *pctinfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( 
            _DPartBrowserEvents * This,
            /* [in] */ UINT iTInfo,
            /* [in] */ LCID lcid,
            /* [out] */ ITypeInfo **ppTInfo);
        
        HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( 
            _DPartBrowserEvents * This,
            /* [in] */ REFIID riid,
            /* [size_is][in] */ LPOLESTR *rgszNames,
            /* [in] */ UINT cNames,
            /* [in] */ LCID lcid,
            /* [size_is][out] */ DISPID *rgDispId);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( 
            _DPartBrowserEvents * This,
            /* [in] */ DISPID dispIdMember,
            /* [in] */ REFIID riid,
            /* [in] */ LCID lcid,
            /* [in] */ WORD wFlags,
            /* [out][in] */ DISPPARAMS *pDispParams,
            /* [out] */ VARIANT *pVarResult,
            /* [out] */ EXCEPINFO *pExcepInfo,
            /* [out] */ UINT *puArgErr);
        
        END_INTERFACE
    } _DPartBrowserEventsVtbl;

    interface _DPartBrowserEvents
    {
        CONST_VTBL struct _DPartBrowserEventsVtbl *lpVtbl;
    };

    

#ifdef COBJMACROS


#define _DPartBrowserEvents_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define _DPartBrowserEvents_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define _DPartBrowserEvents_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define _DPartBrowserEvents_GetTypeInfoCount(This,pctinfo)	\
    (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)

#define _DPartBrowserEvents_GetTypeInfo(This,iTInfo,lcid,ppTInfo)	\
    (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)

#define _DPartBrowserEvents_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)	\
    (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)

#define _DPartBrowserEvents_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)	\
    (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)

#endif /* COBJMACROS */


#endif 	/* C style interface */


#endif 	/* ___DPartBrowserEvents_DISPINTERFACE_DEFINED__ */


DEFINE_GUID(CLSID_PartBrowser,0x1FF57057,0xD598,0x4FC2,0x8F,0x9D,0x70,0x8F,0x59,0xB9,0xC0,0x17);

#ifdef __cplusplus

class DECLSPEC_UUID("1FF57057-D598-4FC2-8F9D-708F59B9C017")
PartBrowser;
#endif
#endif /* __PartBrowserLib_LIBRARY_DEFINED__ */

/* Additional Prototypes for ALL interfaces */

/* end of Additional Prototypes */

#ifdef __cplusplus
}
#endif

#endif



--- NEW FILE: PartBrowser.ico ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: PartBrowserCtrl.cpp ---
// PartBrowserCtrl.cpp : Implementation of the CPartBrowserCtrl ActiveX Control class.

#include "stdafx.h"
#include "PartBrowser.h"
#include "PartBrowserCtrl.h"
#include "PartBrowserPropPage.h"
//#include "..\Mga\MgaLib.h"
#include "..\Interfaces\Mga_i.c"
#include ".\partbrowserctrl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif



IMPLEMENT_DYNCREATE(CPartBrowserCtrl, COleControl)



// Message map

BEGIN_MESSAGE_MAP(CPartBrowserCtrl, COleControl)
	//{{AFX_MSG_MAP(CPartBrowserCtrl)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
	ON_OLEVERB(AFX_IDS_VERB_EDIT, OnEdit)
	ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()



// Dispatch map

BEGIN_DISPATCH_MAP(CPartBrowserCtrl, COleControl)
	//{{AFX_DISPATCH_MAP(CPartBrowserCtrl)
	DISP_FUNCTION_ID(CPartBrowserCtrl, "SetCurrentProject", dispidSetCurrentProject, SetCurrentProject, VT_EMPTY, VTS_UNKNOWN)
	DISP_FUNCTION_ID(CPartBrowserCtrl, "SetMetaModel", dispidSetMetaModel, SetMetaModel, VT_EMPTY, VTS_UNKNOWN)
	DISP_FUNCTION_ID(CPartBrowserCtrl, "SetBgColor", dispidSetBgColor, SetBgColor, VT_EMPTY, VTS_COLOR)
	DISP_FUNCTION_ID(CPartBrowserCtrl, "ChangeAspect", dispidChangeAspect, ChangeAspect, VT_EMPTY, VTS_I4)
	DISP_FUNCTION_ID(CPartBrowserCtrl, "CycleAspect", dispidCycleAspect, CycleAspect, VT_EMPTY, VTS_NONE)
	DISP_FUNCTION_ID(CPartBrowserCtrl, "RePaint", dispidRePaint, RePaint, VT_EMPTY, VTS_NONE)
	//}}AFX_DISPATCH_MAP
	DISP_FUNCTION_ID(CPartBrowserCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()



// Event map

BEGIN_EVENT_MAP(CPartBrowserCtrl, COleControl)
	//{{AFX_EVENT_MAP(CPartBrowserCtrl)
	// NOTE - ClassWizard will add and remove event map entries
	//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_EVENT_MAP
END_EVENT_MAP()


/////////////////////////////////////////////////////////////////////////////
// Native COM interface map - peter
BEGIN_INTERFACE_MAP(CPartBrowserCtrl, COleControl)
	INTERFACE_PART(CPartBrowserCtrl, IID_IMgaEventSink, EventSink)
END_INTERFACE_MAP()


// Property pages

// TODO: Add more property pages as needed.  Remember to increase the count!
BEGIN_PROPPAGEIDS(CPartBrowserCtrl, 1)
	PROPPAGEID(CPartBrowserPropPage::guid)
END_PROPPAGEIDS(CPartBrowserCtrl)



// Initialize class factory and guid

IMPLEMENT_OLECREATE_EX(CPartBrowserCtrl, "PARTBROWSER.PartBrowserCtrl.1",
	0x1ff57057, 0xd598, 0x4fc2, 0x8f, 0x9d, 0x70, 0x8f, 0x59, 0xb9, 0xc0, 0x17)



// Type library ID and version

IMPLEMENT_OLETYPELIB(CPartBrowserCtrl, _tlid, _wVerMajor, _wVerMinor)



// Interface IDs

const IID BASED_CODE IID_DPartBrowser =
		{ 0x2D05F0EE, 0xEB81, 0x4D1D, { 0xA5, 0xC6, 0x43, 0x14, 0x6F, 0x38, 0xBF, 0x81 } };
const IID BASED_CODE IID_DPartBrowserEvents =
		{ 0x5042C3E4, 0x58A9, 0x4059, { 0xA5, 0xE4, 0xFD, 0x7B, 0xFB, 0x3A, 0xA2, 0x2B } };



// Control type information

static const DWORD BASED_CODE _dwPartBrowserOleMisc =
	OLEMISC_ACTIVATEWHENVISIBLE |
	OLEMISC_SETCLIENTSITEFIRST |
	OLEMISC_INSIDEOUT |
	OLEMISC_CANTLINKINSIDE |
	OLEMISC_RECOMPOSEONRESIZE;

IMPLEMENT_OLECTLTYPE(CPartBrowserCtrl, IDS_PARTBROWSER, _dwPartBrowserOleMisc)



// CPartBrowserCtrl::CPartBrowserCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CPartBrowserCtrl

BOOL CPartBrowserCtrl::CPartBrowserCtrlFactory::UpdateRegistry(BOOL bRegister)
{
	// TODO: Verify that your control follows apartment-model threading rules.
	// Refer to MFC TechNote 64 for more information.
	// If your control does not conform to the apartment-model rules, then
	// you must modify the code below, changing the 6th parameter from
	// afxRegInsertable | afxRegApartmentThreading to afxRegInsertable.

	if (bRegister)
		return AfxOleRegisterControlClass(
			AfxGetInstanceHandle(),
			m_clsid,
			m_lpszProgID,
			IDS_PARTBROWSER,
			IDB_PARTBROWSER,
			afxRegInsertable | afxRegApartmentThreading,
			_dwPartBrowserOleMisc,
			_tlid,
			_wVerMajor,
			_wVerMinor);
	else
		return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}



/////////////////////////////////////////////////////////////////////////////
// CPartBrowserCtrl::XEventSink - native COM interface - peter
STDMETHODIMP_(ULONG) CPartBrowserCtrl::XEventSink::AddRef()
{
	METHOD_PROLOGUE(CPartBrowserCtrl,EventSink)
	return pThis->ExternalAddRef();
}

STDMETHODIMP_(ULONG) CPartBrowserCtrl::XEventSink::Release()
{
	METHOD_PROLOGUE(CPartBrowserCtrl,EventSink)
	return pThis->ExternalRelease();
}

STDMETHODIMP CPartBrowserCtrl::XEventSink::QueryInterface(REFIID riid, void** ppv)
{
	METHOD_PROLOGUE(CPartBrowserCtrl,EventSink)
	return pThis->ExternalQueryInterface(&riid, ppv);
}

STDMETHODIMP CPartBrowserCtrl::XEventSink::GlobalEvent(globalevent_enum event)
{
	METHOD_PROLOGUE(CPartBrowserCtrl,EventSink)
	// TODO: Handle global events here - peter
	pThis->OnMgaGlobalEvent(event);
	return S_OK;
}

STDMETHODIMP CPartBrowserCtrl::XEventSink::ObjectEvent(IMgaObject* obj, unsigned long eventmask, VARIANT v)
{
	METHOD_PROLOGUE(CPartBrowserCtrl,EventSink)
	// TODO: Handle object events here - peter
	pThis->m_MgaObjectEventList.Add(obj,eventmask);
	return S_OK;
}


// CPartBrowserCtrl::CPartBrowserCtrl - Constructor

CPartBrowserCtrl::CPartBrowserCtrl()
{
	InitializeIIDs(&IID_DPartBrowser, &IID_DPartBrowserEvents);
	// TODO: Initialize your control's instance data here.
	OutputDebugString("CPartBrowserCtrl constructed\n");
}



// CPartBrowserCtrl::~CPartBrowserCtrl - Destructor

CPartBrowserCtrl::~CPartBrowserCtrl()
{
	// TODO: Cleanup your control's instance data here.
}



// CPartBrowserCtrl::OnDraw - Drawing function

void CPartBrowserCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	if (!pdc)
		return;

	if (m_partBrowserDlg.GetSafeHwnd()) {
		m_partBrowserDlg.MoveWindow(rcBounds, TRUE);
	} else {
		AFX_MANAGE_STATE(AfxGetStaticModuleState());
		CBrush brush (RGB(255, 255, 255));
		pdc->FillRect (rcBounds, &brush);

		CRect edge(rcBounds);
		pdc->DrawEdge(&edge, EDGE_BUMP, BF_RECT);
		
		CString label("PartBrowser OCX");

		BITMAP bm;
		CBitmap bitmap;
		bitmap.LoadBitmap(IDB_PARTBROWSER);
		bitmap.GetBitmap(&bm);
		CSize size(bm.bmWidth, bm.bmHeight);
		pdc->DPtoLP(&size);
		CPoint org(0,0);
		pdc->DPtoLP(&org);
		CPoint pos(rcBounds.Width() / 2, rcBounds.Height() / 2 - (pdc->GetTextExtent(label).cy));
		CDC dcMem;
		dcMem.CreateCompatibleDC(pdc);
		CBitmap *oldbitmap = dcMem.SelectObject(&bitmap);
		dcMem.SetMapMode (pdc->GetMapMode());
		pdc->BitBlt(pos.x, pos.y, size.cx, size.cy, &dcMem, org.x, org.y, SRCCOPY);
		dcMem.SelectObject(oldbitmap);
		
		pdc->SetTextAlign(TA_CENTER);
		pdc->TextOut(rcBounds.Width() / 2, rcBounds.Height() / 2, CString("PartBrowser ActiveX Control"));
	}
}


// CPartBrowserCtrl::DoPropExchange - Persistence support

void CPartBrowserCtrl::DoPropExchange(CPropExchange* pPX)
{
	ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
	COleControl::DoPropExchange(pPX);

	// TODO: Call PX_ functions for each persistent custom property.
}



// CPartBrowserCtrl::OnResetState - Reset control to default state

void CPartBrowserCtrl::OnResetState()
{
	COleControl::OnResetState();  // Resets defaults found in DoPropExchange

	// TODO: Reset any other control state here.
}



// CPartBrowserCtrl::AboutBox - Display an "About" box to the user

void CPartBrowserCtrl::AboutBox()
{
	CDialog dlgAbout(IDD_ABOUTBOX_PARTBROWSER);
	dlgAbout.DoModal();
}



// CPartBrowserCtrl message handlers

int CPartBrowserCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (COleControl::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	m_partBrowserDlg.Create(IDD_PARTBROWSER_DIALOG, this);

	return 0;
}

BOOL CPartBrowserCtrl::PreCreateWindow(CREATESTRUCT& cs) 
{
	cs.dwExStyle |= WS_EX_CONTROLPARENT;
	return COleControl::PreCreateWindow(cs);
}

void CPartBrowserCtrl::SetCurrentProject(IUnknown* project)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CComQIPtr<IMgaProject> ccpMgaProject(project);

	if (project != NULL && ccpMgaProject == NULL) {
		ThrowError(CTL_E_INVALIDPROPERTYVALUE, _T("Unable to cast MgaProject."));
		return;
	}

	m_partBrowserDlg.SetCurrentProject(ccpMgaProject);
}

void CPartBrowserCtrl::SetMetaModel(IUnknown* meta)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CComQIPtr<IMgaMetaModel> ccpMgaMetaModel(meta);

	if (meta != NULL && ccpMgaMetaModel == NULL) {
		ThrowError(CTL_E_INVALIDPROPERTYVALUE, _T("Unable to cast MgaMetaModel."));
		return;
	}

	m_partBrowserDlg.SetMetaModel(ccpMgaMetaModel);
}

void CPartBrowserCtrl::SetBgColor(OLE_COLOR oleBgColor)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	COLORREF bgColor = TranslateColor(oleBgColor);
	m_partBrowserDlg.SetBgColor(bgColor);
}

void CPartBrowserCtrl::ChangeAspect(LONG index)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	m_partBrowserDlg.ChangeAspect(index);
}

void CPartBrowserCtrl::CycleAspect(void)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	m_partBrowserDlg.CycleAspect();
}

void CPartBrowserCtrl::RePaint(void)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	m_partBrowserDlg.PostMessage(WM_PAINT);
}

void CPartBrowserCtrl::OnMgaObjectEvent(IMgaObject *obj, unsigned long eventmask)
{
	CComPtr<IMgaObject> ccpMgaObject(obj);
	// Handling Object Events
	EVENT_TRACE("\n__________ Object Event Begin _________\n");

#ifdef _DEBUG
	if (eventmask & OBJEVENT_DESTROYED) {
		EVENT_TRACE("OBJEVENT_DESTROYED\n");
	}
	if (eventmask & OBJEVENT_REGISTRY) {
		EVENT_TRACE("OBJEVENT_REGISTRY\n");
	}
	if (eventmask & OBJEVENT_PROPERTIES) {
		EVENT_TRACE("OBJEVENT_PROPERTIES\n");
	}
	if (eventmask & OBJEVENT_CREATED) {
		EVENT_TRACE("OBJEVENT_CREATED\n");
	}
	if (eventmask & OBJEVENT_ATTR) {
		EVENT_TRACE("OBJEVENT_ATTR\n");
	}
	if(eventmask & OBJEVENT_NEWCHILD) {
		EVENT_TRACE("OBJEVENT_NEWCHILD\n");
	}
	if(eventmask & OBJEVENT_RELATION) {
		EVENT_TRACE("OBJEVENT_RELATION\n");
	}
	if(eventmask & OBJEVENT_SUBT_INST) {
		EVENT_TRACE("OBJEVENT_SUBT_INST\n");
	}
	if(eventmask & OBJEVENT_PARENT) {
		EVENT_TRACE("OBJEVENT_PARENT\n");
	}
	if(eventmask & OBJEVENT_LOSTCHILD) {
		EVENT_TRACE("OBJEVENT_LOSTCHILD\n");
	}
	if(eventmask & OBJEVENT_REFERENCED) {
		EVENT_TRACE("OBJEVENT_REFERENCED\n");
	}
	if(eventmask & OBJEVENT_CONNECTED) {
		EVENT_TRACE("OBJEVENT_CONNECTED\n");
	}
	if(eventmask & OBJEVENT_SETINCLUDED) {
		EVENT_TRACE("OBJEVENT_SETINCLUDED\n");
	}
	if(eventmask & OBJEVENT_REFRELEASED) {
		EVENT_TRACE("OBJEVENT_REFRELEASED\n");
	}
	if(eventmask & OBJEVENT_DISCONNECTED) {
		EVENT_TRACE("OBJEVENT_DISCONNECTED\n");
	}
	if(eventmask & OBJEVENT_SETEXCLUDED) {
		EVENT_TRACE("OBJEVENT_SETEXCLUDED\n");
	}
	if(eventmask & OBJEVENT_USERBITS) {
		EVENT_TRACE("OBJEVENT_USERBITS\n");
	}
	if(eventmask & OBJEVENT_CLOSEMODEL) {
		EVENT_TRACE("OBJEVENT_CLOSEMODEL\n");
	}
#endif /*_DEBUG */

	EVENT_TRACE("_________ Object Event End _______\n");
}

void CPartBrowserCtrl::OnMgaGlobalEvent(globalevent_enum event)
{
	// Handling Global Events
	if (event == GLOBALEVENT_COMMIT_TRANSACTION) {
		EVENT_TRACE("GLOBALEVENT_COMMIT_TRANSACTION\n");

		// Send message to UI
		PropagateMgaMessages();
	} else if (event == GLOBALEVENT_NOTIFICATION_READY) {
		EVENT_TRACE("GLOBALEVENT_NOTIFICATION_READY\n");

		// Send message to UI
		PropagateMgaMessages();
	} else if (event == GLOBALEVENT_ABORT_TRANSACTION) {
		EVENT_TRACE("GLOBALEVENT_ABORT_TRANSACTION\n");

		// Removing the elements
		m_MgaObjectEventList.RemoveAll();
	} else if (event == GLOBALEVENT_UNDO) {
		EVENT_TRACE("GLOBALEVENT_UNDO\n");
		// Refresh
	} else if (event==GLOBALEVENT_REDO) {
		EVENT_TRACE("GLOBALEVENT_REDO\n");
		// Refresh
	}

	// Not handled messages are not in the release
	// but useful for development
#ifdef _DEBUG
	if (event == GLOBALEVENT_PROJECT_PROPERTIES) {
		EVENT_TRACE("GLOBALEVENT_PROJECT_PROPERTIES\n");
	}
	if (event == GLOBALEVENT_OPEN_PROJECT) {
		EVENT_TRACE("GLOBALEVENT_OPEN_PROJECT\n");
	}
	if (event == GLOBALEVENT_CLOSE_PROJECT) {
		EVENT_TRACE("GLOBALEVENT_CLOSE_PROJECT\n");
	}
	if (event == GLOBALEVENT_NEW_TERRITORY) {
		EVENT_TRACE("GLOBALEVENT_NEW_TERRITORY\n");
	}
	if (event == GLOBALEVENT_DESTROY_TERRITORY) {
		EVENT_TRACE("GLOBALEVENT_DESTROY_TERRITORY\n");
	}

#endif /* _DEBUG */

	EVENT_TRACE("_________ Global Event End _________\n");
}

void CPartBrowserCtrl::SendAspectChanged(LONG index)
{
	this->FireAspectChanged(index);
}

void CPartBrowserCtrl::PropagateMgaMessages()
{
	// Iterating through the list
	while (!m_MgaObjectEventList.IsEmpty()) {
		CMgaObjectEventWrapper* pEventWrapper =
			(CMgaObjectEventWrapper*)m_MgaObjectEventList.RemoveHead();
		// Propagating message to AggregatePropertyPage

		OnMgaObjectEvent(pEventWrapper->m_ccpMgaObject, pEventWrapper->m_eventmask);

		delete pEventWrapper;
	}
}


--- NEW FILE: PartBrowserOLEData.cpp ---
#include <stdafx.h>
#include <afxadv.h>
#include "afxcoll.h"
#include "afxtempl.h"
#include "..\Interfaces\meta.h"
#include "..\Interfaces\mga.h"
#include "..\Interfaces\parser.h"

#include "..\GME\GMEstd.h"

#include "PartBrowserOLEData.h"

#include "PartBrowser_i.c"

CLIPFORMAT CPartBrowserDataSource::cfGMEDesc =	(CLIPFORMAT)(RegisterClipboardFormat(_T("GME Descriptor")));
int CPartBrowserDataSource::myData = 0;

/* --------------------------- CPartBrowserDataDescriptor --------------------------- */
//static // called externally, to destruct certain lists
void CPartBrowserDataDescriptor::destructList(CTypedPtrList<CPtrList, CRect*>& pList)// it is a CRectList
{
	POSITION pos = pList.GetHeadPosition();
	while (pos)
		delete pList.GetNext(pos);
	pList.RemoveAll();
}

CPartBrowserDataDescriptor::CPartBrowserDataDescriptor(CTypedPtrList<CPtrList, CRect*> &list,
													   CTypedPtrList<CPtrList, CRect*> &annList,
													   CPoint dragPoint, CPoint offs)
{
	POSITION pos = list.GetHeadPosition();
	while (pos) {
		CRect *rect = new CRect(list.GetNext(pos));
		rect->OffsetRect(-dragPoint.x,-dragPoint.y);
		rects.AddTail(rect);
	}

	pos = annList.GetHeadPosition();
	while (pos) {
		CRect* rect = new CRect(annList.GetNext(pos));
		rect->OffsetRect(-dragPoint.x,-dragPoint.y);
		annRects.AddTail(rect);
	}

	offset = offs;
	pFile = 0;
}

void CPartBrowserDataDescriptor::Reset()
{
	POSITION pos = rects.GetHeadPosition();
	while (pos)
		delete rects.GetNext(pos);
	rects.RemoveAll();

	pos = annRects.GetHeadPosition();
	while (pos)
		delete annRects.GetNext(pos);
	annRects.RemoveAll();
}

void CPartBrowserDataDescriptor::Serialize(CArchive& ar)
{
	if (ar.IsStoring()) {
		ar << rects.GetCount();
		POSITION pos = rects.GetHeadPosition();
		while (pos)
			ar << *(rects.GetNext(pos));

		ar << annRects.GetCount();
		pos = annRects.GetHeadPosition();
		while (pos)
			ar << *(annRects.GetNext(pos));

		ar << offset;
	} else {
		Reset();
		int n;
		ar >> n;
		for(int i = 0; i < n; i++) {
			CRect* rect = new CRect();
			ar >> *rect;
			rects.AddTail(rect);
		}

		ar >> n;
		for(int j = 0; j < n; j++) {
			CRect* rect = new CRect();
			ar >> *rect;
			annRects.AddTail(rect);
		}
		ar >> offset;
	}
}

bool CPartBrowserDataDescriptor::Load(COleDataObject* pDataObject)
{
	ASSERT(pDataObject != NULL);

	if (pDataObject->IsDataAvailable(CPartBrowserDataSource::cfGMEDesc)) {
		ASSERT(pFile == 0);
		pFile = pDataObject->GetFileData(CPartBrowserDataSource::cfGMEDesc);
		ASSERT(pFile != NULL);
		CArchive ar(pFile, CArchive::load);
		Serialize(ar);
		return true;
	}
	return false;
}

int CPartBrowserDataDescriptor::GetCount()
{
	/* return (rects.GetCount() + annRects.GetCount()); */
	return rects.GetCount(); 
}

void CPartBrowserDataDescriptor::Clean()
{
	delete pFile;
	pFile = 0;
}

void CPartBrowserDataDescriptor::Draw(CDC *pDC,CPoint &pt)
{
	POSITION pos = rects.GetHeadPosition();
	while (pos) {
		CRect rect = *(rects.GetNext(pos));

		rect.OffsetRect(pt);
		CPoint align = rect.CenterPoint();

		// Emulate the grid.
		long gs = GME_GRID_SIZE;
		align.x = (align.x % gs);
		align.y = (align.y % gs);

		
		rect.OffsetRect(-align.x, -align.y);
		// rect.OffsetRect(-offset.x, -offset.y);
		pDC->DrawFocusRect(&rect);

	}

	pos = annRects.GetHeadPosition();
	while (pos) {
		CRect rect = *(annRects.GetNext(pos));

		rect.OffsetRect(pt);
		pDC->DrawFocusRect(&rect);
	}
}


// This function has been simplified for GMEActiveBrowser
// No annotations and grid alignment
void CPartBrowserDataDescriptor::SimpleDraw(CDC *pDC, CPoint &pt)
{
	POSITION pos = rects.GetHeadPosition();
	while (pos) {
		CRect rect = *(rects.GetNext(pos));

		rect.OffsetRect(pt);

		pDC->DrawFocusRect(&rect);

	}
}


void CPartBrowserDataDescriptor::GetBoundingRect(CRect &rBoundingRect)
{
	rBoundingRect = CRect(0, 0, 0, 0);

	CRect Rect;
	POSITION pos = rects.GetHeadPosition();
	
	while (pos) {
		Rect = *(rects.GetNext(pos));
		rBoundingRect.UnionRect(rBoundingRect, Rect);
	}
}


/* --------------------------- CPartBrowserDataSource ------------------------------- */

bool CPartBrowserDataSource::IsGmeNativeDataAvailable(COleDataObject *pDataObject, IMgaProject *project)
{
	ASSERT( project != NULL );

	CComPtr<IDataObject> p = pDataObject->GetIDataObject(FALSE);
	CComPtr<IPartBrowserDataSource> source;
	if (p!= NULL && p.QueryInterface(&source) == S_OK) {
		CComPtr<IUnknown> unknown;
		COMTHROW(source->get_Project(&unknown));
		ASSERT(unknown != NULL);

		CComPtr<IMgaProject> source_project;
		COMTHROW(unknown.QueryInterface(&source_project));
		ASSERT(source_project != NULL);

		return source_project.IsEqualObject(project);
	}
	return false;
}

bool CPartBrowserDataSource::IsXMLDataAvailable(COleDataObject *pDataObject)
{
	ASSERT(pDataObject != NULL);

	return pDataObject->IsDataAvailable(CF_TEXT) != FALSE;
}

bool CPartBrowserDataSource::ParseXMLData(COleDataObject *pDataObject, IMgaObject *target, bool merge = false)
{
	ASSERT(pDataObject != NULL);
	ASSERT(target != NULL);

	// create a temporary filename
	char *fname = _tempnam("c:\\temp", "tmp");
	CString filename = fname;
	free(fname);

	try
	{
		// get the memory file
		CFile *memfile = pDataObject->GetFileData(CF_TEXT);
		if (memfile == NULL)
			return false;
		memfile->SeekToBegin();

		// copy
		CFile file;
		if(file.Open(filename, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary) == 0)
			return false;

		const int buffsize = 10240;
		unsigned char buff[buffsize];
		UINT c;
		do
		{
			c = memfile->Read(buff, buffsize);

			UINT new_c = 0; // addition by ZolMol
			while (buff[new_c] != 0 && new_c < c) ++new_c;
			c = new_c;		// end

			file.Write(buff, c);
		} while(c == buffsize);
		file.Close();

		// clear the memory file
		delete memfile;

		// parse
		CComPtr<IMgaParser> parser;
		COMTHROW(parser.CoCreateInstance(L"Mga.MgaParser"));
		ASSERT(parser != NULL);

		CComBstrObj acckind, version; 
		VARIANT_BOOL is_acc_target;
		COMTHROW(parser->GetClipXMLInfo(PutInBstr(filename), target, &is_acc_target, PutOut(acckind), PutOut( version)));
		CString ver = "0"; // defval
		if (version) // clipboard main token found, otherwise use defval
			CopyTo(version, ver);


		CComObjPtr<IMgaProject> t_project;
		COMTHROW(target->get_Project(PutOut(t_project)));
		CComPtr<IGMEOLEApp> t_GME = CPartBrowserDataSource::get_GME(t_project);
		
		CComBSTR msg, done;
		done.Append("Done.");
		if (ver == "0") {
			msg.Append("Inserting XML data...");
			if (t_GME) COMTHROW(t_GME->ConsoleMessage(msg, MSG_INFO));
			COMTHROW(parser->ParseFCOs(target, PutInBstr(filename)));
			if (t_GME) COMTHROW(t_GME->ConsoleMessage(done, MSG_INFO));
		} else if (ver == "4") {
			msg.Append("Inserting XML SmartCopied data...");
			if (t_GME) COMTHROW(t_GME->ConsoleMessage(msg, MSG_INFO));
			COMTHROW(parser->ParseClos4(target, PutInBstr(filename), merge ? MERGE:ADDITION));
			if (t_GME) COMTHROW(t_GME->ConsoleMessage(done, MSG_INFO));
		} else if (ver == "1" || ver == "") {
			msg.Append("Inserting XML CopyClosured data...");
			if (t_GME) COMTHROW(t_GME->ConsoleMessage(msg, MSG_INFO));
			COMTHROW(parser->ParseClos1(target, PutInBstr(filename)));
			if (t_GME) COMTHROW(t_GME->ConsoleMessage(done, MSG_INFO));
		} else {
			msg.Append("Error: Unknown clipboard closure format");
			if(t_GME) COMTHROW(t_GME->ConsoleMessage(msg, MSG_INFO));

			ASSERT(0);
		}


		CFile::Remove(filename);

		return true;
	}
	catch(hresult_exception &e)
	{
		CFile::Remove(filename);

		try
		{
			CComObjPtr<IErrorInfo> errinfo;
			COMTHROW(GetErrorInfo(0, PutOut(errinfo)));
			ASSERT(errinfo != NULL);

			CString desc;
			COMTHROW(errinfo->GetDescription(PutOut(desc)));

			AfxMessageBox(CString("Error while parsing XML file: ") + desc);
		}
		catch(hresult_exception &)
		{
			AfxMessageBox("Fatal error while parsing XML file!");
		}

		throw e;
	}

	return false;
}

void CPartBrowserDataSource::CacheDescriptor(CPartBrowserDataDescriptor* desc)
{
	CacheGlobalData(cfGMEDesc, CreateDescriptor(desc));
	DelayXMLDump();
}

HGLOBAL CPartBrowserDataSource::CreateDescriptor(CPartBrowserDataDescriptor* desc)
{
	ASSERT(desc);

	CSharedFile file;
	CArchive ar(&file, CArchive::store);
	desc->Serialize(ar);
	ar.Close();
	return file.Detach();
}

void CPartBrowserDataSource::DelayXMLDump()
{
	FORMATETC fe = {
	CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_ISTREAM|TYMED_HGLOBAL
	};

	DelayRenderFileData(CF_TEXT, &fe);
}

BOOL CPartBrowserDataSource::OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile)
{
	if (lpFormatEtc->cfFormat == CF_TEXT) {
		ASSERT(pFile != NULL);

		// TODO: we have to dump it directly to the shared memory file

		try
		{
			char *fname = _tempnam("c:\\temp", "tmp");
			CString filename = fname;
			free(fname);
		
			CComPtr<IMgaDumper> dumper;
			COMTHROW(dumper.CoCreateInstance(L"Mga.MgaDumper"));

			CComObjPtr<IMgaFCOs> fcos;
			if (data) // check whether it is set
				COMTHROW(::QueryInterface(data, fcos));

			CComObjPtr<IMgaFolders> folds;
			if (folders) // check whether it is set
				COMTHROW(::QueryInterface(folders, folds));

			CComObjPtr<IMgaRegNodes> regd;
			if (regdata) // check whether it is set
				COMTHROW(::QueryInterface(regdata, regd));

			COMTHROW(dumper->DumpFCOs(project, fcos, folds, regd, PutInBstr(filename)));

			CFile file;
			if(file.Open(filename, CFile::modeRead | CFile::typeBinary) == 0)
				return FALSE;
			
			const int buffsize = 10240;
			unsigned char buff[buffsize];
			UINT c;
			do
			{
				c = file.Read(buff, buffsize);
				pFile->Write(buff, c);
			} while(c == buffsize);

			buff[0] = 0;
			pFile->Write(buff, 1);

			file.Close();
			CFile::Remove(filename);
		}
		catch(hresult_exception &)
		{
			return FALSE;
		}
		catch(CFileException *)
		{
			return FALSE;
		}

		return TRUE;
	}

	return FALSE;
}

// ****************************************************************************************************
// *********************************   CPartBrowserClosureDataSource  *****************************************
// ****************************************************************************************************
BOOL CPartBrowserClosureDataSource::OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile)
{
	if (lpFormatEtc->cfFormat == CF_TEXT) {
		ASSERT(pFile != NULL);

		// TODO: we have to dump it directly to the shared memory file

		try
		{
			char *fname = _tempnam("c:\\temp", "tmp");
			CString filename = fname;
			free(fname);
		
			CComPtr<IMgaDumper> dumper;
			COMTHROW(dumper.CoCreateInstance(L"Mga.MgaDumper"));

			CComObjPtr<IMgaFCOs> fcos;
			if (data) // is it set?
				COMTHROW(::QueryInterface(data, fcos));

			CComObjPtr<IMgaFolders> fols;
			if (folders) // is it set?
				COMTHROW(::QueryInterface(folders, fols));

			bool is_top_set = false;
			CComObjPtr<IMgaFCOs> top_fcos;
			CComObjPtr<IMgaFolders> top_folds;

			if (m_topFcos) {
				COMTHROW(::QueryInterface( m_topFcos, top_fcos));
				is_top_set = true;
			}

			if (m_topFolders) {
				COMTHROW(::QueryInterface( m_topFolders, top_folds));
				is_top_set = true;
			}

			if (is_top_set)
				COMTHROW(dumper->DumpClosR(fcos, fols, PutInBstr(filename), top_fcos, top_folds, m_options, m_absPathPart, m_acceptingKinds));
			else // if top objects are not set dump starting from RootFolder
				COMTHROW(dumper->DumpClos(fcos, fols, PutInBstr(filename), m_options));

			CFile file;
			if (file.Open(filename, CFile::modeRead | CFile::typeBinary) == 0)
				return FALSE;

			const int buffsize = 10240;
			unsigned char buff[buffsize];
			UINT c;
			do
			{
				c = file.Read(buff, buffsize);
				pFile->Write(buff, c);
			} while (c == buffsize);

			buff[0] = 0;
			pFile->Write(buff, 1);

			file.Close();
			CFile::Remove(filename);
		}
		catch(hresult_exception &)
		{
			return FALSE;
		}
		catch(CFileException *)
		{
			return FALSE;
		}

		return TRUE;
	}

	return FALSE;
}

BEGIN_MESSAGE_MAP(CPartBrowserDataSource, COleDataSource)
	//{{AFX_MSG_MAP(CPartBrowserDataSource)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// Interface Maps

BEGIN_DISPATCH_MAP(CPartBrowserDataSource, COleDataSource)
	//{{AFX_DISPATCH_MAP(CPartBrowserDataSource)
	DISP_PROPERTY_EX(CPartBrowserDataSource, "Data", DispGetData, DispSetData, VT_DISPATCH)
	DISP_PROPERTY_EX(CPartBrowserDataSource, "Folders", DispGetFolders, DispSetFolders, VT_DISPATCH)
	DISP_PROPERTY_EX(CPartBrowserDataSource, "RegistryData", DispGetRegistryData, DispSetRegistryData, VT_DISPATCH)
	DISP_PROPERTY_EX(CPartBrowserDataSource, "Project", DispGetProject, DispSetProject, VT_DISPATCH)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()


BEGIN_INTERFACE_MAP(CPartBrowserDataSource, COleDataSource)
	INTERFACE_PART(CPartBrowserDataSource, IID_IPartBrowserDataSource, PartBrowserDataSource)
	DUAL_ERRORINFO_PART(CPartBrowserDataSource)
END_INTERFACE_MAP()

DELEGATE_DUAL_INTERFACE(CPartBrowserDataSource, PartBrowserDataSource)

// Implement ISupportErrorInfo to indicate we support the
// OLE Automation error handler.
IMPLEMENT_DUAL_ERRORINFO(CPartBrowserDataSource, IID_IPartBrowserDataSource)


STDMETHODIMP CPartBrowserDataSource::XPartBrowserDataSource::get_Data(IUnknown **p)
{
	METHOD_PROLOGUE(CPartBrowserDataSource, PartBrowserDataSource)
	CHECK_OUT(p);

	if (pThis->data != NULL)
		return pThis->data.QueryInterface(p);

	return S_OK;
}

STDMETHODIMP CPartBrowserDataSource::XPartBrowserDataSource::get_Folders(IUnknown **p)
{
	METHOD_PROLOGUE(CPartBrowserDataSource, PartBrowserDataSource)
	CHECK_OUT(p);

	if (pThis->folders != NULL)
		return pThis->folders.QueryInterface(p);

	return S_OK;
}

STDMETHODIMP CPartBrowserDataSource::XPartBrowserDataSource::get_RegistryData(IUnknown **p)
{
	METHOD_PROLOGUE(CPartBrowserDataSource, PartBrowserDataSource)
	CHECK_OUT(p);

	if (pThis->regdata != NULL)
		return pThis->regdata.QueryInterface(p);

	return S_OK;
}

STDMETHODIMP CPartBrowserDataSource::XPartBrowserDataSource::get_Project(IUnknown **p)
{
	METHOD_PROLOGUE(CPartBrowserDataSource, PartBrowserDataSource)
	CHECK_OUT(p);

	return pThis->project.QueryInterface(p);
}




/*static*/ CComPtr<IGMEOLEApp> CPartBrowserDataSource::get_GME(CComObjPtr<IMgaProject> project)
{
	CComPtr<IGMEOLEApp> gme;
	if ( (project != NULL)) {
		CComBSTR bstrName("GME.Application");
		CComPtr<IMgaClient> pClient;
		HRESULT hr = project->GetClientByName(bstrName, &pClient);
		if (SUCCEEDED(hr) && pClient) {
			CComPtr<IDispatch> pDispatch;
			hr = pClient->get_OLEServer(&pDispatch);
			if (SUCCEEDED(hr) && pDispatch) {
				hr = pDispatch.QueryInterface(&gme);
				if (FAILED(hr)) {
					gme = NULL;
				}
			}
		}
	}
	return gme;
}

LPDISPATCH CPartBrowserDataSource::DispGetData() 
{
	CComPtr<IDispatch> p;
	if (data != NULL) {
		data.QueryInterface(&p);
	}

	return p.Detach();
}

void CPartBrowserDataSource::DispSetData(LPDISPATCH)
{
	SetNotSupported();
}

LPDISPATCH CPartBrowserDataSource::DispGetFolders()
{
	CComPtr<IDispatch> p;
	if (folders != NULL) {
		folders.QueryInterface(&p);
	}

	return p.Detach();
}

void CPartBrowserDataSource::DispSetFolders(LPDISPATCH)
{
	SetNotSupported();
}

LPDISPATCH CPartBrowserDataSource::DispGetRegistryData()
{
	CComPtr<IDispatch> p;
	if (regdata != NULL) {
		regdata.QueryInterface(&p);
	}

	return p.Detach();
}

void CPartBrowserDataSource::DispSetRegistryData(LPDISPATCH)
{
	SetNotSupported();
}

LPDISPATCH CPartBrowserDataSource::DispGetProject()
{
	CComPtr<IDispatch> p;
	if (project != NULL) {
		project.QueryInterface(&p);
	}

	return p.Detach();
}

void CPartBrowserDataSource::DispSetProject(LPDISPATCH)
{
	SetNotSupported();
}


--- NEW FILE: PartBrowser.rc ---
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE 
BEGIN
    "1 TYPELIB ""PartBrowser.tlb""\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904e4"
        BEGIN
            VALUE "CompanyName", "ISIS, Vanderbilt University"
            VALUE "FileDescription", "PartBrowser Component"
            VALUE "FileVersion", "1.0.0.1"
            VALUE "InternalName", "PartBrowser.ocx"
            VALUE "LegalCopyright", "2008 (c) ISIS, Vanderbilt University.  All rights reserved."
            VALUE "OriginalFilename", "PartBrowser.ocx"
            VALUE "ProductName", "GME"
            VALUE "ProductVersion", "1.0.0.1"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1252
    END
END


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ABOUTDLL            ICON                    "PartBrowser.ico"

/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//

IDB_PARTBROWSER         BITMAP                  "PartBrowserCtrl.bmp"

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_ABOUTBOX_PARTBROWSER DIALOG  34, 22, 260, 55
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About PartBrowser Control"
FONT 8, "MS Sans Serif"
BEGIN
    ICON            IDI_ABOUTDLL,IDC_STATIC,10,10,20,20
    LTEXT           "PartBrowser Control, Version 1.0",IDC_STATIC,40,10,170,
                    8
    LTEXT           "Copyright (C) 2007, ",IDC_STATIC,40,25,170,8
    DEFPUSHBUTTON   "OK",IDOK,221,7,32,16,WS_GROUP
END

IDD_PROPPAGE_PARTBROWSER DIALOG  0, 0, 250, 62
STYLE DS_SETFONT | WS_CHILD
FONT 8, "MS Sans Serif"
BEGIN
    LTEXT           "TODO: Place controls to manipulate properties of PartBrowser Control on this dialog.",
                    IDC_STATIC,7,25,229,16
END

IDD_PARTBROWSER_DIALOG DIALOGEX 0, 0, 137, 74
STYLE DS_SETFONT | DS_SETFOREGROUND | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CLIENTEDGE
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
    CONTROL         "Tab1",IDC_ASPECT_TAB,"SysTabControl32",TCS_BOTTOM | 
                    TCS_MULTILINE | TCS_RAGGEDRIGHT,7,7,123,60
END

IDD_PARTBROWSERFRAME_DIALOG DIALOG  0, 0, 107, 56
STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_VSCROLL
FONT 8, "MS Sans Serif"
BEGIN
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO 
BEGIN
    IDD_ABOUTBOX_PARTBROWSER, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 253
        TOPMARGIN, 7
        BOTTOMMARGIN, 48
    END

    IDD_PROPPAGE_PARTBROWSER, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 243
        TOPMARGIN, 7
        BOTTOMMARGIN, 55
    END

    IDD_PARTBROWSER_DIALOG, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 130
        TOPMARGIN, 7
        BOTTOMMARGIN, 67
    END

    IDD_PARTBROWSERFRAME_DIALOG, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 92
        TOPMARGIN, 7
        BOTTOMMARGIN, 49
    END
END
#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE 
BEGIN
    IDS_PARTBROWSER         "PartBrowser Control"
    IDS_PARTBROWSER_PPG     "PartBrowser Property Page"
END

STRINGTABLE 
BEGIN
    IDS_PARTBROWSER_PPG_CAPTION "General"
END

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
1 TYPELIB "PartBrowser.tlb"

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED


--- NEW FILE: PartBrowserPane.cpp ---
// PartBrowserPane.cpp : implementation file
//

#include "stdafx.h"
#include "PartBrowserPane.h"
#include "PartBrowserPaneFrame.h"
#include "..\Interfaces\MgaDecorator.h"
#include "..\Annotator\AnnotationDefs.h"
#include "..\Gme\GMEOLEData.h"
#include "Gme_i.c"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// from GME
typedef enum { GME_NAME_FONT = 0, GME_PORTNAME_FONT, GME_CONNLABEL_FONT, GME_FONT_KIND_NUM } GMEFontKind;
static int  fontSizes[GME_FONT_KIND_NUM]	= { 18, 15, 12 };
#define GME_DEFAULT_DECORATOR		"MGA.BoxDecorator"
#define DECORATOR_PREF				"decorator"
typedef CTypedPtrList<CPtrList, CRect *>	CRectList;

/////////////////////////////////////////////////////////////////////////////
// CPartBrowserPane

CPartBrowserPane::CPartBrowserPane():
	mgaProject (NULL),
	mgaMetaModel(NULL),
	currenAspectIndex(-1),
	omitPaintMessages(true)
{
	backgroundColor = ::GetSysColor(COLOR_APPWORKSPACE);
	txtMetricFont.CreateFont(fontSizes[GME_NAME_FONT], 0, 0, 0, true, 0, 0, 0, ANSI_CHARSET,
							 OUT_DEVICE_PRECIS, CLIP_DEFAULT_PRECIS,
							 PROOF_QUALITY, FF_SWISS, "Arial");

	try {
		COMTHROW(dummyDecorator.CoCreateInstance(PutInBstr(GME_DEFAULT_DECORATOR)));
	}
	catch (hresult_exception&) {
	}
}

CPartBrowserPane::~CPartBrowserPane()
{
	dummyDecorator->Destroy();
	dummyDecorator.Release();
	txtMetricFont.DeleteObject();
}

CComBSTR CPartBrowserPane::GetDecoratorProgId(CComPtr<IMgaMetaFCO> metaFCO)
{
	CComBSTR pathBstr(DECORATOR_PREF);
	CComBSTR bstrVal;
	COMTHROW(metaFCO->get_RegistryValue(pathBstr,&bstrVal));
	if (bstrVal.Length() <= 0)
		bstrVal = GME_DEFAULT_DECORATOR;
	return bstrVal;
}

bool CPartBrowserPane::IsPartDisplayable(CComPtr<IMgaMetaPart> metaPart, bool debugPrint)
{
	ASSERT(metaPart != NULL);
	VARIANT_BOOL vb_primary;
	COMTHROW(metaPart->get_IsPrimary(&vb_primary));
	CComPtr<IMgaMetaRole> mmRole;
	COMTHROW(metaPart->get_Role(&mmRole));
	CComPtr<IMgaMetaFCO> mFco;
	COMTHROW(mmRole->get_Kind(&mFco));
	objtype_enum oType;
	COMTHROW(mFco->get_ObjType(&oType));

	if (debugPrint) {
		CComBSTR bstrName;
		COMTHROW(metaPart->get_Name(&bstrName));
		objtype_enum eType;
		COMTHROW(metaPart->get_ObjType(&eType));
		CString cString;
		CopyTo(bstrName, cString);
		CComBSTR bstrRoleName;
		COMTHROW(mmRole->get_DisplayedName(&bstrRoleName));
		CString cString2;
		CopyTo(bstrRoleName, cString2);
	}

	if (vb_primary != VARIANT_FALSE &&
		(oType == OBJTYPE_MODEL ||
		 oType == OBJTYPE_REFERENCE ||
		 oType != OBJTYPE_CONNECTION))
	{
		return true;
	}
	return false;
}

bool CPartBrowserPane::FindObject(CPoint &pt, PartWithDecorator& pdt)
{
	if (currenAspectIndex < 0 || pdts.size() <= 0)
		return NULL;

	try {
		std::vector<PartWithDecorator> pdtv = pdts[currenAspectIndex];
		// calculate the maximum size
		for (std::vector<PartWithDecorator>::iterator ii = pdtv.begin(); ii != pdtv.end(); ++ii) {
			ASSERT((*ii).decorator != NULL);
			long x1 = 0; long y1 = 0;
			long x2 = 0; long y2 = 0;
			COMTHROW((*ii).decorator->GetLocation(&x1, &y1, &x2, &y2));
			CRect rc (x1, y1, x2, y2);
			if (rc.PtInRect(pt)) {
				pdt = (*ii);

				long sizeX = 0;
				long sizeY = 0;
				COMTHROW((*ii).decorator->GetPreferredSize(&sizeX, &sizeY));

				return true;
			}
		}
	}
	catch (hresult_exception&) {
	}

	return false;
}

void CPartBrowserPane::CreateDecorators(CComPtr<IMgaMetaParts> metaParts)
{
	std::vector<PartWithDecorator> pdt;
	try {
		CComPtr<IMgaMetaPart> metaPart;
		MGACOLL_ITERATE(IMgaMetaPart, metaParts) {
			metaPart = MGACOLL_ITER;
			if (IsPartDisplayable(metaPart)) {
				PartWithDecorator tuple;
				tuple.part = metaPart;

				CComPtr<IMgaMetaRole> mmRole;
				COMTHROW(metaPart->get_Role(&mmRole));
				CComPtr<IMgaMetaFCO> mFco;
				COMTHROW(mmRole->get_Kind(&mFco));
				CComPtr<IMgaDecorator> decorator;
				CComBSTR decoratorProgId = GetDecoratorProgId(mFco);
				COMTHROW(decorator.CoCreateInstance(PutInBstr(decoratorProgId)));
				COMTHROW(decorator->Initialize(mgaProject, metaPart, NULL));
				COMTHROW(decorator->SetLocation(0, 0, 0, 0));
				tuple.decorator = decorator;

				pdt.push_back(tuple);
			}
		}
		MGACOLL_ITERATE_END;
	}
	catch (hresult_exception&) {
	}
	pdts.push_back(pdt);
}

void CPartBrowserPane::DestroyDecorators(void)
{
	for (std::vector<std::vector<PartWithDecorator> >::iterator ii = pdts.begin(); ii != pdts.end(); ++ii) {
		for (std::vector<PartWithDecorator>::iterator jj = (*ii).begin(); jj != (*ii).end(); ++jj) {
			(*jj).decorator->Destroy();
			(*jj).decorator.Release();
			// (*jj).part.Release();
		}
		(*ii).clear();
	}
	pdts.clear();
}

void CPartBrowserPane::Resize(CRect r)
{
	if (!mgaMetaModel || currenAspectIndex < 0 || pdts.size() <= 0)
		return;

	bool oldOmitPaintMessages = omitPaintMessages;
	omitPaintMessages = true;
	ChangeAspect(currenAspectIndex);
	omitPaintMessages = oldOmitPaintMessages;

	const int leftMargin = 10;
	const int rightMargin = 10;
	const int topMargin = 10;
	const int bottomMargin = 30;

	const int xPadding = 10;
	const int yPadding = 30;

	// set the location
	int objColumn = 0;
	int leftStartPos = leftMargin + maxSize.cx / 2;
	int rowHeight = 0;

	// calculate the actual offset
	int objNumInRow = (r.Width() - leftMargin - rightMargin + xPadding) / (maxSize.cx + xPadding);
	if (objNumInRow < 1) {
		objNumInRow = 1;
		leftStartPos = r.Width() / 2 - 3;
	}

	// the pt contains the x center point, and y top point
	CPoint pt = CPoint(leftStartPos, topMargin);

	try {
		std::vector<PartWithDecorator> pdtv = pdts[currenAspectIndex];
		// calculate the maximum size
		for (std::vector<PartWithDecorator>::iterator ii = pdtv.begin(); ii != pdtv.end(); ++ii) {
			ASSERT((*ii).decorator != NULL);
			long sizeX = 0;
			long sizeY = 0;
			COMTHROW((*ii).decorator->GetPreferredSize(&sizeX, &sizeY));
			CSize size (sizeX, sizeY);

			// calculate the row height
			if (objColumn == 0) {
				rowHeight = size.cy;

				std::vector<PartWithDecorator>::iterator iibak = ii;
				for (std::vector<PartWithDecorator>::iterator jj = ++ii; jj != pdtv.end() && (objColumn + 1) < objNumInRow; ++jj) {
					ASSERT((*jj).decorator != NULL);
					long sizeX2 = 0;
					long sizeY2 = 0;
					COMTHROW((*jj).decorator->GetPreferredSize(&sizeX2, &sizeY2));
					CSize size2 (sizeX2, sizeY2);

					if (rowHeight < size2.cy)
						rowHeight = size2.cy;

					++objColumn;
				}
				ii = iibak;

				objColumn = 0;
				pt.y += rowHeight / 2;
			}

			// set the location (based on center: pt is the center)
			COMTHROW((*ii).decorator->SetLocation(pt.x - size.cx / 2, pt.y - size.cy / 2, pt.x + size.cx / 2, pt.y + size.cy / 2));

			if (++objColumn >= objNumInRow) {
				objColumn = 0;
				pt.x = leftStartPos;
				pt.y += rowHeight / 2 + yPadding;
			} else {
				pt.x += maxSize.cx + xPadding;
			}
		}
	}
	catch (hresult_exception&) {
	}

	omitPaintMessages = false;

	// if no object in this row
	if (objColumn == 0)
		pt.y -= yPadding;
	else
		pt.y += rowHeight / 2;

	pt.y += bottomMargin;

	CPartBrowserPaneFrame* parent = (CPartBrowserPaneFrame*)GetParent();
	ASSERT(parent != NULL);

	parent->SetLogicalHeight(pt.y);
	parent->SetPageHeight(r.Height());
	parent->SetScrollBar();

	Invalidate();
}

void CPartBrowserPane::SetCurrentProject(CComPtr<IMgaProject> project)
{
	mgaProject = project;
}

void CPartBrowserPane::SetMetaModel(CComPtr<IMgaMetaModel> meta)
{
	mgaMetaModel = meta;

	DestroyDecorators();
	// Store parts and crate & initialize decorators
	if (meta) {
		CComPtr<IMgaMetaAspects> mmAspects;
		COMTHROW(mgaMetaModel->get_Aspects(&mmAspects));
		long aspect_count = 0;
		COMTHROW(mmAspects->get_Count(&aspect_count));
		CComPtr<IMgaMetaAspect> mmAspect;
		MGACOLL_ITERATE(IMgaMetaAspect, mmAspects) {
			mmAspect = MGACOLL_ITER;

			CComBSTR bstr;
			COMTHROW(mmAspect->get_DisplayedName(&bstr));
			CString cString;
			CopyTo(bstr, cString);

			CComPtr<IMgaMetaParts> metaParts;
			COMTHROW(mmAspect->get_Parts(&metaParts));
			CreateDecorators(metaParts);
		}
		MGACOLL_ITERATE_END;
	}
}

void CPartBrowserPane::SetBgColor(COLORREF bgColor)
{
	backgroundColor = bgColor;
}

void CPartBrowserPane::ChangeAspect(int index)
{
	if (currenAspectIndex == index)
		return;

	currenAspectIndex = index;
	if (currenAspectIndex < 0 || pdts.size() <= 0)
		return;

	// create a DC for text metric
	CDC textMetric;
	textMetric.CreateCompatibleDC(NULL);
	CFont* oldCFont = textMetric.SelectObject(&txtMetricFont);
	HFONT oldFont = (HFONT)oldCFont->GetSafeHandle();

	// just to be safe
	maxSize.cx = 30;
	maxSize.cy = 10;

	try {
		std::vector<PartWithDecorator> pdtv = pdts[currenAspectIndex];
		// calculate the maximum size
		for (std::vector<PartWithDecorator>::iterator ii = pdtv.begin(); ii != pdtv.end(); ++ii) {
			ASSERT((*ii).part != NULL);
			ASSERT((*ii).decorator != NULL);

			long sizeX = 0;
			long sizeY = 0;
			COMTHROW((*ii).decorator->GetPreferredSize(&sizeX, &sizeY));
			CSize size (sizeX, sizeY);

			if (maxSize.cx < size.cx)
				maxSize.cx = size.cx;

			if (maxSize.cy < size.cy)
				maxSize.cy = size.cy;

			CComBSTR nameBStr;
			COMTHROW((*ii).part->get_Name(&nameBStr));
			CString nameCString;
			CopyTo(nameBStr, nameCString);
			int text_cx = textMetric.GetTextExtent(nameCString).cx;
			if (maxSize.cx < text_cx)
				maxSize.cx = text_cx;
		}
	}
	catch (hresult_exception&) {
	}

	CPartBrowserPaneFrame* parent = (CPartBrowserPaneFrame*)GetParent();
	ASSERT(parent != NULL);

	Invalidate();

	CFont *oldCFont2 = CFont::FromHandle(oldFont);
	textMetric.SelectObject(oldCFont2);
}


BEGIN_MESSAGE_MAP(CPartBrowserPane, CWnd)
	//{{AFX_MSG_MAP(CPartBrowserPane)
	ON_WM_PAINT()
	ON_WM_ERASEBKGND()
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CPartBrowserPane message handlers

void CPartBrowserPane::OnPaint()
{
	if (omitPaintMessages) {
		CWnd::OnPaint();
		return;
	}

	CPartBrowserPaneFrame* parent = (CPartBrowserPaneFrame*)GetParent();
	ASSERT(parent != NULL);

	CPaintDC dc(this); // device context for painting
	dc.SetWindowOrg(0, parent->GetScrollPosition ());

	if (pdts.size() > 0 && currenAspectIndex >= 0) {
		try {
			std::vector<PartWithDecorator> pdtv = pdts[currenAspectIndex];
			for (std::vector<PartWithDecorator>::iterator ii = pdtv.begin(); ii != pdtv.end(); ++ii) {
				ASSERT((*ii).decorator != NULL);
				COMTHROW((*ii).decorator->Draw(dc.m_hDC));
			}
		}
		catch (hresult_exception&) {
		}
	}

	// Do not call CWnd::OnPaint() for painting messages
}

BOOL CPartBrowserPane::OnEraseBkgnd(CDC* pDC)
{
	RECT r;
	GetClientRect(&r);
	pDC->FillSolidRect(&r, backgroundColor);
	return TRUE;
	
//	return CWnd::OnEraseBkgnd(pDC);
}

void CPartBrowserPane::OnLButtonDown(UINT nFlags, CPoint point) 
{
//	CGMEEventLogger::LogGMEEvent("CPartBrowserPane::OnLButtonDown\r\n");
	
	// Needed to flush the Object Inspector and the Browser (JIRA #GME-52)
	SetFocus();

	CPartBrowserPaneFrame* parent = (CPartBrowserPaneFrame*)GetParent();
	ASSERT(parent != NULL);

	point.y += parent->GetScrollPosition ();

	PartWithDecorator pdt;
	bool found = FindObject(point, pdt);

	if (found) {
//		CGMEEventLogger::LogGMEEvent("    LButton over " + guiObj->GetName() + "\r\n");

		CRect rectAwake = CRect(point.x, point.y, point.x + 1, point.y + 1);
		rectAwake.InflateRect(3, 3);

		long x1 = 0; long y1 = 0;
		long x2 = 0; long y2 = 0;
		COMTHROW(pdt.decorator->GetLocation(&x1, &y1, &x2, &y2));
		CRect partRect (x1, y1, x2, y2);
		CPoint ptClickOffset(point.x - partRect.left, point.y - partRect.top);

		CRectList rects;
		rects.AddTail(&partRect);

		CRectList dummyAnnList;
		CGMEDataDescriptor desc(rects, dummyAnnList, point, ptClickOffset);
//		CGMEDataDescriptor::destructList(rects);

		CGMEDataSource dataSource(mgaProject);
		CComPtr<IMgaMetaRole> mmRole;
		COMTHROW(pdt.part->get_Role(&mmRole));
		dataSource.SetMetaRole(mmRole);
		dataSource.CacheDescriptor(&desc);
		DROPEFFECT de = dataSource.DoDragDrop(DROPEFFECT_COPY, &rectAwake);
	}

	CWnd::OnLButtonDown(nFlags, point);
}

--- NEW FILE: ObjectEventWrapper.cpp ---
// ObjectEventWrapper.cpp: implementation of the CMgaObjectEventWrapper class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ObjectEventWrapper.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMgaObjectEventWrapper::CMgaObjectEventWrapper(IMgaObject *pMgaObject, 
			unsigned long eventmask):m_ccpMgaObject(pMgaObject),m_eventmask(eventmask)
{

}

CMgaObjectEventWrapper::~CMgaObjectEventWrapper()
{

}

--- NEW FILE: PartBrowserPaneFrame.cpp ---
// PartBrowserPaneFrame.cpp : implementation file
//

#include "stdafx.h"
#include "PartBrowserPane.h"
#include "PartBrowserPaneFrame.h"
#include "PartBrowserDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPartBrowserPaneFrame dialog


CPartBrowserPaneFrame::CPartBrowserPaneFrame(CWnd* pParent/* = NULL*/)
	: CDialog(CPartBrowserPaneFrame::IDD, pParent),
	vScrollWidth (::GetSystemMetrics (SM_CXVSCROLL)),	// WinXP default style: 17
	lineSize (20),
	pageSize (60)
{
	//{{AFX_DATA_INIT(CPartBrowserPaneFrame)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CPartBrowserPaneFrame::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPartBrowserPaneFrame)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPartBrowserPaneFrame, CDialog)
	//{{AFX_MSG_MAP(CPartBrowserPaneFrame)
	ON_WM_VSCROLL()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


void CPartBrowserPaneFrame::Resize(RECT r)
{
	MoveWindow(&r);
	GetClientRect(&r);

	// ok, if there is the scroll bar there then we want to
	// increase the size, the number 16 is empirical 

	if (logicalHeight > pageHeight)
		r.right += vScrollWidth;
	
	pane.MoveWindow(&r);
	BringWindowToTop();
	pane.BringWindowToTop();
	pane.Resize(r);
}

void CPartBrowserPaneFrame::SetScrollBar()
{
	if (scrollPos > (logicalHeight - pageHeight + 1))
		scrollPos = (logicalHeight - pageHeight + 1);
	if (scrollPos < 0)
		scrollPos = 0;

	if (logicalHeight > pageHeight) {
		SCROLLINFO si;
		si.cbSize = sizeof(SCROLLINFO);
		si.fMask = SIF_ALL;
		si.nPage = pageHeight;
		si.nMin = 0;
		si.nMax = logicalHeight;
		si.nPos = scrollPos;
		SetScrollInfo(SB_VERT, &si);
	}

	ShowScrollBar(SB_VERT, logicalHeight > pageHeight);
}

/////////////////////////////////////////////////////////////////////////////
// Get/Set methods

CPartBrowserPane& CPartBrowserPaneFrame::GetPane (void)
{
	return pane;
}


void CPartBrowserPaneFrame::SetLogicalHeight (int logHeight)
{
	logicalHeight = logHeight;
}


void CPartBrowserPaneFrame::SetPageHeight (int pgHeight)
{
	pageHeight = pgHeight;
}


int CPartBrowserPaneFrame::GetScrollPosition (void)
{
	return scrollPos;
}


void CPartBrowserPaneFrame::SetScrollPosition (int scrollPosition)
{
	scrollPos = scrollPosition;
}


/////////////////////////////////////////////////////////////////////////////
// CPartBrowserPaneFrame message handlers

BOOL CPartBrowserPaneFrame::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	RECT r;
	GetClientRect(&r);
	pane.Create(NULL, "PartsPane", WS_CHILD | WS_VISIBLE | WS_BORDER, r, this, IDD_PARTBROWSER_PANE);
	pane.ModifyStyleEx(0, WS_EX_CLIENTEDGE);

	return TRUE;	// return TRUE unless you set the focus to a control
					// EXCEPTION: OCX Property Pages should return FALSE
}

void CPartBrowserPaneFrame::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* /*pScrollBar*/)
{
	int oldPos = scrollPos;

	switch(nSBCode)
	{
	case SB_TOP:
		scrollPos = 0;
		break;
	case SB_BOTTOM:
		scrollPos = logicalHeight - pageHeight;
		break;
	case SB_ENDSCROLL:
		break;
	case SB_LINEDOWN:
		scrollPos += lineSize;
		break;
	case SB_LINEUP:
		scrollPos -= lineSize; 
		break;
	case SB_PAGEDOWN:
		scrollPos += pageSize;
		break;
	case SB_PAGEUP:
		scrollPos -= pageSize;
		break;
	case SB_THUMBPOSITION:
	case SB_THUMBTRACK:
		scrollPos = nPos;
		break;
	}

	if (scrollPos > (logicalHeight - pageHeight + 1))
		scrollPos = (logicalHeight - pageHeight + 1);
	if (scrollPos < 0)
		scrollPos = 0;

	pane.ScrollWindow(0, oldPos - scrollPos, NULL, NULL);
	SetScrollPos(SB_VERT, scrollPos);

//	CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}

--- NEW FILE: PartBrowserPropPage.h ---
#pragma once

// PartBrowserPropPage.h : Declaration of the CPartBrowserPropPage property page class.


// CPartBrowserPropPage : See PartBrowserPropPage.cpp for implementation.

class CPartBrowserPropPage : public COlePropertyPage
{
	DECLARE_DYNCREATE(CPartBrowserPropPage)
	DECLARE_OLECREATE_EX(CPartBrowserPropPage)

// Constructor
public:
	CPartBrowserPropPage();

// Dialog Data
	enum { IDD = IDD_PROPPAGE_PARTBROWSER };

// Implementation
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Message maps
protected:
	DECLARE_MESSAGE_MAP()
};


--- NEW FILE: PartBrowserCtrl.h ---
#if !defined(AFX_PARTBROWSERCTRL_H__6E43458B_2522_4805_9C82_4ABE0A87F7BC__INCLUDED_)
#define AFX_PARTBROWSERCTRL_H__6E43458B_2522_4805_9C82_4ABE0A87F7BC__INCLUDED_


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#include "PartBrowserDlg.h"
#include "MgaObjectEventList.h"

// PartBrowserCtrl.h : Declaration of the CPartBrowserCtrl ActiveX Control class.


// CPartBrowserCtrl : See PartBrowserCtrl.cpp for implementation.

class CPartBrowserCtrl : public COleControl
{
	DECLARE_DYNCREATE(CPartBrowserCtrl)

// Constructor
public:
	CPartBrowserCtrl();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPartBrowserCtrl)
	public:
	virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
	virtual void DoPropExchange(CPropExchange* pPX);
	virtual void OnResetState();
	protected:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

// Implementation
protected:
	~CPartBrowserCtrl();

	DECLARE_OLECREATE_EX(CPartBrowserCtrl)    // Class factory and guid
	DECLARE_OLETYPELIB(CPartBrowserCtrl)      // GetTypeInfo
	DECLARE_PROPPAGEIDS(CPartBrowserCtrl)     // Property page IDs
	DECLARE_OLECTLTYPE(CPartBrowserCtrl)		// Type name and misc status

	CPartBrowserDlg	m_partBrowserDlg;

// Message maps
	//{{AFX_MSG(CPartBrowserCtrl)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

// Dispatch maps
	//{{AFX_DISPATCH(CPartBrowserCtrl)
	afx_msg void SetCurrentProject(LPUNKNOWN project);
	afx_msg void SetMetaModel(LPUNKNOWN meta);
	afx_msg void SetBgColor(OLE_COLOR oleBgColor);
	afx_msg void ChangeAspect(LONG index);
	afx_msg void CycleAspect(void);
	afx_msg void RePaint(void);
	//}}AFX_DISPATCH
	DECLARE_DISPATCH_MAP()

	afx_msg void AboutBox();

	void OnMgaObjectEvent(IMgaObject * obj, unsigned long eventmask);
	void OnMgaGlobalEvent(globalevent_enum event);

// Event maps
	//{{AFX_EVENT(CPartBrowserCtrl)
	void FireAspectChanged(LONG index)
		{FireEvent(eventidAspectChanged, EVENT_PARAM(VTS_I4), index); }
	//}}AFX_EVENT
	DECLARE_EVENT_MAP()
// metaPart, &desc, DROPEFFECT_COPY, &rectAwake

// Native COM interfaces - peter
	DECLARE_INTERFACE_MAP()

	BEGIN_INTERFACE_PART(EventSink, IMgaEventSink)
		STDMETHOD(GlobalEvent(globalevent_enum event));
		STDMETHOD(ObjectEvent(IMgaObject* obj, unsigned long eventmask, VARIANT v));
	END_INTERFACE_PART(EventSink)

// Dispatch and event IDs
public:
	enum {
		//{{AFX_DISP_ID(CPartBrowserCtrl)
		dispidCycleAspect = 5L,
		dispidChangeAspect = 4L,
		dispidRePaint = 6L,
		dispidSetBgColor = 3L,
		dispidSetCurrentProject = 1L,
		dispidSetMetaModel = 2L,
		eventidAspectChanged = 1L
		//}}AFX_DISP_ID
	};

	void SendAspectChanged(LONG index);

protected:
	CMgaObjectEventList m_MgaObjectEventList;
	void PropagateMgaMessages();
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PARTBROWSERCTRL_H__6E43458B_2522_4805_9C82_4ABE0A87F7BC__INCLUDED_)

--- NEW FILE: PartBrowser.cpp ---
// PartBrowser.cpp : Implementation of CPartBrowserApp and DLL registration.

#include "stdafx.h"
#include "PartBrowser.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


CPartBrowserApp NEAR theApp;

const GUID CDECL BASED_CODE _tlid =
		{ 0xEA3F7431, 0x913A, 0x421F, { 0x9B, 0x9C, 0xBE, 0xB6, 0xA7, 0x35, 0x28, 0x5A } };
const WORD _wVerMajor = 1;
const WORD _wVerMinor = 0;



// CPartBrowserApp::InitInstance - DLL initialization

BOOL CPartBrowserApp::InitInstance()
{
	BOOL bInit = COleControlModule::InitInstance();

	if (bInit)
	{
		// TODO: Add your own module initialization code here.
	}

	return bInit;
}



// CPartBrowserApp::ExitInstance - DLL termination

int CPartBrowserApp::ExitInstance()
{
	// TODO: Add your own module termination code here.

	return COleControlModule::ExitInstance();
}



// DllRegisterServer - Adds entries to the system registry

STDAPI DllRegisterServer(void)
{
	AFX_MANAGE_STATE(_afxModuleAddrThis);

	if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
		return ResultFromScode(SELFREG_E_TYPELIB);

	if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
		return ResultFromScode(SELFREG_E_CLASS);

	return NOERROR;
}



// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
	AFX_MANAGE_STATE(_afxModuleAddrThis);

	if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
		return ResultFromScode(SELFREG_E_TYPELIB);

	if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
		return ResultFromScode(SELFREG_E_CLASS);

	return NOERROR;
}



More information about the GME-commit mailing list