| 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_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 CFX_FloatPoint& point) { | 19 void CPWL_ListCtrl::SetScrollPos(const CPDF_Point& 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 CFX_FloatPoint CPWL_ListCtrl::GetScrollPos() const { | 35 CPDF_Point CPWL_ListCtrl::GetScrollPos() const { |
| 36 return m_ptScroll; | 36 return m_ptScroll; |
| 37 } | 37 } |
| 38 | 38 |
| 39 CFX_FloatRect CPWL_ListCtrl::GetScrollArea() const { | 39 CPDF_Rect 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 Loading... |
| 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 CFX_FloatRect rcClient = GetClientRect(); | 80 CPDF_Rect 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( | 101 pChild->Move(CPDF_Rect(fLeft, fy - fItemHeight, fWidth - fRight, fy), |
| 102 CFX_FloatRect(fLeft, fy - fItemHeight, fWidth - fRight, fy), TRUE, | 102 TRUE, FALSE); |
| 103 FALSE); | |
| 104 fy -= fItemHeight; | 103 fy -= fItemHeight; |
| 105 fy -= m_fItemSpace; | 104 fy -= m_fItemSpace; |
| 106 } | 105 } |
| 107 } | 106 } |
| 108 } | 107 } |
| 109 | 108 |
| 110 fy += m_fItemSpace; | 109 fy += m_fItemSpace; |
| 111 | 110 |
| 112 fy -= m_fBottomSpace; | 111 fy -= m_fBottomSpace; |
| 113 | 112 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 131 m_fBottomSpace = fSpace; | 130 m_fBottomSpace = fSpace; |
| 132 } | 131 } |
| 133 | 132 |
| 134 void CPWL_ListCtrl::RePosChildWnd() { | 133 void CPWL_ListCtrl::RePosChildWnd() { |
| 135 ResetFace(); | 134 ResetFace(); |
| 136 } | 135 } |
| 137 | 136 |
| 138 void CPWL_ListCtrl::DrawChildAppearance(CFX_RenderDevice* pDevice, | 137 void CPWL_ListCtrl::DrawChildAppearance(CFX_RenderDevice* pDevice, |
| 139 CFX_Matrix* pUser2Device) { | 138 CFX_Matrix* pUser2Device) { |
| 140 pDevice->SaveState(); | 139 pDevice->SaveState(); |
| 141 CFX_FloatRect rcClient = GetClientRect(); | 140 CPDF_Rect rcClient = GetClientRect(); |
| 142 CFX_FloatRect rcTemp = rcClient; | 141 CPDF_Rect rcTemp = rcClient; |
| 143 pUser2Device->TransformRect(rcTemp); | 142 pUser2Device->TransformRect(rcTemp); |
| 144 FX_RECT rcClip((int32_t)rcTemp.left, (int32_t)rcTemp.bottom, | 143 FX_RECT rcClip((int32_t)rcTemp.left, (int32_t)rcTemp.bottom, |
| 145 (int32_t)rcTemp.right, (int32_t)rcTemp.top); | 144 (int32_t)rcTemp.right, (int32_t)rcTemp.top); |
| 146 | 145 |
| 147 pDevice->SetClip_Rect(&rcClip); | 146 pDevice->SetClip_Rect(&rcClip); |
| 148 | 147 |
| 149 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { | 148 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 150 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { | 149 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 151 CFX_FloatRect rcChild = pChild->ChildToParent(pChild->GetWindowRect()); | 150 CPDF_Rect rcChild = pChild->ChildToParent(pChild->GetWindowRect()); |
| 152 if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top)) { | 151 if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top)) { |
| 153 CFX_Matrix mt = pChild->GetChildMatrix(); | 152 CFX_Matrix mt = pChild->GetChildMatrix(); |
| 154 if (mt.IsIdentity()) { | 153 if (mt.IsIdentity()) { |
| 155 pChild->DrawAppearance(pDevice, pUser2Device); | 154 pChild->DrawAppearance(pDevice, pUser2Device); |
| 156 } else { | 155 } else { |
| 157 mt.Concat(*pUser2Device); | 156 mt.Concat(*pUser2Device); |
| 158 pChild->DrawAppearance(pDevice, &mt); | 157 pChild->DrawAppearance(pDevice, &mt); |
| 159 } | 158 } |
| 160 } | 159 } |
| 161 } | 160 } |
| 162 } | 161 } |
| 163 | 162 |
| 164 pDevice->RestoreState(); | 163 pDevice->RestoreState(); |
| 165 } | 164 } |
| 166 | 165 |
| 167 int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) { | 166 int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) { |
| 168 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { | 167 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 169 if (pItem == m_aChildren.GetAt(i)) | 168 if (pItem == m_aChildren.GetAt(i)) |
| 170 return i; | 169 return i; |
| 171 } | 170 } |
| 172 | 171 |
| 173 return -1; | 172 return -1; |
| 174 } | 173 } |
| 175 | 174 |
| 176 CFX_FloatPoint CPWL_ListCtrl::InToOut(const CFX_FloatPoint& point) const { | 175 CPDF_Point CPWL_ListCtrl::InToOut(const CPDF_Point& point) const { |
| 177 CFX_FloatRect rcClient = GetClientRect(); | 176 CPDF_Rect rcClient = GetClientRect(); |
| 178 | 177 |
| 179 return CFX_FloatPoint(point.x + rcClient.left - m_ptScroll.x, | 178 return CPDF_Point(point.x + rcClient.left - m_ptScroll.x, |
| 180 point.y + rcClient.top - m_ptScroll.y); | 179 point.y + rcClient.top - m_ptScroll.y); |
| 181 } | 180 } |
| 182 | 181 |
| 183 CFX_FloatPoint CPWL_ListCtrl::OutToIn(const CFX_FloatPoint& point) const { | 182 CPDF_Point CPWL_ListCtrl::OutToIn(const CPDF_Point& point) const { |
| 184 CFX_FloatRect rcClient = GetClientRect(); | 183 CPDF_Rect rcClient = GetClientRect(); |
| 185 | 184 |
| 186 return CFX_FloatPoint(point.x - rcClient.left + m_ptScroll.x, | 185 return CPDF_Point(point.x - rcClient.left + m_ptScroll.x, |
| 187 point.y - rcClient.top + m_ptScroll.y); | 186 point.y - rcClient.top + m_ptScroll.y); |
| 188 } | 187 } |
| 189 | 188 |
| 190 CFX_FloatRect CPWL_ListCtrl::InToOut(const CFX_FloatRect& rect) const { | 189 CPDF_Rect CPWL_ListCtrl::InToOut(const CPDF_Rect& rect) const { |
| 191 CFX_FloatRect rcClient = GetClientRect(); | 190 CPDF_Rect rcClient = GetClientRect(); |
| 192 | 191 |
| 193 return CFX_FloatRect(rect.left + rcClient.left - m_ptScroll.x, | 192 return CPDF_Rect(rect.left + rcClient.left - m_ptScroll.x, |
| 194 rect.bottom + rcClient.top - m_ptScroll.y, | 193 rect.bottom + rcClient.top - m_ptScroll.y, |
| 195 rect.right + rcClient.left - m_ptScroll.x, | 194 rect.right + rcClient.left - m_ptScroll.x, |
| 196 rect.top + rcClient.top - m_ptScroll.y); | 195 rect.top + rcClient.top - m_ptScroll.y); |
| 197 } | 196 } |
| 198 | 197 |
| 199 CFX_FloatRect CPWL_ListCtrl::OutToIn(const CFX_FloatRect& rect) const { | 198 CPDF_Rect CPWL_ListCtrl::OutToIn(const CPDF_Rect& rect) const { |
| 200 CFX_FloatRect rcClient = GetClientRect(); | 199 CPDF_Rect rcClient = GetClientRect(); |
| 201 | 200 |
| 202 return CFX_FloatRect(rect.left - rcClient.left + m_ptScroll.x, | 201 return CPDF_Rect(rect.left - rcClient.left + m_ptScroll.x, |
| 203 rect.bottom - rcClient.top + m_ptScroll.y, | 202 rect.bottom - rcClient.top + m_ptScroll.y, |
| 204 rect.right - rcClient.left + m_ptScroll.x, | 203 rect.right - rcClient.left + m_ptScroll.x, |
| 205 rect.top - rcClient.top + m_ptScroll.y); | 204 rect.top - rcClient.top + m_ptScroll.y); |
| 206 } | 205 } |
| OLD | NEW |