-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathOutput.cpp
More file actions
175 lines (146 loc) · 4.87 KB
/
Output.cpp
File metadata and controls
175 lines (146 loc) · 4.87 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// Output.cpp : implementation file
//
#include "stdafx.h"
#include "byakhee.h"
#include "MainFrm.h"
#include "Output.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COutput dialog
/**
* Copyright (C) 1998 David Harvey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
COutput::COutput()
{
}
COutput::~COutput()
{
}
BEGIN_MESSAGE_MAP(COutput, CSizingControlBar)
//{{AFX_MSG_MAP(COutput)
ON_WM_CREATE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutput message handlers
void COutput::AddString(CString strText)
{
//add this item to the end
int iPos = m_wndText.AddString(strText);
m_wndText.SetCurSel(iPos);
//remove top item if it's too full
if( m_wndText.GetCount() > 50 ) m_wndText.DeleteString(0);
}
void COutput::Clear()
{
//empty the list box
m_wndText.ResetContent();
}
int COutput::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CSizingControlBar::OnCreate(lpCreateStruct) == -1)
return -1;
//create the list box
if( !m_wndText.Create( LBS_HASSTRINGS|LBS_OWNERDRAWVARIABLE|LBS_NOINTEGRALHEIGHT|WS_VSCROLL|WS_BORDER|WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), this, 0xFFFF )) return -1;
m_wndText.ModifyStyleEx( 0, WS_EX_CLIENTEDGE );
//change the list box font
LoadDisplaySettings();
return 0;
}
void COutput::OnSize(UINT nType, int cx, int cy)
{
CSizingControlBar::OnSize(nType, cx, cy);
CRect rc;
GetClientRect( rc );
//resize the list box
m_wndText.SetWindowPos( NULL, 4, 4, rc.right-8, rc.bottom-8, SWP_NOZORDER );
}
void COutput::LoadDisplaySettings()
{
//delete current font and brush
m_Font.DeleteObject();
//initialise LOGFONT structure
LOGFONT lf;
ZeroMemory( &lf, sizeof(LOGFONT) );
//load settings
CString strSection = "Output";
strcpy( lf.lfFaceName, AfxGetApp()->GetProfileString( strSection, "FontFace", "MS Sans Serif" ) );
lf.lfHeight = AfxGetApp()->GetProfileInt( strSection, "FontSize", -10 );
lf.lfItalic = AfxGetApp()->GetProfileInt( strSection, "FontItalic", 0 );
lf.lfWeight = AfxGetApp()->GetProfileInt( strSection, "FontWeight", 0 );
COLORREF crBackground = AfxGetApp()->GetProfileInt( strSection, "BkColour", GetSysColor(COLOR_WINDOW) );
COLORREF crForeground = AfxGetApp()->GetProfileInt( strSection, "TxColour", GetSysColor(COLOR_WINDOWTEXT) );
//apply settings
m_wndText.SetColours( crForeground, crBackground );
m_Font.CreateFontIndirect( &lf );
m_wndText.SetFont( &m_Font, TRUE );
}
/******************************************************************************************************************/
CScriptObject::MEMBERRESULT CScriptOutput::ExecuteMemberFunction( char* pszName, Variant* pParameters, int nParameters, Variant& returnValue )
{
COutput& wndOutput = ((CMainFrame*)AfxGetMainWnd())->GetOutputWindow();
if( stricmp(pszName, "write") == 0 )
{
if( nParameters == 1 )
{
//FIXME: add multiple lines for each \r and/or \n
wndOutput.AddString( LPCSTR(pParameters[0]) );
wndOutput.m_wndText.RedrawWindow();
return OK;
}
else
return nParameters < 1 ? TOO_FEW_PARAMS : TOO_MANY_PARAMS;
}
if( stricmp(pszName, "show") == 0 )
{
if( nParameters == 0 )
{
((CMainFrame*)AfxGetMainWnd())->ShowControlBar(&wndOutput, TRUE, FALSE);
wndOutput.m_wndText.RedrawWindow();
return OK;
}
else
return TOO_MANY_PARAMS;
}
if( stricmp(pszName, "hide") == 0 )
{
if( nParameters == 0 )
{
((CMainFrame*)AfxGetMainWnd())->ShowControlBar(&wndOutput, FALSE, FALSE);
return OK;
}
else
return TOO_MANY_PARAMS;
}
if( stricmp(pszName, "clear") == 0 )
{
if( nParameters == 0 )
{
wndOutput.Clear();
wndOutput.m_wndText.RedrawWindow();
return OK;
}
else
return TOO_MANY_PARAMS;
}
return NOT_FOUND;
}