4 #include "OutputWnd.h"
\r
5 #include "Resource.h"
\r
7 #include "TortoiseGitBlameDoc.h"
\r
8 #include "TortoiseGitBlameView.h"
\r
11 #define new DEBUG_NEW
\r
13 static char THIS_FILE[] = __FILE__;
\r
16 /////////////////////////////////////////////////////////////////////////////
\r
19 COutputWnd::COutputWnd()
\r
23 COutputWnd::~COutputWnd()
\r
27 IMPLEMENT_DYNCREATE(CGitMFCTabCtrl, CMFCTabCtrl)
\r
29 BEGIN_MESSAGE_MAP(CGitMFCTabCtrl, CMFCTabCtrl)
\r
30 ON_NOTIFY(LVN_ITEMCHANGED, 0, OnLvnItemchangedLoglist)
\r
33 void CGitMFCTabCtrl::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
35 COutputWnd *pWnd=DYNAMIC_DOWNCAST(COutputWnd,this->GetParent());
\r
36 pWnd->OnLvnItemchangedLoglist(pNMHDR,pResult);
\r
39 BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane)
\r
42 ON_NOTIFY(LVN_ITEMCHANGED, 0, OnLvnItemchangedLoglist)
\r
45 int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
47 if (CDockablePane::OnCreate(lpCreateStruct) == -1)
\r
50 TRACE(_T("%u\n"),LVN_ITEMCHANGED);
\r
51 m_Font.CreateStockObject(DEFAULT_GUI_FONT);
\r
54 rectDummy.SetRectEmpty();
\r
56 // Create tabs window:
\r
57 if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 0))
\r
59 TRACE0("Failed to create output tab window\n");
\r
60 return -1; // fail to create
\r
63 // Create output panes:
\r
64 //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
\r
65 const DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;
\r
67 if (! m_LogList.Create(dwStyle,rectDummy,&m_wndTabs,0) )
\r
69 TRACE0("Failed to create output windows\n");
\r
70 return -1; // fail to create
\r
73 if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) ||
\r
74 !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) ||
\r
75 !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4))
\r
77 TRACE0("Failed to create output windows\n");
\r
78 return -1; // fail to create
\r
82 m_LogList.SetFont(&m_Font);
\r
83 //m_wndOutputBuild.SetFont(&m_Font);
\r
84 //m_wndOutputDebug.SetFont(&m_Font);
\r
85 //m_wndOutputFind.SetFont(&m_Font);
\r
90 // Attach list windows to tab:
\r
91 bNameValid = strTabName.LoadString(IDS_GIT_LOG_TAB);
\r
94 m_wndTabs.AddTab(&m_LogList, strTabName, (UINT)0);
\r
96 m_LogList.m_IsIDReplaceAction=TRUE;
\r
97 m_LogList.DeleteAllItems();
\r
98 m_LogList.InsertGitColumn();
\r
102 bNameValid = strTabName.LoadString(IDS_DEBUG_TAB);
\r
103 ASSERT(bNameValid);
\r
104 m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1);
\r
105 bNameValid = strTabName.LoadString(IDS_FIND_TAB);
\r
106 ASSERT(bNameValid);
\r
107 m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2);
\r
110 // Fill output tabs with some dummy text (nothing magic here)
\r
112 // FillDebugWindow();
\r
113 // FillFindWindow();
\r
115 this->SetWindowTextW(_T("Git Log"));
\r
119 void COutputWnd::OnSize(UINT nType, int cx, int cy)
\r
121 CDockablePane::OnSize(nType, cx, cy);
\r
123 // Tab control should cover the whole client area:
\r
124 m_wndTabs.SetWindowPos (NULL, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
\r
127 void COutputWnd::AdjustHorzScroll(CListBox& wndListBox)
\r
129 CClientDC dc(this);
\r
130 CFont* pOldFont = dc.SelectObject(&m_Font);
\r
132 int cxExtentMax = 0;
\r
134 for (int i = 0; i < wndListBox.GetCount(); i ++)
\r
137 wndListBox.GetText(i, strItem);
\r
139 cxExtentMax = max(cxExtentMax, dc.GetTextExtent(strItem).cx);
\r
142 wndListBox.SetHorizontalExtent(cxExtentMax);
\r
143 dc.SelectObject(pOldFont);
\r
146 void COutputWnd::FillBuildWindow()
\r
148 // m_wndOutputBuild.AddString(_T("Build output is being displayed here."));
\r
149 // m_wndOutputBuild.AddString(_T("The output is being displayed in rows of a list view"));
\r
150 // m_wndOutputBuild.AddString(_T("but you can change the way it is displayed as you wish..."));
\r
153 void COutputWnd::FillDebugWindow()
\r
155 // m_wndOutputDebug.AddString(_T("Debug output is being displayed here."));
\r
156 // m_wndOutputDebug.AddString(_T("The output is being displayed in rows of a list view"));
\r
157 // m_wndOutputDebug.AddString(_T("but you can change the way it is displayed as you wish..."));
\r
160 void COutputWnd::FillFindWindow()
\r
162 // m_wndOutputFind.AddString(_T("Find output is being displayed here."));
\r
163 // m_wndOutputFind.AddString(_T("The output is being displayed in rows of a list view"));
\r
164 // m_wndOutputFind.AddString(_T("but you can change the way it is displayed as you wish..."));
\r
167 int COutputWnd::LoadHistory(CString filename)
\r
169 m_LogList.ReloadHashMap();
\r
171 path.SetFromGit(filename);
\r
174 m_LogList.FillGitLog(&path,0/*CGit::LOG_INFO_FULLHISTORY*/);
\r
179 void COutputWnd::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
181 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
\r
184 //if (this->IsThreadRunning())
\r
185 if (pNMLV->iItem >= 0)
\r
187 if (pNMLV->iSubItem != 0)
\r
190 if (pNMLV->uNewState & LVIS_SELECTED)
\r
192 CMainFrame *pMain=DYNAMIC_DOWNCAST(CMainFrame,AfxGetApp()->GetMainWnd());
\r
193 POSITION pos=pMain->GetActiveDocument()->GetFirstViewPosition();
\r
194 CTortoiseGitBlameView *pView=DYNAMIC_DOWNCAST(CTortoiseGitBlameView,pMain->GetActiveDocument()->GetNextView(pos));
\r
195 pView->FocusOn(&this->m_LogList.m_logEntries[pNMLV->iItem]);
\r
199 /////////////////////////////////////////////////////////////////////////////
\r
202 COutputList::COutputList()
\r
206 COutputList::~COutputList()
\r
210 BEGIN_MESSAGE_MAP(COutputList, CListBox)
\r
211 ON_WM_CONTEXTMENU()
\r
212 ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
\r
213 ON_COMMAND(ID_EDIT_CLEAR, OnEditClear)
\r
214 ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput)
\r
215 ON_WM_WINDOWPOSCHANGING()
\r
217 /////////////////////////////////////////////////////////////////////////////
\r
218 // COutputList message handlers
\r
220 void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
\r
223 menu.LoadMenu(IDR_OUTPUT_POPUP);
\r
225 CMenu* pSumMenu = menu.GetSubMenu(0);
\r
227 if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx)))
\r
229 CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;
\r
231 if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE))
\r
234 ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu);
\r
235 UpdateDialogControls(this, FALSE);
\r
241 void COutputList::OnEditCopy()
\r
243 MessageBox(_T("Copy output"));
\r
246 void COutputList::OnEditClear()
\r
248 MessageBox(_T("Clear output"));
\r
251 void COutputList::OnViewOutput()
\r
253 CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner());
\r
254 CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame());
\r
256 if (pMainFrame != NULL && pParentBar != NULL)
\r
258 pMainFrame->SetFocus();
\r
259 pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE);
\r
260 pMainFrame->RecalcLayout();
\r