1 /* 2 * PROJECT: PAINT for ReactOS 3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later) 4 * PURPOSE: Text editor and font chooser for the text tool 5 * COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net> 6 */ 7 8 #pragma once 9 10 #define CX_MINTEXTEDIT 100 11 #define CY_MINTEXTEDIT 24 12 13 class CTextEditWindow : public CWindowImpl<CTextEditWindow> 14 { 15 public: 16 CTextEditWindow(); 17 18 HWND Create(HWND hwndParent); 19 void DoFillBack(HWND hwnd, HDC hDC); 20 void FixEditPos(LPCWSTR pszOldText); 21 void InvalidateEditRect(); 22 void UpdateFont(); 23 BOOL GetEditRect(LPRECT prc) const; 24 void ValidateEditRect(LPCRECT prc OPTIONAL); 25 HFONT GetFont() const { return m_hFont; } 26 27 BEGIN_MSG_MAP(CTextEditWindow) 28 MESSAGE_HANDLER(WM_CREATE, OnCreate) 29 MESSAGE_HANDLER(WM_CLOSE, OnClose) 30 MESSAGE_HANDLER(WM_TOOLSMODELTOOLCHANGED, OnToolsModelToolChanged) 31 MESSAGE_HANDLER(WM_TOOLSMODELSETTINGSCHANGED, OnToolsModelSettingsChanged) 32 MESSAGE_HANDLER(WM_TOOLSMODELZOOMCHANGED, OnToolsModelZoomChanged) 33 MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged) 34 MESSAGE_HANDLER(WM_MOVING, OnMoving) 35 MESSAGE_HANDLER(WM_SIZING, OnSizing) 36 MESSAGE_HANDLER(WM_CHAR, OnChar) 37 MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) 38 MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkGnd) 39 MESSAGE_HANDLER(WM_PAINT, OnPaint) 40 MESSAGE_HANDLER(WM_NCPAINT, OnNCPaint) 41 MESSAGE_HANDLER(WM_NCCALCSIZE, OnNCCalcSize); 42 MESSAGE_HANDLER(WM_NCHITTEST, OnNCHitTest); 43 MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor); 44 MESSAGE_HANDLER(WM_MOVE, OnMove); 45 MESSAGE_HANDLER(WM_SIZE, OnSize); 46 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown); 47 MESSAGE_HANDLER(EM_SETSEL, OnSetSel); 48 MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel); 49 MESSAGE_HANDLER(WM_CUT, OnCut); 50 MESSAGE_HANDLER(WM_PASTE, OnPaste); 51 MESSAGE_HANDLER(WM_CLEAR, OnClear); 52 END_MSG_MAP() 53 54 LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 55 LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 56 LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 57 LRESULT OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 58 LRESULT OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 59 LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 60 LRESULT OnMoving(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 61 LRESULT OnSizing(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 62 LRESULT OnChar(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 63 LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 64 LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 65 LRESULT OnEraseBkGnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 66 LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 67 LRESULT OnNCPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 68 LRESULT OnNCCalcSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 69 LRESULT OnNCHitTest(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 70 LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 71 LRESULT OnMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 72 LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 73 LRESULT OnSetSel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 74 LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 75 LRESULT OnCut(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 76 LRESULT OnPaste(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 77 LRESULT OnClear(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 78 79 protected: 80 HWND m_hwndParent; 81 HFONT m_hFont; 82 HFONT m_hFontZoomed; 83 RECT m_rc; 84 85 INT DoHitTest(RECT& rc, POINT pt); 86 void DrawGrip(HDC hDC, RECT& rc); 87 }; 88