[GME-commit] GMESRC/Paradigms/MetaGME/MetaInterpreter2008/asp AspectPage.cpp, NONE, 1.1 AspectPage.h, NONE, 1.1 AspectSpecDlg.cpp, NONE, 1.1 AspectSpecDlg.h, NONE, 1.1 AspectSpecTbl.cpp, NONE, 1.1 AspectSpecTbl.h, NONE, 1.1 EventsDial.cpp, NONE, 1.1 EventsDial.h, NONE, 1.1 GlobalAspOrder.cpp, NONE, 1.1 GlobalAspOrder.h, NONE, 1.1 InPlaceEdit.cpp, NONE, 1.1 InPlaceEdit.h, NONE, 1.1 InPlaceList.cpp, NONE, 1.1 InPlaceList.h, NONE, 1.1 NameSpecDlg.cpp, NONE, 1.1 NameSpecDlg.h, NONE, 1.1 NameSpecTbl.cpp, NONE, 1.1 NameSpecTbl.h, NONE, 1.1 Options.cpp, NONE, 1.1 options.h, NONE, 1.1

Log messages of CVS commits gme-commit at list.isis.vanderbilt.edu
Wed Mar 12 12:48:44 CDT 2008


Update of /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2008/asp
In directory escher:/tmp/cvs-serv813/MetaInterpreter2008/asp

Added Files:
	AspectPage.cpp AspectPage.h AspectSpecDlg.cpp AspectSpecDlg.h 
	AspectSpecTbl.cpp AspectSpecTbl.h EventsDial.cpp EventsDial.h 
	GlobalAspOrder.cpp GlobalAspOrder.h InPlaceEdit.cpp 
	InPlaceEdit.h InPlaceList.cpp InPlaceList.h NameSpecDlg.cpp 
	NameSpecDlg.h NameSpecTbl.cpp NameSpecTbl.h Options.cpp 
	options.h 
Log Message:
MetaInterpreter2008 is a RawComponent, a faster alternative to MetaInterprter2004.



CVS User: Zoltan Molnar, ISIS (zolmol)

--- NEW FILE: AspectSpecTbl.h ---
#if !defined(AFX_ASPECTSPECTBL_H__62A172B9_B4D4_497D_B466_B7BB7BF98B7F__INCLUDED_)
#define AFX_ASPECTSPECTBL_H__62A172B9_B4D4_497D_B466_B7BB7BF98B7F__INCLUDED_

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

#include <AFXCMN.H>

// MyListCtrl.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CMyListCtrl window

class CAspectSpecTbl : public CListCtrl
{
// Construction
public:
	CAspectSpecTbl();

// Attributes
public:

// Operations
public:

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

// Implementation
public:
	CImageList m_checkImages;
	bool GetRow(int rowID, CString &role, CString& kindAspect, CString& isPrimary);
	void AddRow(int rowID, CString& role, CString& kindAspect, CString& isPrimary);
	virtual ~CAspectSpecTbl();
	int HitTestEx(CPoint &point, int *col) const;
	CEdit* EditSubLabel( int nItem, int nCol );
	CComboBox* ShowInPlaceList( int nItem, int nCol, CStringList &lstItems, int nSel );

	// Generated message map functions
protected:
	//{{AFX_MSG(CAspectSpecTbl)
	afx_msg void OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_ASPECTSPECTBL_H__62A172B9_B4D4_497D_B466_B7BB7BF98B7F__INCLUDED_)

--- NEW FILE: options.h ---
#if !defined(AFX_OPTIONS_H__D33EAC1F_01D6_4270_93F8_069D3BAFE231__INCLUDED_)
#define AFX_OPTIONS_H__D33EAC1F_01D6_4270_93F8_069D3BAFE231__INCLUDED_

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

#include "resource.h"
#include "MyUtil.h"
#include <afxcmn.h>
/////////////////////////////////////////////////////////////////////////////
// Options dialog

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

// Dialog Data
	//{{AFX_DATA(Options)
	enum { IDD = IDD_OPTIONS };
	CSpinButtonCtrl	m_spin;
	CString	m_strRegCont;
	CString	m_strFolCont;
	CString	m_strConnect;
	BOOL	m_dontask;
	CString	m_strPriority;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(Options)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL
	void PASCAL DDV_HexNumber(CDataExchange* pDX, const CString& nmb);

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(Options)
	virtual BOOL OnInitDialog();
	afx_msg void OnButton1();
	afx_msg void OnButton2();
	afx_msg void OnButton3();
	afx_msg void OnDontAskClick();
	virtual void OnOK();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

public:
	void setDefs( int regCont, int folCont, int conn, int prior);
	void getResults( int* v1, int* v2, int* v3, int* vp, bool* ask);

	static bool fetchOpts( IMgaProject* proj, int* v1, int* v2, int* v3, int* vp);
	static void saveOpts( IMgaProject* proj, int v1, int v2, int v3, int vp, bool dont_ask);

	static const std::string OptionsRegistrySubNode_str;
	static const std::string RegContMask_str;
	static const std::string FolContMask_str;
	static const std::string ConnectMask_str;
	static const std::string Priority_str;
	static const std::string DontAsk_str;

protected:
	int m_valRegContMask;// redundancy...
	int m_valFolContMask;
	int m_valConnectMask;
	int m_valPriority;

};

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

#endif // !defined(AFX_OPTIONS_H__D33EAC1F_01D6_4270_93F8_069D3BAFE231__INCLUDED_)

--- NEW FILE: NameSpecTbl.h ---
#if !defined(AFX_ASPECTSPECTBL_H__62A172B9_B4D4_497D_B466_B7BB7BF98B7F__INCLUDED_)
#define AFX_ASPECTSPECTBL_H__62A172B9_B4D4_497D_B466_B7BB7BF98B7F__INCLUDED_

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

#include <AFXCMN.H>

// MyListCtrl.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CMyListCtrl window

class NameSpecTbl : public CListCtrl
{
// Construction
public:
	NameSpecTbl();

// Attributes
public:

// Operations
public:

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

// Implementation
public:
	CImageList m_checkImages;
	bool GetRow( int rowID, CString& name, CString& disp_name, CString& kind);
	void AddRow( int rowID, CString& name, CString& disp_name, CString& kind);

	virtual ~NameSpecTbl();
	virtual BOOL PreCreateWindow( CREATESTRUCT &cs);
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	int HitTestEx(CPoint &point, int *col) const;
	CEdit* EditSubLabel( int nItem, int nCol );
	CComboBox* ShowInPlaceList( int nItem, int nCol, CStringList &lstItems, int nSel );

	static LPCTSTR MakeShortString(CDC* pDC, LPCTSTR lpszLong, int nColumnLen, int nOffset);


	// Generated message map functions
protected:
	//{{AFX_MSG(NameSpecTbl)
	afx_msg void OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_ASPECTSPECTBL_H__62A172B9_B4D4_497D_B466_B7BB7BF98B7F__INCLUDED_)

--- NEW FILE: InPlaceEdit.h ---
//////////////////////////////////////////////////////////////////////
// InPlaceEdit.h : header file
//
// MFC Grid Control - inplace editing class
//
// Written by Chris Maunder <cmaunder at mail.com>
// Copyright (c) 1998-2002. All Rights Reserved.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is 
// not sold for profit without the authors written consent, and 
// providing that this notice and the authors name and all copyright 
// notices remains intact. 
//
// An email letting me know how you are using it would be nice as well. 
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability for any damage/loss of business that
// this product may cause.
//
// For use with CGridCtrl v2.10+
//
//////////////////////////////////////////////////////////////////////

#define IDC_IPEDIT	1976

/////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit window

class CInPlaceEdit : public CEdit
{
// Construction
public:
	CInPlaceEdit(int iItem, int iSubItem, CString sInitText);

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CInPlaceEdit)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CInPlaceEdit();

	// Generated message map functions
protected:
	//{{AFX_MSG(CInPlaceEdit)
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	afx_msg void OnNcDestroy();
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
private:
	int m_iItem;
	int m_iSubItem;
	CString m_sInitText;
	BOOL    m_bESC;	 	// To indicate whether ESC key was pressed
};

/////////////////////////////////////////////////////////////////////////////
--- NEW FILE: InPlaceEdit.cpp ---
// InPlaceEdit.cpp : implementation file
//
// Adapted by Chris Maunder <cmaunder at mail.com>
// Copyright (c) 1998-2002. All Rights Reserved.
//
// The code contained in this file is based on the original
// CInPlaceEdit from http://www.codeguru.com/listview/edit_subitems.shtml
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is 
// not sold for profit without the authors written consent, and 
// providing that this notice and the authors name and all copyright 
// notices remains intact. 
//
// An email letting me know how you are using it would be nice as well. 
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability for any damage/loss of business that
// this product may cause.
//
// For use with CGridCtrl v2.10+
//
// History:
//         10 May 1998  Uses GVN_ notifications instead of LVN_,
//                      Sends notification messages to the parent, 
//                      instead of the parent's parent.
//         15 May 1998  There was a problem when editing with the in-place editor, 
//                      there arises a general protection fault in user.exe, with a 
//                      few qualifications:
//                         (1) This only happens with owner-drawn buttons;
//                         (2) This only happens in Win95
//                         (3) This only happens if the handler for the button does not 
//                             create a new window (even an AfxMessageBox will avoid the 
//                             crash)
//                         (4) This will not happen if Spy++ is running.
//                      PreTranslateMessage was added to route messages correctly.
//                      (Matt Weagle found and fixed this problem)
//         26 Jul 1998  Removed the ES_MULTILINE style - that fixed a few probs!
//          6 Aug 1998  Added nID to the constructor param list
//          6 Sep 1998  Space no longer clears selection when starting edit (Franco Bez)
//         10 Apr 1999  Enter, Tab and Esc key prob fixed (Koay Kah Hoe)
//                      Workaround for bizzare "shrinking window" problem in CE
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "inplaceedit.h"


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

/////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit

CInPlaceEdit::CInPlaceEdit(int iItem, int iSubItem, CString sInitText)
:m_sInitText( sInitText )
{
	m_iItem = iItem;
	m_iSubItem = iSubItem;
	m_bESC = FALSE;
}

CInPlaceEdit::~CInPlaceEdit()
{
}


BEGIN_MESSAGE_MAP(CInPlaceEdit, CEdit)
	//{{AFX_MSG_MAP(CInPlaceEdit)
	ON_WM_KILLFOCUS()
	ON_WM_NCDESTROY()
	ON_WM_CHAR()
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit message handlers

BOOL CInPlaceEdit::PreTranslateMessage(MSG* pMsg)
{
	if( pMsg->message == WM_KEYDOWN )
	{
		if(pMsg->wParam == VK_RETURN
				|| pMsg->wParam == VK_DELETE
				|| pMsg->wParam == VK_ESCAPE
				|| GetKeyState( VK_CONTROL)
				)
		{
			::TranslateMessage(pMsg);
			::DispatchMessage(pMsg);
			return TRUE;		    	// DO NOT process further
		}
	}

	return CEdit::PreTranslateMessage(pMsg);
}


void CInPlaceEdit::OnKillFocus(CWnd* pNewWnd)
{
	CEdit::OnKillFocus(pNewWnd);

	CString str;
	GetWindowText(str);

	// Send Notification to parent of ListView ctrl
	LV_DISPINFO dispinfo;
	dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
	dispinfo.hdr.idFrom = GetDlgCtrlID();
	dispinfo.hdr.code = LVN_ENDLABELEDIT;

	dispinfo.item.mask = LVIF_TEXT;
	dispinfo.item.iItem = m_iItem;
	dispinfo.item.iSubItem = m_iSubItem;
	dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
	dispinfo.item.cchTextMax = str.GetLength();

	GetParent()->GetParent()->SendMessage( WM_NOTIFY, GetParent()->GetDlgCtrlID(), 
					(LPARAM)&dispinfo );

	DestroyWindow();
}

