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