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

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

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master 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
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fpdfsdk/include/pdfwindow/PWL_ListCtrl.h"
8 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
9
10 CPWL_ListCtrl::CPWL_ListCtrl()
11 : m_rcContent(0, 0, 0, 0),
12 m_ptScroll(0, 0),
13 m_fItemSpace(0.0f),
14 m_fTopSpace(0.0f),
15 m_fBottomSpace(0.0f) {}
16
17 CPWL_ListCtrl::~CPWL_ListCtrl() {}
18
19 void CPWL_ListCtrl::SetScrollPos(const CFX_FloatPoint& point) {
20 m_ptScroll = point;
21
22 if (m_ptScroll.x < m_rcContent.left)
23 m_ptScroll.x = m_rcContent.left;
24
25 if (m_ptScroll.x > m_rcContent.right)
26 m_ptScroll.x = m_rcContent.right;
27
28 if (m_ptScroll.y > m_rcContent.top)
29 m_ptScroll.y = m_rcContent.top;
30
31 if (m_ptScroll.y < m_rcContent.bottom)
32 m_ptScroll.y = m_rcContent.bottom;
33 }
34
35 CFX_FloatPoint CPWL_ListCtrl::GetScrollPos() const {
36 return m_ptScroll;
37 }
38
39 CFX_FloatRect CPWL_ListCtrl::GetScrollArea() const {
40 return m_rcContent;
41 }
42
43 void CPWL_ListCtrl::ResetFace() {
44 ResetAll(FALSE, 0);
45 }
46
47 void CPWL_ListCtrl::ResetContent(int32_t nStart) {
48 if (nStart < 0)
49 nStart = 0;
50 if (nStart >= 0 && nStart < m_aChildren.GetSize())
51 ResetAll(TRUE, nStart);
52 }
53
54 FX_FLOAT CPWL_ListCtrl::GetContentsHeight(FX_FLOAT fLimitWidth) {
55 FX_FLOAT fRet = m_fTopSpace;
56
57 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
58
59 if (fLimitWidth > fBorderWidth * 2) {
60 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
61 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
62 FX_FLOAT fLeft = pChild->GetItemLeftMargin();
63 FX_FLOAT fRight = pChild->GetItemRightMargin();
64
65 fRet += pChild->GetItemHeight(fLimitWidth - fBorderWidth * 2 - fLeft -
66 fRight);
67 fRet += m_fItemSpace;
68 }
69 }
70
71 fRet -= m_fItemSpace;
72 }
73
74 fRet += m_fBottomSpace;
75
76 return fRet;
77 }
78
79 void CPWL_ListCtrl::ResetAll(FX_BOOL bMove, int32_t nStart) {
80 CFX_FloatRect rcClient = GetClientRect();
81
82 FX_FLOAT fWidth = rcClient.Width();
83
84 FX_FLOAT fy = 0.0f - m_fTopSpace;
85
86 if (nStart - 1 >= 0 && nStart - 1 < m_aChildren.GetSize())
87 if (CPWL_Wnd* pChild = m_aChildren.GetAt(nStart - 1))
88 fy = pChild->GetWindowRect().bottom - m_fItemSpace;
89
90 for (int32_t i = nStart, sz = m_aChildren.GetSize(); i < sz; i++) {
91 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
92 FX_FLOAT fLeft = pChild->GetItemLeftMargin();
93 FX_FLOAT fRight = pChild->GetItemRightMargin();
94
95 pChild->SetChildMatrix(CFX_Matrix(1, 0, 0, 1,
96 rcClient.left - m_ptScroll.x,
97 rcClient.top - m_ptScroll.y));
98
99 if (bMove) {
100 FX_FLOAT fItemHeight = pChild->GetItemHeight(fWidth - fLeft - fRight);
101 pChild->Move(
102 CFX_FloatRect(fLeft, fy - fItemHeight, fWidth - fRight, fy), TRUE,
103 FALSE);
104 fy -= fItemHeight;
105 fy -= m_fItemSpace;
106 }
107 }
108 }
109
110 fy += m_fItemSpace;
111
112 fy -= m_fBottomSpace;
113
114 if (bMove) {
115 m_rcContent.left = 0;
116 m_rcContent.top = 0;
117 m_rcContent.right = fWidth;
118 m_rcContent.bottom = fy;
119 }
120 }
121
122 void CPWL_ListCtrl::SetItemSpace(FX_FLOAT fSpace) {
123 m_fItemSpace = fSpace;
124 }
125
126 void CPWL_ListCtrl::SetTopSpace(FX_FLOAT fSpace) {
127 m_fTopSpace = fSpace;
128 }
129
130 void CPWL_ListCtrl::SetBottomSpace(FX_FLOAT fSpace) {
131 m_fBottomSpace = fSpace;
132 }
133
134 void CPWL_ListCtrl::RePosChildWnd() {
135 ResetFace();
136 }
137
138 void CPWL_ListCtrl::DrawChildAppearance(CFX_RenderDevice* pDevice,
139 CFX_Matrix* pUser2Device) {
140 pDevice->SaveState();
141 CFX_FloatRect rcClient = GetClientRect();
142 CFX_FloatRect rcTemp = rcClient;
143 pUser2Device->TransformRect(rcTemp);
144 pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.bottom,
145 (int32_t)rcTemp.right, (int32_t)rcTemp.top));
146
147 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
148 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
149 CFX_FloatRect rcChild = pChild->ChildToParent(pChild->GetWindowRect());
150 if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top)) {
151 CFX_Matrix mt = pChild->GetChildMatrix();
152 if (mt.IsIdentity()) {
153 pChild->DrawAppearance(pDevice, pUser2Device);
154 } else {
155 mt.Concat(*pUser2Device);
156 pChild->DrawAppearance(pDevice, &mt);
157 }
158 }
159 }
160 }
161
162 pDevice->RestoreState();
163 }
164
165 int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) {
166 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
167 if (pItem == m_aChildren.GetAt(i))
168 return i;
169 }
170
171 return -1;
172 }
173
174 CFX_FloatPoint CPWL_ListCtrl::InToOut(const CFX_FloatPoint& point) const {
175 CFX_FloatRect rcClient = GetClientRect();
176
177 return CFX_FloatPoint(point.x + rcClient.left - m_ptScroll.x,
178 point.y + rcClient.top - m_ptScroll.y);
179 }
180
181 CFX_FloatPoint CPWL_ListCtrl::OutToIn(const CFX_FloatPoint& point) const {
182 CFX_FloatRect rcClient = GetClientRect();
183
184 return CFX_FloatPoint(point.x - rcClient.left + m_ptScroll.x,
185 point.y - rcClient.top + m_ptScroll.y);
186 }
187
188 CFX_FloatRect CPWL_ListCtrl::InToOut(const CFX_FloatRect& rect) const {
189 CFX_FloatRect rcClient = GetClientRect();
190
191 return CFX_FloatRect(rect.left + rcClient.left - m_ptScroll.x,
192 rect.bottom + rcClient.top - m_ptScroll.y,
193 rect.right + rcClient.left - m_ptScroll.x,
194 rect.top + rcClient.top - m_ptScroll.y);
195 }
196
197 CFX_FloatRect CPWL_ListCtrl::OutToIn(const CFX_FloatRect& rect) const {
198 CFX_FloatRect rcClient = GetClientRect();
199
200 return CFX_FloatRect(rect.left - rcClient.left + m_ptScroll.x,
201 rect.bottom - rcClient.top + m_ptScroll.y,
202 rect.right - rcClient.left + m_ptScroll.x,
203 rect.top - rcClient.top + m_ptScroll.y);
204 }
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