void CInPlaceEdit::OnNcDestroy()
{
	CEdit::OnNcDestroy();

	delete this;
}


void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	if( nChar == VK_ESCAPE || nChar == VK_RETURN)
	{
		if( nChar == VK_ESCAPE )
			m_bESC = TRUE;
		GetParent()->SetFocus();
		return;
	}


	CEdit::OnChar(nChar, nRepCnt, nFlags);

	// Resize edit control if needed

	// Get text extent
	CString str;

	GetWindowText( str );
	CWindowDC dc(this);
	CFont *pFont = GetParent()->GetFont();
	CFont *pFontDC = dc.SelectObject( pFont );
	CSize size = dc.GetTextExtent( str );
	dc.SelectObject( pFontDC );
	size.cx += 5;			   	// add some extra buffer

	// Get client rect
	CRect rect, parentrect;
	GetClientRect( &rect );
	GetParent()->GetClientRect( &parentrect );

	// Transform rect to parent coordinates
	ClientToScreen( &rect );
	GetParent()->ScreenToClient( &rect );

	// Check whether control needs to be resized
	// and whether there is space to grow
	if( size.cx > rect.Width() )
	{
		if( size.cx + rect.left < parentrect.right )
			rect.right = rect.left + size.cx;
		else
			rect.right = parentrect.right;
		MoveWindow( &rect );
	}
}

int CInPlaceEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CEdit::OnCreate(lpCreateStruct) == -1)
		return -1;

	// Set the proper font
	CFont* font = GetParent()->GetFont();
	SetFont(font);

	SetWindowText( m_sInitText );
	SetFocus();
	SetSel( 0, -1 );
	return 0;
}
--- NEW FILE: NameSpecDlg.cpp ---
// AspectSpecDlg.cpp : implementation file
//

#include "stdafx.h"
#include "NameSpecDlg.h"
#include "Any.h"

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

/////////////////////////////////////////////////////////////////////////////
// NameSpecDlg

//IMPLEMENT_DYNAMIC(NameSpecDlg, CPropertySheet)

NameSpecDlg::NameSpecDlg(CWnd* pParent /*=NULL*/)
	: CDialog( NameSpecDlg::IDD, pParent)
	, m_lastID( 0)
{
	//{{AFX_DATA_INIT(NameSpecDlg)
	//}}AFX_DATA_INIT
}

NameSpecDlg::~NameSpecDlg()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// NameSpecDlg message handlers



void NameSpecDlg::GetEntry(int rowID, CString& name, CString& dispname, CString& kind, const void * &ptr)
{
	m_nmlist.GetRow(rowID, name, dispname, kind);
}

void uniqueNames( const CString& to_insert, CStringList& names)
{
	bool found = false;
	POSITION pos;
	pos = names.GetHeadPosition();
	while ( pos && !found)
	{
		if( to_insert.Compare(names.GetNext( pos )) == 0)
		{
			found = true;
		}
	}
	if( !found)
		names.InsertAfter( names.GetTailPosition(), to_insert);
}

void NameSpecDlg::GetNames( int num, CString& curr, CStringList& names)
{
	LARGE_MAP::iterator it = m_map.begin();
	for( int k = 0; k != num && it != m_map.end(); ++it, ++k);

	names.AddHead( curr);
	if( it != m_map.end()) // found
	{
		LARGE_MAP_VAL::iterator jt = it->second.begin();
		for( ; jt != it->second.end(); ++jt)
		{
			CComBSTR nm;
			COMTHROW( (*jt)->get_Name( &nm));

			CString onelem = nm;
			uniqueNames( onelem, names);

		}
	}
}

void NameSpecDlg::GetDispNames( int num, CString& currdispname, CStringList& dispnames)
{
	LARGE_MAP::iterator it = m_map.begin();
	for( int k = 0; k != num && it != m_map.end(); ++it, ++k);

	dispnames.AddHead( currdispname);
	if( it != m_map.end()) // found
	{
		LARGE_MAP_VAL::iterator jt = it->second.begin();
		for( ; jt != it->second.end(); ++jt)
		{
			CString onelem;
			CComBSTR val;
			COMTHROW( (*jt)->get_StrAttrByName( Util::Copy( Any::DisplayedName_str), &val));
			
			if( val && val.Length() > 0 )
			{
				onelem = val;
				uniqueNames( onelem, dispnames);
			}
		}
	}
	uniqueNames( "", dispnames); // thus allowing always the empty disp name possibility
}


BOOL NameSpecDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CRect loc;
	this->GetClientRect(&loc);
	loc.DeflateRect(10, 3*10, 10, 4*10);
	m_nmlist.Create(WS_CHILD|WS_VISIBLE|WS_BORDER/*|LVS_EDITLABELS*/|LVS_REPORT|LVS_SINGLESEL, loc, this, 1);
	
	DEFNAMES_MAP::iterator it = m_dn.begin();
	for( ; it != m_dn.end(); ++it)
	{
		CComPtr<IMgaFCO> ff( it->first);
		CString defname     = it->second.first.c_str();
		CString defdispname = it->second.second.c_str();

		CComPtr<IMgaMetaFCO> meta;
		COMTHROW( ff->get_Meta( &meta));

		CComBSTR b_kind;
		COMTHROW( meta->get_Name( &b_kind));
		CString kind = b_kind;


		//t
		//kind = CString(ff->getName().c_str()) + ":" + kind;
		//et

		m_nmlist.AddRow( m_lastID++, defname, defdispname, kind);
	}

	return TRUE;
}


void NameSpecDlg::OnOK() 
{
	DEFNAMES_MAP::iterator it = m_dn.begin();
	for( int k = 0; k < m_lastID && it != m_dn.end(); ++k, ++it)
	{
		CString name, dispname, kind; void * ptr;
		GetEntry( k, name, dispname, kind, ptr);
		CComPtr<IMgaFCO> fco = it->first;
		std::string newsel_name = (LPCTSTR) name;
		std::string newsel_dispname = (LPCTSTR) dispname;
		m_result[ fco] = make_pair( newsel_name, newsel_dispname);

#ifdef _DEBUG
		//check
		LARGE_MAP_VAL::iterator jt = m_map[ fco].begin();
		//for( ; jt != m_map[ fco].end() && (*jt)->getName() != newsel_name; ++jt); // replaced by
		for( ; jt != m_map[ fco].end(); ++jt)
		{
			CComBSTR nm;
			COMTHROW( (*jt)->get_Name( &nm));
			if( Util::Copy( nm) == newsel_name)
				break;
		}

		if( jt == m_map[ fco].end() && newsel_name != m_dn[ fco].first)
			ASSERT(0); // if not found among equivs and is not the default name
#endif
	}

	CDialog::OnOK();
}

--- NEW FILE: NameSpecDlg.h ---
#if !defined(AFX_ASPECTSPECDLG_H__A771B477_7ECF_41F9_8FCD_1557C770B87C__INCLUDED_)
#define AFX_ASPECTSPECDLG_H__A771B477_7ECF_41F9_8FCD_1557C770B87C__INCLUDED_

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

#include <afxtempl.h>
#include <AFXDLGS.H>
#include "resource.h"
#include "NameSpecTbl.h"
#include <map>
#include <string>
#include <set>
#include "MyUtil.h"
// AspectSpecDlg.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// NameSpecDlg

//class NameSpecDlg : public CPropertySheet
class NameSpecDlg : public CDialog
{
	//DECLARE_DYNAMIC(NameSpecDlg)

// Dialog Data
	//{{AFX_DATA(NameSpecDlg)
	enum { IDD = IDD_EQUIVDIALOG };
	//}}AFX_DATA

// Construction
public:
	NameSpecDlg( CWnd* pParent = NULL);   // standard constructor

// Attributes
public:

	NameSpecTbl	m_nmlist;
	int	m_lastID;
	typedef std::set< IMgaFCO*> LARGE_MAP_VAL;
	typedef std::map< IMgaFCO*, LARGE_MAP_VAL > LARGE_MAP;
	typedef std::pair<std::string, std::string> DEFNAMES_MAP_VAL;
	typedef std::map< IMgaFCO*, DEFNAMES_MAP_VAL > DEFNAMES_MAP;

	LARGE_MAP m_map;//contains the equivalent fcos (which are non-proxy)
	DEFNAMES_MAP m_dn;	// the default values , or initial values shown when the dialog pops up
	DEFNAMES_MAP m_result;	// the result

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(NameSpecDlg)
	public:
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	//}}AFX_VIRTUAL

// Implementation
public:
	void GetEntry(int entryNum, CString& name, CString& dispname, CString& kind, const void * &ptr);

	void GetNames(int num, CString& curname, CStringList& names);
	void GetDispNames( int num, CString& curdispname, CStringList& dispnames);

	virtual ~NameSpecDlg();

	// Generated message map functions
protected:
	//{{AFX_MSG(NameSpecDlg)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_ASPECTSPECDLG_H__A771B477_7ECF_41F9_8FCD_1557C770B87C__INCLUDED_)

--- NEW FILE: EventsDial.h ---
#if !defined(AFX_EVENTSDIAL_H__6AEC715F_5884_4DB8_AB81_DE6C33BF3BF4__INCLUDED_)
#define AFX_EVENTSDIAL_H__6AEC715F_5884_4DB8_AB81_DE6C33BF3BF4__INCLUDED_

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

#include <afxcmn.h>
#include "resource.h"


/////////////////////////////////////////////////////////////////////////////
// EventsDial dialog

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

// Dialog Data
	//{{AFX_DATA(EventsDial)
	enum { IDD = IDD_EVENTSDLG };
	BOOL	m_chkCreated;
	BOOL	m_chkDestroyed;
	BOOL	m_chkAttr;
	BOOL	m_chkNewchild;
	BOOL	m_chkRelation;
	BOOL	m_chkProperties;
	BOOL	m_chkSubtinst;
	BOOL	m_chkParent;
	BOOL	m_chkLostchild;
	BOOL	m_chkReferenced;
	BOOL	m_chkConnected;
	BOOL	m_chkIncludeInSet;
	BOOL	m_chkDisconnect;
	BOOL	m_chkUnrefer;
	BOOL	m_chkExcludeFromSet;
	BOOL	m_chkCloseModel;
	//}}AFX_DATA


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

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(EventsDial)
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
public:
	static int m_valCreated;
	static int m_valDestroyed;
	static int m_valAttr;
	static int m_valRegistry;
	static int m_valNewchild;
	static int m_valRelation;
	static int m_valProperties;
	static int m_valSubtinst;
	static int m_valBase;
	static int m_valPosition;
	static int m_valParent;
	static int m_valLostchild;
	static int m_valReferenced;
	static int m_valConnected;
	static int m_valSetIncluded;
	static int m_valRefReleased;
	static int m_valDisconnected;
	static int m_valSetExcluded;
	static int m_valUserBits;
	static int m_valCloseModel;

	// the sum of all values
	int m_sumAll;

};

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

#endif // !defined(AFX_EVENTSDIAL_H__6AEC715F_5884_4DB8_AB81_DE6C33BF3BF4__INCLUDED_)

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

#include "stdafx.h"
#include "aspectspectbl.h"
#include "AspectSpecDlg.h"
#include "logger.h"
#include "ModelRep.h"
#include "ReferenceRep.h"

#include "globals.h"
extern Globals global_vars;

