Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_Label.cpp

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_Label.h" 9 #include "../../include/pdfwindow/PWL_Label.h"
10 #include "../../include/pdfwindow/PWL_Utils.h" 10 #include "../../include/pdfwindow/PWL_Utils.h"
11 11
12 /* ---------------------------- CPWL_Label ------------------------------ */ 12 /* ---------------------------- CPWL_Label ------------------------------ */
13 13
14 CPWL_Label::CPWL_Label() : m_pEdit(NULL) 14 CPWL_Label::CPWL_Label() : m_pEdit(NULL) {
15 { 15 m_pEdit = IFX_Edit::NewEdit();
16 » m_pEdit = IFX_Edit::NewEdit();
17 16
18 » ASSERT(m_pEdit != NULL); 17 ASSERT(m_pEdit != NULL);
19 } 18 }
20 19
21 CPWL_Label::~CPWL_Label() 20 CPWL_Label::~CPWL_Label() {
22 { 21 IFX_Edit::DelEdit(m_pEdit);
23 » IFX_Edit::DelEdit(m_pEdit);
24 } 22 }
25 23
26 CFX_ByteString CPWL_Label::GetClassName() const 24 CFX_ByteString CPWL_Label::GetClassName() const {
27 { 25 return "CPWL_Label";
28 » return "CPWL_Label";
29 } 26 }
30 27
31 void CPWL_Label::OnCreated() 28 void CPWL_Label::OnCreated() {
32 { 29 SetParamByFlag();
33 » SetParamByFlag(); 30 SetFontSize(GetCreationParam().fFontSize);
34 » SetFontSize(GetCreationParam().fFontSize);
35 31
36 » m_pEdit->SetFontMap(GetFontMap()); 32 m_pEdit->SetFontMap(GetFontMap());
37 » m_pEdit->Initialize(); 33 m_pEdit->Initialize();
38 34
39 » if (HasFlag(PES_TEXTOVERFLOW)) 35 if (HasFlag(PES_TEXTOVERFLOW)) {
40 » { 36 SetClipRect(CPDF_Rect(0.0f, 0.0f, 0.0f, 0.0f));
41 » » SetClipRect(CPDF_Rect(0.0f,0.0f,0.0f,0.0f)); 37 m_pEdit->SetTextOverflow(TRUE);
42 » » m_pEdit->SetTextOverflow(TRUE); 38 }
43 » }
44 } 39 }
45 40
46 void CPWL_Label::SetText(const FX_WCHAR* csText) 41 void CPWL_Label::SetText(const FX_WCHAR* csText) {
47 { 42 m_pEdit->SetText(csText);
48 » m_pEdit->SetText(csText);
49 } 43 }
50 44
51 void CPWL_Label::RePosChildWnd() 45 void CPWL_Label::RePosChildWnd() {
52 { 46 m_pEdit->SetPlateRect(GetClientRect());
53 » m_pEdit->SetPlateRect(GetClientRect());
54 } 47 }
55 48
56 void CPWL_Label::SetFontSize(FX_FLOAT fFontSize) 49 void CPWL_Label::SetFontSize(FX_FLOAT fFontSize) {
57 { 50 m_pEdit->SetFontSize(fFontSize);
58 » m_pEdit->SetFontSize(fFontSize);
59 } 51 }
60 52
61 FX_FLOAT CPWL_Label::GetFontSize() const 53 FX_FLOAT CPWL_Label::GetFontSize() const {
62 { 54 return m_pEdit->GetFontSize();
63 » return m_pEdit->GetFontSize();
64 } 55 }
65 56
66 void CPWL_Label::SetParamByFlag() 57 void CPWL_Label::SetParamByFlag() {
67 { 58 if (HasFlag(PES_LEFT)) {
68 » if (HasFlag(PES_LEFT)) 59 m_pEdit->SetAlignmentH(0);
69 » { 60 } else if (HasFlag(PES_MIDDLE)) {
70 » » m_pEdit->SetAlignmentH(0); 61 m_pEdit->SetAlignmentH(1);
71 » } 62 } else if (HasFlag(PES_RIGHT)) {
72 » else if (HasFlag(PES_MIDDLE)) 63 m_pEdit->SetAlignmentH(2);
73 » { 64 } else {
74 » » m_pEdit->SetAlignmentH(1); 65 m_pEdit->SetAlignmentH(0);
75 » } 66 }
76 » else if (HasFlag(PES_RIGHT))
77 » {
78 » » m_pEdit->SetAlignmentH(2);
79 » }
80 » else
81 » {
82 » » m_pEdit->SetAlignmentH(0);
83 » }
84 67
85 » if (HasFlag(PES_TOP)) 68 if (HasFlag(PES_TOP)) {
86 » { 69 m_pEdit->SetAlignmentV(0);
87 » » m_pEdit->SetAlignmentV(0); 70 } else if (HasFlag(PES_CENTER)) {
88 » } 71 m_pEdit->SetAlignmentV(1);
89 » else if (HasFlag(PES_CENTER)) 72 } else if (HasFlag(PES_BOTTOM)) {
90 » { 73 m_pEdit->SetAlignmentV(2);
91 » » m_pEdit->SetAlignmentV(1); 74 } else {
92 » } 75 m_pEdit->SetAlignmentV(0);
93 » else if (HasFlag(PES_BOTTOM)) 76 }
94 » {
95 » » m_pEdit->SetAlignmentV(2);
96 » }
97 » else
98 » {
99 » » m_pEdit->SetAlignmentV(0);
100 » }
101 77
102 » if (HasFlag(PES_PASSWORD)) 78 if (HasFlag(PES_PASSWORD)) {
103 » { 79 m_pEdit->SetPasswordChar('*');
104 » » m_pEdit->SetPasswordChar('*'); 80 }
105 » }
106 81
107 » m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE)); 82 m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE));
108 » m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN)); 83 m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN));
109 » m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE)); 84 m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE));
110 » m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL)); 85 m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL));
111 } 86 }
112 87
113 void CPWL_Label::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUse r2Device) 88 void CPWL_Label::DrawThisAppearance(CFX_RenderDevice* pDevice,
114 { 89 CPDF_Matrix* pUser2Device) {
115 » CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); 90 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
116 91
117 » GetClientRect(); 92 GetClientRect();
118 93
119 » CPDF_Rect rcClip; 94 CPDF_Rect rcClip;
120 » CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); 95 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange();
121 » CPVT_WordRange* pRange = NULL; 96 CPVT_WordRange* pRange = NULL;
122 97
123 » if (!HasFlag(PES_TEXTOVERFLOW)) 98 if (!HasFlag(PES_TEXTOVERFLOW)) {
124 » { 99 rcClip = GetClientRect();
125 » » rcClip = GetClientRect(); 100 pRange = &wrRange;
126 » » pRange = &wrRange; 101 }
127 » } 102 IFX_SystemHandler* pSysHandler = GetSystemHandler();
128 IFX_SystemHandler* pSysHandler = GetSystemHandler(); 103 IFX_Edit::DrawEdit(
129 » IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pEdit, 104 pDevice, pUser2Device, m_pEdit,
130 » » CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()) , 105 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
131 » » CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTranspare ncy()), 106 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()),
132 » » rcClip, CPDF_Point(0.0f,0.0f), pRange,pSysHandler, NULL); 107 rcClip, CPDF_Point(0.0f, 0.0f), pRange, pSysHandler, NULL);
133 } 108 }
134 109
135 void CPWL_Label::SetHorzScale(int32_t nHorzScale) 110 void CPWL_Label::SetHorzScale(int32_t nHorzScale) {
136 { 111 m_pEdit->SetHorzScale(nHorzScale);
137 » m_pEdit->SetHorzScale(nHorzScale);
138 } 112 }
139 113
140 void CPWL_Label::SetCharSpace(FX_FLOAT fCharSpace) 114 void CPWL_Label::SetCharSpace(FX_FLOAT fCharSpace) {
141 { 115 m_pEdit->SetCharSpace(fCharSpace);
142 » m_pEdit->SetCharSpace(fCharSpace);
143 } 116 }
144 117
145 CPDF_Rect CPWL_Label::GetContentRect() const 118 CPDF_Rect CPWL_Label::GetContentRect() const {
146 { 119 return m_pEdit->GetContentRect();
147 » return m_pEdit->GetContentRect();
148 } 120 }
149 121
150 void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) 122 void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
151 { 123 CPWL_Wnd::GetThisAppearanceStream(sAppStream);
152 » CPWL_Wnd::GetThisAppearanceStream(sAppStream);
153 124
154 » sAppStream << GetTextAppearanceStream(CPDF_Point(0.0f, 0.0f)); 125 sAppStream << GetTextAppearanceStream(CPDF_Point(0.0f, 0.0f));
155 } 126 }
156 127
157 CFX_ByteString CPWL_Label::GetTextAppearanceStream(const CPDF_Point & ptOffset) const 128 CFX_ByteString CPWL_Label::GetTextAppearanceStream(
158 { 129 const CPDF_Point& ptOffset) const {
159 » CFX_ByteTextBuf sRet; 130 CFX_ByteTextBuf sRet;
160 » CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit,ptOffset); 131 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset);
161 132
162 » if (sEdit.GetLength() > 0) 133 if (sEdit.GetLength() > 0) {
163 » { 134 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit
164 » » sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit << "ET\n"; 135 << "ET\n";
165 » } 136 }
166 137
167 » return sRet.GetByteString(); 138 return sRet.GetByteString();
168 } 139 }
169 140
170 CFX_WideString CPWL_Label::GetText() const 141 CFX_WideString CPWL_Label::GetText() const {
171 { 142 return m_pEdit->GetText();
172 » return m_pEdit->GetText();
173 } 143 }
174 144
175 void CPWL_Label::SetLimitChar(int32_t nLimitChar) 145 void CPWL_Label::SetLimitChar(int32_t nLimitChar) {
176 { 146 m_pEdit->SetLimitChar(nLimitChar);
177 » m_pEdit->SetLimitChar(nLimitChar);
178 } 147 }
179 148
180 int32_t CPWL_Label::GetTotalWords() 149 int32_t CPWL_Label::GetTotalWords() {
181 { 150 if (m_pEdit)
182 » if (m_pEdit) 151 return m_pEdit->GetTotalWords();
183 » » return m_pEdit->GetTotalWords();
184 152
185 » return 0; 153 return 0;
186 } 154 }
187
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698