ReactOS 0.4.15-dev-7201-g2de6e75
CTextEditWindow Class Reference

#include <textedit.h>

Inheritance diagram for CTextEditWindow:
Collaboration diagram for CTextEditWindow:

Public Member Functions

 CTextEditWindow ()
 
HWND Create (HWND hwndParent)
 
void DoFillBack (HWND hwnd, HDC hDC)
 
void FixEditPos (LPCWSTR pszOldText)
 
void InvalidateEditRect ()
 
void UpdateFont ()
 
BOOL GetEditRect (LPRECT prc) const
 
void ValidateEditRect (LPCRECT prc OPTIONAL)
 
HFONT GetFont () const
 
 MESSAGE_HANDLER (WM_NCCALCSIZE, OnNCCalcSize)
 
 MESSAGE_HANDLER (WM_NCHITTEST, OnNCHitTest)
 
 MESSAGE_HANDLER (WM_SETCURSOR, OnSetCursor)
 
 MESSAGE_HANDLER (WM_MOVE, OnMove)
 
 MESSAGE_HANDLER (WM_SIZE, OnSize)
 
 MESSAGE_HANDLER (WM_LBUTTONDOWN, OnLButtonDown)
 
 MESSAGE_HANDLER (EM_SETSEL, OnSetSel)
 
 MESSAGE_HANDLER (WM_MOUSEWHEEL, OnMouseWheel)
 
 MESSAGE_HANDLER (WM_CUT, OnCut)
 
 MESSAGE_HANDLER (WM_PASTE, OnPaste)
 
 MESSAGE_HANDLER (WM_CLEAR, OnClear)
 