// keep in sync with Dumper.cpp's DUMPER_NOT_SPECIFIED_STR
#define DUMPER_NOT_SPECIFIED_STR      "Not specified"


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

/////////////////////////////////////////////////////////////////////////////
// CAspectSpecDlg

//IMPLEMENT_DYNAMIC(CAspectSpecDlg, CPropertySheet)

CAspectSpecDlg::CAspectSpecDlg(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
	: CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
	, lastID( 0)
	, countPages( 0)
{
	m_psh.dwFlags |= PSH_NOAPPLYNOW;
}

CAspectSpecDlg::CAspectSpecDlg(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
	: CPropertySheet(pszCaption, pParentWnd, iSelectPage)
	, lastID( 0)
	, countPages( 0)
{
	m_psh.dwFlags |= PSH_NOAPPLYNOW;
}

CAspectSpecDlg::~CAspectSpecDlg()
{
	POSITION pos = aspectPages.GetHeadPosition();
	while (pos) 
		delete aspectPages.GetNext(pos);


	aspectPages.RemoveAll();

}


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

/////////////////////////////////////////////////////////////////////////////
// CAspectSpecDlg message handlers



int CAspectSpecDlg::AddEntry(CString aspectName, CString roleName, CString kindAspect, CString primaryAsp, const void * ptr)
{
	CAspectPage *aspectPage = NULL;

	POSITION pos = aspectPages.GetHeadPosition();
	while (pos) {
		CAspectPage *page = aspectPages.GetNext(pos);
		CString title = page->GetAspectName();;

		if (title == aspectName)
			aspectPage = page;
	}
	
	if (!aspectPage) {
		aspectPage = new CAspectPage();
		aspectPage->SetAspectName(aspectName);
		aspectNames.AddTail(aspectName);
		AddPage(aspectPage);
		aspectPages.AddTail(aspectPage);
		++countPages;
	}

	aspectPage->AddEntry(lastID, roleName, kindAspect, primaryAsp, ptr);
	return lastID++;
}

void CAspectSpecDlg::GetEntry(int rowID, CString &roleName, CString &kindAspect, CString &isPrimary, const void * &ptr)
{
	POSITION pos = aspectPages.GetHeadPosition();
	while (pos) {
		if (aspectPages.GetNext(pos)->GetEntry(rowID, roleName, kindAspect, isPrimary, ptr))
			break;
	}

}

void CAspectSpecDlg::GetAspects(CStringList &aspects)
{
	aspects.RemoveAll();
	aspects.AddTail(&aspectNames);
}

void CAspectSpecDlg::GetAspects( int rowID, CStringList &aspects)
{
	aspects.RemoveAll();
	CString role_name = "N/A", kind_asp = "N/A", is_prim;
	void * ptr;
	GetEntry( rowID, role_name, kind_asp, is_prim, ptr);
	if ( role_name == "N/A") 
		global_vars.err << MSG_ERROR << "Internal error: GetEntry failed. Empty rolename\n";
	const FCO * fco_ptr = static_cast<const FCO*>( ptr);
	if ( fco_ptr)
	{
		if ( fco_ptr->getMyKind() == Any::MODEL)
		{
			const ModelRep * m_ptr = static_cast<const ModelRep *>(ptr);
			m_ptr->getAspectNames( aspects);
		}
		else if (fco_ptr->getMyKind() == Any::REF)
		{
			aspects.AddTail( DUMPER_NOT_SPECIFIED_STR);
			const ReferenceRep * r_ptr = static_cast< const ReferenceRep *>(ptr);
			std::vector< AspectRep *> asps = r_ptr->getAspectsIntersection();
			std::vector< AspectRep *>::iterator asp_it = asps.begin();
			for( ; asp_it != asps.end(); ++asp_it)
			{
				aspects.AddTail( (*asp_it)->getName().c_str());
			}
		}
		else global_vars.err << MSG_ERROR << "Internal error: why other type than Model and Ref has Kindaspect?\n";
	}
	else global_vars.err << MSG_ERROR << "Internal error: zero pointer\n";
}

BOOL CAspectSpecDlg::OnInitDialog() 
{
	// this will call the OnInitDialog of the first PropertyPage
	BOOL bResult = CPropertySheet::OnInitDialog();

	// this portion may modify the layout of tabs (the number of rows they occupy)
	// since the tabnames may be longer then expected
	// so the first page needs to be resized after this 
	CTabCtrl* tab = GetTabControl();
	int count = tab->GetItemCount();
	POSITION pos = aspectNames.GetHeadPosition();
	for (int i = 0; i < count; i++) {
		TC_ITEM tcItem; 
		tcItem.mask = TCIF_TEXT; 
		tcItem.pszText = aspectNames.GetNext(pos).GetBuffer(255);
		tab->SetItem(i, &tcItem ); 
	}

	SetActivePage(0); // activates the first page, and calls AspectPage::OnSize with the updated size (lower than the previous)

	// resizing of controls on the first page
	CAspectPage *firstpage;
	POSITION pos1 = aspectPages.GetHeadPosition();
	if( pos1){
		firstpage = aspectPages.GetNext(pos1);
		firstpage->resizeTableToFitIn();
	}


	return bResult;
}

int CAspectSpecDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	// Set for Scrolling Tabs style if the #of pages exceeds 19
	// otherwise the tabs with long aspect names could occupy the whole window area
	// if 19 aspects with really long names existed still fitted into the window
	// and space left for 3 items
	// that is why we enable the ScrollingTabs in case the number of pages > 19
	// unfortunately the length of the names is not calculated
	EnableStackedTabs( countPages <= 19);

	// Call the base class
	return CPropertySheet::OnCreate(lpCreateStruct);
}

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

#include "stdafx.h"
#include "EventsDial.h"

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

/*static*/ int EventsDial::m_valCreated			= 0x80000000;
/*static*/ int EventsDial::m_valDestroyed		= 0x40000000;
/*static*/ int EventsDial::m_valAttr			= 0x00000001;
/*static*/ int EventsDial::m_valRegistry		= 0x00000002;//not exposed to the user
/*static*/ int EventsDial::m_valNewchild		= 0x00000004;
/*static*/ int EventsDial::m_valRelation		= 0x00000008;//ref pointer, set member, conn endpoint change
/*static*/ int EventsDial::m_valProperties		= 0x00000010;
/*static*/ int EventsDial::m_valSubtinst		= 0x00000020;
/*static*/ int EventsDial::m_valBase			= 0x00000040;//obsolete (based on mga.idl)
/*static*/ int EventsDial::m_valPosition		= 0x00000080;//obsolete (based on mga.idl)
/*static*/ int EventsDial::m_valParent			= 0x00000100;
/*static*/ int EventsDial::m_valLostchild		= 0x00000200;
/*static*/ int EventsDial::m_valReferenced		= 0x00000400;
/*static*/ int EventsDial::m_valConnected		= 0x00000800;
/*static*/ int EventsDial::m_valSetIncluded		= 0x00001000;
/*static*/ int EventsDial::m_valRefReleased		= 0x00002000;
/*static*/ int EventsDial::m_valDisconnected	= 0x00004000;
/*static*/ int EventsDial::m_valSetExcluded		= 0x00008000;
/*static*/ int EventsDial::m_valUserBits		= 0x00FF0000;//not exposed to the user
/*static*/ int EventsDial::m_valCloseModel		= 0x00800000;

/////////////////////////////////////////////////////////////////////////////
// EventsDial dialog

EventsDial::EventsDial(CWnd* pParent /*=NULL*/)
	: CDialog(EventsDial::IDD, pParent)
	, m_sumAll( 0)

{
	//{{AFX_DATA_INIT(EventsDial)
	m_chkCreated = FALSE;
	m_chkDestroyed = FALSE;
	m_chkAttr = FALSE;
	m_chkNewchild = FALSE;
	m_chkRelation = FALSE;
	m_chkProperties = FALSE;
	m_chkSubtinst = FALSE;
	m_chkParent = FALSE;
	m_chkLostchild = FALSE;
	m_chkReferenced = FALSE;
	m_chkConnected = FALSE;
	m_chkIncludeInSet = FALSE;
	m_chkDisconnect = FALSE;
	m_chkUnrefer = FALSE;
	m_chkExcludeFromSet = FALSE;
	m_chkCloseModel = FALSE;
	//}}AFX_DATA_INIT
}


void EventsDial::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(EventsDial)
	DDX_Check(pDX, IDC_CHECK1, m_chkCreated);
	DDX_Check(pDX, IDC_CHECK2, m_chkDestroyed);
	DDX_Check(pDX, IDC_CHECK3, m_chkAttr);
	DDX_Check(pDX, IDC_CHECK5, m_chkNewchild);
	DDX_Check(pDX, IDC_CHECK6, m_chkRelation);
	DDX_Check(pDX, IDC_CHECK7, m_chkProperties);
	DDX_Check(pDX, IDC_CHECK8, m_chkSubtinst);
	DDX_Check(pDX, IDC_CHECK11, m_chkParent);
	DDX_Check(pDX, IDC_CHECK12, m_chkLostchild);
	DDX_Check(pDX, IDC_CHECK13, m_chkReferenced);
	DDX_Check(pDX, IDC_CHECK14, m_chkConnected);
	DDX_Check(pDX, IDC_CHECK16, m_chkIncludeInSet);
	DDX_Check(pDX, IDC_CHECK17, m_chkDisconnect);
	DDX_Check(pDX, IDC_CHECK18, m_chkUnrefer);
	DDX_Check(pDX, IDC_CHECK19, m_chkExcludeFromSet);
	DDX_Check(pDX, IDC_CHECK15, m_chkCloseModel);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(EventsDial, CDialog)
	//{{AFX_MSG_MAP(EventsDial)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// EventsDial message handlers

BOOL EventsDial::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_chkCreated		= ( m_sumAll & m_valCreated) != 0;
	m_chkDestroyed		= ( m_sumAll & m_valDestroyed) != 0;
	m_chkAttr			= ( m_sumAll & m_valAttr) != 0;
	//m_chkRegistry		= ( m_sumAll & m_valRegistry) != 0;
	m_chkNewchild		= ( m_sumAll & m_valNewchild) != 0;
	m_chkRelation		= ( m_sumAll & m_valRelation) != 0;
	m_chkProperties		= ( m_sumAll & m_valProperties) != 0;
	m_chkSubtinst		= ( m_sumAll & m_valSubtinst) != 0;
	//m_chkBase			= ( m_sumAll & m_valBase) != 0;
	//m_chkPosition		= ( m_sumAll & m_valPosition) != 0;
	m_chkParent			= ( m_sumAll & m_valParent) != 0;
	m_chkLostchild		= ( m_sumAll & m_valLostchild) != 0;
	m_chkReferenced		= ( m_sumAll & m_valReferenced) != 0;
	m_chkConnected		= ( m_sumAll & m_valConnected) != 0;
	m_chkIncludeInSet	= ( m_sumAll & m_valSetIncluded ) != 0;
	m_chkUnrefer		= ( m_sumAll & m_valRefReleased ) != 0;
	m_chkDisconnect		= ( m_sumAll & m_valDisconnected ) != 0;
	m_chkExcludeFromSet	= ( m_sumAll & m_valSetExcluded ) != 0;
	m_chkCloseModel		= ( m_sumAll & m_valCloseModel) != 0;

	UpdateData( FALSE);

	return TRUE;
}

