4 #include "PropertiesWnd.h"
\r
5 #include "Resource.h"
\r
7 #include "TortoiseGitBlame.h"
\r
11 static char THIS_FILE[]=__FILE__;
\r
12 #define new DEBUG_NEW
\r
15 /////////////////////////////////////////////////////////////////////////////
\r
18 CPropertiesWnd::CPropertiesWnd()
\r
22 CPropertiesWnd::~CPropertiesWnd()
\r
26 BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane)
\r
29 ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties)
\r
30 ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties)
\r
31 ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties)
\r
32 ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties)
\r
33 ON_COMMAND(ID_PROPERTIES1, OnProperties1)
\r
34 ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1)
\r
35 ON_COMMAND(ID_PROPERTIES2, OnProperties2)
\r
36 ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2)
\r
38 ON_WM_SETTINGCHANGE()
\r
41 /////////////////////////////////////////////////////////////////////////////
\r
42 // CResourceViewBar message handlers
\r
44 void CPropertiesWnd::AdjustLayout()
\r
46 if (GetSafeHwnd() == NULL)
\r
51 CRect rectClient,rectCombo;
\r
52 GetClientRect(rectClient);
\r
54 m_wndObjectCombo.GetWindowRect(&rectCombo);
\r
56 int cyCmb = rectCombo.Size().cy;
\r
57 int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy;
\r
59 m_wndObjectCombo.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), 200, SWP_NOACTIVATE | SWP_NOZORDER);
\r
60 m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER);
\r
61 m_wndPropList.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb + cyTlb, rectClient.Width(), rectClient.Height() -(cyCmb+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER);
\r
64 int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
66 if (CDockablePane::OnCreate(lpCreateStruct) == -1)
\r
70 rectDummy.SetRectEmpty();
\r
73 const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
\r
75 if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1))
\r
77 TRACE0("Failed to create Properties Combo \n");
\r
78 return -1; // fail to create
\r
81 m_wndObjectCombo.AddString(_T("Application"));
\r
82 m_wndObjectCombo.AddString(_T("Properties Window"));
\r
83 m_wndObjectCombo.SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)));
\r
84 m_wndObjectCombo.SetCurSel(0);
\r
86 if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2))
\r
88 TRACE0("Failed to create Properties Grid \n");
\r
89 return -1; // fail to create
\r
94 m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES);
\r
95 m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* Is locked */);
\r
96 m_wndToolBar.CleanUpLockedImages();
\r
97 m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* Locked */);
\r
99 m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
\r
100 m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
\r
101 m_wndToolBar.SetOwner(this);
\r
103 // All commands will be routed via this control , not via the parent frame:
\r
104 m_wndToolBar.SetRouteCommandsViaFrame(FALSE);
\r
110 void CPropertiesWnd::OnSize(UINT nType, int cx, int cy)
\r
112 CDockablePane::OnSize(nType, cx, cy);
\r
116 void CPropertiesWnd::OnExpandAllProperties()
\r
118 m_wndPropList.ExpandAll();
\r
121 void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* pCmdUI)
\r
125 void CPropertiesWnd::OnSortProperties()
\r
127 m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode());
\r
130 void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI)
\r
132 pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode());
\r
135 void CPropertiesWnd::OnProperties1()
\r
137 // TODO: Add your command handler code here
\r
140 void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/)
\r
142 // TODO: Add your command update UI handler code here
\r
145 void CPropertiesWnd::OnProperties2()
\r
147 // TODO: Add your command handler code here
\r
150 void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/)
\r
152 // TODO: Add your command update UI handler code here
\r
155 void CPropertiesWnd::InitPropList()
\r
159 m_wndPropList.EnableHeaderCtrl(FALSE);
\r
160 m_wndPropList.EnableDescriptionArea();
\r
161 m_wndPropList.SetVSDotNetLook();
\r
162 m_wndPropList.MarkModifiedProperties();
\r
164 CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("Basic Info"));
\r
167 m_CommitHash = new CMFCPropertyGridProperty(
\r
168 _T("Commit Hash"),
\r
172 pGroup1->AddSubItem(m_CommitHash);
\r
174 m_AuthorName = new CMFCPropertyGridProperty(
\r
179 pGroup1->AddSubItem(m_AuthorName);
\r
181 m_AuthorDate = new CMFCPropertyGridProperty(
\r
182 _T("Author Date"),
\r
186 pGroup1->AddSubItem(m_AuthorDate);
\r
188 m_AuthorEmail= new CMFCPropertyGridProperty(
\r
189 _T("Author Email"),
\r
193 pGroup1->AddSubItem(m_AuthorEmail);
\r
195 m_CommitterName = new CMFCPropertyGridProperty(
\r
196 _T("Committer Name"),
\r
198 _T("Committer Name")
\r
200 pGroup1->AddSubItem(m_CommitterName);
\r
202 m_CommitterEmail =new CMFCPropertyGridProperty(
\r
203 _T("Committer Email"),
\r
205 _T("Committer Email")
\r
207 pGroup1->AddSubItem(m_CommitterEmail);
\r
209 m_CommitterDate = new CMFCPropertyGridProperty(
\r
210 _T("Committer Date"),
\r
212 _T("Committer Date")
\r
214 pGroup1->AddSubItem(m_CommitterDate);
\r
216 m_Subject = new CMFCPropertyGridProperty(
\r
221 pGroup1->AddSubItem(m_Subject);
\r
223 m_Body = new CMFCPropertyGridProperty(
\r
228 pGroup1->AddSubItem(m_Body);
\r
230 for(int i=0;i<pGroup1->GetSubItemsCount();i++)
\r
232 pGroup1->GetSubItem(i)->AllowEdit(FALSE);
\r
235 //std::vector<CMFCPropertyGridProperty*> m_ParentHash;
\r
236 //std::vector<CMFCPropertyGridProperty*> m_ParentSubject;
\r
238 m_wndPropList.AddProperty(pGroup1);
\r
239 m_BaseInfoGroup=pGroup1;
\r
241 m_ParentGroup=new CMFCPropertyGridProperty(_T("Parent"));
\r
243 m_wndPropList.AddProperty(m_ParentGroup);
\r
245 pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Caption"), (_variant_t) _T("About"), _T("Specifies the text that will be displayed in the window's title bar")));
\r
249 CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("Window Size"), 0, TRUE);
\r
251 pProp = new CMFCPropertyGridProperty(_T("Height"), (_variant_t) 250l, _T("Specifies the window's height"));
\r
252 pProp->EnableSpinControl(TRUE, 0, 1000);
\r
253 pSize->AddSubItem(pProp);
\r
255 pProp = new CMFCPropertyGridProperty( _T("Width"), (_variant_t) 150l, _T("Specifies the window's width"));
\r
256 pProp->EnableSpinControl();
\r
257 pSize->AddSubItem(pProp);
\r
259 m_wndPropList.AddProperty(pSize);
\r
261 CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("Font"));
\r
264 CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
\r
265 font->GetLogFont(&lf);
\r
267 lstrcpy(lf.lfFaceName, _T("Arial"));
\r
269 pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("Font"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the window")));
\r
270 pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("Use System Font"), (_variant_t) true, _T("Specifies that the window uses MS Shell Dlg font")));
\r
272 m_wndPropList.AddProperty(pGroup2);
\r
274 CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("Misc"));
\r
275 pProp = new CMFCPropertyGridProperty(_T("(Name)"), _T("Application"));
\r
276 pProp->Enable(FALSE);
\r
277 pGroup3->AddSubItem(pProp);
\r
279 CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Window Color"), RGB(210, 192, 254), NULL, _T("Specifies the default window color"));
\r
280 pColorProp->EnableOtherButton(_T("Other..."));
\r
281 pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE));
\r
282 pGroup3->AddSubItem(pColorProp);
\r
284 static TCHAR BASED_CODE szFilter[] = _T("Icon Files(*.ico)|*.ico|All Files(*.*)|*.*||");
\r
285 pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Icon"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("Specifies the window icon")));
\r
287 pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Folder"), _T("c:\\")));
\r
289 m_wndPropList.AddProperty(pGroup3);
\r
291 CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("Hierarchy"));
\r
293 CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("First sub-level"));
\r
294 pGroup4->AddSubItem(pGroup41);
\r
296 CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("Second sub-level"));
\r
297 pGroup41->AddSubItem(pGroup411);
\r
299 pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 1"), (_variant_t) _T("Value 1"), _T("This is a description")));
\r
300 pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 2"), (_variant_t) _T("Value 2"), _T("This is a description")));
\r
301 pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 3"), (_variant_t) _T("Value 3"), _T("This is a description")));
\r
303 pGroup4->Expand(FALSE);
\r
304 m_wndPropList.AddProperty(pGroup4);
\r
308 void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd)
\r
310 CDockablePane::OnSetFocus(pOldWnd);
\r
311 m_wndPropList.SetFocus();
\r
314 void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
\r
316 CDockablePane::OnSettingChange(uFlags, lpszSection);
\r
320 void CPropertiesWnd::SetPropListFont()
\r
322 ::DeleteObject(m_fntPropList.Detach());
\r
325 afxGlobalData.fontRegular.GetLogFont(&lf);
\r
327 NONCLIENTMETRICS info;
\r
328 info.cbSize = sizeof(info);
\r
330 afxGlobalData.GetNonClientMetrics(info);
\r
332 lf.lfHeight = info.lfMenuFont.lfHeight;
\r
333 lf.lfWeight = info.lfMenuFont.lfWeight;
\r
334 lf.lfItalic = info.lfMenuFont.lfItalic;
\r
336 m_fntPropList.CreateFontIndirect(&lf);
\r
338 m_wndPropList.SetFont(&m_fntPropList);
\r
340 void CPropertiesWnd::RemoveParent()
\r
342 for(int i=0;i<m_ParentGroup->GetSubItemsCount();i++)
\r
344 CMFCPropertyGridProperty * p=m_ParentGroup->GetSubItem(0);
\r
345 m_ParentGroup->RemoveSubItem(p);
\r
349 void CPropertiesWnd::UpdateProperties(GitRev *rev)
\r
353 m_CommitHash->SetValue(rev->m_CommitHash);
\r
354 m_AuthorName->SetValue(rev->m_AuthorName);
\r
355 m_AuthorDate->SetValue(rev->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")));
\r
356 m_AuthorEmail->SetValue(rev->m_AuthorEmail);
\r
358 m_CommitterName->SetValue(rev->m_CommitterName);
\r
359 m_CommitterEmail->SetValue(rev->m_CommitterEmail);
\r
360 m_CommitterDate->SetValue(rev->m_CommitterDate.Format(_T("%Y-%m-%d %H:%M")));
\r
362 m_Subject->SetValue(rev->m_Subject);
\r
363 m_Body->SetValue(rev->m_Body);
\r
369 CLogDataVector *pLogEntry = &((CMainFrame*)AfxGetApp()->GetMainWnd())->m_wndOutput.m_LogList.m_logEntries;
\r
371 for(unsigned int i=0;i<rev->m_ParentHash.size();i++)
\r
374 CString parentsubject;
\r
377 if( pLogEntry->m_HashMap.find(rev->m_ParentHash[i]) == pLogEntry->m_HashMap.end() )
\r
383 index=pLogEntry->m_HashMap[rev->m_ParentHash[i]];
\r
386 parentsubject=pLogEntry->at(index).m_Subject;
\r
388 str.Format(_T("%d - %s \n %s"),i,rev->m_ParentHash[i],parentsubject);
\r
390 CMFCPropertyGridProperty*p=new CMFCPropertyGridProperty(
\r
391 rev->m_ParentHash[i].Left(8),
\r
395 m_ParentGroup->AddSubItem(p);
\r
396 m_ParentGroup->Expand();
\r
398 for(int i=0;i<m_BaseInfoGroup->GetSubItemsCount();i++)
\r
399 m_BaseInfoGroup->GetSubItem(i)->SetDescription(m_BaseInfoGroup->GetSubItem(i)->GetValue());
\r
403 m_CommitHash->SetValue(_T(""));
\r
404 m_AuthorName->SetValue(_T(""));
\r
405 m_AuthorDate->SetValue(_T(""));
\r
406 m_AuthorEmail->SetValue(_T(""));
\r
408 m_CommitterName->SetValue(_T(""));
\r
409 m_CommitterEmail->SetValue(_T(""));
\r
410 m_CommitterDate->SetValue(_T(""));
\r
412 m_Subject->SetValue(_T(""));
\r
413 m_Body->SetValue(_T(""));
\r
418 //m_ParentHash->SetValue(_T(""));
\r
419 //m_ParentSubject->SetValue(_T(""));
\r
420 for(int i=0;i<m_BaseInfoGroup->GetSubItemsCount();i++)
\r
421 m_BaseInfoGroup->GetSubItem(i)->SetDescription(_T(""));
\r
423 this->Invalidate();
\r
424 m_wndPropList.Invalidate();
\r