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 "xfa/fwl/lightwidget/cfwl_listbox.h" | 7 #include "xfa/fwl/lightwidget/cfwl_listbox.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 int32_t CFWL_ListBox::CountSelItems() { | 76 int32_t CFWL_ListBox::CountSelItems() { |
77 if (!m_pIface) | 77 if (!m_pIface) |
78 return 0; | 78 return 0; |
79 return static_cast<IFWL_ListBox*>(m_pIface)->CountSelItems(); | 79 return static_cast<IFWL_ListBox*>(m_pIface)->CountSelItems(); |
80 } | 80 } |
81 | 81 |
82 IFWL_ListItem* CFWL_ListBox::GetSelItem(int32_t nIndexSel) { | 82 IFWL_ListItem* CFWL_ListBox::GetSelItem(int32_t nIndexSel) { |
83 if (!m_pIface) | 83 if (!m_pIface) |
84 return NULL; | 84 return nullptr; |
85 return static_cast<IFWL_ListBox*>(m_pIface)->GetSelItem(nIndexSel); | 85 return static_cast<IFWL_ListBox*>(m_pIface)->GetSelItem(nIndexSel); |
86 } | 86 } |
87 | 87 |
88 int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) { | 88 int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) { |
89 if (!m_pIface) | 89 if (!m_pIface) |
90 return 0; | 90 return 0; |
91 return static_cast<IFWL_ListBox*>(m_pIface)->GetSelIndex(nIndex); | 91 return static_cast<IFWL_ListBox*>(m_pIface)->GetSelIndex(nIndex); |
92 } | 92 } |
93 | 93 |
94 FWL_Error CFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) { | 94 FWL_Error CFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 | 158 |
159 FWL_Error CFWL_ListBox::SetItemData(IFWL_ListItem* pItem, void* pData) { | 159 FWL_Error CFWL_ListBox::SetItemData(IFWL_ListItem* pItem, void* pData) { |
160 if (!pItem) | 160 if (!pItem) |
161 return FWL_Error::Indefinite; | 161 return FWL_Error::Indefinite; |
162 static_cast<CFWL_ListItem*>(pItem)->m_pData = pData; | 162 static_cast<CFWL_ListItem*>(pItem)->m_pData = pData; |
163 return FWL_Error::Succeeded; | 163 return FWL_Error::Succeeded; |
164 } | 164 } |
165 | 165 |
166 void* CFWL_ListBox::GetItemData(IFWL_ListItem* pItem) { | 166 void* CFWL_ListBox::GetItemData(IFWL_ListItem* pItem) { |
167 if (!pItem) | 167 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr; |
168 return NULL; | |
169 return static_cast<CFWL_ListItem*>(pItem)->m_pData; | |
170 } | 168 } |
171 | 169 |
172 IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { | 170 IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
173 CFX_RectF rtClient; | 171 CFX_RectF rtClient; |
174 m_pIface->GetClientRect(rtClient); | 172 m_pIface->GetClientRect(rtClient); |
175 fx -= rtClient.left; | 173 fx -= rtClient.left; |
176 fy -= rtClient.top; | 174 fy -= rtClient.top; |
177 FX_FLOAT fPosX = 0; | 175 FX_FLOAT fPosX = 0; |
178 FX_FLOAT fPosY = 0; | 176 FX_FLOAT fPosY = 0; |
179 static_cast<IFWL_ListBox*>(m_pIface)->GetScrollPos(fx); | 177 static_cast<IFWL_ListBox*>(m_pIface)->GetScrollPos(fx); |
180 static_cast<IFWL_ListBox*>(m_pIface)->GetScrollPos(fy, FALSE); | 178 static_cast<IFWL_ListBox*>(m_pIface)->GetScrollPos(fy, FALSE); |
181 int32_t nCount = m_ListBoxDP.CountItems(NULL); | 179 int32_t nCount = m_ListBoxDP.CountItems(nullptr); |
182 for (int32_t i = 0; i < nCount; i++) { | 180 for (int32_t i = 0; i < nCount; i++) { |
183 IFWL_ListItem* pItem = m_ListBoxDP.GetItem(NULL, i); | 181 IFWL_ListItem* pItem = m_ListBoxDP.GetItem(nullptr, i); |
184 if (!pItem) { | 182 if (!pItem) { |
185 continue; | 183 continue; |
186 } | 184 } |
187 CFX_RectF rtItem; | 185 CFX_RectF rtItem; |
188 m_ListBoxDP.GetItemRect(NULL, pItem, rtItem); | 186 m_ListBoxDP.GetItemRect(nullptr, pItem, rtItem); |
189 rtItem.Offset(-fPosX, -fPosY); | 187 rtItem.Offset(-fPosX, -fPosY); |
190 if (rtItem.Contains(fx, fy)) { | 188 if (rtItem.Contains(fx, fy)) { |
191 return pItem; | 189 return pItem; |
192 } | 190 } |
193 } | 191 } |
194 return NULL; | 192 return nullptr; |
195 } | 193 } |
196 | 194 |
197 uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) { | 195 uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) { |
198 if (!pItem) | 196 if (!pItem) |
199 return 0; | 197 return 0; |
200 CFWL_ListItem* pListItem = static_cast<CFWL_ListItem*>(pItem); | 198 CFWL_ListItem* pListItem = static_cast<CFWL_ListItem*>(pItem); |
201 return pListItem->m_dwStates | pListItem->m_dwCheckState; | 199 return pListItem->m_dwStates | pListItem->m_dwCheckState; |
202 } | 200 } |
203 | 201 |
204 CFWL_ListBox::CFWL_ListBox() {} | 202 CFWL_ListBox::CFWL_ListBox() {} |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 IFWL_ListItem* pItem, | 264 IFWL_ListItem* pItem, |
267 CFX_RectF& rtItem) { | 265 CFX_RectF& rtItem) { |
268 if (!pItem) | 266 if (!pItem) |
269 return FWL_Error::Indefinite; | 267 return FWL_Error::Indefinite; |
270 rtItem = static_cast<CFWL_ListItem*>(pItem)->m_rtItem; | 268 rtItem = static_cast<CFWL_ListItem*>(pItem)->m_rtItem; |
271 return FWL_Error::Succeeded; | 269 return FWL_Error::Succeeded; |
272 } | 270 } |
273 | 271 |
274 void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget, | 272 void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget, |
275 IFWL_ListItem* pItem) { | 273 IFWL_ListItem* pItem) { |
276 if (!pItem) | 274 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr; |
277 return NULL; | |
278 return static_cast<CFWL_ListItem*>(pItem)->m_pData; | |
279 } | 275 } |
280 | 276 |
281 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget, | 277 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget, |
282 IFWL_ListItem* pItem, | 278 IFWL_ListItem* pItem, |
283 uint32_t dwStyle) { | 279 uint32_t dwStyle) { |
284 if (!pItem) | 280 if (!pItem) |
285 return FWL_Error::Indefinite; | 281 return FWL_Error::Indefinite; |
286 static_cast<CFWL_ListItem*>(pItem)->m_dwStates = dwStyle; | 282 static_cast<CFWL_ListItem*>(pItem)->m_dwStates = dwStyle; |
287 return FWL_Error::Succeeded; | 283 return FWL_Error::Succeeded; |
288 } | 284 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 IFWL_ListItem* pItem, | 335 IFWL_ListItem* pItem, |
340 uint32_t dwCheckState) { | 336 uint32_t dwCheckState) { |
341 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; | 337 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; |
342 return FWL_Error::Succeeded; | 338 return FWL_Error::Succeeded; |
343 } | 339 } |
344 | 340 |
345 CFWL_ListItem::CFWL_ListItem() { | 341 CFWL_ListItem::CFWL_ListItem() { |
346 m_rtItem.Reset(); | 342 m_rtItem.Reset(); |
347 m_dwStates = 0; | 343 m_dwStates = 0; |
348 m_wsText = L""; | 344 m_wsText = L""; |
349 m_pDIB = NULL; | 345 m_pDIB = nullptr; |
350 m_pData = NULL; | 346 m_pData = nullptr; |
351 m_dwCheckState = 0; | 347 m_dwCheckState = 0; |
352 m_rtCheckBox.Reset(); | 348 m_rtCheckBox.Reset(); |
353 } | 349 } |
354 | 350 |
355 CFWL_ListItem::~CFWL_ListItem() {} | 351 CFWL_ListItem::~CFWL_ListItem() {} |
OLD | NEW |