void EventsDial::OnOK() 
{
	UpdateData( TRUE);

	m_sumAll = 0;

	if( m_chkCreated)			m_sumAll |= m_valCreated;
	if( m_chkDestroyed)			m_sumAll |= m_valDestroyed;
	if( m_chkAttr)				m_sumAll |= m_valAttr;
	//if( m_chkRegistry)		m_sumAll |= m_valRegistry;
	if( m_chkNewchild)			m_sumAll |= m_valNewchild;
	if( m_chkRelation)			m_sumAll |= m_valRelation;
	if( m_chkProperties)		m_sumAll |= m_valProperties;
	if( m_chkSubtinst)			m_sumAll |= m_valSubtinst;
	//if( m_chkBase)			m_sumAll |= m_valBase;
	//if( m_chkPosition)		m_sumAll |= m_valPosition;
	if( m_chkParent)			m_sumAll |= m_valParent;
	if( m_chkLostchild)			m_sumAll |= m_valLostchild;
	if( m_chkReferenced)		m_sumAll |= m_valReferenced;
	if( m_chkConnected)			m_sumAll |= m_valConnected;
	if( m_chkIncludeInSet)		m_sumAll |= m_valSetIncluded;
	if( m_chkUnrefer)			m_sumAll |= m_valRefReleased;
	if( m_chkDisconnect)		m_sumAll |= m_valDisconnected;
	if( m_chkExcludeFromSet)	m_sumAll |= m_valSetExcluded;
	if( m_chkCloseModel)		m_sumAll |= m_valCloseModel;
	
	CDialog::OnOK();
}

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

#include "stdafx.h"
#include "Options.h"
#include "EventsDial.h"
#include "MyUtil.h"
#include <afxdlgs.h>

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

/*static*/ const std::string Options::OptionsRegistrySubNode_str = "MetaGME_Options/GeneratedConstraints";
/*static*/ const std::string Options::RegContMask_str = "RegularContainmentEventMask";
/*static*/ const std::string Options::FolContMask_str = "FolderContainmentEventMask";
/*static*/ const std::string Options::ConnectMask_str = "ConnectionEndEventMask";
/*static*/ const std::string Options::Priority_str = "Priority";
/*static*/ const std::string Options::DontAsk_str = "skip_dialog";

/////////////////////////////////////////////////////////////////////////////
// Options dialog

Options::Options(CWnd* pParent /*=NULL*/)
	: CDialog(Options::IDD, pParent)
	, m_valRegContMask( 0 )
	, m_valFolContMask( 0 )
	, m_valConnectMask( 0 )
	, m_valPriority   ( 1 )

{
	//{{AFX_DATA_INIT(Options)
	m_strRegCont = _T("");
	m_strFolCont = _T("");
	m_strConnect = _T("");
	m_dontask = FALSE;
	m_strPriority = _T("");
	//}}AFX_DATA_INIT
}


void Options::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Options)
	DDX_Control(pDX, IDC_SPIN1, m_spin);
	DDX_Text(pDX, IDC_EDIT1, m_strRegCont);
	DDV_HexNumber(pDX, m_strRegCont);
	DDV_MaxChars(pDX, m_strRegCont, 10);
	DDX_Text(pDX, IDC_EDIT2, m_strFolCont);
	DDV_HexNumber(pDX, m_strFolCont);
	DDV_MaxChars(pDX, m_strFolCont, 10);
	DDX_Text(pDX, IDC_EDIT3, m_strConnect);
	DDV_HexNumber(pDX, m_strConnect);
	DDV_MaxChars(pDX, m_strConnect, 10);
	DDX_Check(pDX, IDC_CHECK1, m_dontask);
	DDX_Text(pDX, IDC_EDIT4, m_strPriority);
	DDV_MaxChars(pDX, m_strPriority, 2);
	DDV_MinMaxInt(pDX, atoi( m_strPriority), 1, 10);
	//}}AFX_DATA_MAP
}

void PASCAL Options::DDV_HexNumber(CDataExchange* pDX, const CString& nmb)
{
	if( !pDX->m_bSaveAndValidate) return;

	CString whitespace = " \t\n";
	CString digits = "0123456789";
	CString hexadigits = "0123456789abcdefABCDEF";
	bool fail = false;
	int i = 0;

	//skip whitespaces
	while( i < nmb.GetLength() && whitespace.Find( nmb.GetAt( i)) != -1) ++i;
	
	if( i == nmb.GetLength()) //empty
	{
		return;//do not fail if empty string, will be considered 0
	}

	bool hex = false;
	if( i + 1 < nmb.GetLength() && nmb.GetAt(i) == '0' && (nmb.GetAt(i + 1) == 'x' || nmb.GetAt(i + 1) == 'X'))
	{
		i += 2;
		hex = true;
		digits = hexadigits;
	}

	while( i < nmb.GetLength() && digits.Find( nmb.GetAt(i)) != -1) ++i;
	
	fail = i < nmb.GetLength();

	if( fail)
	{
		AfxMessageBox("Enter a hexadecimal value please!", MB_ICONERROR);
		pDX->Fail();
	}
}

BEGIN_MESSAGE_MAP(Options, CDialog)
	//{{AFX_MSG_MAP(Options)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_CHECK1, OnDontAskClick)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Options message handlers
BOOL Options::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	char buff[32];
	sprintf( buff, "0x%08X", m_valRegContMask);
	m_strRegCont = buff;
	sprintf( buff, "0x%08X", m_valFolContMask);
	m_strFolCont = buff;
	sprintf( buff, "0x%08X", m_valConnectMask);
	m_strConnect = buff;
	sprintf( buff, "%d", m_valPriority);
	m_strPriority = buff;
	
	m_spin.SetRange( 1, 10);
	m_spin.SetPos( m_valPriority);

	UpdateData( FALSE);

	return TRUE;
}

void Options::OnButton1()
{
	UpdateData( TRUE);
	EventsDial d;

	int val = 0;
	if( sscanf( m_strRegCont, "%X", &val) == 1)
		d.m_sumAll = val;

	if( d.DoModal() == IDOK)
	{
		char buff[32];
		sprintf( buff, "0x%08X", d.m_sumAll);
		m_strRegCont = buff;
		m_valRegContMask = d.m_sumAll;
	}

	UpdateData( FALSE);
}

void Options::OnButton2() 
{
	UpdateData( TRUE);
	EventsDial d;

	int val = 0;
	if( sscanf( m_strFolCont, "%X", &val) == 1)
		d.m_sumAll = val;

	if( d.DoModal() == IDOK)
	{
		char buff[32];
		sprintf( buff, "0x%08X", d.m_sumAll);
		m_strFolCont = buff;
		m_valFolContMask = d.m_sumAll;
	}

	UpdateData( FALSE);
}

void Options::OnButton3() 
{
	UpdateData( TRUE);
	EventsDial d;

	int val = 0;
	if( sscanf( m_strConnect, "%X", &val) == 1)
		d.m_sumAll = val;

	if( d.DoModal() == IDOK)
	{
		char buff[32];
		sprintf( buff, "0x%08X", d.m_sumAll);
		m_strConnect = buff;
		m_valConnectMask = d.m_sumAll;
	}

	UpdateData( FALSE);
}

void Options::setDefs( int reg_cont, int fol_cont, int conn_msk, int prior)
{
	m_valRegContMask = reg_cont;
	m_valFolContMask = fol_cont;
	m_valConnectMask = conn_msk;
	m_valPriority    = prior;
}


void Options::getResults( int* v1, int* v2, int* v3, int* vp, bool* dont_ask)
{
	*v1 = m_valRegContMask;
	*v2 = m_valFolContMask;
	*v3 = m_valConnectMask;
	*vp = m_valPriority;

	*dont_ask = m_dontask == TRUE;
}


/*static*/ bool Options::fetchOpts( IMgaProject* proj, int* v1, int* v2, int* v3, int *pr)
{
	CComPtr<IMgaFolder>  rf;
	COMTHROW( proj->get_RootFolder( &rf));

	CComPtr<IMgaRegNode> rn;
	COMTHROW( rf->get_RegistryNode( CComBSTR( OptionsRegistrySubNode_str.c_str()), &rn));

	//BON::RegistryNode rn = proj->getRootFolder()->getRegistry()->getChild( OptionsRegistrySubNode_str);
	if( !rn) return true;

	CComBSTR vl;
	COMTHROW( rn->get_Value( &vl));
	//if( rn->getValue() == DontAsk_str)
	if( Util::Copy( vl) == DontAsk_str)
	{
		return false;
	}
	else
	{
		CComBSTR b_value; std::string value;
		long status = 0; 

		CComPtr<IMgaRegNode> ch1;
		COMTHROW( rn->get_SubNodeByName( Util::Copy( RegContMask_str), &ch1));
		if( ch1) COMTHROW( ch1->get_Status( &status));
		if( ch1) COMTHROW( ch1->get_Value( &b_value));
		value = Util::Copy( b_value);
		if( ch1 && status == 0) // 0: here, -1: in meta, >=1: inherited
			status = sscanf( value.c_str(), "%x", v1); //number stored in hexadecimal format
		
		CComPtr<IMgaRegNode> ch2;
		COMTHROW( rn->get_SubNodeByName( Util::Copy( FolContMask_str), &ch2));
		if( ch2) COMTHROW( ch2->get_Status( &status));
		if( ch2) COMTHROW( ch2->get_Value( &b_value));
		value = Util::Copy( b_value);
		if( ch2 && status == 0)
			status = sscanf( value.c_str(), "%x", v2);
		
		CComPtr<IMgaRegNode> ch3;
		COMTHROW( rn->get_SubNodeByName( Util::Copy( ConnectMask_str), &ch3));
		if( ch3) COMTHROW( ch3->get_Status( &status));
		if( ch3) COMTHROW( ch3->get_Value( &b_value));
		value = Util::Copy( b_value);
		if( ch3 && status == 0)
			status = sscanf( value.c_str(), "%x", v3);

		CComPtr<IMgaRegNode> ch4;
		COMTHROW( rn->get_SubNodeByName( Util::Copy( Priority_str), &ch4));
		if( ch4) COMTHROW( ch4->get_Status( &status));
		if( ch4) COMTHROW( ch4->get_Value( &b_value));
		value = Util::Copy( b_value);
		if( ch4 && status == 0)
		{
			//*pr = ch4->getIntegerValue();
			status = sscanf( value.c_str(), "%d", pr);
		}
	}
	return true;
}


/*static*/ void Options::saveOpts( IMgaProject* proj, int v1, int v2, int v3, int vp, bool dont_ask)
{
	char buff[ 10 + 1 ];

	CComPtr<IMgaFolder>  rf;
	COMTHROW( proj->get_RootFolder( &rf));

	sprintf( buff, "0x%08X", v1);
	COMTHROW( rf->put_RegistryValue( Util::Copy( std::string( OptionsRegistrySubNode_str + "/" + RegContMask_str)), CComBSTR( buff)));

	sprintf( buff, "0x%08X", v2);
	COMTHROW( rf->put_RegistryValue( Util::Copy( std::string( OptionsRegistrySubNode_str + "/" + FolContMask_str)), CComBSTR( buff)));

	sprintf( buff, "0x%08X", v3);
	COMTHROW( rf->put_RegistryValue( Util::Copy( std::string( OptionsRegistrySubNode_str + "/" + ConnectMask_str)), CComBSTR( buff)));

	sprintf( buff, "%d", vp);
	COMTHROW( rf->put_RegistryValue( Util::Copy( std::string( OptionsRegistrySubNode_str + "/" + Priority_str)), CComBSTR( buff)));

	if( dont_ask) COMTHROW( rf->put_RegistryValue( Util::Copy( std::string( OptionsRegistrySubNode_str)), Util::Copy( DontAsk_str)));
}


