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