forked from HaloMods/SparkEdit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOutputPane.cpp
118 lines (92 loc) · 2.84 KB
/
OutputPane.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// OutputPane.cpp : implementation file
//
#include "stdafx.h"
#include "SparkEdit.h"
#include "OutputPane.h"
extern COutputPane *g_pOutput;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COutputPane
IMPLEMENT_DYNCREATE(COutputPane, CFormView)
COutputPane::COutputPane()
: CFormView(COutputPane::IDD)
{
//{{AFX_DATA_INIT(COutputPane)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
COutputPane::~COutputPane()
{
}
void COutputPane::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COutputPane)
DDX_Control(pDX, IDC_OUTPUT_WIN, m_OutputWin);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COutputPane, CFormView)
//{{AFX_MSG_MAP(COutputPane)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutputPane diagnostics
#ifdef _DEBUG
void COutputPane::AssertValid() const
{
CFormView::AssertValid();
}
void COutputPane::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COutputPane message handlers
void COutputPane::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
CRect cr;
GetClientRect(&cr);
if(m_OutputWin.m_hWnd != NULL)
m_OutputWin.MoveWindow(cr.left, cr.top, cr.Width(), cr.Height());
}
void COutputPane::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
g_pOutput = this;
PostText("SparkEdit Version 3.02\n", LOG_BLUE);
PostText("Created by Grenadiac\n", LOG_BLUE);
PostText("Visit www.halomods.com for more information.\n", LOG_BLUE);
}
void COutputPane::PostText(CString msg, COLORREF color)
{
int iTotalTextLength;
CHARFORMAT cf;
PARAFORMAT pf;
/* Grab the first character of the last line */
iTotalTextLength = m_OutputWin.GetWindowTextLength();
/* Gather the formatting information */
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR | CFM_UNDERLINE | CFM_BOLD;
cf.dwEffects = (unsigned long)~(CFE_AUTOCOLOR | CFE_UNDERLINE | CFE_BOLD);
cf.crTextColor = color;
/* Add the actual text */
m_OutputWin.SetSel(iTotalTextLength, iTotalTextLength); // Set carat to last line
m_OutputWin.SetSelectionCharFormat(cf); // Apply formatting prior to text
m_OutputWin.HideSelection(TRUE, FALSE); // Show the current selection
m_OutputWin.ReplaceSel((LPCTSTR)msg); // Add the text
/* Force the paragraph to be left-justified so the horizontal scroll won't go
off to the right. */
pf.cbSize = sizeof(PARAFORMAT);
pf.dwMask = PFM_ALIGNMENT;
pf.wAlignment = PFA_LEFT;
m_OutputWin.SetParaFormat(pf);
/* Vertical scroll one line, horizontal scroll 0 characters */
m_OutputWin.LineScroll(1, 0);
}