void Options::OnOK() 
{
	CDialog::OnOK();//UpdateData( TRUE);

	if( m_strRegCont.IsEmpty() || !sscanf( (LPCTSTR) m_strRegCont, "%x", &m_valRegContMask)) m_valRegContMask = 0;
	if( m_strFolCont.IsEmpty() || !sscanf( (LPCTSTR) m_strFolCont, "%x", &m_valFolContMask)) m_valFolContMask = 0;
	if( m_strConnect.IsEmpty() || !sscanf( (LPCTSTR) m_strConnect, "%x", &m_valConnectMask)) m_valConnectMask = 0;

	m_valPriority = atoi( m_strPriority);
	if( !m_valPriority) m_valPriority = 1;

}

void Options::OnDontAskClick() 
{
	if( ((CButton * ) GetDlgItem( IDC_CHECK1))->GetCheck())
		if( IDCANCEL == MessageBox( CString("If you leave this option checked you can access this dialog later only if you modify the \"") + OptionsRegistrySubNode_str.c_str() + "\" value in the RootFolder's registry to something else than \"" + DontAsk_str.c_str() + "\"!", "Warning!", MB_OKCANCEL | MB_ICONWARNING))
			((CButton *) GetDlgItem( IDC_CHECK1))->SetCheck( 0);
	
}

--- NEW FILE: AspectSpecDlg.h ---
#if !defined(AFX_ASPECTSPECDLG_H__A771B477_7ECF_41F9_8FCD_1557C770B87C__INCLUDED_)
#define AFX_ASPECTSPECDLG_H__A771B477_7ECF_41F9_8FCD_1557C770B87C__INCLUDED_

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

#include <afxtempl.h>
#include <AFXDLGS.H>

#include "AspectPage.h"

class CAspectPage;
class CAspectSpecDlg;
extern CAspectSpecDlg	*theAspectDlg;

typedef CTypedPtrList<CPtrList, CAspectPage*> CAspectPageList;

// AspectSpecDlg.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CAspectSpecDlg

class CAspectSpecDlg : public CPropertySheet
{
	//DECLARE_DYNAMIC(CAspectSpecDlg)

// Construction
public:
	CAspectSpecDlg(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
	CAspectSpecDlg(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);

// Attributes
public:

	CAspectPageList	aspectPages;
	CStringList	aspectNames;
	int	lastID;
	int countPages;
	

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAspectSpecDlg)
	public:
	virtual BOOL OnInitDialog();
	//}}AFX_VIRTUAL

// Implementation
public:
	void GetEntry(int entryNum, CString &roleName, CString &kindAspect, CString &isPrimary, const void * &ptr);
	int AddEntry(CString aspectName, CString roleName, CString  kindAspect, CString primaryAspect, const void * ptr);
	void GetAspects(CStringList& aspects);
	void GetAspects( int rowID, CStringList& aspects);
	virtual ~CAspectSpecDlg();

	// Generated message map functions
protected:
	afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
	//{{AFX_MSG(CAspectSpecDlg)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_ASPECTSPECDLG_H__A771B477_7ECF_41F9_8FCD_1557C770B87C__INCLUDED_)

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

#include "stdafx.h"
#include "aspectspectbl.h"
#include "aspectpage.h"



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

/////////////////////////////////////////////////////////////////////////////
// CAspectPage property page

//IMPLEMENT_DYNCREATE(CAspectPage, CPropertyPage)

int CAspectPage::m_actHeight = 0;//static 
int CAspectPage::m_actWidth = 0; //static

CAspectPage::CAspectPage() 
	: CPropertyPage(IDD_ASPECT_PAGE)
	, m_deflateVal(10)
{
	//{{AFX_DATA_INIT(CAspectPage)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


CAspectPage::~CAspectPage()
{
	POSITION pos = entries.GetHeadPosition();
	while (pos) {
		delete entries.GetNext(pos);
	}
	entries.RemoveAll();

	m_actWidth = m_actHeight = 0;// reset the values
}

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


BEGIN_MESSAGE_MAP(CAspectPage, CPropertyPage)
	ON_WM_SIZE()
	//{{AFX_MSG_MAP(CAspectPage)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAspectPage message handlers

CString CAspectPage::GetAspectName() {
	return aspectName;
}

void CAspectPage::SetAspectName(CString name) {
	aspectName = name;
}

BOOL CAspectPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();

	// TODO: Add extra initialization here

	CRect loc;
	calcPlace( loc);

	aspectTable.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT|LVS_SINGLESEL|LVS_NOSORTHEADER, loc, this, 1);
	POSITION pos = entries.GetHeadPosition();
	while (pos) {
		entry	*e = entries.GetNext(pos);
		aspectTable.AddRow(e->rowID, e->roleName, e->kindAspect, e->isPrimary);
	}

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

void CAspectPage::AddEntry(int rowID, CString roleName, CString kindAspect, CString isPrimary, const void * ptr)
{
	entry* newent = new entry;;

	newent->rowID = rowID;

	newent->roleName = roleName;
	newent->kindAspect = kindAspect;
	newent->isPrimary = isPrimary;
	newent->ptr = ptr;

	entries.AddTail(newent);
}


bool CAspectPage::GetEntry(int rowID, CString &roleName, CString& kindAspect, CString& isPrimary, const void * &ptr)
{
	bool retval = false;

	POSITION pos = entries.GetHeadPosition();
	while (pos) {
		entry	*e = entries.GetNext(pos);
		if (e->rowID == rowID) {
			roleName = e->roleName;
			kindAspect = e->kindAspect;
			isPrimary = e->isPrimary;
			ptr = e->ptr;
			retval = true;
		}
	}
	return retval;
}

void CAspectPage::OnOK() 
{
	// TODO: Add your specialized code here and/or call the base class
	POSITION pos = entries.GetHeadPosition();
	while (pos) {
		entry	*e = entries.GetNext(pos);
		aspectTable.GetRow(e->rowID, e->roleName, e->kindAspect, e->isPrimary);
	}
	
	CPropertyPage::OnOK();
}

void CAspectPage::OnSize( UINT ntype, int cx, int cy)
{
	// this methods captures the size of the remaining area
	// after the stacking tabs have been drawn, so that 
	// the initial page needs to be resized accordingly
	//
	// this method is called several times, first is called
	// with larger cy values (close to the total size of the window)
	// but after the tabs were drawn the it is called with a smaller
	// cy value

	CPropertyPage::OnSize( ntype, cx, cy);
	if ( m_actHeight == 0) m_actHeight = cy;
	
	m_actHeight = cy<m_actHeight?cy:m_actHeight;//minimum
	m_actWidth = cx;

}

void CAspectPage::calcPlace( CRect &loc)
{
	//this->GetClientRect(&loc);
	loc.left = loc.top = 0;
	loc.bottom = m_actHeight;
	loc.right = m_actWidth;

	loc.DeflateRect( m_deflateVal, m_deflateVal);
}

void CAspectPage::resizeTableToFitIn()
{
	CRect loc;
	calcPlace( loc);
	aspectTable.SetWindowPos( 0, loc.left, loc.top, // ignored values
		loc.right - loc.left, loc.bottom - loc.top,
		SWP_SHOWWINDOW|SWP_NOZORDER|SWP_NOMOVE);
}


--- NEW FILE: NameSpecTbl.cpp ---
// AspectSpecTbl.cpp : implementation file
//

#include "stdafx.h"
#include "inplaceedit.h"
#include "inplacelist.h"
#include "NameSpecTbl.h"
#include "NameSpecDlg.h"
extern NameSpecDlg * dlg;

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

#define OFFSET_FIRST    2
#define OFFSET_OTHER    6

/////////////////////////////////////////////////////////////////////////////
// NameSpecTbl

NameSpecTbl::NameSpecTbl()
{
}

NameSpecTbl::~NameSpecTbl()
{
}


BEGIN_MESSAGE_MAP(NameSpecTbl, CListCtrl)
	//{{AFX_MSG_MAP(NameSpecTbl)
	ON_NOTIFY_REFLECT(LVN_ENDLABELEDIT, OnEndlabeledit)
	ON_WM_HSCROLL()
	ON_WM_VSCROLL()
	ON_WM_LBUTTONDOWN()
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// NameSpecTbl message handlers

BOOL NameSpecTbl::PreCreateWindow( CREATESTRUCT &cs)
{
	cs.style |= WS_TABSTOP|LVS_REPORT|LVS_SINGLESEL|LVS_NOSORTHEADER|LVS_OWNERDRAWFIXED;

	return CListCtrl::PreCreateWindow( cs);
}

void NameSpecTbl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) 
{
	LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
	// TODO: Add your control notification handler code here

	LV_ITEM	*plvItem = &pDispInfo->item;

	if (plvItem->pszText != NULL)
	{
		SetItemText(plvItem->iItem, plvItem->iSubItem, plvItem->pszText);
	}

	*pResult = TRUE;
}





// HitTestEx	- Determine the row index and column index for a point
// Returns	- the row index or -1 if point is not over a row
// point	- point to be tested.
// col		- to hold the column index
int NameSpecTbl::HitTestEx(CPoint &point, int *col) const
{
	int colnum = 0;
	int row = HitTest( point, NULL );
	
	if( col ) *col = 0;

	// Make sure that the ListView is in LVS_REPORT
	if( (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT )
		return row;

	// Get the top and bottom row visible
	row = GetTopIndex();
	int bottom = row + GetCountPerPage();
	if( bottom > GetItemCount() )
		bottom = GetItemCount();
	
	// Get the number of columns
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();

	// Loop through the visible rows
	for( ;row <=bottom;row++)
	{
		// Get bounding rect of item and check whether point falls in it.
		CRect rect;
		GetItemRect( row, &rect, LVIR_BOUNDS );
		if( rect.PtInRect(point) )
		{
			// Now find the column
			for( colnum = 0; colnum < nColumnCount; colnum++ )
			{
				int colwidth = GetColumnWidth(colnum);
				if( point.x >= rect.left 
					&& point.x <= (rect.left + colwidth ) )
				{
					if( col ) *col = colnum;
					return row;
				}
				rect.left += colwidth;
			}
		}
	}
	return -1;
}


// ShowInPlaceList		- Creates an in-place drop down list for any 
//				- cell in the list view control
// Returns			- A temporary pointer to the combo-box control
// nItem			- The row index of the cell
// nCol				- The column index of the cell
// lstItems			- A list of strings to populate the control with
// nSel				- Index of the initial selection in the drop down list
CComboBox* NameSpecTbl::ShowInPlaceList( int nItem, int nCol, 
					CStringList &lstItems, int nSel )
{
	// The returned pointer should not be saved

	// Make sure that the item is visible
	if( !EnsureVisible( nItem, TRUE ) ) return NULL;

	// Make sure that nCol is valid 
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();
	if( nCol >= nColumnCount || GetColumnWidth(nCol) < 10 ) 
		return NULL;

	// Get the column offset
	int offset = 0;
	for( int i = 0; i < nCol; i++ )
		offset += GetColumnWidth( i );

	CRect rect;
	GetItemRect( nItem, &rect, LVIR_BOUNDS );

	// Now scroll if we need to expose the column
	CRect rcClient;
	GetClientRect( &rcClient );
	if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
	{
		CSize size;
		size.cx = offset + rect.left;
		size.cy = 0;
		Scroll( size );
		rect.left -= size.cx;
	}

	rect.left += offset+ 1*OFFSET_FIRST;
	rect.right = rect.left + GetColumnWidth( nCol );
	int height = rect.bottom-rect.top;
	rect.bottom += (lstItems.GetCount()+1)*height;
	if( rect.right > rcClient.right) rect.right = rcClient.right;

	DWORD dwStyle = WS_BORDER|WS_CHILD|WS_VISIBLE
					|CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL;
	if( rect.bottom > rcClient.bottom + 4*height) // by zolmol
	{
		rect.bottom = rcClient.bottom + 4*height;//close to the page's bottom
		dwStyle |= WS_VSCROLL; // enable scrollbar
	} // end zolmol

	CComboBox *pList = new CInPlaceList(nItem, nCol, &lstItems, nSel);
	pList->Create( dwStyle, rect, this, IDC_IPEDIT );
	pList->SetItemHeight( -1, height-1);
	pList->SetHorizontalExtent( GetColumnWidth( nCol ));
	pList->ShowDropDown();

	
	return pList;
}



// EditSubLabel		- Start edit of a sub item label
// Returns		- Temporary pointer to the new edit control
// nItem		- The row index of the item to edit
// nCol			- The column of the sub item.
CEdit* NameSpecTbl::EditSubLabel( int nItem, int nCol )
{
	// The returned pointer should not be saved

	// Make sure that the item is visible
	if( !EnsureVisible( nItem, TRUE ) ) return NULL;

	// Make sure that nCol is valid
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();
	if( nCol >= nColumnCount || GetColumnWidth(nCol) < 5 )
		return NULL;

	// Get the column offset
	int offset = 0;
	for( int i = 0; i < nCol; i++ )
		offset += GetColumnWidth( i );

	CRect rect;
	GetItemRect( nItem, &rect, LVIR_BOUNDS );

	// Now scroll if we need to expose the column
	CRect rcClient;
	GetClientRect( &rcClient );
	if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
	{
		CSize size;
		size.cx = offset + rect.left;
		size.cy = 0;
		Scroll( size );
		rect.left -= size.cx;
	}

	// Get Column alignment
	LV_COLUMN lvcol;
	lvcol.mask = LVCF_FMT;
	GetColumn( nCol, &lvcol );
	DWORD dwStyle ;
	if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT)
		dwStyle = ES_LEFT;
	else if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT)
		dwStyle = ES_RIGHT;
	else dwStyle = ES_CENTER;

	rect.left += offset+4;
	rect.right = rect.left + GetColumnWidth( nCol ) - 3 ;
	if( rect.right > rcClient.right) rect.right = rcClient.right;

	dwStyle |= WS_BORDER|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
	CEdit *pEdit = new CInPlaceEdit(nItem, nCol, GetItemText( nItem, nCol ));
	pEdit->Create( dwStyle, rect, this, IDC_IPEDIT );


	return pEdit;
}

