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
|
#ifndef __history_control_h__
#define __history_control_h__
#define NEWSTORYLIST_CLASS "NewstoryList"
struct ADDEVENTS
{
MCONTACT hContact;
MEVENT hFirstEVent;
int eventCount;
};
enum
{
NSM_FIRST = WM_USER + 100,
// wParam = fist item
// lParam = iLast item
// result = number of total selected items
NSM_SELECTITEMS = NSM_FIRST,
// add one or more events
NSM_ADDEVENTS,
NSM_ADDCHATEVENT,
// clear log
NSM_CLEAR,
// result = id
NSM_GETCARET,
// wParam = text
NSM_FINDNEXT,
NSM_FINDPREV,
// wParam = wtext
NSM_FINDNEXTW,
NSM_FINDPREVW,
//
NSM_COPY,
NSM_EXPORT,
NSM_DOWNLOAD,
//
NSM_GETCOUNT,
NSM_GETARRAY,
//
NSM_SEEKEND,
NSM_SEEKTIME,
//
NSM_SET_SRMM, // act inside SRMM dialog
NSM_SET_CONTACT, // set hContact
NSM_SET_OPTIONS, // options were changed
NSM_LAST
};
struct NewstoryListData : public MZeroedObject
{
NewstoryListData(HWND);
HistoryArray items;
int scrollTopItem; // topmost item
int scrollTopPixel; // y coord of topmost item, this should be negative or zero
int caret;
int selStart = -1;
int cachedWindowHeight;
int cachedMaxTopItem; // the largest ID of top item to avoid empty space
int cachedMaxTopPixel;
int cachedWindowWidth = -1;
int totalCount;
RECT rcLastPaint;
bool bWasShift, bSortAscending;
HWND hwnd;
HWND hwndEditBox;
CTimer redrawTimer;
CSrmmBaseDialog *pMsgDlg = nullptr;
void OnContextMenu(int index, POINT pt);
void OnResize(int newWidth);
void OnTimer(CTimer *pTimer);
void AddSelection(int iFirst, int iLast);
void BeginEditItem(int index, bool bReadOnly);
void ClearSelection(int iFirst, int iLast);
void DeleteItems(void);
void EndEditItem(bool bAccept);
void EnsureVisible(int item);
void FixScrollPosition();
ItemData* GetItem(int idx);
int GetItemFromPixel(int yPos);
int GetItemHeight(int index);
ItemData* LoadItem(int idx);
int PaintItem(HDC hdc, int index, int top, int width);
void RecalcScrollBar();
void ScheduleDraw();
void SetCaret(int idx, bool bEnsureVisible);
void SetPos(int pos);
void SetSelection(int iFirst, int iLast);
void ToggleSelection(int iFirst, int iLast);
void LineUp()
{
if (caret > 0)
SetPos(caret - 1);
}
void LineDown()
{
if (caret < totalCount - 1)
SetPos(caret + 1);
}
void PageUp()
{
if (caret > 10)
SetPos(caret - 10);
else
SetPos(0);
}
void PageDown()
{
if (totalCount) {
if (caret + 10 < totalCount - 1)
SetPos(caret + 10);
else
SetPos(totalCount - 1);
}
}
void ScrollTop()
{
SetPos(0);
}
void ScrollBottom()
{
if (totalCount)
SetPos(totalCount - 1);
}
};
void InitNewstoryControl();
#endif // __history_control_h__
|