7 #include "TortoiseGitBlameDoc.h"
8 #include "TortoiseGitBlameView.h"
13 static char THIS_FILE
[] = __FILE__
;
16 /////////////////////////////////////////////////////////////////////////////
19 COutputWnd::COutputWnd()
23 COutputWnd::~COutputWnd()
27 IMPLEMENT_DYNCREATE(CGitMFCTabCtrl
, CMFCTabCtrl
)
29 BEGIN_MESSAGE_MAP(CGitMFCTabCtrl
, CMFCTabCtrl
)
30 ON_NOTIFY(LVN_ITEMCHANGED
, 0, OnLvnItemchangedLoglist
)
33 void CGitMFCTabCtrl::OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
35 COutputWnd
*pWnd
=DYNAMIC_DOWNCAST(COutputWnd
,this->GetParent());
36 pWnd
->OnLvnItemchangedLoglist(pNMHDR
,pResult
);
39 IMPLEMENT_DYNAMIC(COutputWnd
, CDockablePane
)
41 BEGIN_MESSAGE_MAP(COutputWnd
, CDockablePane
)
44 ON_NOTIFY(LVN_ITEMCHANGED
, 0, OnLvnItemchangedLoglist
)
47 int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct
)
49 if (CDockablePane::OnCreate(lpCreateStruct
) == -1)
52 TRACE(_T("%u\n"),LVN_ITEMCHANGED
);
53 m_Font
.CreateStockObject(DEFAULT_GUI_FONT
);
56 rectDummy
.SetRectEmpty();
58 // Create tabs window:
59 if (!m_wndTabs
.Create(CMFCTabCtrl::STYLE_FLAT
, rectDummy
, this, 0))
61 TRACE0("Failed to create output tab window\n");
62 return -1; // fail to create
65 // Create output panes:
66 //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
67 const DWORD dwStyle
=LVS_REPORT
| LVS_SHOWSELALWAYS
| LVS_ALIGNLEFT
| LVS_OWNERDATA
| WS_BORDER
| WS_TABSTOP
|LVS_SINGLESEL
|WS_CHILD
| WS_VISIBLE
;
69 if (! m_LogList
.Create(dwStyle
,rectDummy
,&m_wndTabs
,0) )
71 TRACE0("Failed to create output windows\n");
72 return -1; // fail to create
75 if (!m_wndOutputBuild
.Create(dwStyle
, rectDummy
, &m_wndTabs
, 2) ||
76 !m_wndOutputDebug
.Create(dwStyle
, rectDummy
, &m_wndTabs
, 3) ||
77 !m_wndOutputFind
.Create(dwStyle
, rectDummy
, &m_wndTabs
, 4))
79 TRACE0("Failed to create output windows\n");
80 return -1; // fail to create
84 m_LogList
.SetFont(&m_Font
);
85 //m_wndOutputBuild.SetFont(&m_Font);
86 //m_wndOutputDebug.SetFont(&m_Font);
87 //m_wndOutputFind.SetFont(&m_Font);
92 // Attach list windows to tab:
93 bNameValid
= strTabName
.LoadString(IDS_GIT_LOG_TAB
);
96 m_wndTabs
.AddTab(&m_LogList
, strTabName
, (UINT
)0);
98 m_LogList
.m_IsIDReplaceAction
=TRUE
;
99 m_LogList
.DeleteAllItems();
100 m_LogList
.InsertGitColumn();
104 bNameValid
= strTabName
.LoadString(IDS_DEBUG_TAB
);
106 m_wndTabs
.AddTab(&m_wndOutputDebug
, strTabName
, (UINT
)1);
107 bNameValid
= strTabName
.LoadString(IDS_FIND_TAB
);
109 m_wndTabs
.AddTab(&m_wndOutputFind
, strTabName
, (UINT
)2);
112 // Fill output tabs with some dummy text (nothing magic here)
114 // FillDebugWindow();
117 this->SetWindowTextW(_T("Git Log"));
121 void COutputWnd::OnSize(UINT nType
, int cx
, int cy
)
123 CDockablePane::OnSize(nType
, cx
, cy
);
125 // Tab control should cover the whole client area:
126 m_wndTabs
.SetWindowPos (NULL
, -1, -1, cx
, cy
, SWP_NOMOVE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
129 void COutputWnd::AdjustHorzScroll(CListBox
& wndListBox
)
132 CFont
* pOldFont
= dc
.SelectObject(&m_Font
);
136 for (int i
= 0; i
< wndListBox
.GetCount(); i
++)
139 wndListBox
.GetText(i
, strItem
);
141 cxExtentMax
= max(cxExtentMax
, dc
.GetTextExtent(strItem
).cx
);
144 wndListBox
.SetHorizontalExtent(cxExtentMax
);
145 dc
.SelectObject(pOldFont
);
148 void COutputWnd::FillBuildWindow()
150 // m_wndOutputBuild.AddString(_T("Build output is being displayed here."));
151 // m_wndOutputBuild.AddString(_T("The output is being displayed in rows of a list view"));
152 // m_wndOutputBuild.AddString(_T("but you can change the way it is displayed as you wish..."));
155 void COutputWnd::FillDebugWindow()
157 // m_wndOutputDebug.AddString(_T("Debug output is being displayed here."));
158 // m_wndOutputDebug.AddString(_T("The output is being displayed in rows of a list view"));
159 // m_wndOutputDebug.AddString(_T("but you can change the way it is displayed as you wish..."));
162 void COutputWnd::FillFindWindow()
164 // m_wndOutputFind.AddString(_T("Find output is being displayed here."));
165 // m_wndOutputFind.AddString(_T("The output is being displayed in rows of a list view"));
166 // m_wndOutputFind.AddString(_T("but you can change the way it is displayed as you wish..."));
169 int COutputWnd::LoadHistory(CString filename
)
171 m_LogList
.ReloadHashMap();
173 path
.SetFromGit(filename
);
176 m_LogList
.FillGitLog(&path
,0/*CGit::LOG_INFO_FOLLOW*/);
181 void COutputWnd::OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
183 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
186 //if (this->IsThreadRunning())
187 if (pNMLV
->iItem
>= 0)
189 if (pNMLV
->iSubItem
!= 0)
192 if (pNMLV
->uNewState
& LVIS_SELECTED
)
194 CMainFrame
*pMain
=DYNAMIC_DOWNCAST(CMainFrame
,AfxGetApp()->GetMainWnd());
195 POSITION pos
=pMain
->GetActiveDocument()->GetFirstViewPosition();
196 CTortoiseGitBlameView
*pView
=DYNAMIC_DOWNCAST(CTortoiseGitBlameView
,pMain
->GetActiveDocument()->GetNextView(pos
));
197 pView
->FocusOn(&this->m_LogList
.m_logEntries
[pNMLV
->iItem
]);
201 /////////////////////////////////////////////////////////////////////////////
204 COutputList::COutputList()
208 COutputList::~COutputList()
212 BEGIN_MESSAGE_MAP(COutputList
, CListBox
)
214 ON_COMMAND(ID_EDIT_COPY
, OnEditCopy
)
215 ON_COMMAND(ID_EDIT_CLEAR
, OnEditClear
)
216 ON_COMMAND(ID_VIEW_OUTPUTWND
, OnViewOutput
)
217 ON_WM_WINDOWPOSCHANGING()
219 /////////////////////////////////////////////////////////////////////////////
220 // COutputList message handlers
222 void COutputList::OnContextMenu(CWnd
* /*pWnd*/, CPoint point
)
225 menu
.LoadMenu(IDR_OUTPUT_POPUP
);
227 CMenu
* pSumMenu
= menu
.GetSubMenu(0);
229 if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx
)))
231 CMFCPopupMenu
* pPopupMenu
= new CMFCPopupMenu
;
233 if (!pPopupMenu
->Create(this, point
.x
, point
.y
, (HMENU
)pSumMenu
->m_hMenu
, FALSE
, TRUE
))
236 ((CMDIFrameWndEx
*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu
);
237 UpdateDialogControls(this, FALSE
);
243 void COutputList::OnEditCopy()
245 MessageBox(_T("Copy output"));
248 void COutputList::OnEditClear()
250 MessageBox(_T("Clear output"));
253 void COutputList::OnViewOutput()
255 CDockablePane
* pParentBar
= DYNAMIC_DOWNCAST(CDockablePane
, GetOwner());
256 CMDIFrameWndEx
* pMainFrame
= DYNAMIC_DOWNCAST(CMDIFrameWndEx
, GetTopLevelFrame());
258 if (pMainFrame
!= NULL
&& pParentBar
!= NULL
)
260 pMainFrame
->SetFocus();
261 pMainFrame
->ShowPane(pParentBar
, FALSE
, FALSE
, FALSE
);
262 pMainFrame
->RecalcLayout();