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/include/pdfwindow/PWL_Edit.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" |
8 | 8 |
9 #include "core/include/fxcrt/fx_safe_types.h" | 9 #include "core/include/fxcrt/fx_safe_types.h" |
10 #include "core/include/fxcrt/fx_xml.h" | 10 #include "core/include/fxcrt/fx_xml.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 delete pXML; | 67 delete pXML; |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 m_pEdit->SetText(swText.c_str()); | 71 m_pEdit->SetText(swText.c_str()); |
72 } | 72 } |
73 | 73 |
74 void CPWL_Edit::RePosChildWnd() { | 74 void CPWL_Edit::RePosChildWnd() { |
75 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { | 75 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { |
76 CPDF_Rect rcWindow = m_rcOldWindow; | 76 CFX_FloatRect rcWindow = m_rcOldWindow; |
77 CPDF_Rect rcVScroll = | 77 CFX_FloatRect rcVScroll = |
78 CPDF_Rect(rcWindow.right, rcWindow.bottom, | 78 CFX_FloatRect(rcWindow.right, rcWindow.bottom, |
79 rcWindow.right + PWL_SCROLLBAR_WIDTH, rcWindow.top); | 79 rcWindow.right + PWL_SCROLLBAR_WIDTH, rcWindow.top); |
80 pVSB->Move(rcVScroll, TRUE, FALSE); | 80 pVSB->Move(rcVScroll, TRUE, FALSE); |
81 } | 81 } |
82 | 82 |
83 if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW)) | 83 if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW)) |
84 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect( | 84 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect( |
85 GetClientRect(), 1.0f)); // +1 for caret beside border | 85 GetClientRect(), 1.0f)); // +1 for caret beside border |
86 | 86 |
87 CPWL_EditCtrl::RePosChildWnd(); | 87 CPWL_EditCtrl::RePosChildWnd(); |
88 } | 88 } |
89 | 89 |
90 CPDF_Rect CPWL_Edit::GetClientRect() const { | 90 CFX_FloatRect CPWL_Edit::GetClientRect() const { |
91 CPDF_Rect rcClient = CPWL_Utils::DeflateRect( | 91 CFX_FloatRect rcClient = CPWL_Utils::DeflateRect( |
92 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); | 92 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
93 | 93 |
94 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { | 94 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { |
95 if (pVSB->IsVisible()) { | 95 if (pVSB->IsVisible()) { |
96 rcClient.right -= PWL_SCROLLBAR_WIDTH; | 96 rcClient.right -= PWL_SCROLLBAR_WIDTH; |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 return rcClient; | 100 return rcClient; |
101 } | 101 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 m_pEdit->SetPasswordChar('*', FALSE); | 227 m_pEdit->SetPasswordChar('*', FALSE); |
228 } | 228 } |
229 | 229 |
230 m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE), FALSE); | 230 m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE), FALSE); |
231 m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN), FALSE); | 231 m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN), FALSE); |
232 m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE), FALSE); | 232 m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE), FALSE); |
233 m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL), FALSE); | 233 m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL), FALSE); |
234 m_pEdit->EnableUndo(HasFlag(PES_UNDO)); | 234 m_pEdit->EnableUndo(HasFlag(PES_UNDO)); |
235 | 235 |
236 if (HasFlag(PES_TEXTOVERFLOW)) { | 236 if (HasFlag(PES_TEXTOVERFLOW)) { |
237 SetClipRect(CPDF_Rect(0.0f, 0.0f, 0.0f, 0.0f)); | 237 SetClipRect(CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f)); |
238 m_pEdit->SetTextOverflow(TRUE, FALSE); | 238 m_pEdit->SetTextOverflow(TRUE, FALSE); |
239 } else { | 239 } else { |
240 if (m_pEditCaret) { | 240 if (m_pEditCaret) { |
241 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect( | 241 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect( |
242 GetClientRect(), 1.0f)); // +1 for caret beside border | 242 GetClientRect(), 1.0f)); // +1 for caret beside border |
243 } | 243 } |
244 } | 244 } |
245 | 245 |
246 if (HasFlag(PES_SPELLCHECK)) { | 246 if (HasFlag(PES_SPELLCHECK)) { |
247 m_pSpellCheck = GetCreationParam().pSpellCheck; | 247 m_pSpellCheck = GetCreationParam().pSpellCheck; |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { | 251 void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
252 CPWL_Wnd::GetThisAppearanceStream(sAppStream); | 252 CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
253 | 253 |
254 CPDF_Rect rcClient = GetClientRect(); | 254 CFX_FloatRect rcClient = GetClientRect(); |
255 CFX_ByteTextBuf sLine; | 255 CFX_ByteTextBuf sLine; |
256 | 256 |
257 int32_t nCharArray = m_pEdit->GetCharArray(); | 257 int32_t nCharArray = m_pEdit->GetCharArray(); |
258 | 258 |
259 if (nCharArray > 0) { | 259 if (nCharArray > 0) { |
260 switch (GetBorderStyle()) { | 260 switch (GetBorderStyle()) { |
261 case PBS_SOLID: { | 261 case PBS_SOLID: { |
262 sLine << "q\n" << GetBorderWidth() << " w\n" | 262 sLine << "q\n" << GetBorderWidth() << " w\n" |
263 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) | 263 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
264 << " 2 J 0 j\n"; | 264 << " 2 J 0 j\n"; |
(...skipping 27 matching lines...) Expand all Loading... |
292 | 292 |
293 sLine << "Q\n"; | 293 sLine << "Q\n"; |
294 } break; | 294 } break; |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 sAppStream << sLine; | 298 sAppStream << sLine; |
299 | 299 |
300 CFX_ByteTextBuf sText; | 300 CFX_ByteTextBuf sText; |
301 | 301 |
302 CPDF_Point ptOffset = CPDF_Point(0.0f, 0.0f); | 302 CFX_FloatPoint ptOffset = CFX_FloatPoint(0.0f, 0.0f); |
303 | 303 |
304 CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange(); | 304 CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange(); |
305 CPVT_WordRange wrSelect = GetSelectWordRange(); | 305 CPVT_WordRange wrSelect = GetSelectWordRange(); |
306 CPVT_WordRange wrVisible = | 306 CPVT_WordRange wrVisible = |
307 (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange()); | 307 (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange()); |
308 CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); | 308 CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); |
309 CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); | 309 CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); |
310 | 310 |
311 CPVT_WordRange wrTemp = | 311 CPVT_WordRange wrTemp = |
312 CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); | 312 CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 if (HasFlag(PES_SPELLCHECK)) { | 348 if (HasFlag(PES_SPELLCHECK)) { |
349 CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream( | 349 CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream( |
350 m_pEdit, m_pSpellCheck, ptOffset, &wrVisible); | 350 m_pEdit, m_pSpellCheck, ptOffset, &wrVisible); |
351 if (sSpellCheck.GetLength() > 0) | 351 if (sSpellCheck.GetLength() > 0) |
352 sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0), | 352 sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0), |
353 FALSE) | 353 FALSE) |
354 << sSpellCheck; | 354 << sSpellCheck; |
355 } | 355 } |
356 | 356 |
357 if (sText.GetLength() > 0) { | 357 if (sText.GetLength() > 0) { |
358 CPDF_Rect rcClient = GetClientRect(); | 358 CFX_FloatRect rcClient = GetClientRect(); |
359 sAppStream << "q\n/Tx BMC\n"; | 359 sAppStream << "q\n/Tx BMC\n"; |
360 | 360 |
361 if (!HasFlag(PES_TEXTOVERFLOW)) | 361 if (!HasFlag(PES_TEXTOVERFLOW)) |
362 sAppStream << rcClient.left << " " << rcClient.bottom << " " | 362 sAppStream << rcClient.left << " " << rcClient.bottom << " " |
363 << rcClient.right - rcClient.left << " " | 363 << rcClient.right - rcClient.left << " " |
364 << rcClient.top - rcClient.bottom << " re W n\n"; | 364 << rcClient.top - rcClient.bottom << " re W n\n"; |
365 | 365 |
366 sAppStream << sText; | 366 sAppStream << sText; |
367 | 367 |
368 sAppStream << "EMC\nQ\n"; | 368 sAppStream << "EMC\nQ\n"; |
369 } | 369 } |
370 } | 370 } |
371 | 371 |
372 void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, | 372 void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, |
373 CFX_Matrix* pUser2Device) { | 373 CFX_Matrix* pUser2Device) { |
374 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); | 374 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); |
375 | 375 |
376 CPDF_Rect rcClient = GetClientRect(); | 376 CFX_FloatRect rcClient = GetClientRect(); |
377 CFX_ByteTextBuf sLine; | 377 CFX_ByteTextBuf sLine; |
378 | 378 |
379 int32_t nCharArray = m_pEdit->GetCharArray(); | 379 int32_t nCharArray = m_pEdit->GetCharArray(); |
380 FX_SAFE_INT32 nCharArraySafe = nCharArray; | 380 FX_SAFE_INT32 nCharArraySafe = nCharArray; |
381 nCharArraySafe -= 1; | 381 nCharArraySafe -= 1; |
382 nCharArraySafe *= 2; | 382 nCharArraySafe *= 2; |
383 | 383 |
384 if (nCharArray > 0 && nCharArraySafe.IsValid()) { | 384 if (nCharArray > 0 && nCharArraySafe.IsValid()) { |
385 switch (GetBorderStyle()) { | 385 switch (GetBorderStyle()) { |
386 case PBS_SOLID: { | 386 case PBS_SOLID: { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 434 } |
435 if (path.GetPointCount() > 0) | 435 if (path.GetPointCount() > 0) |
436 pDevice->DrawPath( | 436 pDevice->DrawPath( |
437 &path, pUser2Device, &gsd, 0, | 437 &path, pUser2Device, &gsd, 0, |
438 CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), | 438 CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), |
439 FXFILL_ALTERNATE); | 439 FXFILL_ALTERNATE); |
440 } break; | 440 } break; |
441 } | 441 } |
442 } | 442 } |
443 | 443 |
444 CPDF_Rect rcClip; | 444 CFX_FloatRect rcClip; |
445 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); | 445 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); |
446 CPVT_WordRange* pRange = NULL; | 446 CPVT_WordRange* pRange = NULL; |
447 | 447 |
448 if (!HasFlag(PES_TEXTOVERFLOW)) { | 448 if (!HasFlag(PES_TEXTOVERFLOW)) { |
449 rcClip = GetClientRect(); | 449 rcClip = GetClientRect(); |
450 pRange = &wrRange; | 450 pRange = &wrRange; |
451 } | 451 } |
452 IFX_SystemHandler* pSysHandler = GetSystemHandler(); | 452 IFX_SystemHandler* pSysHandler = GetSystemHandler(); |
453 IFX_Edit::DrawEdit( | 453 IFX_Edit::DrawEdit( |
454 pDevice, pUser2Device, m_pEdit, | 454 pDevice, pUser2Device, m_pEdit, |
455 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 455 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
456 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), | 456 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), |
457 rcClip, CPDF_Point(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller); | 457 rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller); |
458 | 458 |
459 if (HasFlag(PES_SPELLCHECK)) { | 459 if (HasFlag(PES_SPELLCHECK)) { |
460 CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip, | 460 CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip, |
461 CPDF_Point(0.0f, 0.0f), pRange, | 461 CFX_FloatPoint(0.0f, 0.0f), pRange, |
462 GetCreationParam().pSpellCheck); | 462 GetCreationParam().pSpellCheck); |
463 } | 463 } |
464 } | 464 } |
465 | 465 |
466 FX_BOOL CPWL_Edit::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) { | 466 FX_BOOL CPWL_Edit::OnLButtonDown(const CFX_FloatPoint& point, FX_DWORD nFlag) { |
467 CPWL_Wnd::OnLButtonDown(point, nFlag); | 467 CPWL_Wnd::OnLButtonDown(point, nFlag); |
468 | 468 |
469 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { | 469 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { |
470 if (m_bMouseDown) | 470 if (m_bMouseDown) |
471 InvalidateRect(); | 471 InvalidateRect(); |
472 | 472 |
473 m_bMouseDown = TRUE; | 473 m_bMouseDown = TRUE; |
474 SetCapture(); | 474 SetCapture(); |
475 | 475 |
476 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 476 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
477 } | 477 } |
478 | 478 |
479 return TRUE; | 479 return TRUE; |
480 } | 480 } |
481 | 481 |
482 FX_BOOL CPWL_Edit::OnLButtonDblClk(const CPDF_Point& point, FX_DWORD nFlag) { | 482 FX_BOOL CPWL_Edit::OnLButtonDblClk(const CFX_FloatPoint& point, |
| 483 FX_DWORD nFlag) { |
483 CPWL_Wnd::OnLButtonDblClk(point, nFlag); | 484 CPWL_Wnd::OnLButtonDblClk(point, nFlag); |
484 | 485 |
485 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { | 486 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { |
486 m_pEdit->SelectAll(); | 487 m_pEdit->SelectAll(); |
487 } | 488 } |
488 | 489 |
489 return TRUE; | 490 return TRUE; |
490 } | 491 } |
491 | 492 |
492 #define WM_PWLEDIT_UNDO 0x01 | 493 #define WM_PWLEDIT_UNDO 0x01 |
493 #define WM_PWLEDIT_REDO 0x02 | 494 #define WM_PWLEDIT_REDO 0x02 |
494 #define WM_PWLEDIT_CUT 0x03 | 495 #define WM_PWLEDIT_CUT 0x03 |
495 #define WM_PWLEDIT_COPY 0x04 | 496 #define WM_PWLEDIT_COPY 0x04 |
496 #define WM_PWLEDIT_PASTE 0x05 | 497 #define WM_PWLEDIT_PASTE 0x05 |
497 #define WM_PWLEDIT_DELETE 0x06 | 498 #define WM_PWLEDIT_DELETE 0x06 |
498 #define WM_PWLEDIT_SELECTALL 0x07 | 499 #define WM_PWLEDIT_SELECTALL 0x07 |
499 #define WM_PWLEDIT_SUGGEST 0x08 | 500 #define WM_PWLEDIT_SUGGEST 0x08 |
500 | 501 |
501 FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { | 502 FX_BOOL CPWL_Edit::OnRButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) { |
502 if (m_bMouseDown) | 503 if (m_bMouseDown) |
503 return FALSE; | 504 return FALSE; |
504 | 505 |
505 CPWL_Wnd::OnRButtonUp(point, nFlag); | 506 CPWL_Wnd::OnRButtonUp(point, nFlag); |
506 | 507 |
507 if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) | 508 if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) |
508 return TRUE; | 509 return TRUE; |
509 | 510 |
510 IFX_SystemHandler* pSH = GetSystemHandler(); | 511 IFX_SystemHandler* pSH = GetSystemHandler(); |
511 if (!pSH) | 512 if (!pSH) |
512 return FALSE; | 513 return FALSE; |
513 | 514 |
514 SetFocus(); | 515 SetFocus(); |
515 | 516 |
516 CPVT_WordRange wrLatin = GetLatinWordsRange(point); | 517 CPVT_WordRange wrLatin = GetLatinWordsRange(point); |
517 CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin); | 518 CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin); |
518 | 519 |
519 FX_HMENU hPopup = pSH->CreatePopupMenu(); | 520 FX_HMENU hPopup = pSH->CreatePopupMenu(); |
520 if (!hPopup) | 521 if (!hPopup) |
521 return FALSE; | 522 return FALSE; |
522 | 523 |
523 std::vector<CFX_ByteString> sSuggestWords; | 524 std::vector<CFX_ByteString> sSuggestWords; |
524 CPDF_Point ptPopup = point; | 525 CFX_FloatPoint ptPopup = point; |
525 | 526 |
526 if (!IsReadOnly()) { | 527 if (!IsReadOnly()) { |
527 if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) { | 528 if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) { |
528 if (m_pSpellCheck) { | 529 if (m_pSpellCheck) { |
529 CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin); | 530 CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin); |
530 if (!m_pSpellCheck->CheckWord(sLatin)) { | 531 if (!m_pSpellCheck->CheckWord(sLatin)) { |
531 m_pSpellCheck->SuggestWords(sLatin, sSuggestWords); | 532 m_pSpellCheck->SuggestWords(sLatin, sSuggestWords); |
532 | 533 |
533 int32_t nSuggest = pdfium::CollectionSize<int32_t>(sSuggestWords); | 534 int32_t nSuggest = pdfium::CollectionSize<int32_t>(sSuggestWords); |
534 for (int32_t nWord = 0; nWord < nSuggest; nWord++) { | 535 for (int32_t nWord = 0; nWord < nSuggest; nWord++) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 pFocusHandler->OnSetFocus(this); | 678 pFocusHandler->OnSetFocus(this); |
678 } | 679 } |
679 | 680 |
680 m_bFocus = TRUE; | 681 m_bFocus = TRUE; |
681 } | 682 } |
682 | 683 |
683 void CPWL_Edit::OnKillFocus() { | 684 void CPWL_Edit::OnKillFocus() { |
684 ShowVScrollBar(FALSE); | 685 ShowVScrollBar(FALSE); |
685 | 686 |
686 m_pEdit->SelectNone(); | 687 m_pEdit->SelectNone(); |
687 SetCaret(FALSE, CPDF_Point(0.0f, 0.0f), CPDF_Point(0.0f, 0.0f)); | 688 SetCaret(FALSE, CFX_FloatPoint(0.0f, 0.0f), CFX_FloatPoint(0.0f, 0.0f)); |
688 | 689 |
689 SetCharSet(0); | 690 SetCharSet(0); |
690 | 691 |
691 if (!IsReadOnly()) { | 692 if (!IsReadOnly()) { |
692 if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) | 693 if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) |
693 pFocusHandler->OnKillFocus(this); | 694 pFocusHandler->OnKillFocus(this); |
694 } | 695 } |
695 | 696 |
696 m_bFocus = FALSE; | 697 m_bFocus = FALSE; |
697 } | 698 } |
698 | 699 |
699 void CPWL_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint /* = TRUE*/) { | 700 void CPWL_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint /* = TRUE*/) { |
700 m_pEdit->SetHorzScale(nHorzScale, bPaint); | 701 m_pEdit->SetHorzScale(nHorzScale, bPaint); |
701 } | 702 } |
702 | 703 |
703 void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint /* = TRUE*/) { | 704 void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint /* = TRUE*/) { |
704 m_pEdit->SetCharSpace(fCharSpace, bPaint); | 705 m_pEdit->SetCharSpace(fCharSpace, bPaint); |
705 } | 706 } |
706 | 707 |
707 void CPWL_Edit::SetLineLeading(FX_FLOAT fLineLeading, | 708 void CPWL_Edit::SetLineLeading(FX_FLOAT fLineLeading, |
708 FX_BOOL bPaint /* = TRUE*/) { | 709 FX_BOOL bPaint /* = TRUE*/) { |
709 m_pEdit->SetLineLeading(fLineLeading, bPaint); | 710 m_pEdit->SetLineLeading(fLineLeading, bPaint); |
710 } | 711 } |
711 | 712 |
712 CFX_ByteString CPWL_Edit::GetSelectAppearanceStream( | 713 CFX_ByteString CPWL_Edit::GetSelectAppearanceStream( |
713 const CPDF_Point& ptOffset) const { | 714 const CFX_FloatPoint& ptOffset) const { |
714 CPVT_WordRange wr = GetSelectWordRange(); | 715 CPVT_WordRange wr = GetSelectWordRange(); |
715 return CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wr); | 716 return CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wr); |
716 } | 717 } |
717 | 718 |
718 CPVT_WordRange CPWL_Edit::GetSelectWordRange() const { | 719 CPVT_WordRange CPWL_Edit::GetSelectWordRange() const { |
719 if (m_pEdit->IsSelected()) { | 720 if (m_pEdit->IsSelected()) { |
720 int32_t nStart = -1; | 721 int32_t nStart = -1; |
721 int32_t nEnd = -1; | 722 int32_t nEnd = -1; |
722 | 723 |
723 m_pEdit->GetSel(nStart, nEnd); | 724 m_pEdit->GetSel(nStart, nEnd); |
724 | 725 |
725 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStart); | 726 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStart); |
726 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEnd); | 727 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEnd); |
727 | 728 |
728 return CPVT_WordRange(wpStart, wpEnd); | 729 return CPVT_WordRange(wpStart, wpEnd); |
729 } | 730 } |
730 | 731 |
731 return CPVT_WordRange(); | 732 return CPVT_WordRange(); |
732 } | 733 } |
733 | 734 |
734 CFX_ByteString CPWL_Edit::GetTextAppearanceStream( | 735 CFX_ByteString CPWL_Edit::GetTextAppearanceStream( |
735 const CPDF_Point& ptOffset) const { | 736 const CFX_FloatPoint& ptOffset) const { |
736 CFX_ByteTextBuf sRet; | 737 CFX_ByteTextBuf sRet; |
737 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); | 738 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); |
738 | 739 |
739 if (sEdit.GetLength() > 0) { | 740 if (sEdit.GetLength() > 0) { |
740 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit | 741 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit |
741 << "ET\n"; | 742 << "ET\n"; |
742 } | 743 } |
743 | 744 |
744 return sRet.GetByteString(); | 745 return sRet.GetByteString(); |
745 } | 746 } |
746 | 747 |
747 CFX_ByteString CPWL_Edit::GetCaretAppearanceStream( | 748 CFX_ByteString CPWL_Edit::GetCaretAppearanceStream( |
748 const CPDF_Point& ptOffset) const { | 749 const CFX_FloatPoint& ptOffset) const { |
749 if (m_pEditCaret) | 750 if (m_pEditCaret) |
750 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); | 751 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); |
751 | 752 |
752 return CFX_ByteString(); | 753 return CFX_ByteString(); |
753 } | 754 } |
754 | 755 |
755 CPDF_Point CPWL_Edit::GetWordRightBottomPoint(const CPVT_WordPlace& wpWord) { | 756 CFX_FloatPoint CPWL_Edit::GetWordRightBottomPoint( |
756 CPDF_Point pt(0.0f, 0.0f); | 757 const CPVT_WordPlace& wpWord) { |
| 758 CFX_FloatPoint pt(0.0f, 0.0f); |
757 | 759 |
758 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { | 760 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { |
759 CPVT_WordPlace wpOld = pIterator->GetAt(); | 761 CPVT_WordPlace wpOld = pIterator->GetAt(); |
760 pIterator->SetAt(wpWord); | 762 pIterator->SetAt(wpWord); |
761 CPVT_Word word; | 763 CPVT_Word word; |
762 if (pIterator->GetWord(word)) { | 764 if (pIterator->GetWord(word)) { |
763 pt = CPDF_Point(word.ptWord.x + word.fWidth, | 765 pt = CFX_FloatPoint(word.ptWord.x + word.fWidth, |
764 word.ptWord.y + word.fDescent); | 766 word.ptWord.y + word.fDescent); |
765 } | 767 } |
766 | 768 |
767 pIterator->SetAt(wpOld); | 769 pIterator->SetAt(wpOld); |
768 } | 770 } |
769 | 771 |
770 return pt; | 772 return pt; |
771 } | 773 } |
772 | 774 |
773 FX_BOOL CPWL_Edit::IsTextFull() const { | 775 FX_BOOL CPWL_Edit::IsTextFull() const { |
774 return m_pEdit->IsTextFull(); | 776 return m_pEdit->IsTextFull(); |
775 } | 777 } |
776 | 778 |
777 FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, | 779 FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, |
778 const CPDF_Rect& rcPlate, | 780 const CFX_FloatRect& rcPlate, |
779 int32_t nCharArray) { | 781 int32_t nCharArray) { |
780 if (pFont && !pFont->IsStandardFont()) { | 782 if (pFont && !pFont->IsStandardFont()) { |
781 FX_RECT rcBBox; | 783 FX_RECT rcBBox; |
782 pFont->GetFontBBox(rcBBox); | 784 pFont->GetFontBBox(rcBBox); |
783 | 785 |
784 CPDF_Rect rcCell = rcPlate; | 786 CFX_FloatRect rcCell = rcPlate; |
785 FX_FLOAT xdiv = rcCell.Width() / nCharArray * 1000.0f / rcBBox.Width(); | 787 FX_FLOAT xdiv = rcCell.Width() / nCharArray * 1000.0f / rcBBox.Width(); |
786 FX_FLOAT ydiv = -rcCell.Height() * 1000.0f / rcBBox.Height(); | 788 FX_FLOAT ydiv = -rcCell.Height() * 1000.0f / rcBBox.Height(); |
787 | 789 |
788 return xdiv < ydiv ? xdiv : ydiv; | 790 return xdiv < ydiv ? xdiv : ydiv; |
789 } | 791 } |
790 | 792 |
791 return 0.0f; | 793 return 0.0f; |
792 } | 794 } |
793 | 795 |
794 void CPWL_Edit::SetCharArray(int32_t nCharArray) { | 796 void CPWL_Edit::SetCharArray(int32_t nCharArray) { |
(...skipping 16 matching lines...) Expand all Loading... |
811 | 813 |
812 void CPWL_Edit::SetLimitChar(int32_t nLimitChar) { | 814 void CPWL_Edit::SetLimitChar(int32_t nLimitChar) { |
813 m_pEdit->SetLimitChar(nLimitChar); | 815 m_pEdit->SetLimitChar(nLimitChar); |
814 } | 816 } |
815 | 817 |
816 void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText) { | 818 void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText) { |
817 m_pEdit->Clear(); | 819 m_pEdit->Clear(); |
818 m_pEdit->InsertText(csText); | 820 m_pEdit->InsertText(csText); |
819 } | 821 } |
820 | 822 |
821 CPDF_Rect CPWL_Edit::GetFocusRect() const { | 823 CFX_FloatRect CPWL_Edit::GetFocusRect() const { |
822 return CPDF_Rect(); | 824 return CFX_FloatRect(); |
823 } | 825 } |
824 | 826 |
825 void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) { | 827 void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) { |
826 if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { | 828 if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { |
827 if (bShow) { | 829 if (bShow) { |
828 if (!pScroll->IsVisible()) { | 830 if (!pScroll->IsVisible()) { |
829 pScroll->SetVisible(TRUE); | 831 pScroll->SetVisible(TRUE); |
830 CPDF_Rect rcWindow = GetWindowRect(); | 832 CFX_FloatRect rcWindow = GetWindowRect(); |
831 m_rcOldWindow = rcWindow; | 833 m_rcOldWindow = rcWindow; |
832 rcWindow.right += PWL_SCROLLBAR_WIDTH; | 834 rcWindow.right += PWL_SCROLLBAR_WIDTH; |
833 Move(rcWindow, TRUE, TRUE); | 835 Move(rcWindow, TRUE, TRUE); |
834 } | 836 } |
835 } else { | 837 } else { |
836 if (pScroll->IsVisible()) { | 838 if (pScroll->IsVisible()) { |
837 pScroll->SetVisible(FALSE); | 839 pScroll->SetVisible(FALSE); |
838 Move(m_rcOldWindow, TRUE, TRUE); | 840 Move(m_rcOldWindow, TRUE, TRUE); |
839 } | 841 } |
840 } | 842 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 int32_t nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET); | 971 int32_t nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET); |
970 if (nOldCharSet != nNewCharSet) { | 972 if (nOldCharSet != nNewCharSet) { |
971 SetCharSet(nNewCharSet); | 973 SetCharSet(nNewCharSet); |
972 } | 974 } |
973 } | 975 } |
974 | 976 |
975 return CPWL_EditCtrl::OnChar(nChar, nFlag); | 977 return CPWL_EditCtrl::OnChar(nChar, nFlag); |
976 } | 978 } |
977 | 979 |
978 FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, | 980 FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, |
979 const CPDF_Point& point, | 981 const CFX_FloatPoint& point, |
980 FX_DWORD nFlag) { | 982 FX_DWORD nFlag) { |
981 if (HasFlag(PES_MULTILINE)) { | 983 if (HasFlag(PES_MULTILINE)) { |
982 CPDF_Point ptScroll = GetScrollPos(); | 984 CFX_FloatPoint ptScroll = GetScrollPos(); |
983 | 985 |
984 if (zDelta > 0) { | 986 if (zDelta > 0) { |
985 ptScroll.y += GetFontSize(); | 987 ptScroll.y += GetFontSize(); |
986 } else { | 988 } else { |
987 ptScroll.y -= GetFontSize(); | 989 ptScroll.y -= GetFontSize(); |
988 } | 990 } |
989 SetScrollPos(ptScroll); | 991 SetScrollPos(ptScroll); |
990 | 992 |
991 return TRUE; | 993 return TRUE; |
992 } | 994 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 | 1089 |
1088 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { | 1090 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { |
1089 wrRet.EndPos = wr2.EndPos; | 1091 wrRet.EndPos = wr2.EndPos; |
1090 } else { | 1092 } else { |
1091 wrRet.EndPos = wr1.EndPos; | 1093 wrRet.EndPos = wr1.EndPos; |
1092 } | 1094 } |
1093 | 1095 |
1094 return wrRet; | 1096 return wrRet; |
1095 } | 1097 } |
1096 | 1098 |
1097 CPVT_WordRange CPWL_Edit::GetLatinWordsRange(const CPDF_Point& point) const { | 1099 CPVT_WordRange CPWL_Edit::GetLatinWordsRange( |
| 1100 const CFX_FloatPoint& point) const { |
1098 return GetSameWordsRange(m_pEdit->SearchWordPlace(point), TRUE, FALSE); | 1101 return GetSameWordsRange(m_pEdit->SearchWordPlace(point), TRUE, FALSE); |
1099 } | 1102 } |
1100 | 1103 |
1101 CPVT_WordRange CPWL_Edit::GetLatinWordsRange( | 1104 CPVT_WordRange CPWL_Edit::GetLatinWordsRange( |
1102 const CPVT_WordPlace& place) const { | 1105 const CPVT_WordPlace& place) const { |
1103 return GetSameWordsRange(place, TRUE, FALSE); | 1106 return GetSameWordsRange(place, TRUE, FALSE); |
1104 } | 1107 } |
1105 | 1108 |
1106 CPVT_WordRange CPWL_Edit::GetArabicWordsRange( | 1109 CPVT_WordRange CPWL_Edit::GetArabicWordsRange( |
1107 const CPVT_WordPlace& place) const { | 1110 const CPVT_WordPlace& place) const { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 } | 1163 } |
1161 | 1164 |
1162 range.Set(wpStart, wpEnd); | 1165 range.Set(wpStart, wpEnd); |
1163 } | 1166 } |
1164 | 1167 |
1165 return range; | 1168 return range; |
1166 } | 1169 } |
1167 | 1170 |
1168 void CPWL_Edit::GeneratePageObjects( | 1171 void CPWL_Edit::GeneratePageObjects( |
1169 CPDF_PageObjectHolder* pObjectHolder, | 1172 CPDF_PageObjectHolder* pObjectHolder, |
1170 const CPDF_Point& ptOffset, | 1173 const CFX_FloatPoint& ptOffset, |
1171 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 1174 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
1172 IFX_Edit::GeneratePageObjects( | 1175 IFX_Edit::GeneratePageObjects( |
1173 pObjectHolder, m_pEdit, ptOffset, NULL, | 1176 pObjectHolder, m_pEdit, ptOffset, NULL, |
1174 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1177 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
1175 ObjArray); | 1178 ObjArray); |
1176 } | 1179 } |
1177 | 1180 |
1178 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, | 1181 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, |
1179 const CPDF_Point& ptOffset) { | 1182 const CFX_FloatPoint& ptOffset) { |
1180 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 1183 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
1181 IFX_Edit::GeneratePageObjects( | 1184 IFX_Edit::GeneratePageObjects( |
1182 pObjectHolder, m_pEdit, ptOffset, NULL, | 1185 pObjectHolder, m_pEdit, ptOffset, NULL, |
1183 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1186 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
1184 ObjArray); | 1187 ObjArray); |
1185 } | 1188 } |
OLD | NEW |