summaryrefslogtreecommitdiff
path: root/plugins/SpellChecker/src/RichEdit.h
blob: e65f04d3cf7235d91c489c6d5d31f4cb04593eb9 (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
#ifndef __RICHEDIT_H__
#define __RICHEDIT_H__

class RichEdit
{
	HWND m_hwnd;
	IRichEditOle *m_ole;
	ITextDocument *m_textDocument;

	int m_stopped;
	BOOL m_undoEnabled;
	POINT m_old_scroll_pos;
	CHARRANGE m_old_sel;
	POINT m_caretPos;
	uint32_t m_old_mask;
	BOOL m_inverse;

public:
	RichEdit(HWND hwnd);
	~RichEdit();

	bool IsValid() const;
	HWND GetHWND() const;

	LRESULT SendMessage(UINT Msg, WPARAM wParam, LPARAM lParam) const;

	bool IsReadOnly() const;

	void SuspendUndo();
	void ResumeUndo();
	void Stop();
	void Start();
	BOOL IsStopped();

	int GetCharFromPos(const POINT &pt);

	int GetLineCount() const;
	void GetLine(int line, wchar_t *text, size_t text_len) const;
	int GetLineLength(int line) const;
	int GetFirstCharOfLine(int line) const;
	int GetLineFromChar(int charPos) const;

	CHARRANGE GetSel() const;
	void SetSel(int start, int end);
	void SetSel(const CHARRANGE &sel);

	wchar_t* GetText(int start, int end) const;
	int GetTextLength() const;

	void ReplaceSel(const wchar_t *new_text);
	int Replace(int start, int end, const wchar_t *new_text);
	int Insert(int pos, const wchar_t *text);
	int Delete(int start, int end);

private:
	void SetHWND(HWND hwnd);

	int FixSel(CHARRANGE *to_fix, CHARRANGE sel_changed, int new_len);
};

#endif // __RICHEDIT_H__