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
|
#ifndef __history_control_h__
#define __history_control_h__
#define NEWSTORYLIST_CLASS "NewstoryList"
struct NewstoryListData;
class NSWebPage : public document_container
{
typedef std::map<std::wstring, uint_ptr> images_map;
mir_cs m_csImages;
images_map m_images;
position::vector m_clips;
HRGN m_hClipRgn;
HDC m_tmp_hdc;
NewstoryListData &ctrl;
std::string resolve_color(const string &color) const;
uint_ptr get_image(LPCWSTR url_or_path, bool redraw_on_ready);
void get_client_rect(position &client) const override;
void import_css(string &text, const string &url, string &baseurl) override;
void on_anchor_click(const char *url, const element::ptr &el) override;
void set_base_url(const char *base_url) override;
void set_caption(const char *caption) override;
void set_cursor(const char *cursor) override;
void draw_image(uint_ptr hdc, const background_layer &layer, const std::string &url, const std::string &base_url) override;
void get_img_size(uint_ptr img, size &sz);
// document_container members
uint_ptr create_font(const char *faceName, int size, int weight, font_style italic, unsigned int decoration, font_metrics *fm) override;
void delete_font(uint_ptr hFont) override;
const char* get_default_font_name() const override;
int get_default_font_size() const override;
void draw_text(uint_ptr hdc, const char *text, uint_ptr hFont, web_color color, const position &pos) override;
int text_width(const char *text, uint_ptr hFont) override;
void transform_text(string &text, text_transform tt) override;
void draw_borders(uint_ptr hdc, const borders &borders, const position &draw_pos, bool root) override;
void draw_ellipse(HDC hdc, int x, int y, int width, int height, web_color color, int line_width);
void draw_list_marker(uint_ptr hdc, const list_marker &marker) override;
void draw_solid_fill(uint_ptr, const background_layer &, const web_color &) override;
void draw_linear_gradient(uint_ptr, const background_layer &, const background_layer::linear_gradient &) override;
void draw_radial_gradient(uint_ptr, const background_layer &, const background_layer::radial_gradient &) override;
void draw_conic_gradient(uint_ptr, const background_layer &, const background_layer::conic_gradient &) override;
void fill_ellipse(HDC hdc, int x, int y, int width, int height, web_color color);
void fill_rect(HDC hdc, int x, int y, int width, int height, web_color color);
int pt_to_px(int pt) const override;
void add_image(LPCWSTR url, uint_ptr img);
void load_image(const char *src, const char *baseurl, bool redraw_on_ready) override;
void get_image_size(const char *src, const char *baseurl, size &sz) override;
element::ptr create_element(const char *tag_name, const string_map &attributes, const document::ptr &doc) override;
void get_media_features(media_features &media) const override;
void get_language(string &language, string &culture) const override;
void link(const document::ptr &doc, const element::ptr &el) override;
void apply_clip(HDC hdc);
void del_clip() override;
void release_clip(HDC hdc);
void set_clip(const position &pos, const border_radiuses &bdr_radius) override;
void on_mouse_event(const litehtml::element::ptr &, litehtml::mouse_event) override {}
void clear_images();
public:
NSWebPage(NewstoryListData &_1);
~NSWebPage();
COLORREF clText = -1, clBack = -1;
FIBITMAP* find_image(const wchar_t *pwszUrl);
FIBITMAP* load_image(const wchar_t *pwszUrl, ItemData *pItem);
void draw();
};
struct NewstoryListData : public MZeroedObject
{
NewstoryListData(HWND);
mir_cs m_csItems;
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 cachedMaxTopItem; // the largest ID of top item to avoid empty space
int cachedMaxTopPixel;
int cachedWindowWidth = -1, cachedWindowHeight = -1;
int cachedMaxDrawnItem = -1;
int cachedScrollbarPos = -1, cachedScrollbarMax = -1;
int totalCount;
int iLineHeigth;
RECT rcLastPaint;
MCONTACT m_hContact = INVALID_CONTACT_ID;
bool bWasShift, bSortAscending, bWasAtBottom, bReadOnly;
HWND m_hwnd;
HWND hwndEditBox;
CTimer redrawTimer;
CSrmmBaseDialog *pMsgDlg = nullptr;
NSWebPage webPage;
simpledib::dib dib;
void OnContextMenu(int index, POINT pt);
void OnResize();
void onTimer_Draw(CTimer *pTimer);
void AddChatEvent(SESSION_INFO *si, const LOGINFO *lin);
void AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCount, bool bNew = false);
void AddResults(const OBJLIST<SearchResult> &results);
void AddSelection(int iFirst, int iLast);
bool AtBottom(void) const;
bool AtTop(void) const;
void BeginEditItem();
void CalcBottom();
void Clear();
void ClearSelection(int iFirst, int iLast);
void Copy(bool bTextOnly = false);
void CopyPath();
void CopyUrl();
void DeleteItems(void);
void DeliverEvent(MCONTACT hContact, MEVENT hEvent);
void Download(int iOptions);
void EndEditItem(bool bAccept);
void EnsureVisible(int item);
void EventUp();
void EventDown();
void EventPageUp();
void EventPageDown();
int FindNext(const wchar_t *pwszText);
int FindPrev(const wchar_t *pwszText);
void FixScrollPosition(bool bForce = false);
CMStringW GatherSelected(bool bTextOnly);
CMStringA GatherSelectedRtf();
ItemData* GetItem(int idx) const;
int GetItemFromPixel(int yPos);
int GetItemHeight(int index);
int GetItemHeight(ItemData *pItem);
bool HasSelection() const;
void HitTotal(int yCurr, int yTotal);
void LineUp(int iCount = 1);
void LineDown(int iCount = 1);
ItemData* LoadItem(int idx);
void MarkRead(ItemData *pItem);
void OpenFolder();
void PageUp();
void PageDown();
void Paint(simpledib::dib &dib);
void Quote();
void RecalcScrollBar();
void RemoteRead(MCONTACT hContact, MEVENT hEvent);
void Reply();
void ScheduleDraw();
void ScrollBottom();
void ScrollDown(int deltaY);
void ScrollTop();
void ScrollUp(int deltaY);
void SetCaret(int idx, bool bEnsureVisible = true);
void SetContact(MCONTACT hContact);
void SetDialog(CSrmmBaseDialog *pDialog);
void SetPos(int pos);
void SetSelection(int iFirst, int iLast);
void ToggleBookmark();
void ToggleSelection(int iFirst, int iLast);
void TryUp(int iCount);
};
void InitNewstoryControl();
INT_PTR SvcFileReady(WPARAM wParam, LPARAM);
#endif // __history_control_h__
|