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 "fpdfsdk/pdfwindow/PWL_EditCtrl.h" | 7 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
8 | 8 |
9 #include "core/fpdfdoc/cpvt_section.h" | 9 #include "core/fpdfdoc/cpvt_section.h" |
10 #include "core/fpdfdoc/cpvt_word.h" | 10 #include "core/fpdfdoc/cpvt_word.h" |
11 #include "core/fxge/fx_font.h" | 11 #include "core/fxge/fx_font.h" |
12 #include "fpdfsdk/fxedit/fxet_edit.h" | 12 #include "fpdfsdk/fxedit/fxet_edit.h" |
13 #include "fpdfsdk/pdfwindow/PWL_Caret.h" | 13 #include "fpdfsdk/pdfwindow/PWL_Caret.h" |
14 #include "fpdfsdk/pdfwindow/PWL_FontMap.h" | 14 #include "fpdfsdk/pdfwindow/PWL_FontMap.h" |
15 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" | 15 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" |
16 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 16 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
17 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" | 17 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
18 #include "public/fpdf_fwlevent.h" | 18 #include "public/fpdf_fwlevent.h" |
19 | 19 |
20 CPWL_EditCtrl::CPWL_EditCtrl() | 20 CPWL_EditCtrl::CPWL_EditCtrl() |
21 : m_pEdit(new CFX_Edit), | 21 : m_pEdit(new CFX_Edit), |
22 m_pEditCaret(nullptr), | 22 m_pEditCaret(nullptr), |
23 m_bMouseDown(FALSE), | 23 m_bMouseDown(false), |
24 m_nCharSet(FXFONT_DEFAULT_CHARSET), | 24 m_nCharSet(FXFONT_DEFAULT_CHARSET), |
25 m_nCodePage(0) {} | 25 m_nCodePage(0) {} |
26 | 26 |
27 CPWL_EditCtrl::~CPWL_EditCtrl() {} | 27 CPWL_EditCtrl::~CPWL_EditCtrl() {} |
28 | 28 |
29 void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) { | 29 void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) { |
30 cp.eCursorType = FXCT_VBEAM; | 30 cp.eCursorType = FXCT_VBEAM; |
31 } | 31 } |
32 | 32 |
33 void CPWL_EditCtrl::OnCreated() { | 33 void CPWL_EditCtrl::OnCreated() { |
34 SetFontSize(GetCreationParam().fFontSize); | 34 SetFontSize(GetCreationParam().fFontSize); |
35 | 35 |
36 m_pEdit->SetFontMap(GetFontMap()); | 36 m_pEdit->SetFontMap(GetFontMap()); |
37 m_pEdit->SetNotify(this); | 37 m_pEdit->SetNotify(this); |
38 m_pEdit->Initialize(); | 38 m_pEdit->Initialize(); |
39 } | 39 } |
40 | 40 |
41 FX_BOOL CPWL_EditCtrl::IsWndHorV() { | 41 bool CPWL_EditCtrl::IsWndHorV() { |
42 CFX_Matrix mt = GetWindowMatrix(); | 42 CFX_Matrix mt = GetWindowMatrix(); |
43 CFX_FloatPoint point1(0, 1); | 43 CFX_FloatPoint point1(0, 1); |
44 CFX_FloatPoint point2(1, 1); | 44 CFX_FloatPoint point2(1, 1); |
45 | 45 |
46 mt.Transform(point1.x, point1.y); | 46 mt.Transform(point1.x, point1.y); |
47 mt.Transform(point2.x, point2.y); | 47 mt.Transform(point2.x, point2.y); |
48 | 48 |
49 return point2.y == point1.y; | 49 return point2.y == point1.y; |
50 } | 50 } |
51 | 51 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) { | 131 void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) { |
132 m_pEdit->SetFontSize(fFontSize); | 132 m_pEdit->SetFontSize(fFontSize); |
133 } | 133 } |
134 | 134 |
135 FX_FLOAT CPWL_EditCtrl::GetFontSize() const { | 135 FX_FLOAT CPWL_EditCtrl::GetFontSize() const { |
136 return m_pEdit->GetFontSize(); | 136 return m_pEdit->GetFontSize(); |
137 } | 137 } |
138 | 138 |
139 FX_BOOL CPWL_EditCtrl::OnKeyDown(uint16_t nChar, uint32_t nFlag) { | 139 bool CPWL_EditCtrl::OnKeyDown(uint16_t nChar, uint32_t nFlag) { |
140 if (m_bMouseDown) | 140 if (m_bMouseDown) |
141 return TRUE; | 141 return true; |
142 | 142 |
143 FX_BOOL bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag); | 143 bool bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag); |
144 | 144 |
145 // FILTER | 145 // FILTER |
146 switch (nChar) { | 146 switch (nChar) { |
147 default: | 147 default: |
148 return FALSE; | 148 return false; |
149 case FWL_VKEY_Delete: | 149 case FWL_VKEY_Delete: |
150 case FWL_VKEY_Up: | 150 case FWL_VKEY_Up: |
151 case FWL_VKEY_Down: | 151 case FWL_VKEY_Down: |
152 case FWL_VKEY_Left: | 152 case FWL_VKEY_Left: |
153 case FWL_VKEY_Right: | 153 case FWL_VKEY_Right: |
154 case FWL_VKEY_Home: | 154 case FWL_VKEY_Home: |
155 case FWL_VKEY_End: | 155 case FWL_VKEY_End: |
156 case FWL_VKEY_Insert: | 156 case FWL_VKEY_Insert: |
157 case 'C': | 157 case 'C': |
158 case 'V': | 158 case 'V': |
159 case 'X': | 159 case 'X': |
160 case 'A': | 160 case 'A': |
161 case 'Z': | 161 case 'Z': |
162 case 'c': | 162 case 'c': |
163 case 'v': | 163 case 'v': |
164 case 'x': | 164 case 'x': |
165 case 'a': | 165 case 'a': |
166 case 'z': | 166 case 'z': |
167 break; | 167 break; |
168 } | 168 } |
169 | 169 |
170 if (nChar == FWL_VKEY_Delete && m_pEdit->IsSelected()) | 170 if (nChar == FWL_VKEY_Delete && m_pEdit->IsSelected()) |
171 nChar = FWL_VKEY_Unknown; | 171 nChar = FWL_VKEY_Unknown; |
172 | 172 |
173 switch (nChar) { | 173 switch (nChar) { |
174 case FWL_VKEY_Delete: | 174 case FWL_VKEY_Delete: |
175 Delete(); | 175 Delete(); |
176 return TRUE; | 176 return true; |
177 case FWL_VKEY_Insert: | 177 case FWL_VKEY_Insert: |
178 if (IsSHIFTpressed(nFlag)) | 178 if (IsSHIFTpressed(nFlag)) |
179 PasteText(); | 179 PasteText(); |
180 return TRUE; | 180 return true; |
181 case FWL_VKEY_Up: | 181 case FWL_VKEY_Up: |
182 m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag), FALSE); | 182 m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag), false); |
183 return TRUE; | 183 return true; |
184 case FWL_VKEY_Down: | 184 case FWL_VKEY_Down: |
185 m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag), FALSE); | 185 m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag), false); |
186 return TRUE; | 186 return true; |
187 case FWL_VKEY_Left: | 187 case FWL_VKEY_Left: |
188 m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag), FALSE); | 188 m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag), false); |
189 return TRUE; | 189 return true; |
190 case FWL_VKEY_Right: | 190 case FWL_VKEY_Right: |
191 m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag), FALSE); | 191 m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag), false); |
192 return TRUE; | 192 return true; |
193 case FWL_VKEY_Home: | 193 case FWL_VKEY_Home: |
194 m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 194 m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
195 return TRUE; | 195 return true; |
196 case FWL_VKEY_End: | 196 case FWL_VKEY_End: |
197 m_pEdit->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 197 m_pEdit->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
198 return TRUE; | 198 return true; |
199 case FWL_VKEY_Unknown: | 199 case FWL_VKEY_Unknown: |
200 if (!IsSHIFTpressed(nFlag)) | 200 if (!IsSHIFTpressed(nFlag)) |
201 Clear(); | 201 Clear(); |
202 else | 202 else |
203 CutText(); | 203 CutText(); |
204 return TRUE; | 204 return true; |
205 default: | 205 default: |
206 break; | 206 break; |
207 } | 207 } |
208 | 208 |
209 return bRet; | 209 return bRet; |
210 } | 210 } |
211 | 211 |
212 FX_BOOL CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) { | 212 bool CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) { |
213 if (m_bMouseDown) | 213 if (m_bMouseDown) |
214 return TRUE; | 214 return true; |
215 | 215 |
216 CPWL_Wnd::OnChar(nChar, nFlag); | 216 CPWL_Wnd::OnChar(nChar, nFlag); |
217 | 217 |
218 // FILTER | 218 // FILTER |
219 switch (nChar) { | 219 switch (nChar) { |
220 case 0x0A: | 220 case 0x0A: |
221 case 0x1B: | 221 case 0x1B: |
222 return FALSE; | 222 return false; |
223 default: | 223 default: |
224 break; | 224 break; |
225 } | 225 } |
226 | 226 |
227 FX_BOOL bCtrl = IsCTRLpressed(nFlag); | 227 bool bCtrl = IsCTRLpressed(nFlag); |
228 FX_BOOL bAlt = IsALTpressed(nFlag); | 228 bool bAlt = IsALTpressed(nFlag); |
229 FX_BOOL bShift = IsSHIFTpressed(nFlag); | 229 bool bShift = IsSHIFTpressed(nFlag); |
230 | 230 |
231 uint16_t word = nChar; | 231 uint16_t word = nChar; |
232 | 232 |
233 if (bCtrl && !bAlt) { | 233 if (bCtrl && !bAlt) { |
234 switch (nChar) { | 234 switch (nChar) { |
235 case 'C' - 'A' + 1: | 235 case 'C' - 'A' + 1: |
236 CopyText(); | 236 CopyText(); |
237 return TRUE; | 237 return true; |
238 case 'V' - 'A' + 1: | 238 case 'V' - 'A' + 1: |
239 PasteText(); | 239 PasteText(); |
240 return TRUE; | 240 return true; |
241 case 'X' - 'A' + 1: | 241 case 'X' - 'A' + 1: |
242 CutText(); | 242 CutText(); |
243 return TRUE; | 243 return true; |
244 case 'A' - 'A' + 1: | 244 case 'A' - 'A' + 1: |
245 SelectAll(); | 245 SelectAll(); |
246 return TRUE; | 246 return true; |
247 case 'Z' - 'A' + 1: | 247 case 'Z' - 'A' + 1: |
248 if (bShift) | 248 if (bShift) |
249 Redo(); | 249 Redo(); |
250 else | 250 else |
251 Undo(); | 251 Undo(); |
252 return TRUE; | 252 return true; |
253 default: | 253 default: |
254 if (nChar < 32) | 254 if (nChar < 32) |
255 return FALSE; | 255 return false; |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 if (IsReadOnly()) | 259 if (IsReadOnly()) |
260 return TRUE; | 260 return true; |
261 | 261 |
262 if (m_pEdit->IsSelected() && word == FWL_VKEY_Back) | 262 if (m_pEdit->IsSelected() && word == FWL_VKEY_Back) |
263 word = FWL_VKEY_Unknown; | 263 word = FWL_VKEY_Unknown; |
264 | 264 |
265 Clear(); | 265 Clear(); |
266 | 266 |
267 switch (word) { | 267 switch (word) { |
268 case FWL_VKEY_Back: | 268 case FWL_VKEY_Back: |
269 Backspace(); | 269 Backspace(); |
270 break; | 270 break; |
271 case FWL_VKEY_Return: | 271 case FWL_VKEY_Return: |
272 InsertReturn(); | 272 InsertReturn(); |
273 break; | 273 break; |
274 case FWL_VKEY_Unknown: | 274 case FWL_VKEY_Unknown: |
275 break; | 275 break; |
276 default: | 276 default: |
277 InsertWord(word, GetCharSet()); | 277 InsertWord(word, GetCharSet()); |
278 break; | 278 break; |
279 } | 279 } |
280 | 280 |
281 return TRUE; | 281 return true; |
282 } | 282 } |
283 | 283 |
284 FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CFX_FloatPoint& point, | 284 bool CPWL_EditCtrl::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) { |
285 uint32_t nFlag) { | |
286 CPWL_Wnd::OnLButtonDown(point, nFlag); | 285 CPWL_Wnd::OnLButtonDown(point, nFlag); |
287 | 286 |
288 if (ClientHitTest(point)) { | 287 if (ClientHitTest(point)) { |
289 if (m_bMouseDown) | 288 if (m_bMouseDown) |
290 InvalidateRect(); | 289 InvalidateRect(); |
291 | 290 |
292 m_bMouseDown = TRUE; | 291 m_bMouseDown = true; |
293 SetCapture(); | 292 SetCapture(); |
294 | 293 |
295 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 294 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
296 } | 295 } |
297 | 296 |
298 return TRUE; | 297 return true; |
299 } | 298 } |
300 | 299 |
301 FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CFX_FloatPoint& point, | 300 bool CPWL_EditCtrl::OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) { |
302 uint32_t nFlag) { | |
303 CPWL_Wnd::OnLButtonUp(point, nFlag); | 301 CPWL_Wnd::OnLButtonUp(point, nFlag); |
304 | 302 |
305 if (m_bMouseDown) { | 303 if (m_bMouseDown) { |
306 // can receive keybord message | 304 // can receive keybord message |
307 if (ClientHitTest(point) && !IsFocused()) | 305 if (ClientHitTest(point) && !IsFocused()) |
308 SetFocus(); | 306 SetFocus(); |
309 | 307 |
310 ReleaseCapture(); | 308 ReleaseCapture(); |
311 m_bMouseDown = FALSE; | 309 m_bMouseDown = false; |
312 } | 310 } |
313 | 311 |
314 return TRUE; | 312 return true; |
315 } | 313 } |
316 | 314 |
317 FX_BOOL CPWL_EditCtrl::OnMouseMove(const CFX_FloatPoint& point, | 315 bool CPWL_EditCtrl::OnMouseMove(const CFX_FloatPoint& point, uint32_t nFlag) { |
318 uint32_t nFlag) { | |
319 CPWL_Wnd::OnMouseMove(point, nFlag); | 316 CPWL_Wnd::OnMouseMove(point, nFlag); |
320 | 317 |
321 if (m_bMouseDown) | 318 if (m_bMouseDown) |
322 m_pEdit->OnMouseMove(point, FALSE, FALSE); | 319 m_pEdit->OnMouseMove(point, false, false); |
323 | 320 |
324 return TRUE; | 321 return true; |
325 } | 322 } |
326 | 323 |
327 CFX_FloatRect CPWL_EditCtrl::GetContentRect() const { | 324 CFX_FloatRect CPWL_EditCtrl::GetContentRect() const { |
328 return m_pEdit->GetContentRect(); | 325 return m_pEdit->GetContentRect(); |
329 } | 326 } |
330 | 327 |
331 void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) { | 328 void CPWL_EditCtrl::SetEditCaret(bool bVisible) { |
332 CFX_FloatPoint ptHead; | 329 CFX_FloatPoint ptHead; |
333 CFX_FloatPoint ptFoot; | 330 CFX_FloatPoint ptFoot; |
334 if (bVisible) | 331 if (bVisible) |
335 GetCaretInfo(ptHead, ptFoot); | 332 GetCaretInfo(ptHead, ptFoot); |
336 | 333 |
337 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace(); | 334 CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace(); |
338 IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp); | 335 IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp); |
339 } | 336 } |
340 | 337 |
341 void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead, | 338 void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead, |
(...skipping 15 matching lines...) Expand all Loading... |
357 } | 354 } |
358 } | 355 } |
359 | 356 |
360 void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const { | 357 void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const { |
361 CFX_FloatPoint ptHead; | 358 CFX_FloatPoint ptHead; |
362 CFX_FloatPoint ptFoot; | 359 CFX_FloatPoint ptFoot; |
363 GetCaretInfo(ptHead, ptFoot); | 360 GetCaretInfo(ptHead, ptFoot); |
364 PWLtoWnd(ptHead, x, y); | 361 PWLtoWnd(ptHead, x, y); |
365 } | 362 } |
366 | 363 |
367 void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible, | 364 void CPWL_EditCtrl::SetCaret(bool bVisible, |
368 const CFX_FloatPoint& ptHead, | 365 const CFX_FloatPoint& ptHead, |
369 const CFX_FloatPoint& ptFoot) { | 366 const CFX_FloatPoint& ptFoot) { |
370 if (m_pEditCaret) { | 367 if (m_pEditCaret) { |
371 if (!IsFocused() || m_pEdit->IsSelected()) | 368 if (!IsFocused() || m_pEdit->IsSelected()) |
372 bVisible = FALSE; | 369 bVisible = false; |
373 | 370 |
374 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot); | 371 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot); |
375 } | 372 } |
376 } | 373 } |
377 | 374 |
378 CFX_WideString CPWL_EditCtrl::GetText() const { | 375 CFX_WideString CPWL_EditCtrl::GetText() const { |
379 return m_pEdit->GetText(); | 376 return m_pEdit->GetText(); |
380 } | 377 } |
381 | 378 |
382 void CPWL_EditCtrl::SetSel(int32_t nStartChar, int32_t nEndChar) { | 379 void CPWL_EditCtrl::SetSel(int32_t nStartChar, int32_t nEndChar) { |
(...skipping 10 matching lines...) Expand all Loading... |
393 } | 390 } |
394 | 391 |
395 void CPWL_EditCtrl::SelectAll() { | 392 void CPWL_EditCtrl::SelectAll() { |
396 m_pEdit->SelectAll(); | 393 m_pEdit->SelectAll(); |
397 } | 394 } |
398 | 395 |
399 void CPWL_EditCtrl::Paint() { | 396 void CPWL_EditCtrl::Paint() { |
400 m_pEdit->Paint(); | 397 m_pEdit->Paint(); |
401 } | 398 } |
402 | 399 |
403 void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh) { | 400 void CPWL_EditCtrl::EnableRefresh(bool bRefresh) { |
404 m_pEdit->EnableRefresh(bRefresh); | 401 m_pEdit->EnableRefresh(bRefresh); |
405 } | 402 } |
406 | 403 |
407 int32_t CPWL_EditCtrl::GetCaret() const { | 404 int32_t CPWL_EditCtrl::GetCaret() const { |
408 return m_pEdit->GetCaret(); | 405 return m_pEdit->GetCaret(); |
409 } | 406 } |
410 | 407 |
411 void CPWL_EditCtrl::SetCaret(int32_t nPos) { | 408 void CPWL_EditCtrl::SetCaret(int32_t nPos) { |
412 m_pEdit->SetCaret(nPos); | 409 m_pEdit->SetCaret(nPos); |
413 } | 410 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 void CPWL_EditCtrl::SetText(const CFX_WideString& wsText) { | 463 void CPWL_EditCtrl::SetText(const CFX_WideString& wsText) { |
467 m_pEdit->SetText(wsText); | 464 m_pEdit->SetText(wsText); |
468 } | 465 } |
469 | 466 |
470 void CPWL_EditCtrl::CopyText() {} | 467 void CPWL_EditCtrl::CopyText() {} |
471 | 468 |
472 void CPWL_EditCtrl::PasteText() {} | 469 void CPWL_EditCtrl::PasteText() {} |
473 | 470 |
474 void CPWL_EditCtrl::CutText() {} | 471 void CPWL_EditCtrl::CutText() {} |
475 | 472 |
476 void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) {} | 473 void CPWL_EditCtrl::ShowVScrollBar(bool bShow) {} |
477 | 474 |
478 void CPWL_EditCtrl::InsertText(const CFX_WideString& wsText) { | 475 void CPWL_EditCtrl::InsertText(const CFX_WideString& wsText) { |
479 if (!IsReadOnly()) | 476 if (!IsReadOnly()) |
480 m_pEdit->InsertText(wsText, FXFONT_DEFAULT_CHARSET); | 477 m_pEdit->InsertText(wsText, FXFONT_DEFAULT_CHARSET); |
481 } | 478 } |
482 | 479 |
483 void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) { | 480 void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) { |
484 if (!IsReadOnly()) | 481 if (!IsReadOnly()) |
485 m_pEdit->InsertWord(word, nCharset); | 482 m_pEdit->InsertWord(word, nCharset); |
486 } | 483 } |
487 | 484 |
488 void CPWL_EditCtrl::InsertReturn() { | 485 void CPWL_EditCtrl::InsertReturn() { |
489 if (!IsReadOnly()) | 486 if (!IsReadOnly()) |
490 m_pEdit->InsertReturn(); | 487 m_pEdit->InsertReturn(); |
491 } | 488 } |
492 | 489 |
493 void CPWL_EditCtrl::Delete() { | 490 void CPWL_EditCtrl::Delete() { |
494 if (!IsReadOnly()) | 491 if (!IsReadOnly()) |
495 m_pEdit->Delete(); | 492 m_pEdit->Delete(); |
496 } | 493 } |
497 | 494 |
498 void CPWL_EditCtrl::Backspace() { | 495 void CPWL_EditCtrl::Backspace() { |
499 if (!IsReadOnly()) | 496 if (!IsReadOnly()) |
500 m_pEdit->Backspace(); | 497 m_pEdit->Backspace(); |
501 } | 498 } |
502 | 499 |
503 FX_BOOL CPWL_EditCtrl::CanUndo() const { | 500 bool CPWL_EditCtrl::CanUndo() const { |
504 return !IsReadOnly() && m_pEdit->CanUndo(); | 501 return !IsReadOnly() && m_pEdit->CanUndo(); |
505 } | 502 } |
506 | 503 |
507 FX_BOOL CPWL_EditCtrl::CanRedo() const { | 504 bool CPWL_EditCtrl::CanRedo() const { |
508 return !IsReadOnly() && m_pEdit->CanRedo(); | 505 return !IsReadOnly() && m_pEdit->CanRedo(); |
509 } | 506 } |
510 | 507 |
511 void CPWL_EditCtrl::Redo() { | 508 void CPWL_EditCtrl::Redo() { |
512 if (CanRedo()) | 509 if (CanRedo()) |
513 m_pEdit->Redo(); | 510 m_pEdit->Redo(); |
514 } | 511 } |
515 | 512 |
516 void CPWL_EditCtrl::Undo() { | 513 void CPWL_EditCtrl::Undo() { |
517 if (CanUndo()) | 514 if (CanUndo()) |
(...skipping 11 matching lines...) Expand all Loading... |
529 Info.fPlateWidth = fPlateMax - fPlateMin; | 526 Info.fPlateWidth = fPlateMax - fPlateMin; |
530 Info.fContentMin = fContentMin; | 527 Info.fContentMin = fContentMin; |
531 Info.fContentMax = fContentMax; | 528 Info.fContentMax = fContentMax; |
532 Info.fSmallStep = fSmallStep; | 529 Info.fSmallStep = fSmallStep; |
533 Info.fBigStep = fBigStep; | 530 Info.fBigStep = fBigStep; |
534 | 531 |
535 OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info); | 532 OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info); |
536 | 533 |
537 if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || | 534 if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || |
538 IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { | 535 IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { |
539 ShowVScrollBar(FALSE); | 536 ShowVScrollBar(false); |
540 } else { | 537 } else { |
541 ShowVScrollBar(TRUE); | 538 ShowVScrollBar(true); |
542 } | 539 } |
543 } | 540 } |
544 | 541 |
545 void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) { | 542 void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) { |
546 OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy); | 543 OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy); |
547 } | 544 } |
548 | 545 |
549 void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible, | 546 void CPWL_EditCtrl::IOnSetCaret(bool bVisible, |
550 const CFX_FloatPoint& ptHead, | 547 const CFX_FloatPoint& ptHead, |
551 const CFX_FloatPoint& ptFoot, | 548 const CFX_FloatPoint& ptFoot, |
552 const CPVT_WordPlace& place) { | 549 const CPVT_WordPlace& place) { |
553 PWL_CARET_INFO cInfo; | 550 PWL_CARET_INFO cInfo; |
554 cInfo.bVisible = bVisible; | 551 cInfo.bVisible = bVisible; |
555 cInfo.ptHead = ptHead; | 552 cInfo.ptHead = ptHead; |
556 cInfo.ptFoot = ptFoot; | 553 cInfo.ptFoot = ptFoot; |
557 | 554 |
558 OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t) nullptr); | 555 OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t) nullptr); |
559 } | 556 } |
(...skipping 23 matching lines...) Expand all Loading... |
583 CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar, | 580 CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar, |
584 int32_t& nEndChar) const { | 581 int32_t& nEndChar) const { |
585 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); | 582 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); |
586 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); | 583 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); |
587 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); | 584 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); |
588 } | 585 } |
589 | 586 |
590 void CPWL_EditCtrl::SetReadyToInput() { | 587 void CPWL_EditCtrl::SetReadyToInput() { |
591 if (m_bMouseDown) { | 588 if (m_bMouseDown) { |
592 ReleaseCapture(); | 589 ReleaseCapture(); |
593 m_bMouseDown = FALSE; | 590 m_bMouseDown = false; |
594 } | 591 } |
595 } | 592 } |
OLD | NEW |