forked from ddehilster/visualtext3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOutputBarEdit.cpp
196 lines (170 loc) · 4.95 KB
/
OutputBarEdit.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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*******************************************************************************
Copyright (c) 1999-2010 by Text Analysis International, Inc.
All rights reserved.
*******************************************************************************/
// OutputBarEdit.cpp : implementation file
//
#include "stdafx.h"
#include "kb.h"
#include "VisualText.h"
#include "OutputBarEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COutputBarEdit
COutputBarEdit::COutputBarEdit()
{
}
COutputBarEdit::~COutputBarEdit()
{
}
BEGIN_MESSAGE_MAP(COutputBarEdit, CEdit)
//{{AFX_MSG_MAP(COutputBarEdit)
ON_WM_HSCROLL()
//ON_WM_CREATE()
ON_WM_SIZE()
ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
ON_WM_KEYDOWN()
ON_WM_RBUTTONDOWN()
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutputBarEdit message handlers
void COutputBarEdit::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if (m_ScrollBarH.m_hWnd &&
pScrollBar->GetSafeHwnd() == m_ScrollBarH.m_hWnd)
{
SCROLLINFO si;
ZeroMemory(&si, sizeof(si));
si.cbSize = sizeof(si);
si.fMask = SIF_PAGE;
m_ScrollBarH.GetScrollInfo(&si);
int x = m_ScrollBarH.GetScrollPos();
switch (nSBCode)
{
case SB_TOP:
x = 0;
break;
case SB_BOTTOM:
x = INT_MAX;
break;
case SB_LINEUP:
x--;
break;
case SB_LINEDOWN:
x++;
break;
case SB_PAGEUP:
x -= si.nPage;
break;
case SB_PAGEDOWN:
x += si.nPage;
break;
case SB_THUMBTRACK:
x = nPos;
break;
}
si.nPos = x;
si.fMask = SIF_POS;
m_ScrollBarH.SetScrollInfo(&si);
}
CEdit::OnHScroll(nSBCode, nPos, pScrollBar);
}
CScrollBar* COutputBarEdit::GetScrollBarCtrl(int nBar) const
{
if (nBar == SB_HORZ)
{
CScrollBar *pSB = (CScrollBar *)&m_ScrollBarH;
SCROLLINFO si;
ZeroMemory(&si, sizeof(si));
si.cbSize = sizeof(si);
if (m_ScrollBarH.m_hWnd == NULL)
{
pSB->Create(WS_CHILD, CRect(0, 0, 0, 0), (CWnd *)this, 0);
si.fMask = SIF_ALL;
if (::GetScrollInfo(m_hWnd, SB_HORZ, &si))
{
pSB->SetScrollInfo (&si);
}
}
else
{
si.fMask = SIF_RANGE | SIF_POS;
::SendMessage(m_hWnd, WM_SETREDRAW, FALSE, 0);
::ShowScrollBar(m_hWnd, SB_HORZ, TRUE);
::GetScrollInfo(m_hWnd, SB_HORZ, &si);
::ShowScrollBar(m_hWnd, SB_HORZ, FALSE);
::SendMessage(m_hWnd, WM_SETREDRAW, TRUE, 0);
pSB->SetScrollInfo (&si);
}
return pSB;
}
return CEdit::GetScrollBarCtrl(nBar);
}
void COutputBarEdit::OnSize(UINT nType, int cx, int cy)
{
CEdit::OnSize(nType, cx, cy);
if (m_ScrollBarH.m_hWnd)
{
SCROLLINFO si;
ZeroMemory(&si, sizeof(si));
si.cbSize = sizeof(si);
CRect r;
GetClientRect(r);
si.fMask = SIF_PAGE;
si.nPage = r.Width() - 1;
m_ScrollBarH.SetScrollInfo(&si);
}
}
void COutputBarEdit::OnUpdate()
{
//CXTFlatTabCtrl *pParent = (CXTFlatTabCtrl *)GetParent();
//ASSERT_KINDOF(CXTFlatTabCtrl, pParent);
//pParent->SyncScrollBar();
}
void COutputBarEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
OnUpdate();
}
/*
int COutputBarEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CEdit::OnCreate(lpCreateStruct) == -1)
return -1;
m_hookCoolMenu.HookWindow(m_hWnd);
m_hookCoolMenu.LoadToolbar(IDR_MAINFRAME);
return 0;
}
*/
void COutputBarEdit::OnRButtonDown(UINT nFlags, CPoint point)
{
logmsg(_T("COutputBarEdit::OnRbuttonDown")); // 05/14/08 AM.
CPoint pt = point;
ClientToScreen(&pt);
CMenu menu;
VERIFY(menu.LoadMenu(IDR_POPUP));
CMenu* pPopup = menu.GetSubMenu(0);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y,
this);
}
BOOL COutputBarEdit::Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID )
{
dwStyle |= ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL;
if (!CEdit::Create(dwStyle, rect, pParentWnd, nID))
return FALSE;
return TRUE;
}
HBRUSH COutputBarEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here
pDC->SetTextColor( RGB(0x00,0x00,0x00) );
pDC->SetBkColor( RGB(0xFF,0xFF,0xFF) );
// TODO: Return a non-NULL brush if the parent's handler should not be called
return ::GetSysColorBrush(COLOR_WINDOW);
}