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 "../../include/pdfwindow/PDFWindow.h" | 7 #include "../../include/pdfwindow/PDFWindow.h" |
8 #include "../../include/pdfwindow/PWL_Wnd.h" | 8 #include "../../include/pdfwindow/PWL_Wnd.h" |
9 #include "../../include/pdfwindow/PWL_Utils.h" | 9 #include "../../include/pdfwindow/PWL_Utils.h" |
10 #include "../../include/pdfwindow/PWL_Icon.h" | 10 #include "../../include/pdfwindow/PWL_Icon.h" |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 return sRet.GetByteString(); | 634 return sRet.GetByteString(); |
635 } | 635 } |
636 | 636 |
637 CFX_ByteString CPWL_Utils::GetTextAppStream(const CPDF_Rect & rcBBox,IFX_Edit_Fo
ntMap * pFontMap, | 637 CFX_ByteString CPWL_Utils::GetTextAppStream(const CPDF_Rect & rcBBox,IFX_Edit_Fo
ntMap * pFontMap, |
638
const CFX_WideString & sText, FX_INT32 nAlignmen
tH, FX_INT32 nAlignmentV, | 638
const CFX_WideString & sText, FX_INT32 nAlignmen
tH, FX_INT32 nAlignmentV, |
639
FX_FLOAT fFontSize, FX_BOOL bMultiLine, FX_BOOL
bAutoReturn, const CPWL_Color & crText) | 639
FX_FLOAT fFontSize, FX_BOOL bMultiLine, FX_BOOL
bAutoReturn, const CPWL_Color & crText) |
640 { | 640 { |
641 CFX_ByteTextBuf sRet; | 641 CFX_ByteTextBuf sRet; |
642 | 642 |
643 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) | 643 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) |
644 » {» » » | 644 » { |
645 pEdit->SetFontMap(pFontMap); | 645 pEdit->SetFontMap(pFontMap); |
646 | |
647 pEdit->SetPlateRect(rcBBox); | 646 pEdit->SetPlateRect(rcBBox); |
648 pEdit->SetAlignmentH(nAlignmentH); | 647 pEdit->SetAlignmentH(nAlignmentH); |
649 pEdit->SetAlignmentV(nAlignmentV); | 648 pEdit->SetAlignmentV(nAlignmentV); |
650 pEdit->SetMultiLine(bMultiLine); | 649 pEdit->SetMultiLine(bMultiLine); |
651 pEdit->SetAutoReturn(bAutoReturn); | 650 pEdit->SetAutoReturn(bAutoReturn); |
652 if (IsFloatZero(fFontSize)) | 651 if (IsFloatZero(fFontSize)) |
653 pEdit->SetAutoFontSize(TRUE); | 652 pEdit->SetAutoFontSize(TRUE); |
654 else | 653 else |
655 pEdit->SetFontSize(fFontSize); | 654 pEdit->SetFontSize(fFontSize); |
| 655 |
656 pEdit->Initialize(); | 656 pEdit->Initialize(); |
| 657 pEdit->SetText(sText.c_str()); |
657 | 658 |
658 pEdit->SetText(sText); | |
659 | |
660 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit, CPDF_
Point(0.0f,0.0f)); | 659 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit, CPDF_
Point(0.0f,0.0f)); |
661 if (sEdit.GetLength() > 0) | 660 if (sEdit.GetLength() > 0) |
662 { | 661 { |
663 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText)
<< sEdit << "ET\n"; | 662 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText)
<< sEdit << "ET\n"; |
664 } | 663 } |
665 | |
666 IFX_Edit::DelEdit(pEdit); | 664 IFX_Edit::DelEdit(pEdit); |
667 } | 665 } |
668 | 666 |
669 return sRet.GetByteString(); | 667 return sRet.GetByteString(); |
670 } | 668 } |
671 | 669 |
672 CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CPDF_Rect & rcBBox, | 670 CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CPDF_Rect & rcBBox, |
673
IFX_Edit_FontMap * pFontMap, | 671
IFX_Edit_FontMap * pFontMap, |
674
CPDF_Stream * pIconStream, | 672
CPDF_Stream * pIconStream, |
675
CPDF_IconFit & IconFit, | 673
CPDF_IconFit & IconFit, |
676
const CFX_WideString & sLabel,
| 674
const CFX_WideString & sLabel,
|
677
const CPWL_Color & crText, | 675
const CPWL_Color & crText, |
678
FX_FLOAT fFontSize, | 676
FX_FLOAT fFontSize, |
679
FX_INT32 nLayOut) | 677
FX_INT32 nLayOut) |
680 { | 678 { |
681 const FX_FLOAT fAutoFontScale = 1.0f / 3.0f; | 679 const FX_FLOAT fAutoFontScale = 1.0f / 3.0f; |
682 | 680 |
683 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) | 681 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) |
684 » {» » » | 682 » { |
685 pEdit->SetFontMap(pFontMap); | 683 pEdit->SetFontMap(pFontMap); |
686 | |
687 pEdit->SetAlignmentH(1); | 684 pEdit->SetAlignmentH(1); |
688 pEdit->SetAlignmentV(1); | 685 pEdit->SetAlignmentV(1); |
689 pEdit->SetMultiLine(FALSE); | 686 pEdit->SetMultiLine(FALSE); |
690 pEdit->SetAutoReturn(FALSE); | 687 pEdit->SetAutoReturn(FALSE); |
691 if (IsFloatZero(fFontSize)) | 688 if (IsFloatZero(fFontSize)) |
692 pEdit->SetAutoFontSize(TRUE); | 689 pEdit->SetAutoFontSize(TRUE); |
693 else | 690 else |
694 pEdit->SetFontSize(fFontSize); | 691 pEdit->SetFontSize(fFontSize); |
| 692 |
695 pEdit->Initialize(); | 693 pEdit->Initialize(); |
696 » » pEdit->SetText(sLabel); | 694 » » pEdit->SetText(sLabel.c_str()); |
697 | 695 |
698 CPDF_Rect rcLabelContent = pEdit->GetContentRect(); | 696 CPDF_Rect rcLabelContent = pEdit->GetContentRect(); |
699 | |
700 CPWL_Icon Icon; | 697 CPWL_Icon Icon; |
701 PWL_CREATEPARAM cp; | 698 PWL_CREATEPARAM cp; |
702 cp.dwFlags = PWS_VISIBLE; | 699 cp.dwFlags = PWS_VISIBLE; |
703 Icon.Create(cp); | 700 Icon.Create(cp); |
704 Icon.SetIconFit(&IconFit); | 701 Icon.SetIconFit(&IconFit); |
705 Icon.SetPDFStream(pIconStream); | 702 Icon.SetPDFStream(pIconStream); |
706 | 703 |
707 CPDF_Rect rcLabel = CPDF_Rect(0,0,0,0); | 704 CPDF_Rect rcLabel = CPDF_Rect(0,0,0,0); |
708 CPDF_Rect rcIcon = CPDF_Rect(0,0,0,0); | 705 CPDF_Rect rcIcon = CPDF_Rect(0,0,0,0); |
709 FX_FLOAT fWidth = 0.0f; | 706 FX_FLOAT fWidth = 0.0f; |
(...skipping 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2835 case COLORTYPE_RGB: | 2832 case COLORTYPE_RGB: |
2836 CPWL_Utils::ConvertCMYK2RGB(this->fColor1, this->fColor2
, this->fColor3, this->fColor4, this->fColor1, this->fColor2, this->fColor3); | 2833 CPWL_Utils::ConvertCMYK2RGB(this->fColor1, this->fColor2
, this->fColor3, this->fColor4, this->fColor1, this->fColor2, this->fColor3); |
2837 break; | 2834 break; |
2838 } | 2835 } |
2839 break; | 2836 break; |
2840 } | 2837 } |
2841 this->nColorType = nColorType; | 2838 this->nColorType = nColorType; |
2842 } | 2839 } |
2843 | 2840 |
2844 | 2841 |
OLD | NEW |