Create a branch for console restructuration work.
[reactos.git] / base / applications / mspaint / textedit.c
1 /*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL
4 * FILE: base/applications/paint/textedit.c
5 * PURPOSE: Text editor and font chooser for the text tool
6 * PROGRAMMERS: Benedikt Freisen
7 */
8
9 /* INCLUDES *********************************************************/
10
11 #include "precomp.h"
12 #include "textedit.h"
13
14 /* FUNCTIONS ********************************************************/
15
16 void
17 RegisterWclTextEdit()
18 {
19 WNDCLASSEX wclTextEdit;
20 /* initializing and registering the window class used for the text editor */
21 wclTextEdit.hInstance = hProgInstance;
22 wclTextEdit.lpszClassName = _T("TextEdit");
23 wclTextEdit.lpfnWndProc = TextEditWinProc;
24 wclTextEdit.style = CS_DBLCLKS;
25 wclTextEdit.cbSize = sizeof(WNDCLASSEX);
26 wclTextEdit.hIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
27 wclTextEdit.hIconSm = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
28 wclTextEdit.hCursor = LoadCursor(NULL, IDC_ARROW);
29 wclTextEdit.lpszMenuName = NULL;
30 wclTextEdit.cbClsExtra = 0;
31 wclTextEdit.cbWndExtra = 0;
32 wclTextEdit.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
33 RegisterClassEx (&wclTextEdit);
34 }
35
36 LRESULT CALLBACK
37 TextEditWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
38 {
39 switch (message)
40 {
41 case WM_SIZE:
42 {
43 RECT clientRect;
44 GetClientRect(hwnd, &clientRect);
45 MoveWindow(hwndEditCtl, clientRect.left, clientRect.top, RECT_WIDTH(clientRect), RECT_HEIGHT(clientRect), TRUE);
46 break;
47 }
48 case WM_CLOSE:
49 ShowWindow(hwnd, SW_HIDE);
50 break;
51 case WM_COMMAND:
52 switch(HIWORD(wParam))
53 {
54 case EN_UPDATE:
55 {
56 HeapFree(GetProcessHeap(), 0, textToolText);
57 textToolTextMaxLen = GetWindowTextLength(hwndEditCtl) + 1;
58 textToolText = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(TCHAR) * textToolTextMaxLen);
59 GetWindowText(hwndEditCtl, textToolText, textToolTextMaxLen);
60 ForceRefreshSelectionContents();
61 break;
62 }
63 }
64 break;
65 default:
66 return DefWindowProc(hwnd, message, wParam, lParam);
67 }
68
69 return 0;
70 }