| 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_combobox.h" | 7 #include "xfa/fwl/lightwidget/cfwl_combobox.h" |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 void CFWL_ComboBox::RemoveAll() { | 62 void CFWL_ComboBox::RemoveAll() { |
| 63 m_comboBoxData.m_ItemArray.clear(); | 63 m_comboBoxData.m_ItemArray.clear(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 int32_t CFWL_ComboBox::CountItems() { | 66 int32_t CFWL_ComboBox::CountItems() { |
| 67 return m_comboBoxData.CountItems(GetWidget()); | 67 return m_comboBoxData.CountItems(GetWidget()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 FWL_Error CFWL_ComboBox::GetTextByIndex(int32_t iIndex, | 70 FWL_Error CFWL_ComboBox::GetTextByIndex(int32_t iIndex, |
| 71 CFX_WideString& wsText) { | 71 CFX_WideString& wsText) { |
| 72 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>( | 72 CFWL_ComboBoxItem* pItem = |
| 73 m_comboBoxData.GetItem(m_pIface, iIndex)); | 73 static_cast<CFWL_ComboBoxItem*>(m_comboBoxData.GetItem(m_pIface, iIndex)); |
| 74 if (!pItem) | 74 if (!pItem) |
| 75 return FWL_Error::Indefinite; | 75 return FWL_Error::Indefinite; |
| 76 wsText = pItem->m_wsText; | 76 wsText = pItem->m_wsText; |
| 77 return FWL_Error::Succeeded; | 77 return FWL_Error::Succeeded; |
| 78 } | 78 } |
| 79 | 79 |
| 80 int32_t CFWL_ComboBox::GetCurSel() { | 80 int32_t CFWL_ComboBox::GetCurSel() { |
| 81 if (!m_pIface) | 81 if (!m_pIface) |
| 82 return -1; | 82 return -1; |
| 83 return static_cast<IFWL_ComboBox*>(m_pIface)->GetCurSel(); | 83 return static_cast<IFWL_ComboBox*>(m_pIface)->GetCurSel(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return FALSE; | 151 return FALSE; |
| 152 return static_cast<IFWL_ComboBox*>(m_pIface)->EditUndo(pRecord); | 152 return static_cast<IFWL_ComboBox*>(m_pIface)->EditUndo(pRecord); |
| 153 } | 153 } |
| 154 | 154 |
| 155 FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) { | 155 FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) { |
| 156 m_comboBoxData.m_fMaxListHeight = fMaxHeight; | 156 m_comboBoxData.m_fMaxListHeight = fMaxHeight; |
| 157 return FWL_Error::Succeeded; | 157 return FWL_Error::Succeeded; |
| 158 } | 158 } |
| 159 | 159 |
| 160 FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { | 160 FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { |
| 161 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>( | 161 CFWL_ComboBoxItem* pItem = |
| 162 m_comboBoxData.GetItem(m_pIface, iIndex)); | 162 static_cast<CFWL_ComboBoxItem*>(m_comboBoxData.GetItem(m_pIface, iIndex)); |
| 163 if (!pItem) | 163 if (!pItem) |
| 164 return FWL_Error::Indefinite; | 164 return FWL_Error::Indefinite; |
| 165 pItem->m_pData = pData; | 165 pItem->m_pData = pData; |
| 166 return FWL_Error::Succeeded; | 166 return FWL_Error::Succeeded; |
| 167 } | 167 } |
| 168 | 168 |
| 169 void* CFWL_ComboBox::GetItemData(int32_t iIndex) { | 169 void* CFWL_ComboBox::GetItemData(int32_t iIndex) { |
| 170 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>( | 170 CFWL_ComboBoxItem* pItem = |
| 171 m_comboBoxData.GetItem(m_pIface, iIndex)); | 171 static_cast<CFWL_ComboBoxItem*>(m_comboBoxData.GetItem(m_pIface, iIndex)); |
| 172 if (!pItem) | 172 if (!pItem) |
| 173 return NULL; | 173 return NULL; |
| 174 return pItem->m_pData; | 174 return pItem->m_pData; |
| 175 } | 175 } |
| 176 | 176 |
| 177 FWL_Error CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) { | 177 FWL_Error CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) { |
| 178 return static_cast<IFWL_ComboBox*>(m_pIface)->GetListBoxt()->SetThemeProvider( | 178 return static_cast<IFWL_ComboBox*>(m_pIface)->GetListBoxt()->SetThemeProvider( |
| 179 pTheme); | 179 pTheme); |
| 180 } | 180 } |
| 181 | 181 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 m_fItemHeight = 0; | 287 m_fItemHeight = 0; |
| 288 m_fMaxListHeight = 0; | 288 m_fMaxListHeight = 0; |
| 289 } | 289 } |
| 290 | 290 |
| 291 CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP() {} | 291 CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP() {} |
| 292 | 292 |
| 293 int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(IFWL_Widget* pWidget) { | 293 int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(IFWL_Widget* pWidget) { |
| 294 return m_ItemArray.size(); | 294 return m_ItemArray.size(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 FWL_HLISTITEM CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget* pWidget, | 297 IFWL_ListItem* CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget* pWidget, |
| 298 int32_t nIndex) { | 298 int32_t nIndex) { |
| 299 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) | 299 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) |
| 300 return nullptr; | 300 return nullptr; |
| 301 | 301 |
| 302 return reinterpret_cast<FWL_HLISTITEM>(m_ItemArray[nIndex].get()); | 302 return m_ItemArray[nIndex].get(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget, | 305 int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget, |
| 306 FWL_HLISTITEM hItem) { | 306 IFWL_ListItem* pItem) { |
| 307 auto it = std::find_if( | 307 auto it = std::find_if( |
| 308 m_ItemArray.begin(), m_ItemArray.end(), | 308 m_ItemArray.begin(), m_ItemArray.end(), |
| 309 [hItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) { | 309 [pItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) { |
| 310 return candidate.get() == reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 310 return candidate.get() == static_cast<CFWL_ComboBoxItem*>(pItem); |
| 311 }); | 311 }); |
| 312 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; | 312 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; |
| 313 } | 313 } |
| 314 | 314 |
| 315 FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget, | 315 FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget, |
| 316 FWL_HLISTITEM hItem, | 316 IFWL_ListItem* pItem, |
| 317 int32_t nIndex) { | 317 int32_t nIndex) { |
| 318 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) | 318 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) |
| 319 return FALSE; | 319 return FALSE; |
| 320 | 320 |
| 321 m_ItemArray[nIndex].reset(reinterpret_cast<CFWL_ComboBoxItem*>(hItem)); | 321 m_ItemArray[nIndex].reset(static_cast<CFWL_ComboBoxItem*>(pItem)); |
| 322 return TRUE; | 322 return TRUE; |
| 323 } | 323 } |
| 324 | 324 |
| 325 uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget, | 325 uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget, |
| 326 FWL_HLISTITEM hItem) { | 326 IFWL_ListItem* pItem) { |
| 327 if (!hItem) | 327 if (!pItem) |
| 328 return 0; | 328 return 0; |
| 329 return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles; | 329 return static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwStyles; |
| 330 } | 330 } |
| 331 | 331 |
| 332 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget, | 332 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget, |
| 333 FWL_HLISTITEM hItem, | 333 IFWL_ListItem* pItem, |
| 334 CFX_WideString& wsText) { | 334 CFX_WideString& wsText) { |
| 335 if (!hItem) | 335 if (!pItem) |
| 336 return FWL_Error::Indefinite; | 336 return FWL_Error::Indefinite; |
| 337 wsText = reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText; | 337 wsText = static_cast<CFWL_ComboBoxItem*>(pItem)->m_wsText; |
| 338 return FWL_Error::Succeeded; | 338 return FWL_Error::Succeeded; |
| 339 } | 339 } |
| 340 | 340 |
| 341 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget, | 341 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget, |
| 342 FWL_HLISTITEM hItem, | 342 IFWL_ListItem* pItem, |
| 343 CFX_RectF& rtItem) { | 343 CFX_RectF& rtItem) { |
| 344 if (!hItem) | 344 if (!pItem) |
| 345 return FWL_Error::Indefinite; | 345 return FWL_Error::Indefinite; |
| 346 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 346 CFWL_ComboBoxItem* pComboItem = static_cast<CFWL_ComboBoxItem*>(pItem); |
| 347 rtItem.Set(pItem->m_rtItem.left, pItem->m_rtItem.top, pItem->m_rtItem.width, | 347 rtItem.Set(pComboItem->m_rtItem.left, pComboItem->m_rtItem.top, |
| 348 pItem->m_rtItem.height); | 348 pComboItem->m_rtItem.width, pComboItem->m_rtItem.height); |
| 349 return FWL_Error::Succeeded; | 349 return FWL_Error::Succeeded; |
| 350 } | 350 } |
| 351 | 351 |
| 352 void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget, | 352 void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget, |
| 353 FWL_HLISTITEM hItem) { | 353 IFWL_ListItem* pItem) { |
| 354 if (!hItem) | 354 if (!pItem) |
| 355 return NULL; | 355 return NULL; |
| 356 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 356 return static_cast<CFWL_ComboBoxItem*>(pItem)->m_pData; |
| 357 return pItem->m_pData; | |
| 358 } | 357 } |
| 359 | 358 |
| 360 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget, | 359 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget, |
| 361 FWL_HLISTITEM hItem, | 360 IFWL_ListItem* pItem, |
| 362 uint32_t dwStyle) { | 361 uint32_t dwStyle) { |
| 363 if (!hItem) | 362 if (!pItem) |
| 364 return FWL_Error::Indefinite; | 363 return FWL_Error::Indefinite; |
| 365 reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles = dwStyle; | 364 static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwStyles = dwStyle; |
| 366 return FWL_Error::Succeeded; | 365 return FWL_Error::Succeeded; |
| 367 } | 366 } |
| 368 | 367 |
| 369 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget, | 368 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget, |
| 370 FWL_HLISTITEM hItem, | 369 IFWL_ListItem* pItem, |
| 371 const FX_WCHAR* pszText) { | 370 const FX_WCHAR* pszText) { |
| 372 if (!hItem) | 371 if (!pItem) |
| 373 return FWL_Error::Indefinite; | 372 return FWL_Error::Indefinite; |
| 374 reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText = pszText; | 373 static_cast<CFWL_ComboBoxItem*>(pItem)->m_wsText = pszText; |
| 375 return FWL_Error::Succeeded; | 374 return FWL_Error::Succeeded; |
| 376 } | 375 } |
| 377 | 376 |
| 378 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget, | 377 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget, |
| 379 FWL_HLISTITEM hItem, | 378 IFWL_ListItem* pItem, |
| 380 const CFX_RectF& rtItem) { | 379 const CFX_RectF& rtItem) { |
| 381 if (!hItem) | 380 if (!pItem) |
| 382 return FWL_Error::Indefinite; | 381 return FWL_Error::Indefinite; |
| 383 reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_rtItem = rtItem; | 382 static_cast<CFWL_ComboBoxItem*>(pItem)->m_rtItem = rtItem; |
| 384 return FWL_Error::Succeeded; | 383 return FWL_Error::Succeeded; |
| 385 } | 384 } |
| 386 | 385 |
| 387 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) { | 386 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) { |
| 388 return m_fItemHeight; | 387 return m_fItemHeight; |
| 389 } | 388 } |
| 390 | 389 |
| 391 CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(IFWL_Widget* pWidget, | 390 CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon( |
| 392 FWL_HLISTITEM hItem) { | 391 IFWL_Widget* pWidget, |
| 393 if (!hItem) | 392 IFWL_ListItem* pItem) { |
| 393 if (!pItem) |
| 394 return NULL; | 394 return NULL; |
| 395 return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_pDIB; | 395 return static_cast<CFWL_ComboBoxItem*>(pItem)->m_pDIB; |
| 396 } | 396 } |
| 397 | 397 |
| 398 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, | 398 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, |
| 399 FWL_HLISTITEM hItem, | 399 IFWL_ListItem* pItem, |
| 400 CFX_RectF& rtCheck) { | 400 CFX_RectF& rtCheck) { |
| 401 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 401 rtCheck = static_cast<CFWL_ComboBoxItem*>(pItem)->m_rtCheckBox; |
| 402 rtCheck = pItem->m_rtCheckBox; | |
| 403 return FWL_Error::Succeeded; | 402 return FWL_Error::Succeeded; |
| 404 } | 403 } |
| 405 | 404 |
| 406 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect( | 405 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect( |
| 407 IFWL_Widget* pWidget, | 406 IFWL_Widget* pWidget, |
| 408 FWL_HLISTITEM hItem, | 407 IFWL_ListItem* pItem, |
| 409 const CFX_RectF& rtCheck) { | 408 const CFX_RectF& rtCheck) { |
| 410 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 409 static_cast<CFWL_ComboBoxItem*>(pItem)->m_rtCheckBox = rtCheck; |
| 411 pItem->m_rtCheckBox = rtCheck; | |
| 412 return FWL_Error::Succeeded; | 410 return FWL_Error::Succeeded; |
| 413 } | 411 } |
| 414 | 412 |
| 415 uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState( | 413 uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState( |
| 416 IFWL_Widget* pWidget, | 414 IFWL_Widget* pWidget, |
| 417 FWL_HLISTITEM hItem) { | 415 IFWL_ListItem* pItem) { |
| 418 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 416 return static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwCheckState; |
| 419 return pItem->m_dwCheckState; | |
| 420 } | 417 } |
| 421 | 418 |
| 422 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState( | 419 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState( |
| 423 IFWL_Widget* pWidget, | 420 IFWL_Widget* pWidget, |
| 424 FWL_HLISTITEM hItem, | 421 IFWL_ListItem* pItem, |
| 425 uint32_t dwCheckState) { | 422 uint32_t dwCheckState) { |
| 426 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 423 static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwCheckState = dwCheckState; |
| 427 pItem->m_dwCheckState = dwCheckState; | |
| 428 return FWL_Error::Succeeded; | 424 return FWL_Error::Succeeded; |
| 429 } | 425 } |
| 430 | 426 |
| 431 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { | 427 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { |
| 432 return m_fMaxListHeight; | 428 return m_fMaxListHeight; |
| 433 } | 429 } |
| OLD | NEW |