OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../include/pdfwindow/PDFWindow.h" | 7 #include "../../include/pdfwindow/PDFWindow.h" |
8 #include "../../include/pdfwindow/PWL_Wnd.h" | 8 #include "../../include/pdfwindow/PWL_Wnd.h" |
9 #include "../../include/pdfwindow/PWL_EditCtrl.h" | 9 #include "../../include/pdfwindow/PWL_EditCtrl.h" |
10 #include "../../include/pdfwindow/PWL_ScrollBar.h" | 10 #include "../../include/pdfwindow/PWL_ScrollBar.h" |
11 #include "../../include/pdfwindow/PWL_Utils.h" | 11 #include "../../include/pdfwindow/PWL_Utils.h" |
12 #include "../../include/pdfwindow/PWL_Caret.h" | 12 #include "../../include/pdfwindow/PWL_Caret.h" |
13 #include "../../include/pdfwindow/PWL_FontMap.h" | 13 #include "../../include/pdfwindow/PWL_FontMap.h" |
14 | 14 |
15 #define IsFloatZero(f)» » » » » » ((f) < 0.0001 &&
(f) > -0.0001) | 15 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) |
16 #define IsFloatBigger(fa,fb)» » » » ((fa) > (fb) && !IsFloat
Zero((fa) - (fb))) | 16 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
17 #define IsFloatSmaller(fa,fb)» » » » ((fa) < (fb) && !IsFloat
Zero((fa) - (fb))) | 17 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
18 #define IsFloatEqual(fa,fb)» » » » » IsFloatZero((fa)
-(fb)) | 18 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
19 | 19 |
20 /* ---------------------------- CPWL_EditCtrl ------------------------------ */ | 20 /* ---------------------------- CPWL_EditCtrl ------------------------------ */ |
21 | 21 |
22 CPWL_EditCtrl::CPWL_EditCtrl() : | 22 CPWL_EditCtrl::CPWL_EditCtrl() |
23 m_pEdit(NULL), | 23 : m_pEdit(NULL), |
24 m_pEditCaret(NULL), | 24 m_pEditCaret(NULL), |
25 m_bMouseDown(FALSE), | 25 m_bMouseDown(FALSE), |
26 m_pEditNotify(NULL), | 26 m_pEditNotify(NULL), |
27 m_nCharSet(DEFAULT_CHARSET), | 27 m_nCharSet(DEFAULT_CHARSET), |
28 m_nCodePage(0) | 28 m_nCodePage(0) { |
29 { | 29 m_pEdit = IFX_Edit::NewEdit(); |
30 m_pEdit = IFX_Edit::NewEdit(); | 30 ASSERT(m_pEdit != NULL); |
31 ASSERT(m_pEdit != NULL); | 31 } |
32 } | 32 |
33 | 33 CPWL_EditCtrl::~CPWL_EditCtrl() { |
34 CPWL_EditCtrl::~CPWL_EditCtrl() | 34 IFX_Edit::DelEdit(m_pEdit); |
35 { | 35 } |
36 IFX_Edit::DelEdit(m_pEdit); | 36 |
37 } | 37 void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) { |
38 | 38 cp.eCursorType = FXCT_VBEAM; |
39 void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM & cp) | 39 } |
40 { | 40 |
41 cp.eCursorType = FXCT_VBEAM; | 41 void CPWL_EditCtrl::OnCreated() { |
42 } | 42 SetFontSize(this->GetCreationParam().fFontSize); |
43 | 43 |
44 void CPWL_EditCtrl::OnCreated() | 44 m_pEdit->SetFontMap(this->GetFontMap()); |
45 { | 45 m_pEdit->SetNotify(this); |
46 SetFontSize(this->GetCreationParam().fFontSize); | 46 m_pEdit->Initialize(); |
47 | 47 } |
48 m_pEdit->SetFontMap(this->GetFontMap()); | 48 |
49 m_pEdit->SetNotify(this); | 49 FX_BOOL CPWL_EditCtrl::IsWndHorV() { |
50 m_pEdit->Initialize(); | 50 CPDF_Matrix mt = GetWindowMatrix(); |
51 } | 51 CPDF_Point point1(0, 1); |
52 | 52 CPDF_Point point2(1, 1); |
53 FX_BOOL CPWL_EditCtrl::IsWndHorV() | 53 |
54 { | 54 mt.Transform(point1.x, point1.y); |
55 CPDF_Matrix mt = GetWindowMatrix(); | 55 mt.Transform(point2.x, point2.y); |
56 CPDF_Point point1(0,1); | 56 |
57 CPDF_Point point2(1,1); | 57 return point2.y == point1.y; |
58 | 58 } |
59 mt.Transform(point1.x, point1.y); | 59 |
60 mt.Transform(point2.x, point2.y); | 60 void CPWL_EditCtrl::SetCursor() { |
61 | 61 if (IsValid()) { |
62 return point2.y == point1.y; | 62 if (IFX_SystemHandler* pSH = GetSystemHandler()) { |
63 } | 63 if (IsWndHorV()) |
64 | 64 pSH->SetCursor(FXCT_VBEAM); |
65 void CPWL_EditCtrl::SetCursor() | 65 else |
66 { | 66 pSH->SetCursor(FXCT_HBEAM); |
67 if (IsValid()) | 67 } |
68 { | 68 } |
69 if (IFX_SystemHandler* pSH = GetSystemHandler()) | 69 } |
70 { | 70 |
71 if (IsWndHorV()) | 71 void CPWL_EditCtrl::RePosChildWnd() { |
72 pSH->SetCursor(FXCT_VBEAM); | 72 m_pEdit->SetPlateRect(GetClientRect()); |
73 else | 73 } |
74 pSH->SetCursor(FXCT_HBEAM); | 74 |
75 } | 75 void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, |
76 } | 76 FX_DWORD msg, |
77 } | 77 FX_INTPTR wParam, |
78 | 78 FX_INTPTR lParam) { |
79 void CPWL_EditCtrl::RePosChildWnd() | 79 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
80 { | 80 |
81 m_pEdit->SetPlateRect(GetClientRect()); | 81 switch (msg) { |
82 } | 82 case PNM_SETSCROLLINFO: |
83 | 83 switch (wParam) { |
84 void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_
INTPTR lParam) | 84 case SBT_VSCROLL: |
85 { | 85 if (CPWL_Wnd* pChild = GetVScrollBar()) { |
86 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); | 86 pChild->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam); |
87 | 87 } |
88 switch (msg) | 88 break; |
89 { | 89 } |
90 case PNM_SETSCROLLINFO: | 90 break; |
91 switch (wParam) | 91 case PNM_SETSCROLLPOS: |
92 { | 92 switch (wParam) { |
93 case SBT_VSCROLL: | 93 case SBT_VSCROLL: |
94 if (CPWL_Wnd * pChild = GetVScrollBar()) | 94 if (CPWL_Wnd* pChild = GetVScrollBar()) { |
95 { | 95 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); |
96 pChild->OnNotify(pWnd,PNM_SETSCR
OLLINFO,wParam,lParam); | 96 } |
97 } | 97 break; |
98 break; | 98 } |
99 } | 99 break; |
100 break; | 100 case PNM_SCROLLWINDOW: { |
101 case PNM_SETSCROLLPOS: | 101 FX_FLOAT fPos = *(FX_FLOAT*)lParam; |
102 switch (wParam) | 102 switch (wParam) { |
103 { | 103 case SBT_VSCROLL: |
104 case SBT_VSCROLL: | 104 m_pEdit->SetScrollPos(CPDF_Point(m_pEdit->GetScrollPos().x, fPos)); |
105 if (CPWL_Wnd * pChild = GetVScrollBar()) | 105 break; |
106 { | 106 } |
107 pChild->OnNotify(pWnd,PNM_SETSCR
OLLPOS,wParam,lParam); | 107 } break; |
108 } | 108 case PNM_SETCARETINFO: { |
109 break; | 109 if (PWL_CARET_INFO* pCaretInfo = (PWL_CARET_INFO*)wParam) { |
110 } | 110 this->SetCaret( |
111 break; | 111 pCaretInfo->bVisible, pCaretInfo->ptHead, pCaretInfo->ptFoot); |
112 case PNM_SCROLLWINDOW: | 112 } |
113 { | 113 } break; |
114 FX_FLOAT fPos = *(FX_FLOAT*)lParam; | 114 } |
115 switch (wParam) | 115 } |
116 { | 116 |
117 case SBT_VSCROLL: | 117 void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
118 m_pEdit->SetScrollPos(CPDF_Point
(m_pEdit->GetScrollPos().x,fPos)); | 118 if (!IsReadOnly()) |
119 break; | 119 CreateEditCaret(cp); |
120 } | 120 } |
121 } | 121 |
122 break; | 122 void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) { |
123 case PNM_SETCARETINFO: | 123 if (!m_pEditCaret) { |
124 { | 124 m_pEditCaret = new CPWL_Caret; |
125 if (PWL_CARET_INFO * pCaretInfo = (PWL_CARET_INF
O *)wParam) | 125 m_pEditCaret->SetInvalidRect(GetClientRect()); |
126 { | 126 |
127 this->SetCaret(pCaretInfo->bVisible, | 127 PWL_CREATEPARAM ecp = cp; |
128 pCaretInfo->ptHead, | 128 ecp.pParentWnd = this; |
129 pCaretInfo->ptFoot);
| 129 ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP; |
130 } | 130 ecp.dwBorderWidth = 0; |
131 } | 131 ecp.nBorderStyle = PBS_SOLID; |
132 break; | 132 ecp.rcRectWnd = CPDF_Rect(0, 0, 0, 0); |
133 } | 133 |
134 } | 134 m_pEditCaret->Create(ecp); |
135 | 135 } |
136 void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM & cp) | 136 } |
137 { | 137 |
138 if (!IsReadOnly()) | 138 void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) { |
139 CreateEditCaret(cp); | 139 m_pEdit->SetFontSize(fFontSize); |
140 } | 140 } |
141 | 141 |
142 void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM & cp) | 142 FX_FLOAT CPWL_EditCtrl::GetFontSize() const { |
143 { | 143 return m_pEdit->GetFontSize(); |
144 if (!m_pEditCaret) | 144 } |
145 { | 145 |
146 m_pEditCaret = new CPWL_Caret; | 146 FX_BOOL CPWL_EditCtrl::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { |
147 m_pEditCaret->SetInvalidRect(GetClientRect()); | 147 if (m_bMouseDown) |
148 | 148 return TRUE; |
149 PWL_CREATEPARAM ecp = cp; | 149 |
150 ecp.pParentWnd = this; | 150 FX_BOOL bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag); |
151 ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP; | 151 |
152 ecp.dwBorderWidth = 0; | 152 // FILTER |
153 ecp.nBorderStyle = PBS_SOLID; | 153 switch (nChar) { |
154 ecp.rcRectWnd = CPDF_Rect(0,0,0,0); | 154 default: |
155 | 155 return FALSE; |
156 m_pEditCaret->Create(ecp); | 156 case FWL_VKEY_Delete: |
157 } | 157 case FWL_VKEY_Up: |
158 } | 158 case FWL_VKEY_Down: |
159 | 159 case FWL_VKEY_Left: |
160 void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) | 160 case FWL_VKEY_Right: |
161 { | 161 case FWL_VKEY_Home: |
162 m_pEdit->SetFontSize(fFontSize); | 162 case FWL_VKEY_End: |
163 } | 163 case FWL_VKEY_Insert: |
164 | 164 case 'C': |
165 FX_FLOAT CPWL_EditCtrl::GetFontSize() const | 165 case 'V': |
166 { | 166 case 'X': |
167 return m_pEdit->GetFontSize(); | 167 case 'A': |
168 } | 168 case 'Z': |
169 | 169 case 'c': |
170 FX_BOOL CPWL_EditCtrl::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) | 170 case 'v': |
171 { | 171 case 'x': |
172 if (m_bMouseDown) return TRUE; | 172 case 'a': |
173 | 173 case 'z': |
174 FX_BOOL bRet = CPWL_Wnd::OnKeyDown(nChar,nFlag); | 174 break; |
175 | 175 } |
176 //FILTER | 176 |
177 switch (nChar) | 177 if (nChar == FWL_VKEY_Delete) { |
178 { | 178 if (m_pEdit->IsSelected()) |
179 default: | 179 nChar = FWL_VKEY_Unknown; |
180 return FALSE; | 180 } |
181 case FWL_VKEY_Delete: | 181 |
182 case FWL_VKEY_Up: | 182 switch (nChar) { |
183 case FWL_VKEY_Down: | 183 case FWL_VKEY_Delete: |
184 case FWL_VKEY_Left: | 184 Delete(); |
185 case FWL_VKEY_Right: | 185 return TRUE; |
186 case FWL_VKEY_Home: | 186 case FWL_VKEY_Insert: |
187 case FWL_VKEY_End: | 187 if (IsSHIFTpressed(nFlag)) |
188 case FWL_VKEY_Insert: | 188 PasteText(); |
189 case 'C': | 189 return TRUE; |
190 case 'V': | 190 case FWL_VKEY_Up: |
191 case 'X': | 191 m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag), FALSE); |
192 case 'A': | 192 return TRUE; |
193 case 'Z': | 193 case FWL_VKEY_Down: |
194 case 'c': | 194 m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag), FALSE); |
195 case 'v': | 195 return TRUE; |
196 case 'x': | 196 case FWL_VKEY_Left: |
197 case 'a': | 197 m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag), FALSE); |
198 case 'z': | 198 return TRUE; |
199 break; | 199 case FWL_VKEY_Right: |
200 } | 200 m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag), FALSE); |
201 | 201 return TRUE; |
202 if (nChar == FWL_VKEY_Delete) | 202 case FWL_VKEY_Home: |
203 { | 203 m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
204 if (m_pEdit->IsSelected()) | 204 return TRUE; |
205 nChar = FWL_VKEY_Unknown; | 205 case FWL_VKEY_End: |
206 } | 206 m_pEdit->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
207 | 207 return TRUE; |
208 switch (nChar) | 208 case FWL_VKEY_Unknown: |
209 { | 209 if (!IsSHIFTpressed(nFlag)) |
210 case FWL_VKEY_Delete: | 210 Clear(); |
211 Delete(); | 211 else |
212 return TRUE; | 212 CutText(); |
213 case FWL_VKEY_Insert: | 213 return TRUE; |
214 if (IsSHIFTpressed(nFlag)) | 214 default: |
215 PasteText(); | 215 break; |
216 return TRUE; | 216 } |
217 case FWL_VKEY_Up: | 217 |
218 m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag),FALSE); | 218 return bRet; |
219 return TRUE; | 219 } |
220 case FWL_VKEY_Down: | 220 |
221 m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag),FALSE); | 221 FX_BOOL CPWL_EditCtrl::OnChar(FX_WORD nChar, FX_DWORD nFlag) { |
222 return TRUE; | 222 if (m_bMouseDown) |
223 case FWL_VKEY_Left: | 223 return TRUE; |
224 m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag),FALSE); | 224 |
225 return TRUE; | 225 CPWL_Wnd::OnChar(nChar, nFlag); |
226 case FWL_VKEY_Right: | 226 |
227 m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag),FALSE); | 227 // FILTER |
228 return TRUE; | 228 switch (nChar) { |
229 case FWL_VKEY_Home: | 229 case 0x0A: |
230 m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(n
Flag)); | 230 case 0x1B: |
231 return TRUE; | 231 return FALSE; |
232 case FWL_VKEY_End: | 232 default: |
233 m_pEdit->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nF
lag)); | 233 break; |
234 return TRUE; | 234 } |
235 case FWL_VKEY_Unknown: | 235 |
236 if (!IsSHIFTpressed(nFlag)) | 236 FX_BOOL bCtrl = IsCTRLpressed(nFlag); |
237 Clear(); | 237 FX_BOOL bAlt = IsALTpressed(nFlag); |
238 else | 238 FX_BOOL bShift = IsSHIFTpressed(nFlag); |
239 CutText(); | 239 |
240 return TRUE; | 240 FX_WORD word = nChar; |
241 default: | 241 |
242 break; | 242 if (bCtrl && !bAlt) { |
243 } | 243 switch (nChar) { |
244 | 244 case 'C' - 'A' + 1: |
245 return bRet; | 245 this->CopyText(); |
246 } | 246 return TRUE; |
247 | 247 case 'V' - 'A' + 1: |
248 FX_BOOL CPWL_EditCtrl::OnChar(FX_WORD nChar, FX_DWORD nFlag) | 248 this->PasteText(); |
249 { | 249 return TRUE; |
250 if (m_bMouseDown) return TRUE; | 250 case 'X' - 'A' + 1: |
251 | 251 this->CutText(); |
252 CPWL_Wnd::OnChar(nChar,nFlag); | 252 return TRUE; |
253 | 253 case 'A' - 'A' + 1: |
254 //FILTER | 254 this->SelectAll(); |
255 switch (nChar) | 255 return TRUE; |
256 { | 256 case 'Z' - 'A' + 1: |
257 case 0x0A: | 257 if (bShift) |
258 case 0x1B: | 258 Redo(); |
259 return FALSE; | 259 else |
260 default: | 260 Undo(); |
261 break; | 261 return TRUE; |
262 } | 262 default: |
263 | 263 if (nChar < 32) |
264 FX_BOOL bCtrl = IsCTRLpressed(nFlag); | 264 return FALSE; |
265 FX_BOOL bAlt = IsALTpressed(nFlag); | 265 } |
266 FX_BOOL bShift = IsSHIFTpressed(nFlag); | 266 } |
267 | 267 |
268 FX_WORD word = nChar; | 268 if (IsReadOnly()) |
269 | 269 return TRUE; |
270 if (bCtrl && !bAlt) | 270 |
271 { | 271 if (m_pEdit->IsSelected() && word == FWL_VKEY_Back) |
272 switch (nChar) | 272 word = FWL_VKEY_Unknown; |
273 { | 273 |
274 case 'C' - 'A' + 1: | 274 Clear(); |
275 this->CopyText(); | 275 |
276 return TRUE; | 276 switch (word) { |
277 case 'V' - 'A' + 1: | 277 case FWL_VKEY_Back: |
278 this->PasteText(); | 278 Backspace(); |
279 return TRUE; | 279 break; |
280 case 'X' - 'A' + 1: | 280 case FWL_VKEY_Return: |
281 this->CutText(); | 281 InsertReturn(); |
282 return TRUE; | 282 break; |
283 case 'A' - 'A' + 1: | 283 case FWL_VKEY_Unknown: |
284 this->SelectAll(); | 284 break; |
285 return TRUE; | 285 default: |
286 case 'Z' - 'A' + 1: | 286 if (IsINSERTpressed(nFlag)) |
287 if (bShift) | 287 Delete(); |
288 Redo(); | 288 InsertWord(word, this->GetCharSet()); |
289 else | 289 break; |
290 Undo(); | 290 } |
291 return TRUE; | 291 |
292 default: | 292 return TRUE; |
293 if (nChar < 32) | 293 } |
294 return FALSE; | 294 |
295 } | 295 FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) { |
296 } | 296 CPWL_Wnd::OnLButtonDown(point, nFlag); |
297 | 297 |
298 if (IsReadOnly()) return TRUE; | 298 if (ClientHitTest(point)) { |
299 | 299 if (m_bMouseDown) |
300 if (m_pEdit->IsSelected() && word == FWL_VKEY_Back) | 300 this->InvalidateRect(); |
301 word = FWL_VKEY_Unknown; | 301 |
302 | 302 m_bMouseDown = TRUE; |
303 Clear(); | 303 SetCapture(); |
304 | 304 |
305 switch (word) | 305 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
306 { | 306 } |
307 case FWL_VKEY_Back: | 307 |
308 Backspace(); | 308 return TRUE; |
309 break; | 309 } |
310 case FWL_VKEY_Return: | 310 |
311 InsertReturn(); | 311 FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { |
312 break; | 312 CPWL_Wnd::OnLButtonUp(point, nFlag); |
313 case FWL_VKEY_Unknown: | 313 |
314 break; | 314 if (m_bMouseDown) { |
315 default: | 315 // can receive keybord message |
316 if (IsINSERTpressed(nFlag)) | 316 if (ClientHitTest(point) && !this->IsFocused()) |
317 Delete(); | 317 SetFocus(); |
318 InsertWord(word, this->GetCharSet()); | 318 |
319 break; | 319 ReleaseCapture(); |
320 } | 320 m_bMouseDown = FALSE; |
321 | 321 } |
322 return TRUE; | 322 |
323 } | 323 return TRUE; |
324 | 324 } |
325 FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) | 325 |
326 { | 326 FX_BOOL CPWL_EditCtrl::OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag) { |
327 CPWL_Wnd::OnLButtonDown(point,nFlag); | 327 CPWL_Wnd::OnMouseMove(point, nFlag); |
328 | 328 |
329 if (ClientHitTest(point)) | 329 if (m_bMouseDown) |
330 { | 330 m_pEdit->OnMouseMove(point, FALSE, FALSE); |
331 if (m_bMouseDown) | 331 |
332 this->InvalidateRect(); | 332 return TRUE; |
333 | 333 } |
334 m_bMouseDown = TRUE; | 334 |
335 SetCapture(); | 335 CPDF_Rect CPWL_EditCtrl::GetContentRect() const { |
336 | 336 return m_pEdit->GetContentRect(); |
337 m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(n
Flag)); | 337 } |
338 } | 338 |
339 | 339 void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) { |
340 return TRUE; | 340 CPDF_Point ptHead(0, 0), ptFoot(0, 0); |
341 } | 341 |
342 | 342 if (bVisible) { |
343 FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) | 343 GetCaretInfo(ptHead, ptFoot); |
344 { | 344 } |
345 CPWL_Wnd::OnLButtonUp(point,nFlag); | 345 |
346 | 346 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace(); |
347 if (m_bMouseDown) | 347 this->IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp); |
348 { | 348 } |
349 //can receive keybord message | 349 |
350 if (ClientHitTest(point) && !this->IsFocused()) | 350 void CPWL_EditCtrl::GetCaretInfo(CPDF_Point& ptHead, CPDF_Point& ptFoot) const { |
351 SetFocus(); | 351 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { |
352 | 352 pIterator->SetAt(m_pEdit->GetCaret()); |
353 ReleaseCapture(); | 353 CPVT_Word word; |
354 m_bMouseDown = FALSE; | 354 CPVT_Line line; |
355 } | 355 if (pIterator->GetWord(word)) { |
356 | 356 ptHead.x = word.ptWord.x + word.fWidth; |
357 return TRUE; | 357 ptHead.y = word.ptWord.y + word.fAscent; |
358 } | 358 ptFoot.x = word.ptWord.x + word.fWidth; |
359 | 359 ptFoot.y = word.ptWord.y + word.fDescent; |
360 FX_BOOL CPWL_EditCtrl::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag) | 360 } else if (pIterator->GetLine(line)) { |
361 { | 361 ptHead.x = line.ptLine.x; |
362 CPWL_Wnd::OnMouseMove(point,nFlag); | 362 ptHead.y = line.ptLine.y + line.fLineAscent; |
363 | 363 ptFoot.x = line.ptLine.x; |
364 if (m_bMouseDown) | 364 ptFoot.y = line.ptLine.y + line.fLineDescent; |
365 m_pEdit->OnMouseMove(point,FALSE,FALSE); | 365 } |
366 | 366 } |
367 return TRUE; | 367 } |
368 } | 368 |
369 | 369 void CPWL_EditCtrl::GetCaretPos(FX_INT32& x, FX_INT32& y) const { |
370 CPDF_Rect CPWL_EditCtrl::GetContentRect() const | 370 CPDF_Point ptHead(0, 0), ptFoot(0, 0); |
371 { | 371 |
372 return m_pEdit->GetContentRect(); | 372 GetCaretInfo(ptHead, ptFoot); |
373 } | 373 |
374 | 374 PWLtoWnd(ptHead, x, y); |
375 void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) | 375 } |
376 { | 376 |
377 CPDF_Point ptHead(0,0),ptFoot(0,0); | 377 void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible, |
378 | 378 const CPDF_Point& ptHead, |
379 if (bVisible) | 379 const CPDF_Point& ptFoot) { |
380 { | 380 if (m_pEditCaret) { |
381 GetCaretInfo(ptHead,ptFoot); | 381 if (!IsFocused() || m_pEdit->IsSelected()) |
382 } | 382 bVisible = FALSE; |
383 | 383 |
384 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace(); | 384 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot); |
385 this->IOnSetCaret(bVisible,ptHead,ptFoot,wpTemp); | 385 } |
386 } | 386 } |
387 | 387 |
388 void CPWL_EditCtrl::GetCaretInfo(CPDF_Point & ptHead, CPDF_Point & ptFoot) const | 388 FX_BOOL CPWL_EditCtrl::IsModified() const { |
389 { | 389 return m_pEdit->IsModified(); |
390 if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) | 390 } |
391 { | 391 |
392 pIterator->SetAt(m_pEdit->GetCaret()); | 392 CFX_WideString CPWL_EditCtrl::GetText() const { |
393 CPVT_Word word; | 393 return m_pEdit->GetText(); |
394 CPVT_Line line; | 394 } |
395 if (pIterator->GetWord(word)) | 395 |
396 { | 396 void CPWL_EditCtrl::SetSel(FX_INT32 nStartChar, FX_INT32 nEndChar) { |
397 ptHead.x = word.ptWord.x + word.fWidth; | 397 m_pEdit->SetSel(nStartChar, nEndChar); |
398 ptHead.y = word.ptWord.y + word.fAscent; | 398 } |
399 ptFoot.x = word.ptWord.x + word.fWidth; | 399 |
400 ptFoot.y = word.ptWord.y + word.fDescent; | 400 void CPWL_EditCtrl::GetSel(FX_INT32& nStartChar, FX_INT32& nEndChar) const { |
401 } | 401 m_pEdit->GetSel(nStartChar, nEndChar); |
402 else if (pIterator->GetLine(line)) | 402 } |
403 { | 403 |
404 ptHead.x = line.ptLine.x; | 404 void CPWL_EditCtrl::Clear() { |
405 ptHead.y = line.ptLine.y + line.fLineAscent; | 405 if (!IsReadOnly()) |
406 ptFoot.x = line.ptLine.x; | 406 m_pEdit->Clear(); |
407 ptFoot.y = line.ptLine.y + line.fLineDescent; | 407 } |
408 } | 408 |
409 } | 409 void CPWL_EditCtrl::SelectAll() { |
410 } | 410 m_pEdit->SelectAll(); |
411 | 411 } |
412 void CPWL_EditCtrl::GetCaretPos(FX_INT32& x, FX_INT32& y) const | 412 |
413 { | 413 void CPWL_EditCtrl::Paint() { |
414 CPDF_Point ptHead(0,0), ptFoot(0,0); | 414 if (m_pEdit) |
415 | 415 m_pEdit->Paint(); |
416 GetCaretInfo(ptHead,ptFoot); | 416 } |
417 | 417 |
418 PWLtoWnd(ptHead, x, y); | 418 void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh) { |
419 } | 419 if (m_pEdit) |
420 | 420 m_pEdit->EnableRefresh(bRefresh); |
421 void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const
CPDF_Point & ptFoot) | 421 } |
422 { | 422 |
423 if (m_pEditCaret) | 423 FX_INT32 CPWL_EditCtrl::GetCaret() const { |
424 { | 424 if (m_pEdit) |
425 if (!IsFocused() || m_pEdit->IsSelected()) | 425 return m_pEdit->GetCaret(); |
426 bVisible = FALSE; | 426 |
427 | 427 return -1; |
428 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot); | 428 } |
429 } | 429 |
430 } | 430 void CPWL_EditCtrl::SetCaret(FX_INT32 nPos) { |
431 | 431 if (m_pEdit) |
432 FX_BOOL CPWL_EditCtrl::IsModified() const | 432 m_pEdit->SetCaret(nPos); |
433 { | 433 } |
434 return m_pEdit->IsModified(); | 434 |
435 } | 435 FX_INT32 CPWL_EditCtrl::GetTotalWords() const { |
436 | 436 if (m_pEdit) |
437 CFX_WideString CPWL_EditCtrl::GetText() const | 437 return m_pEdit->GetTotalWords(); |
438 { | 438 |
439 return m_pEdit->GetText(); | 439 return 0; |
440 } | 440 } |
441 | 441 |
442 void CPWL_EditCtrl::SetSel(FX_INT32 nStartChar,FX_INT32 nEndChar) | 442 void CPWL_EditCtrl::SetScrollPos(const CPDF_Point& point) { |
443 { | 443 if (m_pEdit) |
444 m_pEdit->SetSel(nStartChar, nEndChar); | 444 m_pEdit->SetScrollPos(point); |
445 } | 445 } |
446 | 446 |
447 void CPWL_EditCtrl::GetSel(FX_INT32 & nStartChar, FX_INT32 & nEndChar ) const | 447 CPDF_Point CPWL_EditCtrl::GetScrollPos() const { |
448 { | 448 if (m_pEdit) |
449 m_pEdit->GetSel(nStartChar, nEndChar); | 449 return m_pEdit->GetScrollPos(); |
450 } | 450 |
451 | 451 return CPDF_Point(0.0f, 0.0f); |
452 void CPWL_EditCtrl::Clear() | 452 } |
453 { | 453 |
454 if (!IsReadOnly()) | 454 CPDF_Font* CPWL_EditCtrl::GetCaretFont() const { |
455 m_pEdit->Clear(); | 455 FX_INT32 nFontIndex = 0; |
456 } | 456 |
457 | 457 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { |
458 void CPWL_EditCtrl::SelectAll() | 458 pIterator->SetAt(m_pEdit->GetCaret()); |
459 { | 459 CPVT_Word word; |
460 m_pEdit->SelectAll(); | 460 CPVT_Section section; |
461 } | 461 if (pIterator->GetWord(word)) { |
462 | 462 nFontIndex = word.nFontIndex; |
463 void CPWL_EditCtrl::Paint() | 463 } else if (HasFlag(PES_RICH)) { |
464 { | 464 if (pIterator->GetSection(section)) { |
465 if (m_pEdit) | 465 nFontIndex = section.WordProps.nFontIndex; |
466 m_pEdit->Paint(); | 466 } |
467 } | 467 } |
468 | 468 } |
469 void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh) | 469 |
470 { | 470 if (IFX_Edit_FontMap* pFontMap = GetFontMap()) |
471 if (m_pEdit) | 471 return pFontMap->GetPDFFont(nFontIndex); |
472 m_pEdit->EnableRefresh(bRefresh); | 472 else |
473 } | 473 return NULL; |
474 | 474 } |
475 FX_INT32 CPWL_EditCtrl::GetCaret() const | 475 |
476 { | 476 FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const { |
477 if (m_pEdit) | 477 FX_FLOAT fFontSize = GetFontSize(); |
478 return m_pEdit->GetCaret(); | 478 |
479 | 479 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { |
480 return -1; | 480 pIterator->SetAt(m_pEdit->GetCaret()); |
481 } | 481 CPVT_Word word; |
482 | 482 CPVT_Section section; |
483 void CPWL_EditCtrl::SetCaret(FX_INT32 nPos) | 483 if (pIterator->GetWord(word)) { |
484 { | 484 fFontSize = word.fFontSize; |
485 if (m_pEdit) | 485 } else if (HasFlag(PES_RICH)) { |
486 m_pEdit->SetCaret(nPos); | 486 if (pIterator->GetSection(section)) { |
487 } | 487 fFontSize = section.WordProps.fFontSize; |
488 | 488 } |
489 FX_INT32 CPWL_EditCtrl::GetTotalWords() const | 489 } |
490 { | 490 } |
491 if (m_pEdit) | 491 |
492 return m_pEdit->GetTotalWords(); | 492 return fFontSize; |
493 | 493 } |
494 return 0; | 494 |
495 } | 495 void CPWL_EditCtrl::SetText(FX_LPCWSTR csText) { |
496 | 496 m_pEdit->SetText(csText); |
497 void CPWL_EditCtrl::SetScrollPos(const CPDF_Point& point) | 497 } |
498 { | 498 |
499 if (m_pEdit) | 499 void CPWL_EditCtrl::CopyText() { |
500 m_pEdit->SetScrollPos(point); | 500 } |
501 } | 501 |
502 | 502 void CPWL_EditCtrl::PasteText() { |
503 CPDF_Point CPWL_EditCtrl::GetScrollPos() const | 503 } |
504 { | 504 |
505 if (m_pEdit) | 505 void CPWL_EditCtrl::CutText() { |
506 return m_pEdit->GetScrollPos(); | 506 } |
507 | 507 |
508 return CPDF_Point(0.0f, 0.0f); | 508 void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) { |
509 } | 509 } |
510 | 510 |
511 CPDF_Font * CPWL_EditCtrl::GetCaretFont() const | 511 void CPWL_EditCtrl::InsertText(FX_LPCWSTR csText) { |
512 { | 512 if (!IsReadOnly()) |
513 FX_INT32 nFontIndex = 0; | 513 m_pEdit->InsertText(csText); |
514 | 514 } |
515 if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) | 515 |
516 { | 516 void CPWL_EditCtrl::InsertWord(FX_WORD word, FX_INT32 nCharset) { |
517 pIterator->SetAt(m_pEdit->GetCaret()); | 517 if (!IsReadOnly()) |
518 CPVT_Word word; | 518 m_pEdit->InsertWord(word, nCharset); |
519 CPVT_Section section; | 519 } |
520 if (pIterator->GetWord(word)) | 520 |
521 { | 521 void CPWL_EditCtrl::InsertReturn() { |
522 nFontIndex = word.nFontIndex; | 522 if (!IsReadOnly()) |
523 } | 523 m_pEdit->InsertReturn(); |
524 else if (HasFlag(PES_RICH)) | 524 } |
525 { | 525 |
526 if (pIterator->GetSection(section)) | 526 void CPWL_EditCtrl::Delete() { |
527 { | 527 if (!IsReadOnly()) |
528 nFontIndex = section.WordProps.nFontIndex; | 528 m_pEdit->Delete(); |
529 } | 529 } |
530 } | 530 |
531 } | 531 void CPWL_EditCtrl::Backspace() { |
532 | 532 if (!IsReadOnly()) |
533 if (IFX_Edit_FontMap * pFontMap = GetFontMap()) | 533 m_pEdit->Backspace(); |
534 return pFontMap->GetPDFFont(nFontIndex); | 534 } |
535 else | 535 |
536 return NULL; | 536 FX_BOOL CPWL_EditCtrl::CanUndo() const { |
537 } | 537 return !IsReadOnly() && m_pEdit->CanUndo(); |
538 | 538 } |
539 FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const | 539 |
540 { | 540 FX_BOOL CPWL_EditCtrl::CanRedo() const { |
541 FX_FLOAT fFontSize = GetFontSize(); | 541 return !IsReadOnly() && m_pEdit->CanRedo(); |
542 | 542 } |
543 if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) | 543 |
544 { | 544 void CPWL_EditCtrl::Redo() { |
545 pIterator->SetAt(m_pEdit->GetCaret()); | 545 if (CanRedo()) |
546 CPVT_Word word; | 546 m_pEdit->Redo(); |
547 CPVT_Section section; | 547 } |
548 if (pIterator->GetWord(word)) | 548 |
549 { | 549 void CPWL_EditCtrl::Undo() { |
550 fFontSize = word.fFontSize; | 550 if (CanUndo()) |
551 } | 551 m_pEdit->Undo(); |
552 else if (HasFlag(PES_RICH)) | 552 } |
553 { | 553 |
554 if (pIterator->GetSection(section)) | 554 void CPWL_EditCtrl::IOnSetScrollInfoY(FX_FLOAT fPlateMin, |
555 { | 555 FX_FLOAT fPlateMax, |
556 fFontSize = section.WordProps.fFontSize; | 556 FX_FLOAT fContentMin, |
557 } | 557 FX_FLOAT fContentMax, |
558 } | 558 FX_FLOAT fSmallStep, |
559 } | 559 FX_FLOAT fBigStep) { |
560 | 560 PWL_SCROLL_INFO Info; |
561 return fFontSize; | 561 |
562 } | 562 Info.fPlateWidth = fPlateMax - fPlateMin; |
563 | 563 Info.fContentMin = fContentMin; |
564 void CPWL_EditCtrl::SetText(FX_LPCWSTR csText) | 564 Info.fContentMax = fContentMax; |
565 { | 565 Info.fSmallStep = fSmallStep; |
566 m_pEdit->SetText(csText); | 566 Info.fBigStep = fBigStep; |
567 } | 567 |
568 | 568 this->OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (FX_INTPTR)&Info); |
569 void CPWL_EditCtrl::CopyText() | 569 |
570 { | 570 // PWL_TRACE("set scroll info:%f\n",fContentMax - fContentMin); |
571 } | 571 |
572 | 572 if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || |
573 void CPWL_EditCtrl::PasteText() | 573 IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { |
574 { | 574 this->ShowVScrollBar(FALSE); |
575 } | 575 } else { |
576 | 576 this->ShowVScrollBar(TRUE); |
577 void CPWL_EditCtrl::CutText() | 577 } |
578 { | 578 } |
579 } | 579 |
580 | 580 void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) { |
581 void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) | 581 // PWL_TRACE("set scroll position:%f\n",fy); |
582 { | 582 this->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&fy); |
583 } | 583 } |
584 | 584 |
585 void CPWL_EditCtrl::InsertText(FX_LPCWSTR csText) | 585 void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible, |
586 { | 586 const CPDF_Point& ptHead, |
587 if (!IsReadOnly()) | 587 const CPDF_Point& ptFoot, |
588 m_pEdit->InsertText(csText); | 588 const CPVT_WordPlace& place) { |
589 } | 589 PWL_CARET_INFO cInfo; |
590 | 590 cInfo.bVisible = bVisible; |
591 void CPWL_EditCtrl::InsertWord(FX_WORD word, FX_INT32 nCharset) | 591 cInfo.ptHead = ptHead; |
592 { | 592 cInfo.ptFoot = ptFoot; |
593 if (!IsReadOnly()) | 593 |
594 m_pEdit->InsertWord(word, nCharset); | 594 this->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&cInfo, (FX_INTPTR)NULL); |
595 } | 595 } |
596 | 596 |
597 void CPWL_EditCtrl::InsertReturn() | 597 void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps, |
598 { | 598 const CPVT_WordProps& wordProps) { |
599 if (!IsReadOnly()) | 599 } |
600 m_pEdit->InsertReturn(); | 600 |
601 } | 601 void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent) { |
602 | 602 if (this->IsValid()) { |
603 void CPWL_EditCtrl::Delete() | 603 if (m_pEditNotify) { |
604 { | 604 m_pEditNotify->OnContentChange(rcContent); |
605 if (!IsReadOnly()) | 605 } |
606 m_pEdit->Delete(); | 606 } |
607 } | 607 } |
608 | 608 |
609 void CPWL_EditCtrl::Backspace() | 609 void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect* pRect) { |
610 { | 610 this->InvalidateRect(pRect); |
611 if (!IsReadOnly()) | 611 } |
612 m_pEdit->Backspace(); | 612 |
613 } | 613 FX_INT32 CPWL_EditCtrl::GetCharSet() const { |
614 | 614 if (m_nCharSet < 0) |
615 FX_BOOL CPWL_EditCtrl::CanUndo() const | 615 return DEFAULT_CHARSET; |
616 { | 616 else |
617 return !IsReadOnly() && m_pEdit->CanUndo(); | 617 return m_nCharSet; |
618 } | 618 } |
619 | 619 |
620 FX_BOOL CPWL_EditCtrl::CanRedo() const | 620 void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect, |
621 { | 621 FX_INT32& nStartChar, |
622 return !IsReadOnly() && m_pEdit->CanRedo(); | 622 FX_INT32& nEndChar) const { |
623 } | 623 nStartChar = m_pEdit->WordPlaceToWordIndex( |
624 | 624 m_pEdit->SearchWordPlace(CPDF_Point(rect.left, rect.top))); |
625 void CPWL_EditCtrl::Redo() | 625 nEndChar = m_pEdit->WordPlaceToWordIndex( |
626 { | 626 m_pEdit->SearchWordPlace(CPDF_Point(rect.right, rect.bottom))); |
627 if (CanRedo()) | 627 } |
628 m_pEdit->Redo(); | 628 |
629 } | 629 CFX_WideString CPWL_EditCtrl::GetText(FX_INT32& nStartChar, |
630 | 630 FX_INT32& nEndChar) const { |
631 void CPWL_EditCtrl::Undo() | 631 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); |
632 { | 632 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); |
633 if (CanUndo()) | 633 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); |
634 m_pEdit->Undo(); | 634 } |
635 } | 635 |
636 | 636 void CPWL_EditCtrl::SetReadyToInput() { |
637 void CPWL_EditCtrl::IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, | 637 if (m_bMouseDown) { |
638
FX_FLOAT fContentMin, FX_FLOAT fContentMax, | 638 ReleaseCapture(); |
639
FX_FLOAT fSmallStep, FX_FLOAT fBigStep) | 639 m_bMouseDown = FALSE; |
640 { | 640 } |
641 PWL_SCROLL_INFO Info; | 641 } |
642 | |
643 Info.fPlateWidth = fPlateMax - fPlateMin; | |
644 Info.fContentMin = fContentMin; | |
645 Info.fContentMax = fContentMax; | |
646 Info.fSmallStep = fSmallStep; | |
647 Info.fBigStep = fBigStep; | |
648 | |
649 this->OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(FX_INTPTR)&Info); | |
650 | |
651 // PWL_TRACE("set scroll info:%f\n",fContentMax - fContentMin); | |
652 | |
653 if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin) | |
654 || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentM
in)) | |
655 { | |
656 this->ShowVScrollBar(FALSE); | |
657 } | |
658 else | |
659 { | |
660 this->ShowVScrollBar(TRUE); | |
661 } | |
662 } | |
663 | |
664 void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) | |
665 { | |
666 // PWL_TRACE("set scroll position:%f\n",fy); | |
667 this->OnNotify(this,PNM_SETSCROLLPOS,SBT_VSCROLL,(FX_INTPTR)&fy); | |
668 } | |
669 | |
670 void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, con
st CPDF_Point & ptFoot, const CPVT_WordPlace& place) | |
671 { | |
672 PWL_CARET_INFO cInfo; | |
673 cInfo.bVisible = bVisible; | |
674 cInfo.ptHead = ptHead; | |
675 cInfo.ptFoot = ptFoot; | |
676 | |
677 this->OnNotify(this,PNM_SETCARETINFO,(FX_INTPTR)&cInfo,(FX_INTPTR)NULL); | |
678 } | |
679 | |
680 void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_Wo
rdProps & wordProps) | |
681 { | |
682 } | |
683 | |
684 void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent) | |
685 { | |
686 if (this->IsValid()) | |
687 { | |
688 if (m_pEditNotify) | |
689 { | |
690 m_pEditNotify->OnContentChange(rcContent); | |
691 } | |
692 } | |
693 } | |
694 | |
695 void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect * pRect) | |
696 { | |
697 this->InvalidateRect(pRect); | |
698 } | |
699 | |
700 FX_INT32 CPWL_EditCtrl::GetCharSet() const | |
701 { | |
702 if (m_nCharSet < 0) | |
703 return DEFAULT_CHARSET; | |
704 else | |
705 return m_nCharSet; | |
706 } | |
707 | |
708 void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect, FX_INT32 & nStartChar, F
X_INT32 & nEndChar) const | |
709 { | |
710 nStartChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF
_Point(rect.left, rect.top))); | |
711 nEndChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_P
oint(rect.right, rect.bottom))); | |
712 } | |
713 | |
714 CFX_WideString CPWL_EditCtrl::GetText(FX_INT32 & nStartChar, FX_INT32 & nEndChar
) const | |
715 { | |
716 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); | |
717 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); | |
718 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); | |
719 } | |
720 | |
721 void CPWL_EditCtrl::SetReadyToInput() | |
722 { | |
723 if (m_bMouseDown) | |
724 { | |
725 ReleaseCapture(); | |
726 m_bMouseDown = FALSE; | |
727 } | |
728 } | |
OLD | NEW |