Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
#include "stdafx.h"
#include <ctrlext.h>
#include "shared.h"
#include "OutputWnd.h"
#include "Resource.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COutputBar
COutputWnd::COutputWnd()
{
}
COutputWnd::~COutputWnd()
{
}
BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane)
ON_WM_CREATE()
ON_WM_SIZE()
END_MESSAGE_MAP()
int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rectDummy;
rectDummy.SetRectEmpty();
// Create tabs window:
if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1))
{
TRACE0("Failed to create output tab window\n");
return -1; // fail to create
}
// Create output panes:
const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) ||
!m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) ||
!m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4))
{
TRACE0("Failed to create output windows\n");
return -1; // fail to create
}
UpdateFonts();
CString strTabName;
BOOL bNameValid;
// Attach list windows to tab:
bNameValid = strTabName.LoadString(IDS_BUILD_TAB);
ASSERT(bNameValid);
m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0);
bNameValid = strTabName.LoadString(IDS_DEBUG_TAB);
ASSERT(bNameValid);
m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1);
bNameValid = strTabName.LoadString(IDS_FIND_TAB);
ASSERT(bNameValid);
m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2);
// Fill output tabs with some dummy text (nothing magic here)
//FillBuildWindow();
FillDebugWindow();
FillFindWindow();
return 0;
}
void COutputWnd::OnSize(UINT nType, int cx, int cy)
{
CDockablePane::OnSize(nType, cx, cy);
// Tab control should cover the whole client area:
m_wndTabs.SetWindowPos (NULL, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
}
void COutputWnd::AdjustHorzScroll(CListBox& wndListBox)
{
CClientDC dc(this);
CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);
int cxExtentMax = 0;
for (int i = 0; i < wndListBox.GetCount(); i ++)
{
CString strItem;
wndListBox.GetText(i, strItem);
cxExtentMax = max(cxExtentMax, dc.GetTextExtent(strItem).cx);
}
wndListBox.SetHorizontalExtent(cxExtentMax);
dc.SelectObject(pOldFont);
}
void COutputWnd::SetWindowInfo(const info_notify& info)
{
COutputList* pWind = nullptr;
switch (info.the_call)
{
case info_notify::output_info:
pWind = &m_wndOutputDebug; break;
case info_notify::other_info:
pWind = &m_wndOutputBuild; break;
case info_notify::find_info:
pWind = &m_wndOutputFind; break;
default:
return;
}
assert(pWind->GetSafeHwnd());
if (info.bClear)
pWind->ClearList();
for (auto pos = 0; ; )
{
auto next = info.str.find("\n", pos);
if (next == std::string::npos)
break;
pWind->AddString(pugi::as_wide(info.str.substr(pos, next - pos)).c_str());
pos = next + 1;
}
pWind->SetCurSel(pWind->GetCount() - 1);
}
void COutputWnd::SetBuildText(const std::string& str)
{
m_wndOutputBuild.ClearList();
for (auto pos = 0; ; )
{
auto next = str.find("\n", pos);
if (next == std::string::npos)
break;
m_wndOutputBuild.AddString(pugi::as_wide(str.substr(pos, next - pos)).c_str());
pos = next + 1;
}
}
void COutputWnd::SetOtherText(const std::string& str)
{
m_wndOutputDebug.ClearList();
for (auto pos = 0; ; )
{
auto next = str.find("\n", pos);
if (next == std::string::npos)
break;
m_wndOutputDebug.AddString(pugi::as_wide(str.substr(pos, next - pos)).c_str());
pos = next + 1;
}
}
void COutputWnd::FillBuildWindow( )
{
m_wndOutputBuild.AddString(_T("Build output is being displayed here."));
m_wndOutputBuild.AddString(_T("The output is being displayed in rows of a list view"));
m_wndOutputBuild.AddString(_T("but you can change the way it is displayed as you wish..."));
}
void COutputWnd::FillDebugWindow()
{
m_wndOutputDebug.AddString(_T("Debug output is being displayed here."));
m_wndOutputDebug.AddString(_T("The output is being displayed in rows of a list view"));
m_wndOutputDebug.AddString(_T("but you can change the way it is displayed as you wish..."));
}
void COutputWnd::FillFindWindow()
{
m_wndOutputFind.AddString(_T("Find output is being displayed here."));
m_wndOutputFind.AddString(_T("The output is being displayed in rows of a list view"));
m_wndOutputFind.AddString(_T("but you can change the way it is displayed as you wish..."));
}
void COutputWnd::UpdateFonts()
{
m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular);
m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular);
m_wndOutputFind.SetFont(&afxGlobalData.fontRegular);
}
/////////////////////////////////////////////////////////////////////////////
// COutputList1
COutputList::COutputList()
{
}
COutputList::~COutputList()
{
}
void COutputList::ClearList( )
{
ResetContent( );
}
BEGIN_MESSAGE_MAP(COutputList, CListBox)
ON_WM_CONTEXTMENU()
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
ON_COMMAND(ID_EDIT_CLEAR, OnEditClear)
ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput)
ON_WM_WINDOWPOSCHANGING()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutputList message handlers
void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
CMenu menu;
menu.LoadMenu(IDR_OUTPUT_POPUP);
CMenu* pSumMenu = menu.GetSubMenu(0);
if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx)))
{
CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;
if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE))
return;
((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu);
UpdateDialogControls(this, FALSE);
}
SetFocus();
}
void COutputList::OnEditCopy()
{
MessageBox(_T("Copy output"));
}
void COutputList::OnEditClear()
{
MessageBox(_T("Clear output"));
}
void COutputList::OnViewOutput()
{
CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner());
CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame());
if (pMainFrame != NULL && pParentBar != NULL)
{
pMainFrame->SetFocus();
pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE);
pMainFrame->RecalcLayout();
}
}
9089253afThis file is pinned to the selected release. Download the original to open it in your design tool.