OSDN Git Service

fa17a70a05c1632ce4e4ea7d69dba19e04889e04
[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 \r
50         if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) ||\r
51                 !m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) ||\r
52                 !m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4))\r
53         {\r
54                 TRACE0("Failed to create output windows\n");\r
55                 return -1;      // fail to create\r
56         }\r
57 \r
58         m_wndOutputBuild.SetFont(&m_Font);\r
59         m_wndOutputDebug.SetFont(&m_Font);\r
60         m_wndOutputFind.SetFont(&m_Font);\r
61 \r
62         CString strTabName;\r
63         BOOL bNameValid;\r
64 \r
65         // Attach list windows to tab:\r
66         bNameValid = strTabName.LoadString(IDS_BUILD_TAB);\r
67         ASSERT(bNameValid);\r
68         m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0);\r
69         bNameValid = strTabName.LoadString(IDS_DEBUG_TAB);\r
70         ASSERT(bNameValid);\r
71         m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1);\r
72         bNameValid = strTabName.LoadString(IDS_FIND_TAB);\r
73         ASSERT(bNameValid);\r
74         m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2);\r
75 \r
76         // Fill output tabs with some dummy text (nothing magic here)\r
77         FillBuildWindow();\r
78         FillDebugWindow();\r
79         FillFindWindow();\r
80 \r
81         return 0;\r
82 }\r
83 \r
84 void COutputWnd::OnSize(UINT nType, int cx, int cy)\r
85 {\r
86         CDockablePane::OnSize(nType, cx, cy);\r
87 \r
88         // Tab control should cover the whole client area:\r
89         m_wndTabs.SetWindowPos (NULL, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);\r
90 }\r
91 \r
92 void COutputWnd::AdjustHorzScroll(CListBox& wndListBox)\r
93 {\r
94         CClientDC dc(this);\r
95         CFont* pOldFont = dc.SelectObject(&m_Font);\r
96 \r
97         int cxExtentMax = 0;\r
98 \r
99         for (int i = 0; i < wndListBox.GetCount(); i ++)\r
100         {\r
101                 CString strItem;\r
102                 wndListBox.GetText(i, strItem);\r
103 \r
104                 cxExtentMax = max(cxExtentMax, dc.GetTextExtent(strItem).cx);\r
105         }\r
106 \r
107         wndListBox.SetHorizontalExtent(cxExtentMax);\r
108         dc.SelectObject(pOldFont);\r
109 }\r
110 \r
111 void COutputWnd::FillBuildWindow()\r
112 {\r
113         m_wndOutputBuild.AddString(_T("Build output is being displayed here."));\r
114         m_wndOutputBuild.AddString(_T("The output is being displayed in rows of a list view"));\r
115         m_wndOutputBuild.AddString(_T("but you can change the way it is displayed as you wish..."));\r
116 }\r
117 \r
118 void COutputWnd::FillDebugWindow()\r
119 {\r
120         m_wndOutputDebug.AddString(_T("Debug output is being displayed here."));\r
121         m_wndOutputDebug.AddString(_T("The output is being displayed in rows of a list view"));\r
122         m_wndOutputDebug.AddString(_T("but you can change the way it is displayed as you wish..."));\r
123 }\r
124 \r
125 void COutputWnd::FillFindWindow()\r
126 {\r
127         m_wndOutputFind.AddString(_T("Find output is being displayed here."));\r
128         m_wndOutputFind.AddString(_T("The output is being displayed in rows of a list view"));\r
129         m_wndOutputFind.AddString(_T("but you can change the way it is displayed as you wish..."));\r
130 }\r
131 \r
132 /////////////////////////////////////////////////////////////////////////////\r
133 // COutputList1\r
134 \r
135 COutputList::COutputList()\r
136 {\r
137 }\r
138 \r
139 COutputList::~COutputList()\r
140 {\r
141 }\r
142 \r
143 BEGIN_MESSAGE_MAP(COutputList, CListBox)\r
144         ON_WM_CONTEXTMENU()\r
145         ON_COMMAND(ID_EDIT_COPY, OnEditCopy)\r
146         ON_COMMAND(ID_EDIT_CLEAR, OnEditClear)\r
147         ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput)\r
148         ON_WM_WINDOWPOSCHANGING()\r
149 END_MESSAGE_MAP()\r
150 /////////////////////////////////////////////////////////////////////////////\r
151 // COutputList message handlers\r
152 \r
153 void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point)\r
154 {\r
155         CMenu menu;\r
156         menu.LoadMenu(IDR_OUTPUT_POPUP);\r
157 \r
158         CMenu* pSumMenu = menu.GetSubMenu(0);\r
159 \r
160         if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx)))\r
161         {\r
162                 CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;\r
163 \r
164                 if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE))\r
165                         return;\r
166 \r
167                 ((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu);\r
168                 UpdateDialogControls(this, FALSE);\r
169         }\r
170 \r
171         SetFocus();\r
172 }\r
173 \r
174 void COutputList::OnEditCopy()\r
175 {\r
176         MessageBox(_T("Copy output"));\r
177 }\r
178 \r
179 void COutputList::OnEditClear()\r
180 {\r
181         MessageBox(_T("Clear output"));\r
182 }\r
183 \r
184 void COutputList::OnViewOutput()\r
185 {\r
186         CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner());\r
187         CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame());\r
188 \r
189         if (pMainFrame != NULL && pParentBar != NULL)\r
190         {\r
191                 pMainFrame->SetFocus();\r
192                 pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE);\r
193                 pMainFrame->RecalcLayout();\r
194 \r
195         }\r
196 }\r
197 \r
198 \r