void NameSpecTbl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	if( GetFocus() != this ) SetFocus();
	CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
}



void NameSpecTbl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	if( GetFocus() != this ) SetFocus();	
	CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
}


void NameSpecTbl::OnLButtonDown(UINT nFlags, CPoint point) 
{
	int index;
	CListCtrl::OnLButtonDown(nFlags, point);

	int colnum;
	if( ( index = HitTestEx( point, &colnum )) != -1 )
	{
		UINT flag = LVIS_FOCUSED;
		if( (GetItemState( index, flag ) & flag) == flag )
		{
			// Add check for LVS_EDITLABELS
			/*if( GetWindowLong(m_hWnd, GWL_STYLE) & LVS_EDITLABELS )*/
			if(colnum==0)
			{
				char buff[128];
				LVITEM item;
				item.mask = LVIF_TEXT;
				item.iItem = index;
				item.iSubItem = 0;
				item.pszText = buff;
				item.cchTextMax = 127;
				if (GetItem(&item) && CString(item.pszText) != "N/A") {
					CStringList lstItems;
					int rowID = GetItemData( index);
					dlg->GetNames( rowID, CString(item.pszText), lstItems);
					ShowInPlaceList( index, colnum, lstItems, 0 );
				}
			}
			else if(colnum==1)
			{
				char buff[128];
				LVITEM item;
				item.mask = LVIF_TEXT;
				item.iItem = index;
				item.iSubItem = 1;
				item.pszText = buff;
				item.cchTextMax = 127;
				if (GetItem(&item) && CString(item.pszText) != "N/A") {
					CStringList lstItems;
					int rowID = GetItemData( index);
					dlg->GetDispNames( rowID, CString(item.pszText), lstItems);
					ShowInPlaceList( index, colnum, lstItems, 0 );
				}
			}
		}
		else
			SetItemState( index, LVIS_SELECTED | LVIS_FOCUSED , 
					LVIS_SELECTED | LVIS_FOCUSED);
	}
}



void NameSpecTbl::AddRow(int rowID, CString& name, CString& disp_name, CString& kind)
{
	LV_ITEM lvItem;
	lvItem.mask = LVIF_TEXT;
	lvItem.iItem = GetItemCount();
	lvItem.iSubItem = 0;
	lvItem.pszText = name.GetBuffer( name.GetLength());
	int index = InsertItem(&lvItem);
	
	lvItem.iSubItem = 1;
	lvItem.pszText = disp_name.GetBuffer( disp_name.GetLength());
	SetItem(&lvItem);

	lvItem.iSubItem = 2;
	lvItem.pszText = kind.GetBuffer( kind.GetLength());
	SetItem(&lvItem);

	SetItemData(index, rowID);
}

int NameSpecTbl::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CListCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;

	int col1size = 3*GetStringWidth("TipicalLongTipicalLongName")/2;
	int col2size = 3*GetStringWidth("KindName")/2;

	InsertColumn(0, _T("Name"), LVCFMT_LEFT,  col1size, -1);
	InsertColumn(1, _T("Displayed Name"), LVCFMT_LEFT,  col1size, -1);
	InsertColumn(2, _T("Kind"), LVCFMT_LEFT, col2size, -1);

	return 0;
}

bool NameSpecTbl::GetRow(int rowID, CString& name, CString& disp_name, CString& kind)
{
	LVFINDINFO lvFind;
	lvFind.flags = LVFI_PARAM;
	lvFind.lParam = rowID;
	int idx = FindItem(&lvFind);

	if (idx == -1)
		return false;


	LV_ITEM lvItem;
	lvItem.mask = LVIF_TEXT;
	lvItem.iItem = idx;
	lvItem.pszText = name.GetBuffer(255);
	lvItem.cchTextMax = 254;
	lvItem.iSubItem = 0;
	GetItem(&lvItem);
	
	
	lvItem.iSubItem = 1;
	lvItem.pszText = disp_name.GetBuffer(255);
	lvItem.cchTextMax = 254;
	GetItem(&lvItem);

	lvItem.iSubItem = 2;
	lvItem.pszText = kind.GetBuffer(255);
	lvItem.cchTextMax = 254;
	GetItem(&lvItem);

	return true;
}

void NameSpecTbl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect rcItem(lpDrawItemStruct->rcItem);
	int nItem = lpDrawItemStruct->itemID;
	BOOL bFocus = (GetFocus() == this);
	COLORREF clrTextSave, clrBkSave;
	static _TCHAR szBuff[MAX_PATH];
	LPCTSTR pszText;

// get item data

	LV_ITEM lvi;
	lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
	lvi.iItem = nItem;
	lvi.iSubItem = 0;
	lvi.pszText = szBuff;
	lvi.cchTextMax = sizeof(szBuff);
	lvi.stateMask = 0xFFFF;     // get all state flags
	GetItem(&lvi);

	BOOL bSelected = (bFocus || (GetStyle() & LVS_SHOWSELALWAYS)) && lvi.state & LVIS_SELECTED;
	bSelected = bSelected || (lvi.state & LVIS_DROPHILITED);

// set colors if item is selected

	CRect rcAllLabels;
	GetItemRect(nItem, rcAllLabels, LVIR_BOUNDS);

	CRect rcLabel;
	GetItemRect(nItem, rcLabel, LVIR_LABEL);

	rcAllLabels.left = rcLabel.left;

	if (bSelected)
	{
		// the return value is the previous color, so save it
		clrTextSave = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
		clrBkSave = pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));

		pDC->FillRect(rcAllLabels, &CBrush( ::GetSysColor(COLOR_HIGHLIGHT)));
	}
	else
		pDC->FillRect(rcAllLabels, &CBrush( ::GetSysColor(COLOR_WINDOW)));

// draw item label

	GetItemRect(nItem, rcItem, LVIR_LABEL);

	pszText = MakeShortString(pDC, szBuff, rcItem.right-rcItem.left, 2*OFFSET_FIRST);

	rcLabel = rcItem;
	rcLabel.left += OFFSET_FIRST;
	rcLabel.right -= OFFSET_FIRST;

	pDC->DrawText(pszText,-1,rcLabel,DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);

	// draw scroll down button MZ
	CRect rc = rcItem;

	rc.left = rc.right - ::GetSystemMetrics(SM_CXHSCROLL);
	//rc.top = rc.bottom - ::GetSystemMetrics(SM_CYVSCROLL);
	//rc.DeflateRect(1,1);


	if( rc.left > OFFSET_FIRST + 1)
		pDC->DrawFrameControl(rc, DFC_SCROLL, DFCS_SCROLLDOWN);

// draw labels for extra columns

	LV_COLUMN lvc;
	lvc.mask = LVCF_FMT | LVCF_WIDTH;

	for(int nColumn = 1; GetColumn(nColumn, &lvc); nColumn++)
	{
		rcItem.left = rcItem.right;
		rcItem.right += lvc.cx;

		int nRetLen = GetItemText(nItem, nColumn,
						szBuff, sizeof(szBuff));
		if (nColumn != 1 && nRetLen == 0) // in case of the first column we will draw the DFCS_SCROLLDOWN symbol
			continue;

		pszText = MakeShortString(pDC, szBuff,
			rcItem.right - rcItem.left, 2*OFFSET_OTHER);

		UINT nJustify = DT_LEFT;

		if(pszText == szBuff)
		{
			switch(lvc.fmt & LVCFMT_JUSTIFYMASK)
			{
			case LVCFMT_RIGHT:
				nJustify = DT_RIGHT;
				break;
			case LVCFMT_CENTER:
				nJustify = DT_CENTER;
				break;
			default:
				break;
			}
		}

		rcLabel = rcItem;
		rcLabel.left += OFFSET_OTHER;
		//rcLabel.right -= OFFSET_OTHER;

		pDC->DrawText(pszText, -1, rcLabel,
			nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);

		
		CRect r2 = rcLabel;
		r2.left = r2.right - ::GetSystemMetrics(SM_CXHSCROLL);
		if( nColumn == 1 && r2.left > OFFSET_FIRST + 1)
			pDC->DrawFrameControl(r2, DFC_SCROLL, DFCS_SCROLLDOWN);
	}

// draw focus rectangle if item has focus

	if (lvi.state & LVIS_FOCUSED && bFocus) pDC->DrawFocusRect(rcAllLabels);

	
// set original colors if item was selected

	if (bSelected)
	{
		pDC->SetTextColor(clrTextSave);
		pDC->SetBkColor(clrBkSave);
	}
}

LPCTSTR NameSpecTbl::MakeShortString(CDC* pDC, LPCTSTR lpszLong, int nColumnLen, int nOffset)
{
	static const _TCHAR szEmpty[] = _T("");
	static const _TCHAR szThreeDots[] = _T("...");

	int nStringLen = lstrlen(lpszLong);

	if(nStringLen == 0 ||
		(pDC->GetTextExtent(lpszLong, nStringLen).cx + nOffset) <= nColumnLen)
	{
		return(lpszLong);
	}

	static _TCHAR szShort[MAX_PATH];

	lstrcpy(szShort,lpszLong);
	int nAddLen = pDC->GetTextExtent(szThreeDots,sizeof(szThreeDots)).cx;

	if( nOffset + nAddLen > nColumnLen) return szEmpty;


	for(int i = nStringLen-1; i > 0; i--)
	{
		szShort[i] = 0;
		if((pDC->GetTextExtent(szShort, i).cx + nOffset + nAddLen)
			<= nColumnLen)
		{
			break;
		}
	}

	lstrcat(szShort, szThreeDots);
	return(szShort);
}

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

