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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 456 |
457 void CPWL_Edit::OnKillFocus() { | 457 void CPWL_Edit::OnKillFocus() { |
458 ShowVScrollBar(FALSE); | 458 ShowVScrollBar(FALSE); |
459 | 459 |
460 m_pEdit->SelectNone(); | 460 m_pEdit->SelectNone(); |
461 SetCaret(FALSE, CFX_FloatPoint(0.0f, 0.0f), CFX_FloatPoint(0.0f, 0.0f)); | 461 SetCaret(FALSE, CFX_FloatPoint(0.0f, 0.0f), CFX_FloatPoint(0.0f, 0.0f)); |
462 SetCharSet(FXFONT_ANSI_CHARSET); | 462 SetCharSet(FXFONT_ANSI_CHARSET); |
463 m_bFocus = FALSE; | 463 m_bFocus = FALSE; |
464 } | 464 } |
465 | 465 |
466 void CPWL_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint /* = TRUE*/) { | 466 void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace) { |
467 m_pEdit->SetHorzScale(nHorzScale, bPaint); | 467 m_pEdit->SetCharSpace(fCharSpace); |
468 } | |
469 | |
470 void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint /* = TRUE*/) { | |
471 m_pEdit->SetCharSpace(fCharSpace, bPaint); | |
472 } | |
473 | |
474 void CPWL_Edit::SetLineLeading(FX_FLOAT fLineLeading, | |
475 FX_BOOL bPaint /* = TRUE*/) { | |
476 m_pEdit->SetLineLeading(fLineLeading, bPaint); | |
477 } | 468 } |
478 | 469 |
479 CFX_ByteString CPWL_Edit::GetSelectAppearanceStream( | 470 CFX_ByteString CPWL_Edit::GetSelectAppearanceStream( |
480 const CFX_FloatPoint& ptOffset) const { | 471 const CFX_FloatPoint& ptOffset) const { |
481 CPVT_WordRange wr = GetSelectWordRange(); | 472 CPVT_WordRange wr = GetSelectWordRange(); |
482 return CPWL_Utils::GetEditSelAppStream(m_pEdit.get(), ptOffset, &wr); | 473 return CPWL_Utils::GetEditSelAppStream(m_pEdit.get(), ptOffset, &wr); |
483 } | 474 } |
484 | 475 |
485 CPVT_WordRange CPWL_Edit::GetSelectWordRange() const { | 476 CPVT_WordRange CPWL_Edit::GetSelectWordRange() const { |
486 if (m_pEdit->IsSelected()) { | 477 if (m_pEdit->IsSelected()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 | 543 |
553 return xdiv < ydiv ? xdiv : ydiv; | 544 return xdiv < ydiv ? xdiv : ydiv; |
554 } | 545 } |
555 | 546 |
556 return 0.0f; | 547 return 0.0f; |
557 } | 548 } |
558 | 549 |
559 void CPWL_Edit::SetCharArray(int32_t nCharArray) { | 550 void CPWL_Edit::SetCharArray(int32_t nCharArray) { |
560 if (HasFlag(PES_CHARARRAY) && nCharArray > 0) { | 551 if (HasFlag(PES_CHARARRAY) && nCharArray > 0) { |
561 m_pEdit->SetCharArray(nCharArray); | 552 m_pEdit->SetCharArray(nCharArray); |
562 m_pEdit->SetTextOverflow(TRUE); | 553 m_pEdit->SetTextOverflow(TRUE, TRUE); |
563 | 554 |
564 if (HasFlag(PWS_AUTOFONTSIZE)) { | 555 if (HasFlag(PWS_AUTOFONTSIZE)) { |
565 if (IPVT_FontMap* pFontMap = GetFontMap()) { | 556 if (IPVT_FontMap* pFontMap = GetFontMap()) { |
566 FX_FLOAT fFontSize = GetCharArrayAutoFontSize( | 557 FX_FLOAT fFontSize = GetCharArrayAutoFontSize( |
567 pFontMap->GetPDFFont(0), GetClientRect(), nCharArray); | 558 pFontMap->GetPDFFont(0), GetClientRect(), nCharArray); |
568 if (fFontSize > 0.0f) { | 559 if (fFontSize > 0.0f) { |
569 m_pEdit->SetAutoFontSize(FALSE); | 560 m_pEdit->SetAutoFontSize(FALSE, TRUE); |
570 m_pEdit->SetFontSize(fFontSize); | 561 m_pEdit->SetFontSize(fFontSize); |
571 } | 562 } |
572 } | 563 } |
573 } | 564 } |
574 } | 565 } |
575 } | 566 } |
576 | 567 |
577 void CPWL_Edit::SetLimitChar(int32_t nLimitChar) { | 568 void CPWL_Edit::SetLimitChar(int32_t nLimitChar) { |
578 m_pEdit->SetLimitChar(nLimitChar); | 569 m_pEdit->SetLimitChar(nLimitChar); |
579 } | 570 } |
580 | 571 |
581 void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText) { | 572 void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText) { |
582 m_pEdit->Clear(); | 573 m_pEdit->Clear(); |
583 m_pEdit->InsertText(csText); | 574 m_pEdit->InsertText(csText, DEFAULT_CHARSET); |
584 } | 575 } |
585 | 576 |
586 CFX_FloatRect CPWL_Edit::GetFocusRect() const { | 577 CFX_FloatRect CPWL_Edit::GetFocusRect() const { |
587 return CFX_FloatRect(); | 578 return CFX_FloatRect(); |
588 } | 579 } |
589 | 580 |
590 void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) { | 581 void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) { |
591 if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { | 582 if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { |
592 if (bShow) { | 583 if (bShow) { |
593 if (!pScroll->IsVisible()) { | 584 if (!pScroll->IsVisible()) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 } | 891 } |
901 | 892 |
902 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, | 893 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, |
903 const CFX_FloatPoint& ptOffset) { | 894 const CFX_FloatPoint& ptOffset) { |
904 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 895 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
905 CFX_Edit::GeneratePageObjects( | 896 CFX_Edit::GeneratePageObjects( |
906 pObjectHolder, m_pEdit.get(), ptOffset, nullptr, | 897 pObjectHolder, m_pEdit.get(), ptOffset, nullptr, |
907 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 898 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
908 ObjArray); | 899 ObjArray); |
909 } | 900 } |
OLD | NEW |