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
|
/*
Copyright (c) 2005 Victor Pavlychko (nullbyte@sotline.net.ua)
Copyright (C) 2012-24 Miranda NG team (https://miranda-ng.org)
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 version 2
of the License.
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, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
class CNewStoryLogWindow : public CSimpleLogWindow
{
HWND m_hwnd = nullptr;
NewstoryListData *m_histCtrl;
public:
CNewStoryLogWindow(CMsgDialog &pDlg) :
CSimpleLogWindow(pDlg)
{}
void Attach() override
{
RECT rc;
GetClientRect(GetDlgItem(m_pDlg.GetHwnd(), IDC_SRMM_LOG), &rc);
m_hwnd = ::CreateWindowW(_T(NEWSTORYLIST_CLASS), L"NewStory", WS_VISIBLE | WS_CHILD | WS_TABSTOP,
0, 0, rc.left - rc.right, rc.bottom - rc.top, m_pDlg.GetHwnd(), 0, m_pDlg.GetInst(), 0);
m_histCtrl = (NewstoryListData *)GetWindowLongPtr(m_hwnd, 0);
m_histCtrl->SetDialog(&m_pDlg);
}
void Detach() override
{
WindowList_Remove(g_hNewstoryLogs, m_pDlg.GetHwnd());
::DestroyWindow(m_hwnd);
}
//////////////////////////////////////////////////////////////////////////////////////
bool AtBottom() override
{
return m_histCtrl->AtBottom();
}
void Clear() override
{
m_histCtrl->Clear();
}
HWND GetHwnd() override
{
return m_hwnd;
}
wchar_t* GetSelectedText() override
{
return m_histCtrl->GatherSelected(true).Detach();
}
int GetType() override
{
return 1;
}
void LogEvents(MEVENT hDbEvent, int count, bool bAppend) override
{
if (!hDbEvent)
return;
if (!bAppend)
Clear();
m_histCtrl->AddEvent(m_pDlg.m_hContact, hDbEvent, count, true);
}
void LogChatEvent(const LOGINFO &lin) override
{
m_histCtrl->AddChatEvent(m_pDlg.getChat(), &lin);
}
void Resize() override
{
bool bottomScroll = AtBottom();
RECT rc;
GetWindowRect(GetDlgItem(m_pDlg.GetHwnd(), IDC_SRMM_LOG), &rc);
POINT pt = { rc.left, rc.top };
ScreenToClient(GetParent(m_hwnd), &pt);
::SetWindowPos(m_hwnd, 0, pt.x, pt.y, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOZORDER);
if (bottomScroll)
ScrollToBottom();
}
void ScrollToBottom() override
{
m_histCtrl->ScrollBottom();
}
};
CSrmmLogWindow *__cdecl NewStory_Stub(CMsgDialog &pDlg)
{
return new CNewStoryLogWindow(pDlg);
}
|