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/core/cfwl_listbox.h" | 7 #include "xfa/fwl/core/cfwl_listbox.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 void CFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) { | 94 void CFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) { |
95 if (GetWidget()) | 95 if (GetWidget()) |
96 ToListBox(GetWidget())->GetItemText(pItem, wsText); | 96 ToListBox(GetWidget())->GetItemText(pItem, wsText); |
97 } | 97 } |
98 | 98 |
99 void CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, bool bVert) { | 99 void CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, bool bVert) { |
100 if (GetWidget()) | 100 if (GetWidget()) |
101 ToListBox(GetWidget())->GetScrollPos(fPos, bVert); | 101 ToListBox(GetWidget())->GetScrollPos(fPos, bVert); |
102 } | 102 } |
103 | 103 |
104 int32_t CFWL_ListBox::CountItems() { | 104 int32_t CFWL_ListBox::CountItems() const { |
105 return pdfium::CollectionSize<int32_t>(m_ItemArray); | 105 return pdfium::CollectionSize<int32_t>(m_ItemArray); |
106 } | 106 } |
107 | 107 |
108 CFWL_ListItem* CFWL_ListBox::GetItem(int32_t nIndex) { | 108 CFWL_ListItem* CFWL_ListBox::GetItem(int32_t nIndex) { |
109 if (nIndex < 0 || nIndex >= CountItems()) | 109 if (nIndex < 0 || nIndex >= CountItems()) |
110 return nullptr; | 110 return nullptr; |
111 | 111 |
112 return m_ItemArray[nIndex].get(); | 112 return m_ItemArray[nIndex].get(); |
113 } | 113 } |
114 | 114 |
115 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { | 115 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { |
116 if (!pItem) | 116 if (!pItem) |
117 return 0; | 117 return 0; |
118 CFWL_ListItem* pListItem = static_cast<CFWL_ListItem*>(pItem); | 118 CFWL_ListItem* pListItem = static_cast<CFWL_ListItem*>(pItem); |
119 return pListItem->m_dwStates | pListItem->m_dwCheckState; | 119 return pListItem->m_dwStates | pListItem->m_dwCheckState; |
120 } | 120 } |
121 | 121 |
122 void CFWL_ListBox::GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) { | 122 void CFWL_ListBox::GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) { |
123 wsCaption = L""; | 123 wsCaption = L""; |
124 } | 124 } |
125 | 125 |
126 int32_t CFWL_ListBox::CountItems(const IFWL_Widget* pWidget) { | 126 int32_t CFWL_ListBox::CountItems(const IFWL_Widget* pWidget) const { |
127 return pdfium::CollectionSize<int32_t>(m_ItemArray); | 127 return pdfium::CollectionSize<int32_t>(m_ItemArray); |
128 } | 128 } |
129 | 129 |
130 CFWL_ListItem* CFWL_ListBox::GetItem(const IFWL_Widget* pWidget, | 130 CFWL_ListItem* CFWL_ListBox::GetItem(const IFWL_Widget* pWidget, |
131 int32_t nIndex) { | 131 int32_t nIndex) const { |
132 if (nIndex < 0 || nIndex >= CountItems(pWidget)) | 132 if (nIndex < 0 || nIndex >= CountItems(pWidget)) |
133 return nullptr; | 133 return nullptr; |
134 | 134 |
135 return m_ItemArray[nIndex].get(); | 135 return m_ItemArray[nIndex].get(); |
136 } | 136 } |
137 | 137 |
138 int32_t CFWL_ListBox::GetItemIndex(IFWL_Widget* pWidget, CFWL_ListItem* pItem) { | 138 int32_t CFWL_ListBox::GetItemIndex(IFWL_Widget* pWidget, CFWL_ListItem* pItem) { |
139 auto it = std::find_if( | 139 auto it = std::find_if( |
140 m_ItemArray.begin(), m_ItemArray.end(), | 140 m_ItemArray.begin(), m_ItemArray.end(), |
141 [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) { | 141 [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 uint32_t CFWL_ListBox::GetItemCheckState(IFWL_Widget* pWidget, | 223 uint32_t CFWL_ListBox::GetItemCheckState(IFWL_Widget* pWidget, |
224 CFWL_ListItem* pItem) { | 224 CFWL_ListItem* pItem) { |
225 return static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState; | 225 return static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState; |
226 } | 226 } |
227 | 227 |
228 void CFWL_ListBox::SetItemCheckState(IFWL_Widget* pWidget, | 228 void CFWL_ListBox::SetItemCheckState(IFWL_Widget* pWidget, |
229 CFWL_ListItem* pItem, | 229 CFWL_ListItem* pItem, |
230 uint32_t dwCheckState) { | 230 uint32_t dwCheckState) { |
231 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; | 231 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; |
232 } | 232 } |
OLD | NEW |