#include "stdafx.h"
#include "inplaceedit.h"
#include "inplacelist.h"
#include "aspectspectbl.h"
#include "aspectspecdlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAspectSpecTbl

CAspectSpecTbl::CAspectSpecTbl()
{
}

CAspectSpecTbl::~CAspectSpecTbl()
{
}


BEGIN_MESSAGE_MAP(CAspectSpecTbl, CListCtrl)
	//{{AFX_MSG_MAP(CAspectSpecTbl)
	ON_NOTIFY_REFLECT(LVN_ENDLABELEDIT, OnEndlabeledit)
	ON_WM_HSCROLL()
	ON_WM_VSCROLL()
	ON_WM_LBUTTONDOWN()
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAspectSpecTbl message handlers

void CAspectSpecTbl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) 
{
	LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
	// TODO: Add your control notification handler code here

	LV_ITEM	*plvItem = &pDispInfo->item;

	if (plvItem->pszText != NULL)
	{
		SetItemText(plvItem->iItem, plvItem->iSubItem, plvItem->pszText);
	}

	*pResult = TRUE;
}





// HitTestEx	- Determine the row index and column index for a point
// Returns	- the row index or -1 if point is not over a row
// point	- point to be tested.
// col		- to hold the column index
int CAspectSpecTbl::HitTestEx(CPoint &point, int *col) const
{
	int colnum = 0;
	int row = HitTest( point, NULL );
	
	if( col ) *col = 0;

	// Make sure that the ListView is in LVS_REPORT
	if( (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT )
		return row;

	// Get the top and bottom row visible
	row = GetTopIndex();
	int bottom = row + GetCountPerPage();
	if( bottom > GetItemCount() )
		bottom = GetItemCount();
	
	// Get the number of columns
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();

	// Loop through the visible rows
	for( ;row <=bottom;row++)
	{
		// Get bounding rect of item and check whether point falls in it.
		CRect rect;
		GetItemRect( row, &rect, LVIR_BOUNDS );
		if( rect.PtInRect(point) )
		{
			// Now find the column
			for( colnum = 0; colnum < nColumnCount; colnum++ )
			{
				int colwidth = GetColumnWidth(colnum);
				if( point.x >= rect.left 
					&& point.x <= (rect.left + colwidth ) )
				{
					if( col ) *col = colnum;
					return row;
				}
				rect.left += colwidth;
			}
		}
	}
	return -1;
}


// ShowInPlaceList		- Creates an in-place drop down list for any 
//				- cell in the list view control
// Returns			- A temporary pointer to the combo-box control
// nItem			- The row index of the cell
// nCol				- The column index of the cell
// lstItems			- A list of strings to populate the control with
// nSel				- Index of the initial selection in the drop down list
CComboBox* CAspectSpecTbl::ShowInPlaceList( int nItem, int nCol, 
					CStringList &lstItems, int nSel )
{
	// The returned pointer should not be saved

	// Make sure that the item is visible
	if( !EnsureVisible( nItem, TRUE ) ) return NULL;

	// Make sure that nCol is valid 
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();
	if( nCol >= nColumnCount || GetColumnWidth(nCol) < 10 ) 
		return NULL;

	// Get the column offset
	int offset = 0;
	for( int i = 0; i < nCol; i++ )
		offset += GetColumnWidth( i );

	CRect rect;
	GetItemRect( nItem, &rect, LVIR_BOUNDS );

	// Now scroll if we need to expose the column
	CRect rcClient;
	GetClientRect( &rcClient );
	if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
	{
		CSize size;
		size.cx = offset + rect.left;
		size.cy = 0;
		Scroll( size );
		rect.left -= size.cx;
	}

	rect.left += offset+4;
	rect.right = rect.left + GetColumnWidth( nCol ) - 3 ;
	int height = rect.bottom-rect.top;
	rect.bottom += (lstItems.GetCount()+1)*height;
	if( rect.right > rcClient.right) rect.right = rcClient.right;

	DWORD dwStyle = WS_BORDER|WS_CHILD|WS_VISIBLE
					|CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL;
	if( rect.bottom > rcClient.bottom + 4*height) // by zolmol
	{
		rect.bottom = rcClient.bottom + 4*height;//close to the propertypage's bottom
		dwStyle |= WS_VSCROLL; // enable scrollbar
	} // end zolmol

	CComboBox *pList = new CInPlaceList(nItem, nCol, &lstItems, nSel);
	pList->Create( dwStyle, rect, this, IDC_IPEDIT );
	pList->SetItemHeight( -1, height);
	pList->SetHorizontalExtent( GetColumnWidth( nCol ));

	
	return pList;
}



// EditSubLabel		- Start edit of a sub item label
// Returns		- Temporary pointer to the new edit control
// nItem		- The row index of the item to edit
// nCol			- The column of the sub item.
CEdit* CAspectSpecTbl::EditSubLabel( int nItem, int nCol )
{
	// The returned pointer should not be saved

	// Make sure that the item is visible
	if( !EnsureVisible( nItem, TRUE ) ) return NULL;

	// Make sure that nCol is valid
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();
	if( nCol >= nColumnCount || GetColumnWidth(nCol) < 5 )
		return NULL;

	// Get the column offset
	int offset = 0;
	for( int i = 0; i < nCol; i++ )
		offset += GetColumnWidth( i );

	CRect rect;
	GetItemRect( nItem, &rect, LVIR_BOUNDS );

	// Now scroll if we need to expose the column
	CRect rcClient;
	GetClientRect( &rcClient );
	if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
	{
		CSize size;
		size.cx = offset + rect.left;
		size.cy = 0;
		Scroll( size );
		rect.left -= size.cx;
	}

	// Get Column alignment
	LV_COLUMN lvcol;
	lvcol.mask = LVCF_FMT;
	GetColumn( nCol, &lvcol );
	DWORD dwStyle ;
	if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT)
		dwStyle = ES_LEFT;
	else if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT)
		dwStyle = ES_RIGHT;
	else dwStyle = ES_CENTER;

	rect.left += offset+4;
	rect.right = rect.left + GetColumnWidth( nCol ) - 3 ;
	if( rect.right > rcClient.right) rect.right = rcClient.right;

	dwStyle |= WS_BORDER|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
	CEdit *pEdit = new CInPlaceEdit(nItem, nCol, GetItemText( nItem, nCol ));
	pEdit->Create( dwStyle, rect, this, IDC_IPEDIT );


	return pEdit;
}

void CAspectSpecTbl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	if( GetFocus() != this ) SetFocus();
	CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
}



void CAspectSpecTbl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	if( GetFocus() != this ) SetFocus();	
	CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
}


/*
void CAspectSpecTbl::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	CListCtrl::OnLButtonDown(nFlags, point);

	int index;
	int colnum;
	if( ( index = HitTestEx( point, &colnum )) != -1 )
	{
		UINT flag = LVIS_FOCUSED;
		if( (GetItemState( index, flag ) & flag) == flag && colnum > 0)
		{
			// Add check for LVS_EDITLABELS
			if( GetWindowLong(m_hWnd, GWL_STYLE) & LVS_EDITLABELS )
				EditSubLabel( index, colnum );
		}
		else
			SetItemState( index, LVIS_SELECTED | LVIS_FOCUSED ,
				    	LVIS_SELECTED | LVIS_FOCUSED); 
	}

}
*/
void CAspectSpecTbl::OnLButtonDown(UINT nFlags, CPoint point) 
{
	int index;
	CListCtrl::OnLButtonDown(nFlags, point);

	int colnum;
	if( ( index = HitTestEx( point, &colnum )) != -1 )
	{
		UINT flag = LVIS_FOCUSED;
		if( (GetItemState( index, flag ) & flag) == flag )
		{
			// Add check for LVS_EDITLABELS
			/*if( GetWindowLong(m_hWnd, GWL_STYLE) & LVS_EDITLABELS )*/
			if(colnum==1)
			{
				char buff[64];
				LVITEM item;
				item.mask = LVIF_TEXT;
				item.iItem = index;
				item.iSubItem = 1;
				item.pszText = buff;
				item.cchTextMax = 63;
				if (GetItem(&item) && CString(item.pszText) != "N/A") {
					CStringList lstItems;
					int rowID = GetItemData( index);
					//theAspectDlg->GetAspects(lstItems);
					theAspectDlg->GetAspects( rowID, lstItems);
					ShowInPlaceList( index, colnum, lstItems, 0 );
				}
			}
			if(colnum==2)
			{
				char buff[64];
				LVITEM item;
				item.mask = LVIF_TEXT;
				item.iItem = index;
				item.iSubItem = 2;
				item.pszText = buff;
				item.cchTextMax = 63;
				if (GetItem(&item) && CString(item.pszText) != "N/A") {
					CStringList lstItems;
					lstItems.AddTail("yes");
					lstItems.AddTail("no");
					ShowInPlaceList( index, colnum, lstItems, 0 );
				}
			}

		}
		else
			SetItemState( index, LVIS_SELECTED | LVIS_FOCUSED , 
					LVIS_SELECTED | LVIS_FOCUSED);
	}
}



void CAspectSpecTbl::AddRow(int rowID, CString& role, CString& kindAspect, CString& isPrimary)
{
	LV_ITEM lvItem;
	lvItem.mask = LVIF_TEXT;
	lvItem.iItem = GetItemCount();
	lvItem.iSubItem = 0;
	lvItem.pszText = role.GetBuffer(role.GetLength());
	int index = InsertItem(&lvItem);
	

	lvItem.iSubItem = 1;
	lvItem.pszText = kindAspect.GetBuffer( kindAspect.GetLength()); // modif role.getl
	SetItem(&lvItem);

	lvItem.iSubItem = 2;
	lvItem.pszText = isPrimary.GetBuffer( isPrimary.GetLength());// ? _T("yes"): _T("no");
	// lvItem.stateMask = LVIS_STATEIMAGEMASK;
	// lvItem.state = INDEXTOSTATEIMAGEMASK(isPrimary ? 0 : 1);
	// lvItem.iImage = isPrimary ? 0 : 1;

	SetItem(&lvItem);

	SetItemData(index, rowID);
	
}

int CAspectSpecTbl::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CListCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;

	// m_checkImages.Create(::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), ILC_COLOR4 | ILC_MASK, 2, 1);
	// CWinApp *pApp = AfxGetApp();
	// HICON hIcon = pApp->LoadIcon(IDI_ICON_UNCHECKED);
	// if (hIcon) {
	//	m_checkImages.Add(hIcon);
	//	::DeleteObject(hIcon);
	// }

	// hIcon = pApp->LoadIcon(IDI_ICON_CHECKED);
	// if (hIcon) {
	// 	m_checkImages.Add(hIcon);
	//	::DeleteObject(hIcon);
	// }

	// SetImageList(&m_checkImages, LVSIL_NORMAL);
	
	// ListView_SetExtendedListViewStyle (m_hWnd, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);

	// TODO: Add your specialized creation code here
	int col1size = 3*GetStringWidth("TipicalContainerN::LongRoleName")/2;
	int col2size = 3*GetStringWidth("LongAspectName")/2;
	int col3size = 3*GetStringWidth("Primary")/2;

	InsertColumn(0, _T("Role"), LVCFMT_LEFT,  col1size, -1);
	InsertColumn(1, _T("KindAspect"), LVCFMT_LEFT, col2size, -1);
	InsertColumn(2, _T("Primary"), LVCFMT_LEFT, col3size, -1);

	return 0;
}

