summaryrefslogtreecommitdiff
path: root/plugins/NewStory/src/history_control.h
blob: 2e1e6901f65682f5c465a66549a6a8a07b22bd3d (plain)
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
#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,
	NSM_ADDRESULTS,

	// 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 cachedMaxDrawnItem = -1;
	int cachedScrollbarPos = -1;
	unsigned int cachedScrollbarPage = -1;
	int totalCount;

	RECT rcLastPaint;

	bool bWasShift, bSortAscending, hasData, bScrollBottom;

	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);
	void      LineUp();
	void      LineDown();
	ItemData* LoadItem(int idx);
	void      PageUp();
	void      PageDown();
	int       PaintItem(HDC hdc, int index, int top, int width);
	void      RecalcScrollBar();
	void      ScheduleDraw();
	void      ScrollTop();
	void      ScrollBottom();
	void      SetCaret(int idx, bool bEnsureVisible = true);
	void      SetPos(int pos);
	void      SetSelection(int iFirst, int iLast);
	void      ToggleBookmark();
	void      ToggleSelection(int iFirst, int iLast);
};

void InitNewstoryControl();

#endif // __history_control_h__