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/include/pdfwindow/PWL_Label.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_Label.h" |
8 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 8 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
9 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 void CPWL_Label::OnCreated() { | 24 void CPWL_Label::OnCreated() { |
25 SetParamByFlag(); | 25 SetParamByFlag(); |
26 SetFontSize(GetCreationParam().fFontSize); | 26 SetFontSize(GetCreationParam().fFontSize); |
27 | 27 |
28 m_pEdit->SetFontMap(GetFontMap()); | 28 m_pEdit->SetFontMap(GetFontMap()); |
29 m_pEdit->Initialize(); | 29 m_pEdit->Initialize(); |
30 | 30 |
31 if (HasFlag(PES_TEXTOVERFLOW)) { | 31 if (HasFlag(PES_TEXTOVERFLOW)) { |
32 SetClipRect(CPDF_Rect(0.0f, 0.0f, 0.0f, 0.0f)); | 32 SetClipRect(CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f)); |
33 m_pEdit->SetTextOverflow(TRUE); | 33 m_pEdit->SetTextOverflow(TRUE); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 void CPWL_Label::SetText(const FX_WCHAR* csText) { | 37 void CPWL_Label::SetText(const FX_WCHAR* csText) { |
38 m_pEdit->SetText(csText); | 38 m_pEdit->SetText(csText); |
39 } | 39 } |
40 | 40 |
41 void CPWL_Label::RePosChildWnd() { | 41 void CPWL_Label::RePosChildWnd() { |
42 m_pEdit->SetPlateRect(GetClientRect()); | 42 m_pEdit->SetPlateRect(GetClientRect()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE)); | 80 m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE)); |
81 m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL)); | 81 m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL)); |
82 } | 82 } |
83 | 83 |
84 void CPWL_Label::DrawThisAppearance(CFX_RenderDevice* pDevice, | 84 void CPWL_Label::DrawThisAppearance(CFX_RenderDevice* pDevice, |
85 CFX_Matrix* pUser2Device) { | 85 CFX_Matrix* pUser2Device) { |
86 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); | 86 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); |
87 | 87 |
88 GetClientRect(); | 88 GetClientRect(); |
89 | 89 |
90 CPDF_Rect rcClip; | 90 CFX_FloatRect rcClip; |
91 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); | 91 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); |
92 CPVT_WordRange* pRange = NULL; | 92 CPVT_WordRange* pRange = NULL; |
93 | 93 |
94 if (!HasFlag(PES_TEXTOVERFLOW)) { | 94 if (!HasFlag(PES_TEXTOVERFLOW)) { |
95 rcClip = GetClientRect(); | 95 rcClip = GetClientRect(); |
96 pRange = &wrRange; | 96 pRange = &wrRange; |
97 } | 97 } |
98 IFX_SystemHandler* pSysHandler = GetSystemHandler(); | 98 IFX_SystemHandler* pSysHandler = GetSystemHandler(); |
99 IFX_Edit::DrawEdit( | 99 IFX_Edit::DrawEdit( |
100 pDevice, pUser2Device, m_pEdit, | 100 pDevice, pUser2Device, m_pEdit, |
101 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 101 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
102 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), | 102 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), |
103 rcClip, CPDF_Point(0.0f, 0.0f), pRange, pSysHandler, NULL); | 103 rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, NULL); |
104 } | 104 } |
105 | 105 |
106 void CPWL_Label::SetHorzScale(int32_t nHorzScale) { | 106 void CPWL_Label::SetHorzScale(int32_t nHorzScale) { |
107 m_pEdit->SetHorzScale(nHorzScale); | 107 m_pEdit->SetHorzScale(nHorzScale); |
108 } | 108 } |
109 | 109 |
110 void CPWL_Label::SetCharSpace(FX_FLOAT fCharSpace) { | 110 void CPWL_Label::SetCharSpace(FX_FLOAT fCharSpace) { |
111 m_pEdit->SetCharSpace(fCharSpace); | 111 m_pEdit->SetCharSpace(fCharSpace); |
112 } | 112 } |
113 | 113 |
114 CPDF_Rect CPWL_Label::GetContentRect() const { | 114 CFX_FloatRect CPWL_Label::GetContentRect() const { |
115 return m_pEdit->GetContentRect(); | 115 return m_pEdit->GetContentRect(); |
116 } | 116 } |
117 | 117 |
118 void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { | 118 void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
119 CPWL_Wnd::GetThisAppearanceStream(sAppStream); | 119 CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
120 | 120 |
121 sAppStream << GetTextAppearanceStream(CPDF_Point(0.0f, 0.0f)); | 121 sAppStream << GetTextAppearanceStream(CFX_FloatPoint(0.0f, 0.0f)); |
122 } | 122 } |
123 | 123 |
124 CFX_ByteString CPWL_Label::GetTextAppearanceStream( | 124 CFX_ByteString CPWL_Label::GetTextAppearanceStream( |
125 const CPDF_Point& ptOffset) const { | 125 const CFX_FloatPoint& ptOffset) const { |
126 CFX_ByteTextBuf sRet; | 126 CFX_ByteTextBuf sRet; |
127 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); | 127 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); |
128 | 128 |
129 if (sEdit.GetLength() > 0) { | 129 if (sEdit.GetLength() > 0) { |
130 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit | 130 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit |
131 << "ET\n"; | 131 << "ET\n"; |
132 } | 132 } |
133 | 133 |
134 return sRet.GetByteString(); | 134 return sRet.GetByteString(); |
135 } | 135 } |
136 | 136 |
137 CFX_WideString CPWL_Label::GetText() const { | 137 CFX_WideString CPWL_Label::GetText() const { |
138 return m_pEdit->GetText(); | 138 return m_pEdit->GetText(); |
139 } | 139 } |
140 | 140 |
141 void CPWL_Label::SetLimitChar(int32_t nLimitChar) { | 141 void CPWL_Label::SetLimitChar(int32_t nLimitChar) { |
142 m_pEdit->SetLimitChar(nLimitChar); | 142 m_pEdit->SetLimitChar(nLimitChar); |
143 } | 143 } |
144 | 144 |
145 int32_t CPWL_Label::GetTotalWords() { | 145 int32_t CPWL_Label::GetTotalWords() { |
146 if (m_pEdit) | 146 if (m_pEdit) |
147 return m_pEdit->GetTotalWords(); | 147 return m_pEdit->GetTotalWords(); |
148 | 148 |
149 return 0; | 149 return 0; |
150 } | 150 } |
OLD | NEW |