ReactOS  0.4.15-dev-4872-g8a3db97
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 (LPCTSTR 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)
 
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 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)
 

Protected Member Functions

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

Protected Attributes

HWND m_hwndParent
 
HFONT m_hFont
 
HFONT m_hFontZoomed
 
LONG m_nAppIsMovingOrSizing
 
RECT m_rc
 

Detailed Description

Definition at line 14 of file textedit.h.

Constructor & Destructor Documentation

◆ CTextEditWindow()

CTextEditWindow::CTextEditWindow ( )

Definition at line 17 of file textedit.cpp.

18 {
20 }
LONG m_nAppIsMovingOrSizing
Definition: textedit.h:74
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
HFONT m_hFontZoomed
Definition: textedit.h:73
#define NULL
Definition: types.h:112
HFONT m_hFont
Definition: textedit.h:72

Member Function Documentation

◆ Create()

HWND CTextEditWindow::Create ( HWND  hwndParent)

Definition at line 297 of file textedit.cpp.

298 {
300 
303  HWND hwnd = ::CreateWindowEx(0, WC_EDIT, NULL, style, 0, 0, 0, 0,
305  if (hwnd)
306  {
307 #undef SubclassWindow // Don't use this macro
309 
310  UpdateFont();
311 
312  PostMessage(WM_SIZE, 0, 0);
313  }
314 
315  return m_hWnd;
316 }
#define WS_THICKFRAME
Definition: pedump.c:630
#define ES_MULTILINE
Definition: pedump.c:667
#define WS_CHILD
Definition: pedump.c:617
#define SubclassWindow(hwnd, lpfn)
Definition: windowsx.h:517
#define CreateWindowEx
Definition: winuser.h:5735
#define ES_WANTRETURN
Definition: pedump.c:676
static HWND hwndParent
Definition: cryptui.c:300
#define PostMessage
Definition: winuser.h:5812
#define ES_AUTOVSCROLL
Definition: pedump.c:671
HWND m_hwndParent
Definition: textedit.h:71
#define WM_SIZE
Definition: winuser.h:1598
unsigned long DWORD
Definition: ntddk_ex.h:95
void UpdateFont()
Definition: textedit.cpp:402
HINSTANCE hProgInstance
Definition: main.cpp:50
#define NULL
Definition: types.h:112
#define WC_EDIT
Definition: commctrl.h:4689
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
Arabic default style
Definition: afstyles.h:93
#define ES_LEFT
Definition: pedump.c:664

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

◆ DoFillBack()

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

Definition at line 318 of file textedit.cpp.

319 {
321  return;
322 
323  RECT rc;
324  SendMessage(EM_GETRECT, 0, (LPARAM)&rc);
325  MapWindowPoints(hwnd, (LPPOINT)&rc, 2);
326 
327  HBRUSH hbr = CreateSolidBrush(paletteModel.GetBgColor());
328  FillRect(hDC, &rc, hbr);
329  DeleteObject(hbr);
330 }
ToolsModel toolsModel
Definition: main.cpp:18
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
COLORREF GetBgColor() const
LONG_PTR LPARAM
Definition: windef.h:208
static HDC hDC
Definition: 3dtext.c:33
PaletteModel paletteModel
Definition: main.cpp:28
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define SendMessage
Definition: winuser.h:5823
#define EM_GETRECT
Definition: winuser.h:1983
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:135

◆ DoHitTest()

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

Definition at line 37 of file textedit.cpp.

38 {
39  RECT rcGrip;
40 
41  SetRect(&rcGrip, RECT0);
42  if (PtInRect(&rcGrip, pt))
43  return HTTOPLEFT;
44  SetRect(&rcGrip, RECT1);
45  if (PtInRect(&rcGrip, pt))
46  return HTTOP;
47  SetRect(&rcGrip, RECT2);
48  if (PtInRect(&rcGrip, pt))
49  return HTTOPRIGHT;
50 
51  SetRect(&rcGrip, RECT3);
52  if (PtInRect(&rcGrip, pt))
53  return HTLEFT;
54  SetRect(&rcGrip, RECT4);
55  if (PtInRect(&rcGrip, pt))
56  return HTRIGHT;
57 
58  SetRect(&rcGrip, RECT5);
59  if (PtInRect(&rcGrip, pt))
60  return HTBOTTOMLEFT;
61  SetRect(&rcGrip, RECT6);
62  if (PtInRect(&rcGrip, pt))
63  return HTBOTTOM;
64  SetRect(&rcGrip, RECT7);
65  if (PtInRect(&rcGrip, pt))
66  return HTBOTTOMRIGHT;
67 
68  // On border line?
69  RECT rcInner = rc;
70  InflateRect(&rcInner, -3, -3);
71  if (!PtInRect(&rcInner, pt) && PtInRect(&rc, pt))
72  return HTCAPTION;
73 
74  return HTCLIENT;
75 }
#define HTTOP
Definition: winuser.h:2470
#define HTLEFT
Definition: winuser.h:2467
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define RECT5
Definition: textedit.cpp:33
#define RECT1
Definition: textedit.cpp:29
#define pt(x, y)
Definition: drawing.c:79
#define RECT3
Definition: textedit.cpp:31
#define RECT2
Definition: textedit.cpp:30
#define HTBOTTOMLEFT
Definition: winuser.h:2474
#define HTRIGHT
Definition: winuser.h:2469
#define RECT7
Definition: textedit.cpp:35
#define RECT6
Definition: textedit.cpp:34
#define HTTOPLEFT
Definition: winuser.h:2471
#define RECT4
Definition: textedit.cpp:32
#define HTTOPRIGHT
Definition: winuser.h:2472
#define HTBOTTOM
Definition: winuser.h:2473
#define RECT0
Definition: textedit.cpp:28
#define HTBOTTOMRIGHT
Definition: winuser.h:2475
#define HTCAPTION
Definition: winuser.h:2456
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define HTCLIENT
Definition: winuser.h:2455

Referenced by OnNCHitTest().

◆ DrawGrip()

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

Definition at line 77 of file textedit.cpp.

78 {
80  HPEN hPen = CreatePen(PS_DOT, 1, GetSysColor(COLOR_HIGHLIGHT));
81  HGDIOBJ hPenOld = SelectObject(hDC, hPen);
82  InflateRect(&rc, -1, -1);
83  Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
84  InflateRect(&rc, 1, 1);
85  SelectObject(hDC, hPenOld);
86  SelectObject(hDC, hbrOld);
87  DeleteObject(hPen);
88 
89  RECT rcGrip;
90  HBRUSH hbrHighlight = GetSysColorBrush(COLOR_HIGHLIGHT);
91 
92  SetRect(&rcGrip, RECT0);
93  FillRect(hDC, &rcGrip, hbrHighlight);
94  SetRect(&rcGrip, RECT1);
95  FillRect(hDC, &rcGrip, hbrHighlight);
96  SetRect(&rcGrip, RECT2);
97  FillRect(hDC, &rcGrip, hbrHighlight);
98 
99  SetRect(&rcGrip, RECT3);
100  FillRect(hDC, &rcGrip, hbrHighlight);
101  SetRect(&rcGrip, RECT4);
102  FillRect(hDC, &rcGrip, hbrHighlight);
103 
104  SetRect(&rcGrip, RECT5);
105  FillRect(hDC, &rcGrip, hbrHighlight);
106  SetRect(&rcGrip, RECT6);
107  FillRect(hDC, &rcGrip, hbrHighlight);
108  SetRect(&rcGrip, RECT7);
109  FillRect(hDC, &rcGrip, hbrHighlight);
110 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define RECT5
Definition: textedit.cpp:33
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define COLOR_HIGHLIGHT
Definition: winuser.h:920
#define RECT1
Definition: textedit.cpp:29
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define RECT3
Definition: textedit.cpp:31
#define NULL_BRUSH
Definition: wingdi.h:901
#define RECT2
Definition: textedit.cpp:30
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:306
#define RECT7
Definition: textedit.cpp:35
LONG right
Definition: windef.h:308
DWORD WINAPI GetSysColor(_In_ int)
#define RECT6
Definition: textedit.cpp:34
#define RECT4
Definition: textedit.cpp:32
#define RECT0
Definition: textedit.cpp:28
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define PS_DOT
Definition: wingdi.h:588
LONG bottom
Definition: windef.h:309
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)

Referenced by OnNCPaint(), and OnPaint().

◆ FixEditPos()

void CTextEditWindow::FixEditPos ( LPCTSTR  pszOldText)

Definition at line 112 of file textedit.cpp.

113 {
114  CString szText;
115  GetWindowText(szText);
116 
117  RECT rcParent;
118  ::GetWindowRect(m_hwndParent, &rcParent);
119 
120  RECT rc, rcWnd, rcText;
121  GetWindowRect(&rcWnd);
122  rcText = rcWnd;
123 
124  HDC hDC = GetDC();
125  if (hDC)
126  {
128  TEXTMETRIC tm;
129  GetTextMetrics(hDC, &tm);
130  szText += TEXT("x"); // This is a trick to enable the last newlines
131  const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
133  DrawText(hDC, szText, -1, &rcText, uFormat | DT_CALCRECT);
134  if (tm.tmDescent > 0)
135  rcText.bottom += tm.tmDescent;
136  ReleaseDC(hDC);
137  }
138 
139  UnionRect(&rc, &rcText, &rcWnd);
141 
142  rcWnd = rc;
143  ::GetClientRect(m_hwndParent, &rcParent);
144  IntersectRect(&rc, &rcParent, &rcWnd);
145 
147  MoveWindow(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE);
149 
152 
154 }
#define DT_EXPANDTABS
Definition: winuser.h:532
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
#define DT_WORDBREAK
Definition: winuser.h:544
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
LONG m_nAppIsMovingOrSizing
Definition: textedit.h:74
LONG left
Definition: windef.h:306
#define GetTextMetrics
Definition: wingdi.h:4474
LONG right
Definition: windef.h:308
#define DT_NOPREFIX
Definition: winuser.h:537
#define DrawText
Definition: winuser.h:5751
#define GetWindowText
Definition: winuser.h:5778
#define FALSE
Definition: types.h:117
#define DT_LEFT
Definition: winuser.h:534
#define DT_CALCRECT
Definition: winuser.h:526
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define DefWindowProc
Definition: ros2win.h:31
HWND m_hwndParent
Definition: textedit.h:71
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI UnionRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define SB_LEFT
Definition: winuser.h:575
Definition: time.h:68
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define DT_NOCLIP
Definition: winuser.h:536
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SB_TOP
Definition: winuser.h:578
#define TEXT(s)
Definition: k32.h:26
HFONT m_hFontZoomed
Definition: textedit.h:73
#define DT_TOP
Definition: winuser.h:542
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define WM_HSCROLL
Definition: winuser.h:1730
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define DT_EDITCONTROL
Definition: winuser.h:528
#define WM_VSCROLL
Definition: winuser.h:1731

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

◆ GetEditRect()

BOOL CTextEditWindow::GetEditRect ( LPRECT  prc) const

Definition at line 453 of file textedit.cpp.

454 {
455  *prc = m_rc;
456  return TRUE;
457 }
#define TRUE
Definition: types.h:120
_Out_ LPRECT prc
Definition: ntgdi.h:1658

Referenced by TextTool::OnButtonUp().

◆ GetFont()

HFONT CTextEditWindow::GetFont ( ) const
inline

Definition at line 26 of file textedit.h.

26 { return m_hFont; }
HFONT m_hFont
Definition: textedit.h:72

Referenced by TextTool::OnButtonUp().

◆ InvalidateEditRect()

void CTextEditWindow::InvalidateEditRect ( )

Definition at line 354 of file textedit.cpp.

355 {
356  RECT rc;
357  GetWindowRect(&rc);
360 
361  GetClientRect(&rc);
363  rc.left = UnZoomed(rc.left);
364  rc.top = UnZoomed(rc.top);
365  rc.right = UnZoomed(rc.right);
366  rc.bottom = UnZoomed(rc.bottom);
367  m_rc = rc;
368 }
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define TRUE
Definition: types.h:120
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
CImgAreaWindow imageArea
Definition: main.cpp:72
HWND m_hwndParent
Definition: textedit.h:71
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define NULL
Definition: types.h:112
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
static int UnZoomed(int xy)
Definition: common.h:42

Referenced by TextTool::OnButtonUp(), OnMove(), OnSetSel(), and OnSize().

◆ MESSAGE_HANDLER() [1/8]

CTextEditWindow::MESSAGE_HANDLER ( WM_NCCALCSIZE  ,
OnNCCalcSize   
)

◆ MESSAGE_HANDLER() [2/8]

CTextEditWindow::MESSAGE_HANDLER ( WM_NCHITTEST  ,
OnNCHitTest   
)

◆ MESSAGE_HANDLER() [3/8]

CTextEditWindow::MESSAGE_HANDLER ( WM_SETCURSOR  ,
OnSetCursor   
)

◆ MESSAGE_HANDLER() [4/8]

CTextEditWindow::MESSAGE_HANDLER ( WM_MOVE  ,
OnMove   
)

◆ MESSAGE_HANDLER() [5/8]

CTextEditWindow::MESSAGE_HANDLER ( WM_SIZE  ,
OnSize   
)

◆ MESSAGE_HANDLER() [6/8]

CTextEditWindow::MESSAGE_HANDLER ( WM_LBUTTONDOWN  ,
OnLButtonDown   
)

◆ MESSAGE_HANDLER() [7/8]

CTextEditWindow::MESSAGE_HANDLER ( EM_SETSEL  ,
OnSetSel   
)

◆ MESSAGE_HANDLER() [8/8]

CTextEditWindow::MESSAGE_HANDLER ( WM_MOUSEWHEEL  ,
OnMouseWheel   
)

◆ OnChar()

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

Definition at line 156 of file textedit.cpp.

157 {
158  if (wParam == VK_TAB)
159  return 0; // FIXME: Tabs
160 
161  CString szText;
162  GetWindowText(szText);
163 
165  FixEditPos(szText);
166 
167  return ret;
168 }
#define VK_TAB
Definition: winuser.h:2179
WPARAM wParam
Definition: combotst.c:138
#define GetWindowText
Definition: winuser.h:5778
#define DefWindowProc
Definition: ros2win.h:31
int ret
void FixEditPos(LPCTSTR pszOldText)
Definition: textedit.cpp:112
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139

◆ OnClose()

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

Definition at line 338 of file textedit.cpp.

339 {
341  if (m_hFont)
342  {
344  m_hFont = NULL;
345  }
346  if (m_hFontZoomed)
347  {
350  }
351  return 0;
352 }
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HFONT m_hFontZoomed
Definition: textedit.h:73
#define NULL
Definition: types.h:112
HFONT m_hFont
Definition: textedit.h:72

◆ OnCreate()

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

Definition at line 332 of file textedit.cpp.

333 {
334  UpdateFont();
335  return 0;
336 }
void UpdateFont()
Definition: textedit.cpp:402

◆ OnEraseBkGnd()

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

Definition at line 194 of file textedit.cpp.

195 {
196  HDC hDC = (HDC)wParam;
198  {
199  RECT rc;
200  GetClientRect(&rc);
201  HBRUSH hbr = CreateSolidBrush(paletteModel.GetBgColor());
202  FillRect(hDC, &rc, hbr);
203  DeleteObject(hbr);
204  }
206  return TRUE;
207 }
ToolsModel toolsModel
Definition: main.cpp:18
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
WPARAM wParam
Definition: combotst.c:138
COLORREF GetBgColor() const
COLORREF GetFgColor() const
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:911
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
PaletteModel paletteModel
Definition: main.cpp:28
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:135

◆ OnKeyDown()

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

Definition at line 170 of file textedit.cpp.

171 {
172  if (wParam == VK_ESCAPE)
173  {
175  return 0;
176  }
177 
178  CString szText;
179  GetWindowText(szText);
180 
182  FixEditPos(szText);
183  return ret;
184 }
ToolsModel toolsModel
Definition: main.cpp:18
void OnCancelDraw()
Definition: toolsmodel.cpp:215
#define VK_ESCAPE
Definition: winuser.h:2194
WPARAM wParam
Definition: combotst.c:138
#define GetWindowText
Definition: winuser.h:5778
#define DefWindowProc
Definition: ros2win.h:31
int ret
void FixEditPos(LPCTSTR pszOldText)
Definition: textedit.cpp:112
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139

◆ OnLButtonDown()

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

Definition at line 186 of file textedit.cpp.

187 {
191  return ret;
192 }
WPARAM wParam
Definition: combotst.c:138
#define DefWindowProc
Definition: ros2win.h:31
int ret
#define SB_LEFT
Definition: winuser.h:575
#define SB_TOP
Definition: winuser.h:578
#define WM_HSCROLL
Definition: winuser.h:1730
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
#define WM_VSCROLL
Definition: winuser.h:1731

◆ OnMouseWheel()

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

Definition at line 508 of file textedit.cpp.

509 {
511 }
WPARAM wParam
Definition: combotst.c:138
HWND WINAPI GetParent(_In_ HWND)
#define SendMessage
Definition: winuser.h:5823
LPARAM lParam
Definition: combotst.c:139

◆ OnMove()

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

Definition at line 266 of file textedit.cpp.

267 {
269 
270  if (m_nAppIsMovingOrSizing == 0)
271  {
272  Reposition();
274  }
275  return ret;
276 }
LONG m_nAppIsMovingOrSizing
Definition: textedit.h:74
WPARAM wParam
Definition: combotst.c:138
#define DefWindowProc
Definition: ros2win.h:31
int ret
void Reposition()
Definition: textedit.cpp:471
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
void InvalidateEditRect()
Definition: textedit.cpp:354

◆ OnNCCalcSize()

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

Definition at line 242 of file textedit.cpp.

243 {
244  return 0; // No frame.
245 }

◆ OnNCHitTest()

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

Definition at line 247 of file textedit.cpp.

248 {
250  RECT rc;
251  GetWindowRect(&rc);
252  return DoHitTest(rc, pt);
253 }
#define pt(x, y)
Definition: drawing.c:79
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
INT DoHitTest(RECT &rc, POINT pt)
Definition: textedit.cpp:37
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
LPARAM lParam
Definition: combotst.c:139

◆ OnNCPaint()

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

Definition at line 226 of file textedit.cpp.

227 {
228  RECT rc;
229  GetWindowRect(&rc);
230 
232  if (hDC)
233  {
234  OffsetRect(&rc, -rc.left, -rc.top);
235  DrawGrip(hDC, rc);
236  ReleaseDC(hDC);
237  }
238 
239  return 0;
240 }
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define DCX_WINDOW
Definition: winuser.h:2100
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
void DrawGrip(HDC hDC, RECT &rc)
Definition: textedit.cpp:77
static HDC hDC
Definition: 3dtext.c:33
#define DCX_PARENTCLIP
Definition: winuser.h:2102
#define NULL
Definition: types.h:112
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

◆ OnPaint()

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

Definition at line 209 of file textedit.cpp.

210 {
211  RECT rc;
212  GetClientRect(&rc);
213 
214  DefWindowProc(nMsg, wParam, lParam);
215 
216  HDC hDC = GetDC();
217  if (hDC)
218  {
219  DrawGrip(hDC, rc);
220  ReleaseDC(hDC);
221  }
222 
223  return 0;
224 }
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
WPARAM wParam
Definition: combotst.c:138
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
void DrawGrip(HDC hDC, RECT &rc)
Definition: textedit.cpp:77
#define DefWindowProc
Definition: ros2win.h:31
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LPARAM lParam
Definition: combotst.c:139

◆ OnPaletteModelColorChanged()

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

Definition at line 370 of file textedit.cpp.

371 {
372  UpdateFont();
373  return 0;
374 }
void UpdateFont()
Definition: textedit.cpp:402

◆ OnSetCursor()

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

Definition at line 255 of file textedit.cpp.

256 {
257  UINT nHitTest = LOWORD(lParam);
258  if (nHitTest == HTCAPTION)
259  {
261  return FALSE;
262  }
263  return DefWindowProc(nMsg, wParam, lParam);
264 }
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
#define DefWindowProc
Definition: ros2win.h:31
#define LoadCursor
Definition: winuser.h:5792
#define HTCAPTION
Definition: winuser.h:2456
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define IDC_SIZEALL
Definition: winuser.h:691
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

◆ OnSetSel()

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

Definition at line 444 of file textedit.cpp.

445 {
450  return ret;
451 }
WPARAM wParam
Definition: combotst.c:138
#define DefWindowProc
Definition: ros2win.h:31
int ret
#define SB_LEFT
Definition: winuser.h:575
#define SB_TOP
Definition: winuser.h:578
#define WM_HSCROLL
Definition: winuser.h:1730
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
#define WM_VSCROLL
Definition: winuser.h:1731
void InvalidateEditRect()
Definition: textedit.cpp:354

◆ OnSize()

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

Definition at line 278 of file textedit.cpp.

279 {
281 
282  RECT rc;
283  GetClientRect(&rc);
284  SendMessage(EM_SETRECTNP, 0, (LPARAM)&rc);
286 
287  if (m_nAppIsMovingOrSizing == 0)
288  {
289  Reposition();
291  }
292 
293  return ret;
294 }
#define EC_RIGHTMARGIN
Definition: winuser.h:2587
#define EM_SETMARGINS
Definition: winuser.h:1999
LONG m_nAppIsMovingOrSizing
Definition: textedit.h:74
WPARAM wParam
Definition: combotst.c:138
#define EC_LEFTMARGIN
Definition: winuser.h:2586
#define MAKELONG(a, b)
Definition: typedefs.h:249
LONG_PTR LPARAM
Definition: windef.h:208
#define DefWindowProc
Definition: ros2win.h:31
int ret
#define EM_SETRECTNP
Definition: winuser.h:2004
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SendMessage
Definition: winuser.h:5823
void Reposition()
Definition: textedit.cpp:471
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
void InvalidateEditRect()
Definition: textedit.cpp:354

◆ OnToolsModelSettingsChanged()

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

Definition at line 376 of file textedit.cpp.

377 {
378  UpdateFont();
379  return 0;
380 }
void UpdateFont()
Definition: textedit.cpp:402

◆ OnToolsModelToolChanged()

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

Definition at line 389 of file textedit.cpp.

390 {
391  if (wParam == TOOL_TEXT)
392  {
393  UpdateFont();
394  }
395  else
396  {
398  }
399  return 0;
400 }
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
WPARAM wParam
Definition: combotst.c:138
void UpdateFont()
Definition: textedit.cpp:402

◆ OnToolsModelZoomChanged()

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

Definition at line 382 of file textedit.cpp.

383 {
384  UpdateFont();
386  return 0;
387 }
void ValidateEditRect(LPCRECT prc OPTIONAL)
Definition: textedit.cpp:459
void UpdateFont()
Definition: textedit.cpp:402
#define NULL
Definition: types.h:112

◆ Reposition()

void CTextEditWindow::Reposition ( )
protected

Definition at line 471 of file textedit.cpp.

472 {
473  RECT rc, rcImage;
474  GetWindowRect(&rc);
475 
477  imageArea.GetClientRect(&rcImage);
478 
479  if (rc.bottom > rcImage.bottom)
480  {
481  rc.top = rcImage.bottom - (rc.bottom - rc.top);
482  rc.bottom = rcImage.bottom;
483  }
484 
485  if (rc.right > rcImage.right)
486  {
487  rc.left = rcImage.right - (rc.right - rc.left);
488  rc.right = rcImage.right;
489  }
490 
491  if (rc.left < 0)
492  {
493  rc.right += -rc.left;
494  rc.left = 0;
495  }
496 
497  if (rc.top < 0)
498  {
499  rc.bottom += -rc.top;
500  rc.top = 0;
501  }
502 
504  MoveWindow(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE);
506 }
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define TRUE
Definition: types.h:120
LONG top
Definition: windef.h:307
LONG m_nAppIsMovingOrSizing
Definition: textedit.h:74
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
CImgAreaWindow imageArea
Definition: main.cpp:72
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:507
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define NULL
Definition: types.h:112
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by OnMove(), and OnSize().

◆ UpdateFont()

void CTextEditWindow::UpdateFont ( )

Definition at line 402 of file textedit.cpp.

403 {
404  if (m_hFont)
405  {
407  m_hFont = NULL;
408  }
409  if (m_hFontZoomed)
410  {
413  }
414 
415  LOGFONT lf;
416  ZeroMemory(&lf, sizeof(lf));
417  lf.lfCharSet = DEFAULT_CHARSET; // registrySettings.CharSet; // Ignore
422 
423  HDC hdc = GetDC();
424  if (hdc)
425  {
426  INT nFontSize = registrySettings.PointSize;
427  lf.lfHeight = -MulDiv(nFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
428  ReleaseDC(hdc);
429  }
430 
432 
433  lf.lfHeight = Zoomed(lf.lfHeight);
435 
436  SetWindowFont(m_hWnd, m_hFontZoomed, TRUE);
438 
439  FixEditPos(NULL);
440 
441  Invalidate();
442 }
BYTE lfItalic
Definition: dimm.idl:47
static int Zoomed(int xy)
Definition: common.h:37
#define EC_RIGHTMARGIN
Definition: winuser.h:2587
#define EM_SETMARGINS
Definition: winuser.h:1999
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
BYTE lfUnderline
Definition: dimm.idl:48
#define SetWindowFont(hwnd, hfont, fRedraw)
Definition: windowsx.h:508
#define ZeroMemory
Definition: winbase.h:1667
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BYTE lfCharSet
Definition: dimm.idl:50
CString strFontName
Definition: registry.h:35
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define DEFAULT_CHARSET
Definition: wingdi.h:384
int32_t INT
Definition: typedefs.h:58
LONG lfHeight
Definition: dimm.idl:42
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define EC_LEFTMARGIN
Definition: winuser.h:2586
#define MAKELONG(a, b)
Definition: typedefs.h:249
LONG lfWeight
Definition: dimm.idl:46
#define DefWindowProc
Definition: ros2win.h:31
#define _countof(array)
Definition: sndvol32.h:68
DWORD PointSize
Definition: registry.h:36
DWORD Underline
Definition: registry.h:39
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
void FixEditPos(LPCTSTR pszOldText)
Definition: textedit.cpp:112
#define FW_BOLD
Definition: wingdi.h:378
HFONT m_hFontZoomed
Definition: textedit.h:73
#define CreateFontIndirect
Definition: wingdi.h:4444
#define NULL
Definition: types.h:112
#define FW_NORMAL
Definition: wingdi.h:373
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
#define LOGPIXELSY
Definition: wingdi.h:719
RegistrySettings registrySettings
Definition: main.cpp:30
HFONT m_hFont
Definition: textedit.h:72
#define lstrcpyn
Definition: winbase.h:3736

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

◆ ValidateEditRect()

void CTextEditWindow::ValidateEditRect ( LPCRECT prc  OPTIONAL)

Definition at line 459 of file textedit.cpp.

460 {
461  if (prc)
462  m_rc = *prc;
463  INT x0 = Zoomed(m_rc.left), y0 = Zoomed(m_rc.top);
465 
467  MoveWindow(x0, y0, x1 - x0, y1 - y0, TRUE);
469 }
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3706
static int Zoomed(int xy)
Definition: common.h:37
GLint x0
Definition: linetemp.h:95
#define TRUE
Definition: types.h:120
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
LONG top
Definition: windef.h:307
LONG m_nAppIsMovingOrSizing
Definition: textedit.h:74
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
GLint y0
Definition: linetemp.h:96
LONG bottom
Definition: windef.h:309
_Out_ LPRECT prc
Definition: ntgdi.h:1658

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

Member Data Documentation

◆ m_hFont

HFONT CTextEditWindow::m_hFont
protected

Definition at line 72 of file textedit.h.

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

◆ m_hFontZoomed

HFONT CTextEditWindow::m_hFontZoomed
protected

Definition at line 73 of file textedit.h.

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

◆ m_hwndParent

HWND CTextEditWindow::m_hwndParent
protected

Definition at line 71 of file textedit.h.

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

◆ m_nAppIsMovingOrSizing

LONG CTextEditWindow::m_nAppIsMovingOrSizing
protected

Definition at line 74 of file textedit.h.

Referenced by FixEditPos(), OnMove(), OnSize(), Reposition(), and ValidateEditRect().

◆ m_rc

RECT CTextEditWindow::m_rc
protected

Definition at line 75 of file textedit.h.

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


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