-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextEditor.h
69 lines (60 loc) · 1.95 KB
/
TextEditor.h
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
#ifndef TEXTEDITOR_H
#define TEXTEDITOR_H
#include <Windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <string>
#include <commctrl.h>
#include <winuser.h>
#pragma comment(lib, "Comctl32.lib")
#include <memory>
#include <functional>
#include <iostream>
using namespace std;
#include "TabControl.h"
#include "DocumentText.h"
class TextEditor {
public:
CommandHistory commandHistory;
HWND hMainWindow;
HMENU hMenu;
static HINSTANCE hInstance;
TabControl* tabControl = nullptr;
vector<unique_ptr<DocumentText>> documents;
int m_nFontHeight = 16;
static const int LONGEST_LINE = 1024;
TextEditor();
void undo();
void redo();
void setCursorPosition(size_t position);
void updateEditControl();
void show();
static LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
static void setInstance(HINSTANCE hInst);
LRESULT OnPaint(HWND hWnd);
void SubclassEditControl(HWND hEditControl);
DocumentText* currentDocument;
private:
void registerWindowClass();
void createMainWindow();
void addMenus();
void addControls();
LRESULT handleMessage(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
void handleException(const std::exception& e);
void handleUnknownException();
LRESULT handleCommand(WPARAM wp, LPARAM lp);
void createNewTab();
void openFile();
void saveFile();
void saveFileAs();
void saveAllFiles();
void displayFile(DocumentText* document, HWND editControl);
void writeFile(const std::wstring& path, DocumentText* document);
void updateWindowTitle();
LONG PaintLine(HDC hdc, ULONG nLineNo, DocumentText* document, const RECT& clientRect);
static LRESULT CALLBACK SubclassEditProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
DocumentText* getCurrentDocument();
void SynchronizeDocumentWithEdit(HWND hEditControl);
};
#endif // TEXTEDITOR_H