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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_ListCtrl.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_ListCtrl.h" 9 #include "../../include/pdfwindow/PWL_ListCtrl.h"
10 10
11 /* ---------------------------- CPWL_ListCtrl ---------------------------- */ 11 /* ---------------------------- CPWL_ListCtrl ---------------------------- */
12 12
13 CPWL_ListCtrl::CPWL_ListCtrl() : 13 CPWL_ListCtrl::CPWL_ListCtrl()
14 » m_rcContent(0,0,0,0), 14 : m_rcContent(0, 0, 0, 0),
15 » m_ptScroll(0,0), 15 m_ptScroll(0, 0),
16 » m_fItemSpace(0.0f), 16 m_fItemSpace(0.0f),
17 » m_fTopSpace(0.0f), 17 m_fTopSpace(0.0f),
18 » m_fBottomSpace(0.0f) 18 m_fBottomSpace(0.0f) {}
19 { 19
20 CPWL_ListCtrl::~CPWL_ListCtrl() {}
21
22 void CPWL_ListCtrl::SetScrollPos(const CPDF_Point& point) {
23 m_ptScroll = point;
24
25 if (m_ptScroll.x < m_rcContent.left)
26 m_ptScroll.x = m_rcContent.left;
27
28 if (m_ptScroll.x > m_rcContent.right)
29 m_ptScroll.x = m_rcContent.right;
30
31 if (m_ptScroll.y > m_rcContent.top)
32 m_ptScroll.y = m_rcContent.top;
33
34 if (m_ptScroll.y < m_rcContent.bottom)
35 m_ptScroll.y = m_rcContent.bottom;
20 } 36 }
21 37
22 CPWL_ListCtrl::~CPWL_ListCtrl() 38 CPDF_Point CPWL_ListCtrl::GetScrollPos() const {
23 { 39 return m_ptScroll;
24 } 40 }
25 41
26 void CPWL_ListCtrl::SetScrollPos(const CPDF_Point& point) 42 CPDF_Rect CPWL_ListCtrl::GetScrollArea() const {
27 { 43 return m_rcContent;
28 » m_ptScroll = point;
29
30 » if (m_ptScroll.x < m_rcContent.left)
31 » » m_ptScroll.x = m_rcContent.left;
32
33 » if (m_ptScroll.x > m_rcContent.right)
34 » » m_ptScroll.x = m_rcContent.right;
35
36 » if (m_ptScroll.y > m_rcContent.top)
37 » » m_ptScroll.y = m_rcContent.top;
38
39 » if (m_ptScroll.y < m_rcContent.bottom)
40 » » m_ptScroll.y = m_rcContent.bottom;
41 } 44 }
42 45
43 CPDF_Point CPWL_ListCtrl::GetScrollPos() const 46 void CPWL_ListCtrl::ResetFace() {
44 { 47 ResetAll(FALSE, 0);
45 » return m_ptScroll;
46 } 48 }
47 49
48 CPDF_Rect CPWL_ListCtrl::GetScrollArea() const 50 void CPWL_ListCtrl::ResetContent(int32_t nStart) {
49 { 51 if (nStart < 0)
50 » return m_rcContent; 52 nStart = 0;
53 if (nStart >= 0 && nStart < m_aChildren.GetSize())
54 ResetAll(TRUE, nStart);
51 } 55 }
52 56
53 void CPWL_ListCtrl::ResetFace() 57 FX_FLOAT CPWL_ListCtrl::GetContentsHeight(FX_FLOAT fLimitWidth) {
54 { 58 FX_FLOAT fRet = m_fTopSpace;
55 » ResetAll(FALSE, 0); 59
60 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
61
62 if (fLimitWidth > fBorderWidth * 2) {
63 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
64 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
65 FX_FLOAT fLeft = pChild->GetItemLeftMargin();
66 FX_FLOAT fRight = pChild->GetItemRightMargin();
67
68 fRet += pChild->GetItemHeight(fLimitWidth - fBorderWidth * 2 - fLeft -
69 fRight);
70 fRet += m_fItemSpace;
71 }
72 }
73
74 fRet -= m_fItemSpace;
75 }
76
77 fRet += m_fBottomSpace;
78
79 return fRet;
56 } 80 }
57 81
58 void CPWL_ListCtrl::ResetContent(int32_t nStart) 82 void CPWL_ListCtrl::ResetAll(FX_BOOL bMove, int32_t nStart) {
59 { 83 CPDF_Rect rcClient = GetClientRect();
60 » if (nStart < 0) 84
61 » » nStart = 0; 85 FX_FLOAT fWidth = rcClient.Width();
62 » if (nStart >= 0 && nStart < m_aChildren.GetSize()) 86
63 » » ResetAll(TRUE, nStart); 87 FX_FLOAT fy = 0.0f - m_fTopSpace;
88
89 if (nStart - 1 >= 0 && nStart - 1 < m_aChildren.GetSize())
90 if (CPWL_Wnd* pChild = m_aChildren.GetAt(nStart - 1))
91 fy = pChild->GetWindowRect().bottom - m_fItemSpace;
92
93 for (int32_t i = nStart, sz = m_aChildren.GetSize(); i < sz; i++) {
94 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
95 FX_FLOAT fLeft = pChild->GetItemLeftMargin();
96 FX_FLOAT fRight = pChild->GetItemRightMargin();
97
98 pChild->SetChildMatrix(CPDF_Matrix(1, 0, 0, 1,
99 rcClient.left - m_ptScroll.x,
100 rcClient.top - m_ptScroll.y));
101
102 if (bMove) {
103 FX_FLOAT fItemHeight = pChild->GetItemHeight(fWidth - fLeft - fRight);
104 pChild->Move(CPDF_Rect(fLeft, fy - fItemHeight, fWidth - fRight, fy),
105 TRUE, FALSE);
106 fy -= fItemHeight;
107 fy -= m_fItemSpace;
108 }
109 }
110 }
111
112 fy += m_fItemSpace;
113
114 fy -= m_fBottomSpace;
115
116 if (bMove) {
117 m_rcContent.left = 0;
118 m_rcContent.top = 0;
119 m_rcContent.right = fWidth;
120 m_rcContent.bottom = fy;
121 }
64 } 122 }
65 123
66 FX_FLOAT CPWL_ListCtrl::GetContentsHeight(FX_FLOAT fLimitWidth) 124 void CPWL_ListCtrl::SetItemSpace(FX_FLOAT fSpace) {
67 { 125 m_fItemSpace = fSpace;
68 » FX_FLOAT fRet = m_fTopSpace;
69
70 » FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
71
72 » if (fLimitWidth > fBorderWidth* 2)
73 » {
74 » » for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
75 » » {
76 » » » if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
77 » » » {
78 » » » » FX_FLOAT fLeft = pChild->GetItemLeftMargin();
79 » » » » FX_FLOAT fRight = pChild->GetItemRightMargin();
80
81 » » » » fRet += pChild->GetItemHeight(fLimitWidth - fBor derWidth* 2 - fLeft - fRight);
82 » » » » fRet += m_fItemSpace;
83 » » » }
84 » » }
85
86 » » fRet -= m_fItemSpace;
87 » }
88
89 » fRet += m_fBottomSpace;
90
91 » return fRet;
92 } 126 }
93 127
94 void CPWL_ListCtrl::ResetAll(FX_BOOL bMove, int32_t nStart) 128 void CPWL_ListCtrl::SetTopSpace(FX_FLOAT fSpace) {
95 { 129 m_fTopSpace = fSpace;
96 » CPDF_Rect rcClient = GetClientRect();
97
98 » FX_FLOAT fWidth = rcClient.Width();
99
100 » FX_FLOAT fy = 0.0f - m_fTopSpace;
101
102 » if (nStart-1 >= 0 && nStart-1 < m_aChildren.GetSize())
103 » » if (CPWL_Wnd* pChild = m_aChildren.GetAt(nStart-1))
104 » » » fy = pChild->GetWindowRect().bottom - m_fItemSpace;
105
106 » for (int32_t i=nStart,sz=m_aChildren.GetSize(); i<sz; i++)
107 » {
108 » » if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
109 » » {
110 » » » FX_FLOAT fLeft = pChild->GetItemLeftMargin();
111 » » » FX_FLOAT fRight = pChild->GetItemRightMargin();
112
113 » » » pChild->SetChildMatrix(
114 » » » » CPDF_Matrix(1,0,0,1,
115 » » » » rcClient.left - m_ptScroll.x,
116 » » » » rcClient.top - m_ptScroll.y)
117 » » » » );
118
119 » » » if (bMove)
120 » » » {
121 » » » » FX_FLOAT fItemHeight = pChild->GetItemHeight(fWi dth - fLeft - fRight);
122 » » » » pChild->Move(CPDF_Rect(fLeft, fy-fItemHeight, fW idth - fRight, fy), TRUE, FALSE);
123 » » » » fy -= fItemHeight;
124 » » » » fy -= m_fItemSpace;
125 » » » }
126 » » }
127 » }
128
129 » fy += m_fItemSpace;
130
131 » fy -= m_fBottomSpace;
132
133 » if (bMove)
134 » {
135 » » m_rcContent.left = 0;
136 » » m_rcContent.top = 0;
137 » » m_rcContent.right = fWidth;
138 » » m_rcContent.bottom = fy;
139 » }
140 } 130 }
141 131
142 void CPWL_ListCtrl::SetItemSpace(FX_FLOAT fSpace) 132 void CPWL_ListCtrl::SetBottomSpace(FX_FLOAT fSpace) {
143 { 133 m_fBottomSpace = fSpace;
144 » m_fItemSpace = fSpace;
145 } 134 }
146 135
147 void CPWL_ListCtrl::SetTopSpace(FX_FLOAT fSpace) 136 void CPWL_ListCtrl::RePosChildWnd() {
148 { 137 ResetFace();
149 » m_fTopSpace = fSpace;
150 } 138 }
151 139
152 void CPWL_ListCtrl::SetBottomSpace(FX_FLOAT fSpace) 140 void CPWL_ListCtrl::DrawChildAppearance(CFX_RenderDevice* pDevice,
153 { 141 CPDF_Matrix* pUser2Device) {
154 » m_fBottomSpace = fSpace; 142 pDevice->SaveState();
143 CPDF_Rect rcClient = GetClientRect();
144 CPDF_Rect rcTemp = rcClient;
145 pUser2Device->TransformRect(rcTemp);
146 FX_RECT rcClip((int32_t)rcTemp.left, (int32_t)rcTemp.bottom,
147 (int32_t)rcTemp.right, (int32_t)rcTemp.top);
148
149 pDevice->SetClip_Rect(&rcClip);
150
151 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
152 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
153 CPDF_Rect rcChild = pChild->ChildToParent(pChild->GetWindowRect());
154 if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top)) {
155 CPDF_Matrix mt = pChild->GetChildMatrix();
156 if (mt.IsIdentity()) {
157 pChild->DrawAppearance(pDevice, pUser2Device);
158 } else {
159 mt.Concat(*pUser2Device);
160 pChild->DrawAppearance(pDevice, &mt);
161 }
162 }
163 }
164 }
165
166 pDevice->RestoreState();
155 } 167 }
156 168
157 void CPWL_ListCtrl::RePosChildWnd() 169 int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) {
158 { 170 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
159 » ResetFace(); 171 if (pItem == m_aChildren.GetAt(i))
172 return i;
173 }
174
175 return -1;
160 } 176 }
161 177
162 void CPWL_ListCtrl::DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device) 178 CPDF_Point CPWL_ListCtrl::InToOut(const CPDF_Point& point) const {
163 { 179 CPDF_Rect rcClient = GetClientRect();
164 » pDevice->SaveState();
165 » CPDF_Rect rcClient = GetClientRect();
166 » CPDF_Rect rcTemp = rcClient;
167 » pUser2Device->TransformRect(rcTemp);
168 » FX_RECT rcClip((int32_t)rcTemp.left,
169 » » (int32_t)rcTemp.bottom,
170 » » (int32_t)rcTemp.right,
171 » » (int32_t)rcTemp.top);
172 180
173 » pDevice->SetClip_Rect(&rcClip); 181 return CPDF_Point(point.x + rcClient.left - m_ptScroll.x,
174 182 point.y + rcClient.top - m_ptScroll.y);
175 » for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
176 » {
177 » » if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
178 » » {
179 » » » CPDF_Rect rcChild = pChild->ChildToParent(pChild->GetWin dowRect());
180 » » » if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top))
181 » » » {
182 » » » » CPDF_Matrix mt = pChild->GetChildMatrix();
183 » » » » if (mt.IsIdentity())
184 » » » » {
185 » » » » » pChild->DrawAppearance(pDevice,pUser2Dev ice);
186 » » » » }
187 » » » » else
188 » » » » {
189 » » » » » mt.Concat(*pUser2Device);
190 » » » » » pChild->DrawAppearance(pDevice,&mt);
191 » » » » }
192 » » » }
193 » » }
194 » }
195
196 » pDevice->RestoreState();
197 } 183 }
198 184
199 int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) 185 CPDF_Point CPWL_ListCtrl::OutToIn(const CPDF_Point& point) const {
200 { 186 CPDF_Rect rcClient = GetClientRect();
201 » for (int32_t i=0, sz=m_aChildren.GetSize(); i<sz; i++)
202 » {
203 » » if (pItem == m_aChildren.GetAt(i))
204 » » » return i;
205 » }
206 187
207 » return -1; 188 return CPDF_Point(point.x - rcClient.left + m_ptScroll.x,
189 point.y - rcClient.top + m_ptScroll.y);
208 } 190 }
209 191
210 CPDF_Point CPWL_ListCtrl::InToOut(const CPDF_Point& point) const 192 CPDF_Rect CPWL_ListCtrl::InToOut(const CPDF_Rect& rect) const {
211 { 193 CPDF_Rect rcClient = GetClientRect();
212 » CPDF_Rect rcClient = GetClientRect();
213 194
214 » return CPDF_Point(point.x + rcClient.left - m_ptScroll.x, 195 return CPDF_Rect(rect.left + rcClient.left - m_ptScroll.x,
215 » » point.y + rcClient.top - m_ptScroll.y); 196 rect.bottom + rcClient.top - m_ptScroll.y,
197 rect.right + rcClient.left - m_ptScroll.x,
198 rect.top + rcClient.top - m_ptScroll.y);
216 } 199 }
217 200
218 CPDF_Point CPWL_ListCtrl::OutToIn(const CPDF_Point& point) const 201 CPDF_Rect CPWL_ListCtrl::OutToIn(const CPDF_Rect& rect) const {
219 { 202 CPDF_Rect rcClient = GetClientRect();
220 » CPDF_Rect rcClient = GetClientRect();
221 203
222 » return CPDF_Point(point.x - rcClient.left + m_ptScroll.x, 204 return CPDF_Rect(rect.left - rcClient.left + m_ptScroll.x,
223 » » point.y - rcClient.top + m_ptScroll.y); 205 rect.bottom - rcClient.top + m_ptScroll.y,
206 rect.right - rcClient.left + m_ptScroll.x,
207 rect.top - rcClient.top + m_ptScroll.y);
224 } 208 }
225
226 CPDF_Rect CPWL_ListCtrl::InToOut(const CPDF_Rect& rect) const
227 {
228 CPDF_Rect rcClient = GetClientRect();
229
230 return CPDF_Rect(rect.left + rcClient.left - m_ptScroll.x,
231 rect.bottom + rcClient.top - m_ptScroll.y,
232 rect.right + rcClient.left - m_ptScroll.x,
233 rect.top + rcClient.top - m_ptScroll.y);
234 }
235
236 CPDF_Rect CPWL_ListCtrl::OutToIn(const CPDF_Rect& rect) const
237 {
238 CPDF_Rect rcClient = GetClientRect();
239
240 return CPDF_Rect(rect.left - rcClient.left + m_ptScroll.x,
241 rect.bottom - rcClient.top + m_ptScroll.y,
242 rect.right - rcClient.left + m_ptScroll.x,
243 rect.top - rcClient.top + m_ptScroll.y);
244 }
245
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698