LRESULT OnCreate (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnClose (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnToolsModelToolChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnToolsModelSettingsChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnToolsModelZoomChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnPaletteModelColorChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMoving (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSizing (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnChar (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnKeyDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnEraseBkGnd (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnPaint (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnNCPaint (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnNCCalcSize (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnNCHitTest (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSetCursor (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMove (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSize (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSetSel (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMouseWheel (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnCut (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnPaste (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnClear (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 

Protected Member Functions

INT DoHitTest (RECT &rc, POINT pt)
 
void DrawGrip (HDC hDC, RECT &rc)
 

Protected Attributes

HWND m_hwndParent
 
HFONT m_hFont
 
HFONT m_hFontZoomed
 
RECT m_rc
 

Detailed Description

Definition at line 13 of file textedit.h.

Constructor & Destructor Documentation

◆ CTextEditWindow()

CTextEditWindow::CTextEditWindow ( )

Definition at line 16 of file textedit.cpp.

17 : m_hFont(NULL)
19{
21}
HFONT m_hFontZoomed
Definition: textedit.h:82
HFONT m_hFont
Definition: textedit.h:81
#define NULL
Definition: types.h:112
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)

Member Function Documentation

◆ Create()

HWND CTextEditWindow::Create ( HWND  hwndParent)

Definition at line 224 of file textedit.cpp.

225{
227
230 HWND hwnd = ::CreateWindowEx(0, WC_EDIT, NULL, style, 0, 0, 0, 0,
232 if (hwnd)
233 {
234#undef SubclassWindow // Don't use this macro
236
237 UpdateFont();
238
239 PostMessage(WM_SIZE, 0, 0);
240 }
241
242 return m_hWnd;
243}
Arabic default style
Definition: afstyles.h:94
HINSTANCE g_hinstExe
Definition: main.cpp:17
HWND m_hwndParent
Definition: textedit.h:80
void UpdateFont()
Definition: textedit.cpp:326
static HWND hwndParent
Definition: cryptui.c:300
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WS_CHILD
Definition: pedump.c:617
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define ES_WANTRETURN
Definition: pedump.c:676
#define ES_LEFT
Definition: pedump.c:664
#define ES_MULTILINE
Definition: pedump.c:667
#define WS_THICKFRAME
Definition: pedump.c:630
#define WC_EDIT
Definition: commctrl.h:4689
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define SubclassWindow(hwnd, lpfn)
Definition: windowsx.h:542
#define CreateWindowEx
Definition: winuser.h:5754
#define WM_SIZE
Definition: winuser.h:1610
#define PostMessage
Definition: winuser.h:5831

Referenced by TextTool::OnButtonDown(), and TextTool::OnButtonUp().

◆ DoFillBack()

void CTextEditWindow::DoFillBack ( HWND  hwnd,
HDC  hDC 
)

Definition at line 245 of file textedit.cpp.

246{
248 return;
249
250 RECT rc;
251 SendMessage(EM_GETRECT, 0, (LPARAM)&rc);
252 MapWindowPoints(hwnd, (LPPOINT)&rc, 2);
253
255 FillRect(hDC, &rc, hbr);
256 DeleteObject(hbr);
257}
static HDC hDC
Definition: 3dtext.c:33
ToolsModel toolsModel
Definition: toolsmodel.cpp:10
COLORREF GetBgColor() const
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:249
pKey DeleteObject()
PaletteModel paletteModel
LONG_PTR LPARAM
Definition: windef.h:208
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define EM_GETRECT
Definition: winuser.h:1995
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define SendMessage
Definition: winuser.h:5842

◆ DoHitTest()

INT CTextEditWindow::DoHitTest ( RECT rc,
POINT  pt 
)
protected

Definition at line 23 of file textedit.cpp.

24{
25 switch (getSizeBoxHitTest(pt, &rc))
26 {
27 case HIT_NONE: return HTNOWHERE;
28 case HIT_UPPER_LEFT: return HTTOPLEFT;
29 case HIT_UPPER_CENTER: return HTTOP;
30 case HIT_UPPER_RIGHT: return HTTOPRIGHT;
31 case HIT_MIDDLE_LEFT: return HTLEFT;
32 case HIT_MIDDLE_RIGHT: return HTRIGHT;
33 case HIT_LOWER_LEFT: return HTBOTTOMLEFT;
34 case HIT_LOWER_CENTER: return HTBOTTOM;
35 case HIT_LOWER_RIGHT: return HTBOTTOMRIGHT;
36 case HIT_BORDER: return HTCAPTION; // Enable drag move
37 case HIT_INNER: return HTCLIENT;
38 }
39 return HTNOWHERE;
40}
@ HIT_NONE
Definition: precomp.h:56
@ HIT_BORDER
Definition: precomp.h:65
@ HIT_LOWER_RIGHT
Definition: precomp.h:64
@ HIT_LOWER_CENTER
Definition: precomp.h:63
@ HIT_UPPER_LEFT
Definition: precomp.h:57
@ HIT_INNER
Definition: precomp.h:66
@ HIT_LOWER_LEFT
Definition: precomp.h:62
@ HIT_UPPER_CENTER
Definition: precomp.h:58
@ HIT_UPPER_RIGHT
Definition: precomp.h:59
@ HIT_MIDDLE_RIGHT
Definition: precomp.h:61
@ HIT_MIDDLE_LEFT
Definition: precomp.h:60
#define pt(x, y)
Definition: drawing.c:79
HITTEST getSizeBoxHitTest(POINT pt, LPCRECT prcBase)
Definition: sizebox.cpp:80
#define HTTOPRIGHT
Definition: winuser.h:2491
#define HTCAPTION
Definition: winuser.h:2475
#define HTTOPLEFT
Definition: winuser.h:2490
#define HTBOTTOM
Definition: winuser.h:2492
#define HTRIGHT
Definition: winuser.h:2488
#define HTCLIENT
Definition: winuser.h:2474
#define HTBOTTOMRIGHT
Definition: winuser.h:2494
#define HTNOWHERE
Definition: winuser.h:2473
#define HTBOTTOMLEFT
Definition: winuser.h:2493
#define HTTOP
Definition: winuser.h:2489
#define HTLEFT
Definition: winuser.h:2486

Referenced by OnNCHitTest().

◆ DrawGrip()

void CTextEditWindow::DrawGrip ( HDC  hDC,
RECT rc 
)
protected

Definition at line 42 of file textedit.cpp.

43{
44 drawSizeBoxes(hDC, &rc, TRUE, NULL);
45}
#define TRUE
Definition: types.h:120
VOID drawSizeBoxes(HDC hdc, LPCRECT prcBase, BOOL bDrawFrame, LPCRECT prcPaint)
Definition: sizebox.cpp:103

Referenced by OnNCPaint(), and OnPaint().

◆ FixEditPos()

void CTextEditWindow::FixEditPos ( LPCWSTR  pszOldText)

Definition at line 47 of file textedit.cpp.

48{
49 CStringW szText;
50 GetWindowText(szText);
51
52 RECT rcParent;
53 ::GetWindowRect(m_hwndParent, &rcParent);
54
55 CRect rc, rcWnd, rcText;
56 GetWindowRect(&rcWnd);
57 rcText = rcWnd;
58
59 HDC hDC = GetDC();
60 if (hDC)
61 {
65 szText += L"x"; // This is a trick to enable the g_ptEnd newlines
66 const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
68 DrawTextW(hDC, szText, -1, &rcText, uFormat | DT_CALCRECT);
69 if (tm.tmDescent > 0)
70 rcText.bottom += tm.tmDescent;
72 }
73
74 UnionRect(&rc, &rcText, &rcWnd);
76
77 rcWnd = rc;
78 ::GetClientRect(m_hwndParent, &rcParent);
79 rc.IntersectRect(&rcParent, &rcWnd);
80
81 MoveWindow(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE);
82
85
87}
BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2) noexcept
Definition: atltypes.h:346
#define FALSE
Definition: types.h:117
static HDC
Definition: imagelist.c:92
unsigned int UINT
Definition: ndis.h:50
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define L(x)
Definition: ntvdm.h:50
#define DefWindowProc
Definition: ros2win.h:31
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
Definition: time.h:68
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define GetTextMetrics
Definition: wingdi.h:4474
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define DT_NOPREFIX
Definition: winuser.h:537
#define WM_HSCROLL
Definition: winuser.h:1742
#define WM_VSCROLL
Definition: winuser.h:1743
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SB_LEFT
Definition: winuser.h:575
#define DT_NOCLIP
Definition: winuser.h:536
#define DT_LEFT
Definition: winuser.h:534
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_TOP
Definition: winuser.h:542
#define DT_WORDBREAK
Definition: winuser.h:544
HDC WINAPI GetDC(_In_opt_ HWND)
#define GetWindowText
Definition: winuser.h:5797
#define SB_TOP
Definition: winuser.h:578
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define DT_EXPANDTABS
Definition: winuser.h:532
#define DT_CALCRECT
Definition: winuser.h:526
BOOL WINAPI UnionRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define DT_EDITCONTROL
Definition: winuser.h:528
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by OnChar(), OnKeyDown(), OnPaste(), and UpdateFont().

◆ GetEditRect()

BOOL CTextEditWindow::GetEditRect ( LPRECT  prc) const

Definition at line 377 of file textedit.cpp.

378{
379 *prc = m_rc;
380 return TRUE;
381}
_Out_ LPRECT prc
Definition: ntgdi.h:1658

Referenced by TextTool::draw().

◆ GetFont()

HFONT CTextEditWindow::GetFont ( ) const
inline

Definition at line 25 of file textedit.h.

25{ return m_hFont; }

Referenced by TextTool::draw().

◆ InvalidateEditRect()

void CTextEditWindow::InvalidateEditRect ( )

Definition at line 281 of file textedit.cpp.

282{
283 RECT rc;
284 GetWindowRect(&rc);
287
288 GetClientRect(&rc);
291 m_rc = rc;
292}
CCanvasWindow canvasWindow
Definition: canvas.cpp:10
VOID CanvasToImage(POINT &pt)
Definition: canvas.cpp:53

Referenced by TextTool::draw(), and OnSetSel().

◆ MESSAGE_HANDLER() [1/11]

CTextEditWindow::MESSAGE_HANDLER ( EM_SETSEL  ,
OnSetSel   
)

◆ MESSAGE_HANDLER() [2/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_CLEAR  ,
OnClear   
)

◆ MESSAGE_HANDLER() [3/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_CUT  ,
OnCut   
)

◆ MESSAGE_HANDLER() [4/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_LBUTTONDOWN  ,
OnLButtonDown   
)

◆ MESSAGE_HANDLER() [5/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_MOUSEWHEEL  ,
OnMouseWheel   
)

◆ MESSAGE_HANDLER() [6/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_MOVE  ,
OnMove   
)

◆ MESSAGE_HANDLER() [7/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_NCCALCSIZE  ,
OnNCCalcSize   
)

◆ MESSAGE_HANDLER() [8/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_NCHITTEST  ,
OnNCHitTest   
)

◆ MESSAGE_HANDLER() [9/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_PASTE  ,
OnPaste   
)

◆ MESSAGE_HANDLER() [10/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_SETCURSOR  ,
OnSetCursor   
)

◆ MESSAGE_HANDLER() [11/11]

CTextEditWindow::MESSAGE_HANDLER ( WM_SIZE  ,
OnSize   
)

◆ OnChar()

LRESULT CTextEditWindow::OnChar ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 89 of file textedit.cpp.

90{
91 if (wParam == VK_TAB)
92 return 0; // FIXME: Tabs
93
94 CStringW szText;
95 GetWindowText(szText);
96
98 FixEditPos(szText);
99
100 return ret;
101}
void FixEditPos(LPCWSTR pszOldText)
Definition: textedit.cpp:47
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
int ret
LONG_PTR LRESULT
Definition: windef.h:209
#define VK_TAB
Definition: winuser.h:2198

◆ OnClear()

LRESULT CTextEditWindow::OnClear ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 513 of file textedit.cpp.

514{
516 Invalidate(TRUE); // Redraw
517 return ret;
518}

◆ OnClose()

LRESULT CTextEditWindow::OnClose ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 265 of file textedit.cpp.

266{
268 if (m_hFont)
269 {
271 m_hFont = NULL;
272 }
273 if (m_hFontZoomed)
274 {
277 }
278 return 0;
279}
#define SW_HIDE
Definition: winuser.h:767
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)

◆ OnCreate()

LRESULT CTextEditWindow::OnCreate ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 259 of file textedit.cpp.

260{
261 UpdateFont();
262 return 0;
263}

◆ OnCut()

LRESULT CTextEditWindow::OnCut ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 499 of file textedit.cpp.

500{
502 Invalidate(TRUE); // Redraw
503 return ret;
504}

◆ OnEraseBkGnd()

LRESULT CTextEditWindow::OnEraseBkGnd ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 127 of file textedit.cpp.

128{
129 HDC hDC = (HDC)wParam;
131 {
132 RECT rc;
133 GetClientRect(&rc);
135 FillRect(hDC, &rc, hbr);
136 DeleteObject(hbr);
137 }
139 return TRUE;
140}
COLORREF GetFgColor() const
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918

◆ OnKeyDown()

LRESULT CTextEditWindow::OnKeyDown ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 103 of file textedit.cpp.

104{
105 if (wParam == VK_ESCAPE)
106 {
108 return 0;
109 }
110
111 CStringW szText;
112 GetWindowText(szText);
113
115 FixEditPos(szText);
116 return ret;
117}
void OnEndDraw(BOOL bCancel)
Definition: mouse.cpp:1178
#define VK_ESCAPE
Definition: winuser.h:2213

◆ OnLButtonDown()

LRESULT CTextEditWindow::OnLButtonDown ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 119 of file textedit.cpp.

120{
124 return ret;
125}

◆ OnMouseWheel()

LRESULT CTextEditWindow::OnMouseWheel ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 494 of file textedit.cpp.

495{
496 return ::SendMessageW(GetParent(), nMsg, wParam, lParam);
497}
HWND WINAPI GetParent(_In_ HWND)

◆ OnMove()

LRESULT CTextEditWindow::OnMove ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 205 of file textedit.cpp.

206{
208 return ret;
209}

◆ OnMoving()

LRESULT CTextEditWindow::OnMoving ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 394 of file textedit.cpp.

395{
396 // Restrict the window position to the image area
397 LPRECT prcMoving = (LPRECT)lParam;
398 CRect rcMoving = *prcMoving;
399
400 CRect rcImage;
401 canvasWindow.GetImageRect(rcImage);
403 canvasWindow.MapWindowPoints(NULL, &rcImage);
404
405 CRect rcWnd;
406 GetWindowRect(&rcWnd);
407 INT cx = rcWnd.Width(), cy = rcWnd.Height();
408
409 if (rcMoving.left < rcImage.left)
410 {
411 rcMoving.left = rcImage.left;
412 rcMoving.right = rcImage.left + cx;
413 }
414 else if (rcMoving.right > rcImage.right)
415 {
416 rcMoving.right = rcImage.right;
417 rcMoving.left = rcImage.right - cx;
418 }
419
420 if (rcMoving.top < rcImage.top)
421 {
422 rcMoving.top = rcImage.top;
423 rcMoving.bottom = rcImage.top + cy;
424 }
425 else if (rcMoving.bottom > rcImage.bottom)
426 {
427 rcMoving.bottom = rcImage.bottom;
428 rcMoving.top = rcImage.bottom - cy;
429 }
430
431 *prcMoving = rcMoving;
432 Invalidate(TRUE);
433 return TRUE;
434}
VOID ImageToCanvas(POINT &pt)
Definition: canvas.cpp:40
VOID GetImageRect(RECT &rc)
Definition: canvas.cpp:66
int Width() const noexcept
Definition: atltypes.h:461
int Height() const noexcept
Definition: atltypes.h:318
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
int32_t INT
Definition: typedefs.h:58
#define LPRECT
Definition: precomp.h:28

◆ OnNCCalcSize()

LRESULT CTextEditWindow::OnNCCalcSize ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 175 of file textedit.cpp.

176{
177 return 0; // No frame.
178}

◆ OnNCHitTest()

LRESULT CTextEditWindow::OnNCHitTest ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 180 of file textedit.cpp.

181{
183 RECT rc;
184 GetWindowRect(&rc);
185 return DoHitTest(rc, pt);
186}
INT DoHitTest(RECT &rc, POINT pt)
Definition: textedit.cpp:23
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299

◆ OnNCPaint()

LRESULT CTextEditWindow::OnNCPaint ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 159 of file textedit.cpp.

160{
161 CRect rc;
162 GetWindowRect(&rc);
163
165 if (hDC)
166 {
167 rc.OffsetRect(-rc.left, -rc.top);
168 DrawGrip(hDC, rc);
169 ReleaseDC(hDC);
170 }
171
172 return 0;
173}
void OffsetRect(int x, int y) noexcept
Definition: atltypes.h:403
void DrawGrip(HDC hDC, RECT &rc)
Definition: textedit.cpp:42
#define DCX_WINDOW
Definition: winuser.h:2112
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define DCX_PARENTCLIP
Definition: winuser.h:2114

◆ OnPaint()

LRESULT CTextEditWindow::OnPaint ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 142 of file textedit.cpp.

143{
144 RECT rc;
145 GetClientRect(&rc);
146
148
149 HDC hDC = GetDC();
150 if (hDC)
151 {
152 DrawGrip(hDC, rc);
153 ReleaseDC(hDC);
154 }
155
156 return 0;
157}

◆ OnPaletteModelColorChanged()

LRESULT CTextEditWindow::OnPaletteModelColorChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 294 of file textedit.cpp.

295{
296 UpdateFont();
297 return 0;
298}

◆ OnPaste()

LRESULT CTextEditWindow::OnPaste ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 506 of file textedit.cpp.

507{
510 return ret;
511}

◆ OnSetCursor()

LRESULT CTextEditWindow::OnSetCursor ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 188 of file textedit.cpp.

189{
191 {
192 bHandled = FALSE;
193 return 0;
194 }
195
196 UINT nHitTest = LOWORD(lParam);
197 if (nHitTest == HTCAPTION)
198 {
199 ::SetCursor(::LoadCursorW(NULL, (LPCWSTR)IDC_SIZEALL)); // Enable drag move
200 return FALSE;
201 }
202 return DefWindowProc(nMsg, wParam, lParam);
203}
static BOOL IsWaiting()
Definition: CWaitCursor.h:40
#define LOWORD(l)
Definition: pedump.c:82
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define IDC_SIZEALL
Definition: winuser.h:696
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ OnSetSel()

LRESULT CTextEditWindow::OnSetSel ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 368 of file textedit.cpp.

369{
374 return ret;
375}
void InvalidateEditRect()
Definition: textedit.cpp:281

◆ OnSize()

LRESULT CTextEditWindow::OnSize ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 211 of file textedit.cpp.

212{
214
215 RECT rc;
216 GetClientRect(&rc);
219
220 return ret;
221}
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define EC_RIGHTMARGIN
Definition: winuser.h:2606
#define EM_SETRECTNP
Definition: winuser.h:2016
#define EC_LEFTMARGIN
Definition: winuser.h:2605
#define EM_SETMARGINS
Definition: winuser.h:2011

◆ OnSizing()

LRESULT CTextEditWindow::OnSizing ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 436 of file textedit.cpp.

437{
438 // Restrict the window size to the image area
439 LPRECT prcSizing = (LPRECT)lParam;
440 CRect rcSizing = *prcSizing;
441
442 CRect rcImage;
443 canvasWindow.GetImageRect(rcImage);
445 canvasWindow.MapWindowPoints(NULL, &rcImage);
446
447 // Horizontally
448 switch (wParam)
449 {
450 case WMSZ_BOTTOMLEFT:
451 case WMSZ_LEFT:
452 case WMSZ_TOPLEFT:
453 if (rcSizing.left < rcImage.left)
454 rcSizing.left = rcImage.left;
455 break;
456 case WMSZ_BOTTOMRIGHT:
457 case WMSZ_RIGHT:
458 case WMSZ_TOPRIGHT:
459 if (rcSizing.right > rcImage.right)
460 rcSizing.right = rcImage.right;
461 break;
462 case WMSZ_TOP:
463 case WMSZ_BOTTOM:
464 default:
465 break;
466 }
467
468 // Vertically
469 switch (wParam)
470 {
471 case WMSZ_BOTTOM:
472 case WMSZ_BOTTOMLEFT:
473 case WMSZ_BOTTOMRIGHT:
474 if (rcSizing.bottom > rcImage.bottom)
475 rcSizing.bottom = rcImage.bottom;
476 break;
477 case WMSZ_TOP:
478 case WMSZ_TOPLEFT:
479 case WMSZ_TOPRIGHT:
480 if (rcSizing.top < rcImage.top)
481 rcSizing.top = rcImage.top;
482 break;
483 case WMSZ_LEFT:
484 case WMSZ_RIGHT:
485 default:
486 break;
487 }
488
489 *prcSizing = rcSizing;
490 Invalidate(TRUE);
491 return TRUE;
492}
#define WMSZ_BOTTOMRIGHT
Definition: winuser.h:2470
#define WMSZ_BOTTOMLEFT
Definition: winuser.h:2469
#define WMSZ_TOP
Definition: winuser.h:2465
#define WMSZ_LEFT
Definition: winuser.h:2463
#define WMSZ_TOPLEFT
Definition: winuser.h:2466
#define WMSZ_TOPRIGHT
Definition: winuser.h:2467
#define WMSZ_BOTTOM
Definition: winuser.h:2468
#define WMSZ_RIGHT
Definition: winuser.h:2464

◆ OnToolsModelSettingsChanged()

LRESULT CTextEditWindow::OnToolsModelSettingsChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 300 of file textedit.cpp.

301{
302 UpdateFont();
303 return 0;
304}

◆ OnToolsModelToolChanged()

LRESULT CTextEditWindow::OnToolsModelToolChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 313 of file textedit.cpp.

314{
315 if (wParam == TOOL_TEXT)
316 {
317 UpdateFont();
318 }
319 else
320 {
322 }
323 return 0;
324}
@ TOOL_TEXT
Definition: toolsmodel.h:21

◆ OnToolsModelZoomChanged()

LRESULT CTextEditWindow::OnToolsModelZoomChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 306 of file textedit.cpp.

307{
308 UpdateFont();
310 return 0;
311}
void ValidateEditRect(LPCRECT prc OPTIONAL)
Definition: textedit.cpp:383

◆ UpdateFont()

void CTextEditWindow::UpdateFont ( )

Definition at line 326 of file textedit.cpp.

327{
328 if (m_hFont)
329 {
331 m_hFont = NULL;
332 }
333 if (m_hFontZoomed)
334 {
337 }
338
339 LOGFONTW lf;
340 ZeroMemory(&lf, sizeof(lf));
341 lf.lfCharSet = DEFAULT_CHARSET; // registrySettings.CharSet; // Ignore
346
347 HDC hdc = GetDC();
348 if (hdc)
349 {
350 INT nFontSize = registrySettings.PointSize;
351 lf.lfHeight = -MulDiv(nFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
352 ReleaseDC(hdc);
353 }
354
356
357 lf.lfHeight = Zoomed(lf.lfHeight);
359
362
364
365 Invalidate();
366}
RegistrySettings registrySettings
Definition: registry.cpp:14
DWORD PointSize
Definition: registry.h:34
DWORD Underline
Definition: registry.h:37
CStringW strFontName
Definition: registry.h:33
HDC hdc
Definition: main.c:9
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
BYTE lfItalic
Definition: dimm.idl:64
LONG lfHeight
Definition: dimm.idl:59
LONG lfWeight
Definition: dimm.idl:63
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
BYTE lfUnderline
Definition: dimm.idl:65
BYTE lfCharSet
Definition: dimm.idl:67
static int Zoomed(int xy)
Definition: toolsmodel.h:150
#define ZeroMemory
Definition: winbase.h:1712
#define SetWindowFont(hwnd, hfont, fRedraw)
Definition: windowsx.h:533
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define FW_BOLD
Definition: wingdi.h:378
#define LOGPIXELSY
Definition: wingdi.h:719
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define FW_NORMAL
Definition: wingdi.h:373
#define CreateFontIndirect
Definition: wingdi.h:4444
unsigned char BYTE
Definition: xxhash.c:193

Referenced by Create(), OnCreate(), OnPaletteModelColorChanged(), OnToolsModelSettingsChanged(), OnToolsModelToolChanged(), and OnToolsModelZoomChanged().

◆ ValidateEditRect()

void CTextEditWindow::ValidateEditRect ( LPCRECT prc  OPTIONAL)

Definition at line 383 of file textedit.cpp.

384{
385 if (prc)
386 m_rc = *prc;
387
388 CRect rc = m_rc;
390
391 MoveWindow(rc.left, rc.top, rc.Width(), rc.Height(), TRUE);
392}

Referenced by TextTool::OnButtonUp(), and OnToolsModelZoomChanged().

Member Data Documentation

◆ m_hFont

HFONT CTextEditWindow::m_hFont
protected

Definition at line 81 of file textedit.h.

Referenced by GetFont(), OnClose(), and UpdateFont().

◆ m_hFontZoomed

HFONT CTextEditWindow::m_hFontZoomed
protected

Definition at line 82 of file textedit.h.

Referenced by FixEditPos(), OnClose(), and UpdateFont().

◆ m_hwndParent

HWND CTextEditWindow::m_hwndParent
protected

Definition at line 80 of file textedit.h.

Referenced by Create(), FixEditPos(), and InvalidateEditRect().

◆ m_rc

RECT CTextEditWindow::m_rc
protected

Definition at line 83 of file textedit.h.

Referenced by CTextEditWindow(), GetEditRect(), InvalidateEditRect(), and ValidateEditRect().


The documentation for this class was generated from the following files: