Chromium Code Reviews| 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/include/cpvt_section.h" | 9 #include "core/fpdfdoc/include/cpvt_section.h" |
| 10 #include "core/fpdfdoc/include/cpvt_word.h" | 10 #include "core/fpdfdoc/include/cpvt_word.h" |
|
dsinclair
2016/09/19 13:04:53
Include fx_font.h?
npm
2016/09/19 14:08:32
Done.
| |
| 11 #include "fpdfsdk/fxedit/include/fxet_edit.h" | 11 #include "fpdfsdk/fxedit/include/fxet_edit.h" |
| 12 #include "fpdfsdk/pdfwindow/PWL_Caret.h" | 12 #include "fpdfsdk/pdfwindow/PWL_Caret.h" |
| 13 #include "fpdfsdk/pdfwindow/PWL_FontMap.h" | 13 #include "fpdfsdk/pdfwindow/PWL_FontMap.h" |
| 14 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" | 14 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" |
| 15 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 15 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 16 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" | 16 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
| 17 #include "public/fpdf_fwlevent.h" | 17 #include "public/fpdf_fwlevent.h" |
| 18 | 18 |
| 19 CPWL_EditCtrl::CPWL_EditCtrl() | 19 CPWL_EditCtrl::CPWL_EditCtrl() |
| 20 : m_pEdit(new CFX_Edit), | 20 : m_pEdit(new CFX_Edit), |
| 21 m_pEditCaret(nullptr), | 21 m_pEditCaret(nullptr), |
| 22 m_bMouseDown(FALSE), | 22 m_bMouseDown(FALSE), |
| 23 m_nCharSet(DEFAULT_CHARSET), | 23 m_nCharSet(FXFONT_DEFAULT_CHARSET), |
| 24 m_nCodePage(0) {} | 24 m_nCodePage(0) {} |
| 25 | 25 |
| 26 CPWL_EditCtrl::~CPWL_EditCtrl() {} | 26 CPWL_EditCtrl::~CPWL_EditCtrl() {} |
| 27 | 27 |
| 28 void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) { | 28 void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) { |
| 29 cp.eCursorType = FXCT_VBEAM; | 29 cp.eCursorType = FXCT_VBEAM; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void CPWL_EditCtrl::OnCreated() { | 32 void CPWL_EditCtrl::OnCreated() { |
| 33 SetFontSize(GetCreationParam().fFontSize); | 33 SetFontSize(GetCreationParam().fFontSize); |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 void CPWL_EditCtrl::CopyText() {} | 469 void CPWL_EditCtrl::CopyText() {} |
| 470 | 470 |
| 471 void CPWL_EditCtrl::PasteText() {} | 471 void CPWL_EditCtrl::PasteText() {} |
| 472 | 472 |
| 473 void CPWL_EditCtrl::CutText() {} | 473 void CPWL_EditCtrl::CutText() {} |
| 474 | 474 |
| 475 void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) {} | 475 void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) {} |
| 476 | 476 |
| 477 void CPWL_EditCtrl::InsertText(const CFX_WideString& wsText) { | 477 void CPWL_EditCtrl::InsertText(const CFX_WideString& wsText) { |
| 478 if (!IsReadOnly()) | 478 if (!IsReadOnly()) |
| 479 m_pEdit->InsertText(wsText, DEFAULT_CHARSET); | 479 m_pEdit->InsertText(wsText, FXFONT_DEFAULT_CHARSET); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) { | 482 void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) { |
| 483 if (!IsReadOnly()) | 483 if (!IsReadOnly()) |
| 484 m_pEdit->InsertWord(word, nCharset); | 484 m_pEdit->InsertWord(word, nCharset); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void CPWL_EditCtrl::InsertReturn() { | 487 void CPWL_EditCtrl::InsertReturn() { |
| 488 if (!IsReadOnly()) | 488 if (!IsReadOnly()) |
| 489 m_pEdit->InsertReturn(); | 489 m_pEdit->InsertReturn(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps, | 560 void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps, |
| 561 const CPVT_WordProps& wordProps) {} | 561 const CPVT_WordProps& wordProps) {} |
| 562 | 562 |
| 563 void CPWL_EditCtrl::IOnContentChange(const CFX_FloatRect& rcContent) {} | 563 void CPWL_EditCtrl::IOnContentChange(const CFX_FloatRect& rcContent) {} |
| 564 | 564 |
| 565 void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) { | 565 void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) { |
| 566 InvalidateRect(pRect); | 566 InvalidateRect(pRect); |
| 567 } | 567 } |
| 568 | 568 |
| 569 int32_t CPWL_EditCtrl::GetCharSet() const { | 569 int32_t CPWL_EditCtrl::GetCharSet() const { |
| 570 return m_nCharSet < 0 ? DEFAULT_CHARSET : m_nCharSet; | 570 return m_nCharSet < 0 ? FXFONT_DEFAULT_CHARSET : m_nCharSet; |
| 571 } | 571 } |
| 572 | 572 |
| 573 void CPWL_EditCtrl::GetTextRange(const CFX_FloatRect& rect, | 573 void CPWL_EditCtrl::GetTextRange(const CFX_FloatRect& rect, |
| 574 int32_t& nStartChar, | 574 int32_t& nStartChar, |
| 575 int32_t& nEndChar) const { | 575 int32_t& nEndChar) const { |
| 576 nStartChar = m_pEdit->WordPlaceToWordIndex( | 576 nStartChar = m_pEdit->WordPlaceToWordIndex( |
| 577 m_pEdit->SearchWordPlace(CFX_FloatPoint(rect.left, rect.top))); | 577 m_pEdit->SearchWordPlace(CFX_FloatPoint(rect.left, rect.top))); |
| 578 nEndChar = m_pEdit->WordPlaceToWordIndex( | 578 nEndChar = m_pEdit->WordPlaceToWordIndex( |
| 579 m_pEdit->SearchWordPlace(CFX_FloatPoint(rect.right, rect.bottom))); | 579 m_pEdit->SearchWordPlace(CFX_FloatPoint(rect.right, rect.bottom))); |
| 580 } | 580 } |
| 581 | 581 |
| 582 CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar, | 582 CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar, |
| 583 int32_t& nEndChar) const { | 583 int32_t& nEndChar) const { |
| 584 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); | 584 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); |
| 585 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); | 585 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); |
| 586 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); | 586 return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); |
| 587 } | 587 } |
| 588 | 588 |
| 589 void CPWL_EditCtrl::SetReadyToInput() { | 589 void CPWL_EditCtrl::SetReadyToInput() { |
| 590 if (m_bMouseDown) { | 590 if (m_bMouseDown) { |
| 591 ReleaseCapture(); | 591 ReleaseCapture(); |
| 592 m_bMouseDown = FALSE; | 592 m_bMouseDown = FALSE; |
| 593 } | 593 } |
| 594 } | 594 } |
| OLD | NEW |