| 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 |
| 11 #include "third_party/base/ptr_util.h" | 11 #include "third_party/base/ptr_util.h" |
| 12 #include "third_party/base/stl_util.h" | 12 #include "third_party/base/stl_util.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 IFWL_ListBox* ToListBox(IFWL_Widget* widget) { | 16 IFWL_ListBox* ToListBox(IFWL_Widget* widget) { |
| 17 return static_cast<IFWL_ListBox*>(widget); | 17 return static_cast<IFWL_ListBox*>(widget); |
| 18 } | 18 } |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 CFWL_ListBox::CFWL_ListBox(const IFWL_App* app) : CFWL_Widget(app) {} | 22 CFWL_ListBox::CFWL_ListBox(const IFWL_App* app) : CFWL_Widget(app) {} |
| 23 | 23 |
| 24 CFWL_ListBox::~CFWL_ListBox() {} | 24 CFWL_ListBox::~CFWL_ListBox() {} |
| 25 | 25 |
| 26 void CFWL_ListBox::Initialize() { | 26 void CFWL_ListBox::Initialize() { |
| 27 ASSERT(!m_pIface); | 27 ASSERT(!m_pIface); |
| 28 | 28 |
| 29 m_pIface = pdfium::MakeUnique<IFWL_ListBox>( | 29 m_pIface = pdfium::MakeUnique<IFWL_ListBox>( |
| 30 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(&m_ListBoxDP), nullptr); | 30 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(this), nullptr); |
| 31 | 31 |
| 32 CFWL_Widget::Initialize(); | 32 CFWL_Widget::Initialize(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem) { | 35 FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem) { |
| 36 static_cast<CFWL_ListItem*>(pItem)->m_pDIB = pDIB; | 36 static_cast<CFWL_ListItem*>(pItem)->m_pDIB = pDIB; |
| 37 return FWL_Error::Succeeded; | 37 return FWL_Error::Succeeded; |
| 38 } | 38 } |
| 39 | 39 |
| 40 IFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, | 40 IFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, |
| 41 bool bSelect) { | 41 bool bSelect) { |
| 42 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); | 42 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); |
| 43 pItem->m_dwStates = 0; | 43 pItem->m_dwStates = 0; |
| 44 pItem->m_wsText = wsAdd; | 44 pItem->m_wsText = wsAdd; |
| 45 pItem->m_dwStates = bSelect ? FWL_ITEMSTATE_LTB_Selected : 0; | 45 pItem->m_dwStates = bSelect ? FWL_ITEMSTATE_LTB_Selected : 0; |
| 46 m_ListBoxDP.m_ItemArray.push_back(std::move(pItem)); | 46 m_ItemArray.push_back(std::move(pItem)); |
| 47 return m_ListBoxDP.m_ItemArray.back().get(); | 47 return m_ItemArray.back().get(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool CFWL_ListBox::DeleteString(IFWL_ListItem* pItem) { | 50 bool CFWL_ListBox::DeleteString(IFWL_ListItem* pItem) { |
| 51 int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), pItem); | 51 int32_t nIndex = GetItemIndex(GetWidget(), pItem); |
| 52 if (nIndex < 0 || | 52 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) { |
| 53 static_cast<size_t>(nIndex) >= m_ListBoxDP.m_ItemArray.size()) { | |
| 54 return false; | 53 return false; |
| 55 } | 54 } |
| 56 int32_t iCount = m_ListBoxDP.CountItems(m_pIface.get()); | 55 int32_t iCount = CountItems(m_pIface.get()); |
| 57 int32_t iSel = nIndex + 1; | 56 int32_t iSel = nIndex + 1; |
| 58 if (iSel >= iCount) { | 57 if (iSel >= iCount) { |
| 59 iSel = nIndex - 1; | 58 iSel = nIndex - 1; |
| 60 if (iSel < 0) { | 59 if (iSel < 0) { |
| 61 iSel = -1; | 60 iSel = -1; |
| 62 } | 61 } |
| 63 } | 62 } |
| 64 if (iSel >= 0) { | 63 if (iSel >= 0) { |
| 65 CFWL_ListItem* pSel = | 64 CFWL_ListItem* pSel = |
| 66 static_cast<CFWL_ListItem*>(m_ListBoxDP.GetItem(m_pIface.get(), iSel)); | 65 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iSel)); |
| 67 pSel->m_dwStates |= FWL_ITEMSTATE_LTB_Selected; | 66 pSel->m_dwStates |= FWL_ITEMSTATE_LTB_Selected; |
| 68 } | 67 } |
| 69 m_ListBoxDP.m_ItemArray.erase(m_ListBoxDP.m_ItemArray.begin() + nIndex); | 68 m_ItemArray.erase(m_ItemArray.begin() + nIndex); |
| 70 return true; | 69 return true; |
| 71 } | 70 } |
| 72 | 71 |
| 73 void CFWL_ListBox::DeleteAll() { | 72 void CFWL_ListBox::DeleteAll() { |
| 74 m_ListBoxDP.m_ItemArray.clear(); | 73 m_ItemArray.clear(); |
| 75 } | 74 } |
| 76 | 75 |
| 77 int32_t CFWL_ListBox::CountSelItems() { | 76 int32_t CFWL_ListBox::CountSelItems() { |
| 78 if (!GetWidget()) | 77 if (!GetWidget()) |
| 79 return 0; | 78 return 0; |
| 80 return ToListBox(GetWidget())->CountSelItems(); | 79 return ToListBox(GetWidget())->CountSelItems(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 IFWL_ListItem* CFWL_ListBox::GetSelItem(int32_t nIndexSel) { | 82 IFWL_ListItem* CFWL_ListBox::GetSelItem(int32_t nIndexSel) { |
| 84 if (!GetWidget()) | 83 if (!GetWidget()) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 105 return ToListBox(GetWidget())->GetItemText(pItem, wsText); | 104 return ToListBox(GetWidget())->GetItemText(pItem, wsText); |
| 106 } | 105 } |
| 107 | 106 |
| 108 FWL_Error CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, bool bVert) { | 107 FWL_Error CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, bool bVert) { |
| 109 if (!GetWidget()) | 108 if (!GetWidget()) |
| 110 return FWL_Error::Indefinite; | 109 return FWL_Error::Indefinite; |
| 111 return ToListBox(GetWidget())->GetScrollPos(fPos, bVert); | 110 return ToListBox(GetWidget())->GetScrollPos(fPos, bVert); |
| 112 } | 111 } |
| 113 | 112 |
| 114 FWL_Error CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) { | 113 FWL_Error CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) { |
| 115 m_ListBoxDP.m_fItemHeight = fItemHeight; | 114 m_fItemHeight = fItemHeight; |
| 116 return FWL_Error::Succeeded; | 115 return FWL_Error::Succeeded; |
| 117 } | 116 } |
| 118 | 117 |
| 119 IFWL_ListItem* CFWL_ListBox::GetFocusItem() { | 118 IFWL_ListItem* CFWL_ListBox::GetFocusItem() { |
| 120 for (const auto& pItem : m_ListBoxDP.m_ItemArray) { | 119 for (const auto& pItem : m_ItemArray) { |
| 121 if (pItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused) | 120 if (pItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused) |
| 122 return pItem.get(); | 121 return pItem.get(); |
| 123 } | 122 } |
| 124 return nullptr; | 123 return nullptr; |
| 125 } | 124 } |
| 126 | 125 |
| 127 FWL_Error CFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) { | 126 FWL_Error CFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) { |
| 128 int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), pItem); | 127 int32_t nIndex = GetItemIndex(GetWidget(), pItem); |
| 129 m_ListBoxDP.m_ItemArray[nIndex]->m_dwStates |= FWL_ITEMSTATE_LTB_Focused; | 128 m_ItemArray[nIndex]->m_dwStates |= FWL_ITEMSTATE_LTB_Focused; |
| 130 return FWL_Error::Succeeded; | 129 return FWL_Error::Succeeded; |
| 131 } | 130 } |
| 132 | 131 |
| 133 int32_t CFWL_ListBox::CountItems() { | 132 int32_t CFWL_ListBox::CountItems() { |
| 134 return pdfium::CollectionSize<int32_t>(m_ListBoxDP.m_ItemArray); | 133 return pdfium::CollectionSize<int32_t>(m_ItemArray); |
| 135 } | 134 } |
| 136 | 135 |
| 137 IFWL_ListItem* CFWL_ListBox::GetItem(int32_t nIndex) { | 136 IFWL_ListItem* CFWL_ListBox::GetItem(int32_t nIndex) { |
| 138 if (nIndex < 0 || nIndex >= CountItems()) | 137 if (nIndex < 0 || nIndex >= CountItems()) |
| 139 return nullptr; | 138 return nullptr; |
| 140 | 139 |
| 141 return m_ListBoxDP.m_ItemArray[nIndex].get(); | 140 return m_ItemArray[nIndex].get(); |
| 142 } | 141 } |
| 143 | 142 |
| 144 FWL_Error CFWL_ListBox::SetItemString(IFWL_ListItem* pItem, | 143 FWL_Error CFWL_ListBox::SetItemString(IFWL_ListItem* pItem, |
| 145 const CFX_WideStringC& wsText) { | 144 const CFX_WideStringC& wsText) { |
| 146 if (!pItem) | 145 if (!pItem) |
| 147 return FWL_Error::Indefinite; | 146 return FWL_Error::Indefinite; |
| 148 static_cast<CFWL_ListItem*>(pItem)->m_wsText = wsText; | 147 static_cast<CFWL_ListItem*>(pItem)->m_wsText = wsText; |
| 149 return FWL_Error::Succeeded; | 148 return FWL_Error::Succeeded; |
| 150 } | 149 } |
| 151 | 150 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 170 | 169 |
| 171 IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { | 170 IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
| 172 CFX_RectF rtClient; | 171 CFX_RectF rtClient; |
| 173 GetWidget()->GetClientRect(rtClient); | 172 GetWidget()->GetClientRect(rtClient); |
| 174 fx -= rtClient.left; | 173 fx -= rtClient.left; |
| 175 fy -= rtClient.top; | 174 fy -= rtClient.top; |
| 176 FX_FLOAT fPosX = 0; | 175 FX_FLOAT fPosX = 0; |
| 177 FX_FLOAT fPosY = 0; | 176 FX_FLOAT fPosY = 0; |
| 178 ToListBox(GetWidget())->GetScrollPos(fx); | 177 ToListBox(GetWidget())->GetScrollPos(fx); |
| 179 ToListBox(GetWidget())->GetScrollPos(fy, false); | 178 ToListBox(GetWidget())->GetScrollPos(fy, false); |
| 180 int32_t nCount = m_ListBoxDP.CountItems(nullptr); | 179 int32_t nCount = CountItems(nullptr); |
| 181 for (int32_t i = 0; i < nCount; i++) { | 180 for (int32_t i = 0; i < nCount; i++) { |
| 182 IFWL_ListItem* pItem = m_ListBoxDP.GetItem(nullptr, i); | 181 IFWL_ListItem* pItem = GetItem(nullptr, i); |
| 183 if (!pItem) { | 182 if (!pItem) { |
| 184 continue; | 183 continue; |
| 185 } | 184 } |
| 186 CFX_RectF rtItem; | 185 CFX_RectF rtItem; |
| 187 m_ListBoxDP.GetItemRect(nullptr, pItem, rtItem); | 186 GetItemRect(nullptr, pItem, rtItem); |
| 188 rtItem.Offset(-fPosX, -fPosY); | 187 rtItem.Offset(-fPosX, -fPosY); |
| 189 if (rtItem.Contains(fx, fy)) { | 188 if (rtItem.Contains(fx, fy)) { |
| 190 return pItem; | 189 return pItem; |
| 191 } | 190 } |
| 192 } | 191 } |
| 193 return nullptr; | 192 return nullptr; |
| 194 } | 193 } |
| 195 | 194 |
| 196 uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) { | 195 uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) { |
| 197 if (!pItem) | 196 if (!pItem) |
| 198 return 0; | 197 return 0; |
| 199 CFWL_ListItem* pListItem = static_cast<CFWL_ListItem*>(pItem); | 198 CFWL_ListItem* pListItem = static_cast<CFWL_ListItem*>(pItem); |
| 200 return pListItem->m_dwStates | pListItem->m_dwCheckState; | 199 return pListItem->m_dwStates | pListItem->m_dwCheckState; |
| 201 } | 200 } |
| 202 | 201 |
| 203 CFWL_ListBox::CFWL_ListBoxDP::CFWL_ListBoxDP() {} | 202 FWL_Error CFWL_ListBox::GetCaption(IFWL_Widget* pWidget, |
| 204 | 203 CFX_WideString& wsCaption) { |
| 205 CFWL_ListBox::CFWL_ListBoxDP::~CFWL_ListBoxDP() {} | |
| 206 | |
| 207 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget* pWidget, | |
| 208 CFX_WideString& wsCaption) { | |
| 209 wsCaption = m_wsData; | 204 wsCaption = m_wsData; |
| 210 return FWL_Error::Succeeded; | 205 return FWL_Error::Succeeded; |
| 211 } | 206 } |
| 212 | 207 |
| 213 int32_t CFWL_ListBox::CFWL_ListBoxDP::CountItems(const IFWL_Widget* pWidget) { | 208 int32_t CFWL_ListBox::CountItems(const IFWL_Widget* pWidget) { |
| 214 return pdfium::CollectionSize<int32_t>(m_ItemArray); | 209 return pdfium::CollectionSize<int32_t>(m_ItemArray); |
| 215 } | 210 } |
| 216 | 211 |
| 217 IFWL_ListItem* CFWL_ListBox::CFWL_ListBoxDP::GetItem(const IFWL_Widget* pWidget, | 212 IFWL_ListItem* CFWL_ListBox::GetItem(const IFWL_Widget* pWidget, |
| 218 int32_t nIndex) { | 213 int32_t nIndex) { |
| 219 if (nIndex < 0 || nIndex >= CountItems(pWidget)) | 214 if (nIndex < 0 || nIndex >= CountItems(pWidget)) |
| 220 return nullptr; | 215 return nullptr; |
| 221 | 216 |
| 222 return m_ItemArray[nIndex].get(); | 217 return m_ItemArray[nIndex].get(); |
| 223 } | 218 } |
| 224 | 219 |
| 225 int32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemIndex(IFWL_Widget* pWidget, | 220 int32_t CFWL_ListBox::GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) { |
| 226 IFWL_ListItem* pItem) { | |
| 227 auto it = std::find_if( | 221 auto it = std::find_if( |
| 228 m_ItemArray.begin(), m_ItemArray.end(), | 222 m_ItemArray.begin(), m_ItemArray.end(), |
| 229 [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) { | 223 [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) { |
| 230 return candidate.get() == static_cast<CFWL_ListItem*>(pItem); | 224 return candidate.get() == static_cast<CFWL_ListItem*>(pItem); |
| 231 }); | 225 }); |
| 232 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; | 226 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; |
| 233 } | 227 } |
| 234 | 228 |
| 235 bool CFWL_ListBox::CFWL_ListBoxDP::SetItemIndex(IFWL_Widget* pWidget, | 229 bool CFWL_ListBox::SetItemIndex(IFWL_Widget* pWidget, |
| 236 IFWL_ListItem* pItem, | 230 IFWL_ListItem* pItem, |
| 237 int32_t nIndex) { | 231 int32_t nIndex) { |
| 238 if (nIndex < 0 || nIndex >= CountItems(pWidget)) | 232 if (nIndex < 0 || nIndex >= CountItems(pWidget)) |
| 239 return false; | 233 return false; |
| 240 m_ItemArray[nIndex].reset(static_cast<CFWL_ListItem*>(pItem)); | 234 m_ItemArray[nIndex].reset(static_cast<CFWL_ListItem*>(pItem)); |
| 241 return true; | 235 return true; |
| 242 } | 236 } |
| 243 | 237 |
| 244 uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget* pWidget, | 238 uint32_t CFWL_ListBox::GetItemStyles(IFWL_Widget* pWidget, |
| 245 IFWL_ListItem* pItem) { | 239 IFWL_ListItem* pItem) { |
| 246 if (!pItem) | 240 if (!pItem) |
| 247 return 0; | 241 return 0; |
| 248 return static_cast<CFWL_ListItem*>(pItem)->m_dwStates; | 242 return static_cast<CFWL_ListItem*>(pItem)->m_dwStates; |
| 249 } | 243 } |
| 250 | 244 |
| 251 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget, | 245 FWL_Error CFWL_ListBox::GetItemText(IFWL_Widget* pWidget, |
| 252 IFWL_ListItem* pItem, | 246 IFWL_ListItem* pItem, |
| 253 CFX_WideString& wsText) { | 247 CFX_WideString& wsText) { |
| 254 if (!pItem) | 248 if (!pItem) |
| 255 return FWL_Error::Indefinite; | 249 return FWL_Error::Indefinite; |
| 256 wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText; | 250 wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText; |
| 257 return FWL_Error::Succeeded; | 251 return FWL_Error::Succeeded; |
| 258 } | 252 } |
| 259 | 253 |
| 260 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget, | 254 FWL_Error CFWL_ListBox::GetItemRect(IFWL_Widget* pWidget, |
| 261 IFWL_ListItem* pItem, | 255 IFWL_ListItem* pItem, |
| 262 CFX_RectF& rtItem) { | 256 CFX_RectF& rtItem) { |
| 263 if (!pItem) | 257 if (!pItem) |
| 264 return FWL_Error::Indefinite; | 258 return FWL_Error::Indefinite; |
| 265 rtItem = static_cast<CFWL_ListItem*>(pItem)->m_rtItem; | 259 rtItem = static_cast<CFWL_ListItem*>(pItem)->m_rtItem; |
| 266 return FWL_Error::Succeeded; | 260 return FWL_Error::Succeeded; |
| 267 } | 261 } |
| 268 | 262 |
| 269 void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget, | 263 void* CFWL_ListBox::GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) { |
| 270 IFWL_ListItem* pItem) { | |
| 271 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr; | 264 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr; |
| 272 } | 265 } |
| 273 | 266 |
| 274 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget, | 267 FWL_Error CFWL_ListBox::SetItemStyles(IFWL_Widget* pWidget, |
| 275 IFWL_ListItem* pItem, | 268 IFWL_ListItem* pItem, |
| 276 uint32_t dwStyle) { | 269 uint32_t dwStyle) { |
| 277 if (!pItem) | 270 if (!pItem) |
| 278 return FWL_Error::Indefinite; | 271 return FWL_Error::Indefinite; |
| 279 static_cast<CFWL_ListItem*>(pItem)->m_dwStates = dwStyle; | 272 static_cast<CFWL_ListItem*>(pItem)->m_dwStates = dwStyle; |
| 280 return FWL_Error::Succeeded; | 273 return FWL_Error::Succeeded; |
| 281 } | 274 } |
| 282 | 275 |
| 283 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget, | 276 FWL_Error CFWL_ListBox::SetItemText(IFWL_Widget* pWidget, |
| 284 IFWL_ListItem* pItem, | 277 IFWL_ListItem* pItem, |
| 285 const FX_WCHAR* pszText) { | 278 const FX_WCHAR* pszText) { |
| 286 if (!pItem) | 279 if (!pItem) |
| 287 return FWL_Error::Indefinite; | 280 return FWL_Error::Indefinite; |
| 288 static_cast<CFWL_ListItem*>(pItem)->m_wsText = pszText; | 281 static_cast<CFWL_ListItem*>(pItem)->m_wsText = pszText; |
| 289 return FWL_Error::Succeeded; | 282 return FWL_Error::Succeeded; |
| 290 } | 283 } |
| 291 | 284 |
| 292 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget, | 285 FWL_Error CFWL_ListBox::SetItemRect(IFWL_Widget* pWidget, |
| 293 IFWL_ListItem* pItem, | 286 IFWL_ListItem* pItem, |
| 294 const CFX_RectF& rtItem) { | 287 const CFX_RectF& rtItem) { |
| 295 if (!pItem) | 288 if (!pItem) |
| 296 return FWL_Error::Indefinite; | 289 return FWL_Error::Indefinite; |
| 297 static_cast<CFWL_ListItem*>(pItem)->m_rtItem = rtItem; | 290 static_cast<CFWL_ListItem*>(pItem)->m_rtItem = rtItem; |
| 298 return FWL_Error::Succeeded; | 291 return FWL_Error::Succeeded; |
| 299 } | 292 } |
| 300 | 293 |
| 301 FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget* pWidget) { | 294 FX_FLOAT CFWL_ListBox::GetItemHeight(IFWL_Widget* pWidget) { |
| 302 return m_fItemHeight; | 295 return m_fItemHeight; |
| 303 } | 296 } |
| 304 | 297 |
| 305 CFX_DIBitmap* CFWL_ListBox::CFWL_ListBoxDP::GetItemIcon(IFWL_Widget* pWidget, | 298 CFX_DIBitmap* CFWL_ListBox::GetItemIcon(IFWL_Widget* pWidget, |
| 306 IFWL_ListItem* pItem) { | 299 IFWL_ListItem* pItem) { |
| 307 return static_cast<CFWL_ListItem*>(pItem)->m_pDIB; | 300 return static_cast<CFWL_ListItem*>(pItem)->m_pDIB; |
| 308 } | 301 } |
| 309 | 302 |
| 310 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, | 303 FWL_Error CFWL_ListBox::GetItemCheckRect(IFWL_Widget* pWidget, |
| 311 IFWL_ListItem* pItem, | 304 IFWL_ListItem* pItem, |
| 312 CFX_RectF& rtCheck) { | 305 CFX_RectF& rtCheck) { |
| 313 rtCheck = static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox; | 306 rtCheck = static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox; |
| 314 return FWL_Error::Succeeded; | 307 return FWL_Error::Succeeded; |
| 315 } | 308 } |
| 316 | 309 |
| 317 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect( | 310 FWL_Error CFWL_ListBox::SetItemCheckRect(IFWL_Widget* pWidget, |
| 318 IFWL_Widget* pWidget, | 311 IFWL_ListItem* pItem, |
| 319 IFWL_ListItem* pItem, | 312 const CFX_RectF& rtCheck) { |
| 320 const CFX_RectF& rtCheck) { | |
| 321 static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox = rtCheck; | 313 static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox = rtCheck; |
| 322 return FWL_Error::Succeeded; | 314 return FWL_Error::Succeeded; |
| 323 } | 315 } |
| 324 | 316 |
| 325 uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckState(IFWL_Widget* pWidget, | 317 uint32_t CFWL_ListBox::GetItemCheckState(IFWL_Widget* pWidget, |
| 326 IFWL_ListItem* pItem) { | 318 IFWL_ListItem* pItem) { |
| 327 return static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState; | 319 return static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState; |
| 328 } | 320 } |
| 329 | 321 |
| 330 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState( | 322 FWL_Error CFWL_ListBox::SetItemCheckState(IFWL_Widget* pWidget, |
| 331 IFWL_Widget* pWidget, | 323 IFWL_ListItem* pItem, |
| 332 IFWL_ListItem* pItem, | 324 uint32_t dwCheckState) { |
| 333 uint32_t dwCheckState) { | |
| 334 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; | 325 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; |
| 335 return FWL_Error::Succeeded; | 326 return FWL_Error::Succeeded; |
| 336 } | 327 } |
| 337 | 328 |
| 338 CFWL_ListItem::CFWL_ListItem() { | 329 CFWL_ListItem::CFWL_ListItem() { |
| 339 m_rtItem.Reset(); | 330 m_rtItem.Reset(); |
| 340 m_dwStates = 0; | 331 m_dwStates = 0; |
| 341 m_wsText = L""; | 332 m_wsText = L""; |
| 342 m_pDIB = nullptr; | 333 m_pDIB = nullptr; |
| 343 m_pData = nullptr; | 334 m_pData = nullptr; |
| 344 m_dwCheckState = 0; | 335 m_dwCheckState = 0; |
| 345 m_rtCheckBox.Reset(); | 336 m_rtCheckBox.Reset(); |
| 346 } | 337 } |
| 347 | 338 |
| 348 CFWL_ListItem::~CFWL_ListItem() {} | 339 CFWL_ListItem::~CFWL_ListItem() {} |
| OLD | NEW |