bool CAspectSpecTbl::GetRow(int rowID, CString &role, CString &kindAspect, CString& isPrimary)
{

	LVFINDINFO lvFind;
	lvFind.flags = LVFI_PARAM;
	lvFind.lParam = rowID;
	int idx = FindItem(&lvFind);

	if (idx == -1)
		return false;


	LV_ITEM lvItem;
	lvItem.mask = LVIF_TEXT;
	lvItem.iItem = idx;
	lvItem.pszText = role.GetBuffer(255);
	lvItem.cchTextMax = 254;
	lvItem.iSubItem = 0;
	GetItem(&lvItem);
	
	

	lvItem.iSubItem = 1;
	lvItem.pszText = kindAspect.GetBuffer(255);
	lvItem.cchTextMax = 254;
	GetItem(&lvItem);


	//CString tmpStr;
	lvItem.pszText = isPrimary.GetBuffer(10); //tmpStr
	lvItem.cchTextMax = 9;
	lvItem.iSubItem = 2;
	GetItem(&lvItem);
	//isPrimary = (tmpStr == "yes");
	
	return true;
}


--- NEW FILE: GlobalAspOrder.h ---
#if !defined(AFX_GLOBALASPORDER_H__08D873D5_01E0_43ED_82A6_DA11600879BE__INCLUDED_)
#define AFX_GLOBALASPORDER_H__08D873D5_01E0_43ED_82A6_DA11600879BE__INCLUDED_

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

// GlobalAspOrder.h : header file
//

#include "resource.h"
#include <afxcmn.h>
#include <afxext.h>
#include "AspectRep.h"
#include "vector"


/////////////////////////////////////////////////////////////////////////////
// GlobalAspOrder dialog

class GlobalAspOrder : public CDialog
{
// Construction
public:
	GlobalAspOrder(CWnd* pParent = NULL);   // standard constructor
	void addAspects( const std::vector< AspectRep *>& oo);
	std::vector< AspectRep *> m_resultAspects;

// Dialog Data
	//{{AFX_DATA(GlobalAspOrder)
	enum { IDD = IDD_ASPECTORDER_DLG };
	CButton	m_down;
	CButton	m_up;
	CListBox	m_list;
	//}}AFX_DATA


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

// Implementation
protected:
	std::vector< AspectRep *> m_aspects;

	// Generated message map functions
	//{{AFX_MSG(GlobalAspOrder)
	afx_msg void OnMoveUp();
	afx_msg void OnMoveDown();
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

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

#endif // !defined(AFX_GLOBALASPORDER_H__08D873D5_01E0_43ED_82A6_DA11600879BE__INCLUDED_)

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

#include "stdafx.h"
#include "inplacelist.h"


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

/////////////////////////////////////////////////////////////////////////////
// CInPlaceList

CInPlaceList::CInPlaceList(int iItem, int iSubItem, CStringList *plstItems, int nSel)
{
	m_iItem = iItem;
	m_iSubItem = iSubItem;

	m_lstItems.AddTail( plstItems );
	m_nSel = nSel;
	m_bESC = FALSE;
}

CInPlaceList::~CInPlaceList()
{
}


BEGIN_MESSAGE_MAP(CInPlaceList, CComboBox)
	//{{AFX_MSG_MAP(CInPlaceList)
	ON_WM_CREATE()
	ON_WM_KILLFOCUS()
	ON_WM_CHAR()
	ON_WM_NCDESTROY()
	ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInPlaceList message handlers

int CInPlaceList::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CComboBox::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// Set the proper font
	CFont* font = GetParent()->GetFont();
	SetFont(font);

	for( POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL; )
	{
		AddString( (LPCTSTR) (m_lstItems.GetNext( pos )) );
	}
	SetCurSel( m_nSel );
	SetFocus();
	return 0;
}

BOOL CInPlaceList::PreTranslateMessage(MSG* pMsg) 
{
	if( pMsg->message == WM_KEYDOWN )
	{
		if(pMsg->wParam == VK_RETURN 
				|| pMsg->wParam == VK_ESCAPE
				)
		{
			::TranslateMessage(pMsg);
			::DispatchMessage(pMsg);
			return TRUE;				// DO NOT process further
		}
	}
	
	return CComboBox::PreTranslateMessage(pMsg);
}

void CInPlaceList::OnKillFocus(CWnd* pNewWnd) 
{
	CComboBox::OnKillFocus(pNewWnd);
	
	CString str;
	GetWindowText(str);

	// Send Notification to parent of ListView ctrl
	LV_DISPINFO dispinfo;
	dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
	dispinfo.hdr.idFrom = GetDlgCtrlID();
	dispinfo.hdr.code = LVN_ENDLABELEDIT;

	dispinfo.item.mask = LVIF_TEXT;
	dispinfo.item.iItem = m_iItem;
	dispinfo.item.iSubItem = m_iSubItem;
	dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
	dispinfo.item.cchTextMax = str.GetLength();

	GetParent()->GetParent()->SendMessage( WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo );

	PostMessage( WM_CLOSE );
}

void CInPlaceList::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	if( nChar == VK_ESCAPE || nChar == VK_RETURN)
	{
		if( nChar == VK_ESCAPE )
			m_bESC = TRUE;
		GetParent()->SetFocus();
		return;
	}
	
	CComboBox::OnChar(nChar, nRepCnt, nFlags);
}

void CInPlaceList::OnNcDestroy() 
{
	CComboBox::OnNcDestroy();
	
	delete this;
}

void CInPlaceList::OnCloseup() 
{
	GetParent()->SetFocus();
}

--- NEW FILE: InPlaceList.h ---
// InPlaceList.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CInPlaceList window

class CInPlaceList : public CComboBox
{
// Construction
public:
	CInPlaceList(int iItem, int iSubItem, CStringList *plstItems, int nSel);

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CInPlaceList)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CInPlaceList();

	// Generated message map functions
protected:
	//{{AFX_MSG(CInPlaceList)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnNcDestroy();
	afx_msg void OnCloseup();
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
private:
	int 	m_iItem;
	int 	m_iSubItem;
	CStringList m_lstItems;
	int 	m_nSel;
	BOOL	m_bESC;				// To indicate whether ESC key was pressed
};

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

--- NEW FILE: AspectPage.h ---
#if !defined(AFX_ASPECTPAGE_H__CD948654_3126_480E_B332_504C347524BF__INCLUDED_)
#define AFX_ASPECTPAGE_H__CD948654_3126_480E_B332_504C347524BF__INCLUDED_

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

#include "resource.h"
#include <AFXDLGS.H>
#include "AspectSpecDlg.h"
#include "AspectSpecTbl.h"

class CAspectSpecTbl;
class CAspectSpecDlg;

typedef struct {
	int	rowID;
	CString roleName;
	CString kindAspect;
	CString isPrimary;
	const void * ptr;
} entry;

typedef CTypedPtrList<CPtrList, entry*> CEntryList;
// AspectPage.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CAspectPage dialog

class CAspectPage : public CPropertyPage
{
	//DECLARE_DYNCREATE(CAspectPage)

// Construction
public:
	void AddEntry(int rowID, CString roleName, CString kindAspect, CString isPrimary, const void * ptr);
	bool GetEntry(int rowID, CString &roleName, CString& kindAspect, CString& isPrimary, const void * &ptr);
	void SetAspectName(CString name);
	CString GetAspectName();
	CAspectPage() ;
	~CAspectPage();
	static int m_actHeight; // the height of the user area (since stacking tabs may occupy a huge amount of place)
	static int m_actWidth;	// do not forget to reset to 0 upon destruction
	const int m_deflateVal;
	void resizeTableToFitIn();
	void calcPlace( CRect& loc);

// Dialog Data
	//{{AFX_DATA(CAspectPage)
	enum { IDD = IDD_ASPECT_PAGE };
	//}}AFX_DATA


// Overrides
	// ClassWizard generate virtual function overrides
	//{{AFX_VIRTUAL(CAspectPage)
	public:
	virtual void OnOK();
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	CEntryList entries;
	CAspectSpecTbl aspectTable;
	CString	aspectName;

	afx_msg void OnSize( UINT, int, int );
	// Generated message map functions
	//{{AFX_MSG(CAspectPage)
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

};

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

#endif // !defined(AFX_ASPECTPAGE_H__CD948654_3126_480E_B332_504C347524BF__INCLUDED_)

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

#include "stdafx.h"
#include "GlobalAspOrder.h"
#include "afxdlgs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GlobalAspOrder dialog


GlobalAspOrder::GlobalAspOrder(CWnd* pParent /*=NULL*/)
	: CDialog(GlobalAspOrder::IDD, pParent)
{
	//{{AFX_DATA_INIT(GlobalAspOrder)
	//}}AFX_DATA_INIT
}


void GlobalAspOrder::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(GlobalAspOrder)
	DDX_Control(pDX, IDC_BUTTON2, m_down);
	DDX_Control(pDX, IDC_BUTTON1, m_up);
	DDX_Control(pDX, IDC_LIST3, m_list);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(GlobalAspOrder, CDialog)
	//{{AFX_MSG_MAP(GlobalAspOrder)
	ON_BN_CLICKED(IDC_BUTTON1, OnMoveUp)
	ON_BN_CLICKED(IDC_BUTTON2, OnMoveDown)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GlobalAspOrder message handlers

void GlobalAspOrder::OnMoveUp() 
{
	CString text; 
	int idx = m_list.GetCurSel();
	if (LB_ERR != idx && idx > 0)
	{
		int data = m_list.GetItemData( idx);
		m_list.GetText( idx, text);

		m_list.DeleteString( idx);

		m_list.InsertString( idx - 1, text);
		m_list.SetItemData( idx - 1, data);
		m_list.SetCurSel( idx - 1);
	}
}

void GlobalAspOrder::OnMoveDown() 
{
	CString text; 
	int idx = m_list.GetCurSel();
	if (LB_ERR != idx && idx + 1 < m_list.GetCount())
	{
		int data = m_list.GetItemData( idx);
		m_list.GetText( idx, text);

		m_list.DeleteString( idx);

		m_list.InsertString( idx + 1, text);
		m_list.SetItemData( idx + 1, data);
		m_list.SetCurSel( idx + 1);
	}
}


void GlobalAspOrder::addAspects( const std::vector< AspectRep *>& oo)
{
	m_aspects = oo;
}


/*
Presumes that the addAspects has been called!
*/
BOOL GlobalAspOrder::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_down.SetIcon( ::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICONDN)));
	m_up.SetIcon( ::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICONUP)));
	
	std::vector< AspectRep *>::const_iterator i;
	unsigned int k;

	for( k = 0, i = m_aspects.begin(); i != m_aspects.end(); ++i, ++k)
	{
		CString asp_name = (*i)->getName().c_str();
		m_list.AddString( asp_name);
		m_list.SetItemData( k, k);
	}	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void GlobalAspOrder::OnOK() 
{
	//std::string mmm;

	int howmany = m_list.GetCount();

	for( int k = 0; k < howmany; ++k)
	{
		unsigned int data = m_list.GetItemData( k);
		if ( data < m_aspects.size())
		{
			m_resultAspects.push_back( m_aspects[data]);
			//mmm += m_aspects[data]->getName() + "\n";
		}
	}
	ASSERT( howmany == m_aspects.size()); // if we've lost aspects

	//AfxMessageBox( mmm.c_str());
	CDialog::OnOK();
}




More information about the GME-commit mailing list