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

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

Issue 1737593006: Re-land "Replace CPDF_Rect and CPDF_Point with CFX types." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Ooops. Created 4 years, 9 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
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_ListBox.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Note.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "fpdfsdk/include/pdfwindow/PWL_ListCtrl.h" 7 #include "fpdfsdk/include/pdfwindow/PWL_ListCtrl.h"
8 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" 8 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
9 9
10 CPWL_ListCtrl::CPWL_ListCtrl() 10 CPWL_ListCtrl::CPWL_ListCtrl()
11 : m_rcContent(0, 0, 0, 0), 11 : m_rcContent(0, 0, 0, 0),
12 m_ptScroll(0, 0), 12 m_ptScroll(0, 0),
13 m_fItemSpace(0.0f), 13 m_fItemSpace(0.0f),
14 m_fTopSpace(0.0f), 14 m_fTopSpace(0.0f),
15 m_fBottomSpace(0.0f) {} 15 m_fBottomSpace(0.0f) {}
16 16
17 CPWL_ListCtrl::~CPWL_ListCtrl() {} 17 CPWL_ListCtrl::~CPWL_ListCtrl() {}
18 18
19 void CPWL_ListCtrl::SetScrollPos(const CPDF_Point& point) { 19 void CPWL_ListCtrl::SetScrollPos(const CFX_FloatPoint& point) {
20 m_ptScroll = point; 20 m_ptScroll = point;
21 21
22 if (m_ptScroll.x < m_rcContent.left) 22 if (m_ptScroll.x < m_rcContent.left)
23 m_ptScroll.x = m_rcContent.left; 23 m_ptScroll.x = m_rcContent.left;
24 24
25 if (m_ptScroll.x > m_rcContent.right) 25 if (m_ptScroll.x > m_rcContent.right)
26 m_ptScroll.x = m_rcContent.right; 26 m_ptScroll.x = m_rcContent.right;
27 27
28 if (m_ptScroll.y > m_rcContent.top) 28 if (m_ptScroll.y > m_rcContent.top)
29 m_ptScroll.y = m_rcContent.top; 29 m_ptScroll.y = m_rcContent.top;
30 30
31 if (m_ptScroll.y < m_rcContent.bottom) 31 if (m_ptScroll.y < m_rcContent.bottom)
32 m_ptScroll.y = m_rcContent.bottom; 32 m_ptScroll.y = m_rcContent.bottom;
33 } 33 }
34 34
35 CPDF_Point CPWL_ListCtrl::GetScrollPos() const { 35 CFX_FloatPoint CPWL_ListCtrl::GetScrollPos() const {
36 return m_ptScroll; 36 return m_ptScroll;
37 } 37 }
38 38
39 CPDF_Rect CPWL_ListCtrl::GetScrollArea() const { 39 CFX_FloatRect CPWL_ListCtrl::GetScrollArea() const {
40 return m_rcContent; 40 return m_rcContent;
41 } 41 }
42 42
43 void CPWL_ListCtrl::ResetFace() { 43 void CPWL_ListCtrl::ResetFace() {
44 ResetAll(FALSE, 0); 44 ResetAll(FALSE, 0);
45 } 45 }
46 46
47 void CPWL_ListCtrl::ResetContent(int32_t nStart) { 47 void CPWL_ListCtrl::ResetContent(int32_t nStart) {
48 if (nStart < 0) 48 if (nStart < 0)
49 nStart = 0; 49 nStart = 0;
(...skipping 20 matching lines...) Expand all
70 70
71 fRet -= m_fItemSpace; 71 fRet -= m_fItemSpace;
72 } 72 }
73 73
74 fRet += m_fBottomSpace; 74 fRet += m_fBottomSpace;
75 75
76 return fRet; 76 return fRet;
77 } 77 }
78 78
79 void CPWL_ListCtrl::ResetAll(FX_BOOL bMove, int32_t nStart) { 79 void CPWL_ListCtrl::ResetAll(FX_BOOL bMove, int32_t nStart) {
80 CPDF_Rect rcClient = GetClientRect(); 80 CFX_FloatRect rcClient = GetClientRect();
81 81
82 FX_FLOAT fWidth = rcClient.Width(); 82 FX_FLOAT fWidth = rcClient.Width();
83 83
84 FX_FLOAT fy = 0.0f - m_fTopSpace; 84 FX_FLOAT fy = 0.0f - m_fTopSpace;
85 85
86 if (nStart - 1 >= 0 && nStart - 1 < m_aChildren.GetSize()) 86 if (nStart - 1 >= 0 && nStart - 1 < m_aChildren.GetSize())
87 if (CPWL_Wnd* pChild = m_aChildren.GetAt(nStart - 1)) 87 if (CPWL_Wnd* pChild = m_aChildren.GetAt(nStart - 1))
88 fy = pChild->GetWindowRect().bottom - m_fItemSpace; 88 fy = pChild->GetWindowRect().bottom - m_fItemSpace;
89 89
90 for (int32_t i = nStart, sz = m_aChildren.GetSize(); i < sz; i++) { 90 for (int32_t i = nStart, sz = m_aChildren.GetSize(); i < sz; i++) {
91 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { 91 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
92 FX_FLOAT fLeft = pChild->GetItemLeftMargin(); 92 FX_FLOAT fLeft = pChild->GetItemLeftMargin();
93 FX_FLOAT fRight = pChild->GetItemRightMargin(); 93 FX_FLOAT fRight = pChild->GetItemRightMargin();
94 94
95 pChild->SetChildMatrix(CFX_Matrix(1, 0, 0, 1, 95 pChild->SetChildMatrix(CFX_Matrix(1, 0, 0, 1,
96 rcClient.left - m_ptScroll.x, 96 rcClient.left - m_ptScroll.x,
97 rcClient.top - m_ptScroll.y)); 97 rcClient.top - m_ptScroll.y));
98 98
99 if (bMove) { 99 if (bMove) {
100 FX_FLOAT fItemHeight = pChild->GetItemHeight(fWidth - fLeft - fRight); 100 FX_FLOAT fItemHeight = pChild->GetItemHeight(fWidth - fLeft - fRight);
101 pChild->Move(CPDF_Rect(fLeft, fy - fItemHeight, fWidth - fRight, fy), 101 pChild->Move(
102 TRUE, FALSE); 102 CFX_FloatRect(fLeft, fy - fItemHeight, fWidth - fRight, fy), TRUE,
103 FALSE);
103 fy -= fItemHeight; 104 fy -= fItemHeight;
104 fy -= m_fItemSpace; 105 fy -= m_fItemSpace;
105 } 106 }
106 } 107 }
107 } 108 }
108 109
109 fy += m_fItemSpace; 110 fy += m_fItemSpace;
110 111
111 fy -= m_fBottomSpace; 112 fy -= m_fBottomSpace;
112 113
(...skipping 17 matching lines...) Expand all
130 m_fBottomSpace = fSpace; 131 m_fBottomSpace = fSpace;
131 } 132 }
132 133
133 void CPWL_ListCtrl::RePosChildWnd() { 134 void CPWL_ListCtrl::RePosChildWnd() {
134 ResetFace(); 135 ResetFace();
135 } 136 }
136 137
137 void CPWL_ListCtrl::DrawChildAppearance(CFX_RenderDevice* pDevice, 138 void CPWL_ListCtrl::DrawChildAppearance(CFX_RenderDevice* pDevice,
138 CFX_Matrix* pUser2Device) { 139 CFX_Matrix* pUser2Device) {
139 pDevice->SaveState(); 140 pDevice->SaveState();
140 CPDF_Rect rcClient = GetClientRect(); 141 CFX_FloatRect rcClient = GetClientRect();
141 CPDF_Rect rcTemp = rcClient; 142 CFX_FloatRect rcTemp = rcClient;
142 pUser2Device->TransformRect(rcTemp); 143 pUser2Device->TransformRect(rcTemp);
143 FX_RECT rcClip((int32_t)rcTemp.left, (int32_t)rcTemp.bottom, 144 FX_RECT rcClip((int32_t)rcTemp.left, (int32_t)rcTemp.bottom,
144 (int32_t)rcTemp.right, (int32_t)rcTemp.top); 145 (int32_t)rcTemp.right, (int32_t)rcTemp.top);
145 146
146 pDevice->SetClip_Rect(&rcClip); 147 pDevice->SetClip_Rect(&rcClip);
147 148
148 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { 149 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
149 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { 150 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
150 CPDF_Rect rcChild = pChild->ChildToParent(pChild->GetWindowRect()); 151 CFX_FloatRect rcChild = pChild->ChildToParent(pChild->GetWindowRect());
151 if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top)) { 152 if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top)) {
152 CFX_Matrix mt = pChild->GetChildMatrix(); 153 CFX_Matrix mt = pChild->GetChildMatrix();
153 if (mt.IsIdentity()) { 154 if (mt.IsIdentity()) {
154 pChild->DrawAppearance(pDevice, pUser2Device); 155 pChild->DrawAppearance(pDevice, pUser2Device);
155 } else { 156 } else {
156 mt.Concat(*pUser2Device); 157 mt.Concat(*pUser2Device);
157 pChild->DrawAppearance(pDevice, &mt); 158 pChild->DrawAppearance(pDevice, &mt);
158 } 159 }
159 } 160 }
160 } 161 }
161 } 162 }
162 163
163 pDevice->RestoreState(); 164 pDevice->RestoreState();
164 } 165 }
165 166
166 int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) { 167 int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) {
167 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { 168 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
168 if (pItem == m_aChildren.GetAt(i)) 169 if (pItem == m_aChildren.GetAt(i))
169 return i; 170 return i;
170 } 171 }
171 172
172 return -1; 173 return -1;
173 } 174 }
174 175
175 CPDF_Point CPWL_ListCtrl::InToOut(const CPDF_Point& point) const { 176 CFX_FloatPoint CPWL_ListCtrl::InToOut(const CFX_FloatPoint& point) const {
176 CPDF_Rect rcClient = GetClientRect(); 177 CFX_FloatRect rcClient = GetClientRect();
177 178
178 return CPDF_Point(point.x + rcClient.left - m_ptScroll.x, 179 return CFX_FloatPoint(point.x + rcClient.left - m_ptScroll.x,
179 point.y + rcClient.top - m_ptScroll.y); 180 point.y + rcClient.top - m_ptScroll.y);
180 } 181 }
181 182
182 CPDF_Point CPWL_ListCtrl::OutToIn(const CPDF_Point& point) const { 183 CFX_FloatPoint CPWL_ListCtrl::OutToIn(const CFX_FloatPoint& point) const {
183 CPDF_Rect rcClient = GetClientRect(); 184 CFX_FloatRect rcClient = GetClientRect();
184 185
185 return CPDF_Point(point.x - rcClient.left + m_ptScroll.x, 186 return CFX_FloatPoint(point.x - rcClient.left + m_ptScroll.x,
186 point.y - rcClient.top + m_ptScroll.y); 187 point.y - rcClient.top + m_ptScroll.y);
187 } 188 }
188 189
189 CPDF_Rect CPWL_ListCtrl::InToOut(const CPDF_Rect& rect) const { 190 CFX_FloatRect CPWL_ListCtrl::InToOut(const CFX_FloatRect& rect) const {
190 CPDF_Rect rcClient = GetClientRect(); 191 CFX_FloatRect rcClient = GetClientRect();
191 192
192 return CPDF_Rect(rect.left + rcClient.left - m_ptScroll.x, 193 return CFX_FloatRect(rect.left + rcClient.left - m_ptScroll.x,
193 rect.bottom + rcClient.top - m_ptScroll.y, 194 rect.bottom + rcClient.top - m_ptScroll.y,
194 rect.right + rcClient.left - m_ptScroll.x, 195 rect.right + rcClient.left - m_ptScroll.x,
195 rect.top + rcClient.top - m_ptScroll.y); 196 rect.top + rcClient.top - m_ptScroll.y);
196 } 197 }
197 198
198 CPDF_Rect CPWL_ListCtrl::OutToIn(const CPDF_Rect& rect) const { 199 CFX_FloatRect CPWL_ListCtrl::OutToIn(const CFX_FloatRect& rect) const {
199 CPDF_Rect rcClient = GetClientRect(); 200 CFX_FloatRect rcClient = GetClientRect();
200 201
201 return CPDF_Rect(rect.left - rcClient.left + m_ptScroll.x, 202 return CFX_FloatRect(rect.left - rcClient.left + m_ptScroll.x,
202 rect.bottom - rcClient.top + m_ptScroll.y, 203 rect.bottom - rcClient.top + m_ptScroll.y,
203 rect.right - rcClient.left + m_ptScroll.x, 204 rect.right - rcClient.left + m_ptScroll.x,
204 rect.top - rcClient.top + m_ptScroll.y); 205 rect.top - rcClient.top + m_ptScroll.y);
205 } 206 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_ListBox.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Note.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698