GME
13
|
00001 // AspectSyncDlg.cpp : implementation file 00002 // 00003 00004 #include "stdafx.h" 00005 #include "GMEApp.h" 00006 #include "AspectSyncDlg.h" 00007 00008 #include "GMEview.h" 00009 00010 #include "guiobject.h" 00011 #include "guimeta.h" 00012 00013 #ifdef _DEBUG 00014 #define new DEBUG_NEW 00015 #undef THIS_FILE 00016 static char THIS_FILE[] = __FILE__; 00017 #endif 00018 00020 // CAspectSyncDlg dialog 00021 00022 00023 CAspectSyncDlg::CAspectSyncDlg(CWnd* pParent /*=NULL*/) 00024 : CDialog(CAspectSyncDlg::IDD, pParent) 00025 { 00026 //{{AFX_DATA_INIT(CAspectSyncDlg) 00027 m_priorityForSrcVisible = FALSE; 00028 m_priorityForSelected = FALSE; 00029 //}}AFX_DATA_INIT 00030 } 00031 00032 00033 void CAspectSyncDlg::DoDataExchange(CDataExchange* pDX) 00034 { 00035 CDialog::DoDataExchange(pDX); 00036 //{{AFX_DATA_MAP(CAspectSyncDlg) 00037 DDX_Control(pDX, IDC_DSTASPECT_LIST, m_dstAspectList); 00038 DDX_Control(pDX, IDC_SELOBJS_LIST, m_syncObjsList); 00039 DDX_Control(pDX, IDC_SRCASPECT_COMBO, m_srcAspectCombo); 00040 DDX_Check(pDX, IDC_PRIORITY_CHECK, m_priorityForSrcVisible); 00041 DDX_Check(pDX, IDC_PRIORITY_CHECK2, m_priorityForSelected); 00042 //}}AFX_DATA_MAP 00043 } 00044 00045 00046 BEGIN_MESSAGE_MAP(CAspectSyncDlg, CDialog) 00047 //{{AFX_MSG_MAP(CAspectSyncDlg) 00048 //}}AFX_MSG_MAP 00049 END_MESSAGE_MAP() 00050 00052 // CAspectSyncDlg message handlers 00053 00054 BOOL CAspectSyncDlg::OnInitDialog() 00055 { 00056 CDialog::OnInitDialog(); 00057 00058 // ATTENTION ! Requires IE4 00059 m_syncObjsList.SetExtendedStyle(m_syncObjsList.GetExtendedStyle() | LVS_EX_FULLROWSELECT); 00060 m_dstAspectList.SetExtendedStyle(m_dstAspectList.GetExtendedStyle() | LVS_EX_FULLROWSELECT); 00061 00062 CRect rect; 00063 m_dstAspectList.GetClientRect(&rect); 00064 m_dstAspectList.InsertColumn(0, _T("Aspect"), LVCFMT_LEFT, rect.Width()); 00065 00066 m_syncObjsList.GetClientRect(&rect); 00067 m_syncObjsList.InsertColumn(0, _T("Name"), LVCFMT_LEFT, rect.Width()/2); 00068 m_syncObjsList.InsertColumn(1, _T("Kind"), LVCFMT_LEFT, rect.Width()/4); 00069 m_syncObjsList.InsertColumn(2, _T("Role"), LVCFMT_LEFT, rect.Width()/4); 00070 00071 00072 int aspectCount = 0; 00073 POSITION apos = m_allAspects.GetHeadPosition(); 00074 while (apos) { 00075 CGuiMetaAspect *metaAspect = m_allAspects.GetNext(apos); 00076 00077 int nItem = m_srcAspectCombo.AddString(metaAspect->name); 00078 m_srcAspectCombo.SetItemData(nItem, (DWORD)metaAspect); 00079 00080 if (m_srcAspect == metaAspect) { 00081 m_srcAspectCombo.SetCurSel(nItem); 00082 } 00083 00084 nItem = m_dstAspectList.InsertItem(aspectCount++, metaAspect->name); 00085 m_dstAspectList.SetItemData(nItem, (DWORD)metaAspect); 00086 if (m_srcAspect != metaAspect) { 00087 m_dstAspectList.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); 00088 } else { 00089 m_dstAspectList.SetItemState(nItem, LVIS_SELECTED, 0); 00090 } 00091 } 00092 00093 int objCount = 0; 00094 POSITION opos = m_allObjects.GetHeadPosition(); 00095 while (opos) { 00096 CGuiObject *obj = m_allObjects.GetNext(opos); 00097 00098 00099 bool isSelected = (m_movingObjects.Find(obj) != NULL); 00100 00101 LVITEM lvItem; 00102 00103 lvItem.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM; 00104 lvItem.iItem = objCount; 00105 lvItem.iSubItem = 0; 00106 lvItem.state = isSelected ? LVIS_SELECTED : 0; 00107 lvItem.stateMask = isSelected ? LVIS_SELECTED : 0; 00108 lvItem.pszText = obj->GetName().GetBuffer(obj->GetName().GetLength()); 00109 lvItem.lParam = (LPARAM)obj; 00110 00111 m_syncObjsList.InsertItem(&lvItem); 00112 00113 lvItem.mask = LVIF_TEXT; 00114 lvItem.iSubItem = 1; 00115 lvItem.pszText = obj->kindName.GetBuffer(obj->kindName.GetLength()); 00116 00117 m_syncObjsList.SetItem(&lvItem); 00118 00119 lvItem.iSubItem = 2; 00120 lvItem.pszText = obj->roleName.GetBuffer(obj->roleName.GetLength()); 00121 00122 m_syncObjsList.SetItem(&lvItem); 00123 } 00124 00125 return TRUE; // return TRUE unless you set the focus to a control 00126 // EXCEPTION: OCX Property Pages should return FALSE 00127 } 00128 00129 00130 BOOL CAspectSyncDlg::PreTranslateMessage(MSG* pMsg) 00131 { 00132 00133 if (pMsg->message==WM_KEYDOWN) { 00134 if (pMsg->wParam=='A' && ::GetKeyState(VK_CONTROL)) { 00135 if (pMsg->hwnd == m_syncObjsList.m_hWnd) { 00136 int item = m_syncObjsList.GetNextItem(-1, LVNI_ALL); 00137 while (item != -1) { 00138 m_syncObjsList.SetItemState(item, LVIS_SELECTED, LVIS_SELECTED); 00139 item = m_syncObjsList.GetNextItem(item, LVNI_ALL); 00140 } 00141 } 00142 00143 if (pMsg->hwnd == m_dstAspectList.m_hWnd) { 00144 int item = m_dstAspectList.GetNextItem(-1, LVNI_ALL); 00145 while (item != -1) { 00146 m_dstAspectList.SetItemState(item, LVIS_SELECTED, LVIS_SELECTED); 00147 item = m_dstAspectList.GetNextItem(item, LVNI_ALL); 00148 } 00149 } 00150 00151 } 00152 } 00153 00154 return CDialog::PreTranslateMessage(pMsg); 00155 } 00156 00157 void CAspectSyncDlg::OnOK() 00158 { 00159 00160 m_dstAspects.RemoveAll(); 00161 m_movingObjects.RemoveAll(); 00162 m_srcAspect = NULL; 00163 00164 int nItem; 00165 POSITION apos = m_dstAspectList.GetFirstSelectedItemPosition(); 00166 while (apos) { 00167 nItem = m_dstAspectList.GetNextSelectedItem(apos); 00168 m_dstAspects.AddTail((CGuiMetaAspect*)m_dstAspectList.GetItemData(nItem)); 00169 } 00170 00171 nItem = m_srcAspectCombo.GetCurSel(); 00172 m_srcAspect = (CGuiMetaAspect*)m_srcAspectCombo.GetItemData(nItem); 00173 00174 int nCount = m_syncObjsList.GetItemCount(); 00175 for (nItem = 0; nItem < nCount; nItem++) { 00176 CGuiObject* obj = (CGuiObject*)m_syncObjsList.GetItemData(nItem); 00177 if (m_syncObjsList.GetItemState(nItem, LVIS_SELECTED) == LVIS_SELECTED) { 00178 m_movingObjects.AddTail(obj); 00179 } 00180 } 00181 00182 CDialog::OnOK(); 00183 }