| 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_Edit.h" | 7 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), | 460 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), |
| 461 rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller); | 461 rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller); |
| 462 | 462 |
| 463 if (HasFlag(PES_SPELLCHECK)) { | 463 if (HasFlag(PES_SPELLCHECK)) { |
| 464 CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip, | 464 CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip, |
| 465 CFX_FloatPoint(0.0f, 0.0f), pRange, | 465 CFX_FloatPoint(0.0f, 0.0f), pRange, |
| 466 GetCreationParam().pSpellCheck); | 466 GetCreationParam().pSpellCheck); |
| 467 } | 467 } |
| 468 } | 468 } |
| 469 | 469 |
| 470 FX_BOOL CPWL_Edit::OnLButtonDown(const CFX_FloatPoint& point, FX_DWORD nFlag) { | 470 FX_BOOL CPWL_Edit::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) { |
| 471 CPWL_Wnd::OnLButtonDown(point, nFlag); | 471 CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 472 | 472 |
| 473 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { | 473 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { |
| 474 if (m_bMouseDown) | 474 if (m_bMouseDown) |
| 475 InvalidateRect(); | 475 InvalidateRect(); |
| 476 | 476 |
| 477 m_bMouseDown = TRUE; | 477 m_bMouseDown = TRUE; |
| 478 SetCapture(); | 478 SetCapture(); |
| 479 | 479 |
| 480 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 480 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 481 } | 481 } |
| 482 | 482 |
| 483 return TRUE; | 483 return TRUE; |
| 484 } | 484 } |
| 485 | 485 |
| 486 FX_BOOL CPWL_Edit::OnLButtonDblClk(const CFX_FloatPoint& point, | 486 FX_BOOL CPWL_Edit::OnLButtonDblClk(const CFX_FloatPoint& point, |
| 487 FX_DWORD nFlag) { | 487 uint32_t nFlag) { |
| 488 CPWL_Wnd::OnLButtonDblClk(point, nFlag); | 488 CPWL_Wnd::OnLButtonDblClk(point, nFlag); |
| 489 | 489 |
| 490 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { | 490 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { |
| 491 m_pEdit->SelectAll(); | 491 m_pEdit->SelectAll(); |
| 492 } | 492 } |
| 493 | 493 |
| 494 return TRUE; | 494 return TRUE; |
| 495 } | 495 } |
| 496 | 496 |
| 497 #define WM_PWLEDIT_UNDO 0x01 | 497 #define WM_PWLEDIT_UNDO 0x01 |
| 498 #define WM_PWLEDIT_REDO 0x02 | 498 #define WM_PWLEDIT_REDO 0x02 |
| 499 #define WM_PWLEDIT_CUT 0x03 | 499 #define WM_PWLEDIT_CUT 0x03 |
| 500 #define WM_PWLEDIT_COPY 0x04 | 500 #define WM_PWLEDIT_COPY 0x04 |
| 501 #define WM_PWLEDIT_PASTE 0x05 | 501 #define WM_PWLEDIT_PASTE 0x05 |
| 502 #define WM_PWLEDIT_DELETE 0x06 | 502 #define WM_PWLEDIT_DELETE 0x06 |
| 503 #define WM_PWLEDIT_SELECTALL 0x07 | 503 #define WM_PWLEDIT_SELECTALL 0x07 |
| 504 #define WM_PWLEDIT_SUGGEST 0x08 | 504 #define WM_PWLEDIT_SUGGEST 0x08 |
| 505 | 505 |
| 506 FX_BOOL CPWL_Edit::OnRButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) { | 506 FX_BOOL CPWL_Edit::OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) { |
| 507 if (m_bMouseDown) | 507 if (m_bMouseDown) |
| 508 return FALSE; | 508 return FALSE; |
| 509 | 509 |
| 510 CPWL_Wnd::OnRButtonUp(point, nFlag); | 510 CPWL_Wnd::OnRButtonUp(point, nFlag); |
| 511 | 511 |
| 512 if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) | 512 if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) |
| 513 return TRUE; | 513 return TRUE; |
| 514 | 514 |
| 515 IFX_SystemHandler* pSH = GetSystemHandler(); | 515 IFX_SystemHandler* pSH = GetSystemHandler(); |
| 516 if (!pSH) | 516 if (!pSH) |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 return FALSE; | 855 return FALSE; |
| 856 } | 856 } |
| 857 | 857 |
| 858 void CPWL_Edit::EnableSpellCheck(FX_BOOL bEnabled) { | 858 void CPWL_Edit::EnableSpellCheck(FX_BOOL bEnabled) { |
| 859 if (bEnabled) | 859 if (bEnabled) |
| 860 AddFlag(PES_SPELLCHECK); | 860 AddFlag(PES_SPELLCHECK); |
| 861 else | 861 else |
| 862 RemoveFlag(PES_SPELLCHECK); | 862 RemoveFlag(PES_SPELLCHECK); |
| 863 } | 863 } |
| 864 | 864 |
| 865 FX_BOOL CPWL_Edit::OnKeyDown(uint16_t nChar, FX_DWORD nFlag) { | 865 FX_BOOL CPWL_Edit::OnKeyDown(uint16_t nChar, uint32_t nFlag) { |
| 866 if (m_bMouseDown) | 866 if (m_bMouseDown) |
| 867 return TRUE; | 867 return TRUE; |
| 868 | 868 |
| 869 if (nChar == FWL_VKEY_Delete) { | 869 if (nChar == FWL_VKEY_Delete) { |
| 870 if (m_pFillerNotify) { | 870 if (m_pFillerNotify) { |
| 871 FX_BOOL bRC = TRUE; | 871 FX_BOOL bRC = TRUE; |
| 872 FX_BOOL bExit = FALSE; | 872 FX_BOOL bExit = FALSE; |
| 873 CFX_WideString strChange; | 873 CFX_WideString strChange; |
| 874 CFX_WideString strChangeEx; | 874 CFX_WideString strChangeEx; |
| 875 | 875 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 896 return TRUE; | 896 return TRUE; |
| 897 | 897 |
| 898 return bRet; | 898 return bRet; |
| 899 } | 899 } |
| 900 | 900 |
| 901 /** | 901 /** |
| 902 *In case of implementation swallow the OnKeyDown event. | 902 *In case of implementation swallow the OnKeyDown event. |
| 903 *If the event is swallowed, implementation may do other unexpected things, which | 903 *If the event is swallowed, implementation may do other unexpected things, which |
| 904 *is not the control means to do. | 904 *is not the control means to do. |
| 905 */ | 905 */ |
| 906 FX_BOOL CPWL_Edit::IsProceedtoOnChar(uint16_t nKeyCode, FX_DWORD nFlag) { | 906 FX_BOOL CPWL_Edit::IsProceedtoOnChar(uint16_t nKeyCode, uint32_t nFlag) { |
| 907 FX_BOOL bCtrl = IsCTRLpressed(nFlag); | 907 FX_BOOL bCtrl = IsCTRLpressed(nFlag); |
| 908 FX_BOOL bAlt = IsALTpressed(nFlag); | 908 FX_BOOL bAlt = IsALTpressed(nFlag); |
| 909 if (bCtrl && !bAlt) { | 909 if (bCtrl && !bAlt) { |
| 910 // hot keys for edit control. | 910 // hot keys for edit control. |
| 911 switch (nKeyCode) { | 911 switch (nKeyCode) { |
| 912 case 'C': | 912 case 'C': |
| 913 case 'V': | 913 case 'V': |
| 914 case 'X': | 914 case 'X': |
| 915 case 'A': | 915 case 'A': |
| 916 case 'Z': | 916 case 'Z': |
| 917 return TRUE; | 917 return TRUE; |
| 918 default: | 918 default: |
| 919 break; | 919 break; |
| 920 } | 920 } |
| 921 } | 921 } |
| 922 // control characters. | 922 // control characters. |
| 923 switch (nKeyCode) { | 923 switch (nKeyCode) { |
| 924 case FWL_VKEY_Escape: | 924 case FWL_VKEY_Escape: |
| 925 case FWL_VKEY_Back: | 925 case FWL_VKEY_Back: |
| 926 case FWL_VKEY_Return: | 926 case FWL_VKEY_Return: |
| 927 case FWL_VKEY_Space: | 927 case FWL_VKEY_Space: |
| 928 return TRUE; | 928 return TRUE; |
| 929 default: | 929 default: |
| 930 return FALSE; | 930 return FALSE; |
| 931 } | 931 } |
| 932 } | 932 } |
| 933 | 933 |
| 934 FX_BOOL CPWL_Edit::OnChar(uint16_t nChar, FX_DWORD nFlag) { | 934 FX_BOOL CPWL_Edit::OnChar(uint16_t nChar, uint32_t nFlag) { |
| 935 if (m_bMouseDown) | 935 if (m_bMouseDown) |
| 936 return TRUE; | 936 return TRUE; |
| 937 | 937 |
| 938 FX_BOOL bRC = TRUE; | 938 FX_BOOL bRC = TRUE; |
| 939 FX_BOOL bExit = FALSE; | 939 FX_BOOL bExit = FALSE; |
| 940 | 940 |
| 941 if (!IsCTRLpressed(nFlag)) { | 941 if (!IsCTRLpressed(nFlag)) { |
| 942 if (m_pFillerNotify) { | 942 if (m_pFillerNotify) { |
| 943 CFX_WideString swChange; | 943 CFX_WideString swChange; |
| 944 | 944 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 if (nOldCharSet != nNewCharSet) { | 976 if (nOldCharSet != nNewCharSet) { |
| 977 SetCharSet(nNewCharSet); | 977 SetCharSet(nNewCharSet); |
| 978 } | 978 } |
| 979 } | 979 } |
| 980 | 980 |
| 981 return CPWL_EditCtrl::OnChar(nChar, nFlag); | 981 return CPWL_EditCtrl::OnChar(nChar, nFlag); |
| 982 } | 982 } |
| 983 | 983 |
| 984 FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, | 984 FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, |
| 985 const CFX_FloatPoint& point, | 985 const CFX_FloatPoint& point, |
| 986 FX_DWORD nFlag) { | 986 uint32_t nFlag) { |
| 987 if (HasFlag(PES_MULTILINE)) { | 987 if (HasFlag(PES_MULTILINE)) { |
| 988 CFX_FloatPoint ptScroll = GetScrollPos(); | 988 CFX_FloatPoint ptScroll = GetScrollPos(); |
| 989 | 989 |
| 990 if (zDelta > 0) { | 990 if (zDelta > 0) { |
| 991 ptScroll.y += GetFontSize(); | 991 ptScroll.y += GetFontSize(); |
| 992 } else { | 992 } else { |
| 993 ptScroll.y -= GetFontSize(); | 993 ptScroll.y -= GetFontSize(); |
| 994 } | 994 } |
| 995 SetScrollPos(ptScroll); | 995 SetScrollPos(ptScroll); |
| 996 | 996 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, | 1185 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, |
| 1186 const CFX_FloatPoint& ptOffset) { | 1186 const CFX_FloatPoint& ptOffset) { |
| 1187 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 1187 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
| 1188 IFX_Edit::GeneratePageObjects( | 1188 IFX_Edit::GeneratePageObjects( |
| 1189 pObjectHolder, m_pEdit, ptOffset, NULL, | 1189 pObjectHolder, m_pEdit, ptOffset, NULL, |
| 1190 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1190 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 1191 ObjArray); | 1191 ObjArray); |
| 1192 } | 1192 } |
| OLD | NEW |