OSDN Git Service

Show Column at Log List
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / OutputWnd.cpp
1 \r
2 #include "stdafx.h"\r
3 \r
4 #include "OutputWnd.h"\r
5 #include "Resource.h"\r
6 #include "MainFrm.h"\r
7 \r
8 #ifdef _DEBUG\r
9 #define new DEBUG_NEW\r
10 #undef THIS_FILE\r
11 static char THIS_FILE[] = __FILE__;\r
12 #endif\r
13 \r
14 /////////////////////////////////////////////////////////////////////////////\r
15 // COutputBar\r
16 \r
17 COutputWnd::COutputWnd()\r
18 {\r
19 }\r
20 \r
21 COutputWnd::~COutputWnd()\r
22 {\r
23 }\r
24 \r
25 BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane)\r
26         ON_WM_CREATE()\r
27         ON_WM_SIZE()\r
28 END_MESSAGE_MAP()\r
29 \r
30 int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)\r
31 {\r
32         if (CDockablePane::OnCreate(lpCreateStruct) == -1)\r
33                 return -1;\r
34 \r
35         m_Font.CreateStockObject(DEFAULT_GUI_FONT);\r
36 \r
37         CRect rectDummy;\r
38         rectDummy.SetRectEmpty();\r
39 \r
40         // Create tabs window:\r
41         if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1))\r
42         {\r
43                 TRACE0("Failed to create output tab window\n");\r
44                 return -1;      // fail to create\r
45         }\r
46 \r
47         // Create output panes:\r
48         //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;\r
49         const DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP;\r
50 \r
51         if (! m_LogList.Create(dwStyle,rectDummy,&m_wndTabs,2) )\r
52         {\r
53                 TRACE0("Failed to create output windows\n");\r
54                 return -1;      // fail to create\r
55         }\r
56 #if 0\r
57         if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) ||\r
58                 !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) ||\r
59                 !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4))\r
60         {\r
61                 TRACE0("Failed to create output windows\n");\r
62                 return -1;      // fail to create\r
63         }\r
64 #endif\r
65 \r
66         m_LogList.SetFont(&m_Font);\r
67         //m_wndOutputBuild.SetFont(&m_Font);\r
68         //m_wndOutputDebug.SetFont(&m_Font);\r
69         //m_wndOutputFind.SetFont(&m_Font);\r
70 \r
71         CString strTabName;\r
72         BOOL bNameValid;\r
73 \r
74         // Attach list windows to tab:\r
75         bNameValid = strTabName.LoadString(IDS_GIT_LOG_TAB);\r
76         ASSERT(bNameValid);\r
77 \r
78         m_wndTabs.AddTab(&m_LogList, strTabName, (UINT)0);\r
79 \r
80         m_LogList.DeleteAllItems();\r
81         m_LogList.InsertGitColumn();\r
82 \r
83 \r
84 #if 0\r
85         bNameValid = strTabName.LoadString(IDS_DEBUG_TAB);\r
86         ASSERT(bNameValid);\r
87         m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1);\r
88         bNameValid = strTabName.LoadString(IDS_FIND_TAB);\r
89         ASSERT(bNameValid);\r
90         m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2);\r
91 #endif;\r
92 \r
93         // Fill output tabs with some dummy text (nothing magic here)\r
94         FillBuildWindow();\r
95 //      FillDebugWindow();\r
96 //      FillFindWindow();\r
97 \r
98         return 0;\r
99 }\r
100 \r
101 void COutputWnd::OnSize(UINT nType, int cx, int cy)\r
102 {\r
103         CDockablePane::OnSize(nType, cx, cy);\r
104 \r
105         // Tab control should cover the whole client area:\r
106         m_wndTabs.SetWindowPos (NULL, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);\r
107 }\r
108 \r
109 void COutputWnd::AdjustHorzScroll(CListBox& wndListBox)\r
110 {\r
111         CClientDC dc(this);\r
112         CFont* pOldFont = dc.SelectObject(&m_Font);\r
113 \r
114         int cxExtentMax = 0;\r
115 \r
116         for (int i = 0; i < wndListBox.GetCount(); i ++)\r
117         {\r
118                 CString strItem;\r
119                 wndListBox.GetText(i, strItem);\r
120 \r
121                 cxExtentMax = max(cxExtentMax, dc.GetTextExtent(strItem).cx);\r
122         }\r
123 \r
124         wndListBox.SetHorizontalExtent(cxExtentMax);\r
125         dc.SelectObject(pOldFont);\r
126 }\r
127 \r
128 void COutputWnd::FillBuildWindow()\r
129 {\r
130 //      m_wndOutputBuild.AddString(_T("Build output is being displayed here."));\r
131 //      m_wndOutputBuild.AddString(_T("The output is being displayed in rows of a list view"));\r
132 //      m_wndOutputBuild.AddString(_T("but you can change the way it is displayed as you wish..."));\r
133 }\r
134 \r
135 void COutputWnd::FillDebugWindow()\r
136 {\r
137 //      m_wndOutputDebug.AddString(_T("Debug output is being displayed here."));\r
138 //      m_wndOutputDebug.AddString(_T("The output is being displayed in rows of a list view"));\r
139 //      m_wndOutputDebug.AddString(_T("but you can change the way it is displayed as you wish..."));\r
140 }\r
141 \r
142 void COutputWnd::FillFindWindow()\r
143 {\r
144 //      m_wndOutputFind.AddString(_T("Find output is being displayed here."));\r
145 //      m_wndOutputFind.AddString(_T("The output is being displayed in rows of a list view"));\r
146 //      m_wndOutputFind.AddString(_T("but you can change the way it is displayed as you wish..."));\r
147 }\r
148 \r
149 /////////////////////////////////////////////////////////////////////////////\r
150 // COutputList1\r
151 \r
152 COutputList::COutputList()\r
153 {\r
154 }\r
155 \r
156 COutputList::~COutputList()\r
157 {\r
158 }\r
159 \r
160 BEGIN_MESSAGE_MAP(COutputList, CListBox)\r
161         ON_WM_CONTEXTMENU()\r
162         ON_COMMAND(ID_EDIT_COPY, OnEditCopy)\r
163         ON_COMMAND(ID_EDIT_CLEAR, OnEditClear)\r
164         ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput)\r
165         ON_WM_WINDOWPOSCHANGING()\r
166 END_MESSAGE_MAP()\r
167 /////////////////////////////////////////////////////////////////////////////\r
168 // COutputList message handlers\r
169 \r
170 void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point)\r
171 {\r
172         CMenu menu;\r
173         menu.LoadMenu(IDR_OUTPUT_POPUP);\r
174 \r
175         CMenu* pSumMenu = menu.GetSubMenu(0);\r
176 \r
177         if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx)))\r
178         {\r
179                 CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;\r
180 \r
181                 if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE))\r
182                         return;\r
183 \r
184                 ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu);\r
185                 UpdateDialogControls(this, FALSE);\r
186         }\r
187 \r
188         SetFocus();\r
189 }\r
190 \r
191 void COutputList::OnEditCopy()\r
192 {\r
193         MessageBox(_T("Copy output"));\r
194 }\r
195 \r
196 void COutputList::OnEditClear()\r
197 {\r
198         MessageBox(_T("Clear output"));\r
199 }\r
200 \r
201 void COutputList::OnViewOutput()\r
202 {\r
203         CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner());\r
204         CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame());\r
205 \r
206         if (pMainFrame != NULL && pParentBar != NULL)\r
207         {\r
208                 pMainFrame->SetFocus();\r
209                 pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE);\r
210                 pMainFrame->RecalcLayout();\r
211 \r
212         }\r
213 }\r
214 \r
215 \r