| 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* hItem) { |
| 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 [hItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) { |
| 310 return candidate.get() == reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 310 return candidate.get() == static_cast<CFWL_ComboBoxItem*>(hItem); |
| 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* hItem, |
| 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*>(hItem)); |
| 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* hItem) { |
| 327 if (!hItem) | 327 if (!hItem) |
| 328 return 0; | 328 return 0; |
| 329 return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles; | 329 return static_cast<CFWL_ComboBoxItem*>(hItem)->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* hItem, |
| 334 CFX_WideString& wsText) { | 334 CFX_WideString& wsText) { |
| 335 if (!hItem) | 335 if (!hItem) |
| 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*>(hItem)->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* hItem, |
| 343 CFX_RectF& rtItem) { | 343 CFX_RectF& rtItem) { |
| 344 if (!hItem) | 344 if (!hItem) |
| 345 return FWL_Error::Indefinite; | 345 return FWL_Error::Indefinite; |
| 346 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 346 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>(hItem); |
| 347 rtItem.Set(pItem->m_rtItem.left, pItem->m_rtItem.top, pItem->m_rtItem.width, | 347 rtItem.Set(pItem->m_rtItem.left, pItem->m_rtItem.top, pItem->m_rtItem.width, |
| 348 pItem->m_rtItem.height); | 348 pItem->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* hItem) { |
| 354 if (!hItem) | 354 if (!hItem) |
| 355 return NULL; | 355 return NULL; |
| 356 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 356 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>(hItem); |
| 357 return pItem->m_pData; | 357 return pItem->m_pData; |
| 358 } | 358 } |
| 359 | 359 |
| 360 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget, | 360 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget, |
| 361 FWL_HLISTITEM hItem, | 361 IFWL_ListItem* hItem, |
| 362 uint32_t dwStyle) { | 362 uint32_t dwStyle) { |
| 363 if (!hItem) | 363 if (!hItem) |
| 364 return FWL_Error::Indefinite; | 364 return FWL_Error::Indefinite; |
| 365 reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles = dwStyle; | 365 static_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles = dwStyle; |
| 366 return FWL_Error::Succeeded; | 366 return FWL_Error::Succeeded; |
| 367 } | 367 } |
| 368 | 368 |
| 369 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget, | 369 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget, |
| 370 FWL_HLISTITEM hItem, | 370 IFWL_ListItem* hItem, |
| 371 const FX_WCHAR* pszText) { | 371 const FX_WCHAR* pszText) { |
| 372 if (!hItem) | 372 if (!hItem) |
| 373 return FWL_Error::Indefinite; | 373 return FWL_Error::Indefinite; |
| 374 reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText = pszText; | 374 static_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText = pszText; |
| 375 return FWL_Error::Succeeded; | 375 return FWL_Error::Succeeded; |
| 376 } | 376 } |
| 377 | 377 |
| 378 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget, | 378 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget, |
| 379 FWL_HLISTITEM hItem, | 379 IFWL_ListItem* hItem, |
| 380 const CFX_RectF& rtItem) { | 380 const CFX_RectF& rtItem) { |
| 381 if (!hItem) | 381 if (!hItem) |
| 382 return FWL_Error::Indefinite; | 382 return FWL_Error::Indefinite; |
| 383 reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_rtItem = rtItem; | 383 static_cast<CFWL_ComboBoxItem*>(hItem)->m_rtItem = rtItem; |
| 384 return FWL_Error::Succeeded; | 384 return FWL_Error::Succeeded; |
| 385 } | 385 } |
| 386 | 386 |
| 387 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) { | 387 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) { |
| 388 return m_fItemHeight; | 388 return m_fItemHeight; |
| 389 } | 389 } |
| 390 | 390 |
| 391 CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(IFWL_Widget* pWidget, | 391 CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon( |
| 392 FWL_HLISTITEM hItem) { | 392 IFWL_Widget* pWidget, |
| 393 IFWL_ListItem* hItem) { |
| 393 if (!hItem) | 394 if (!hItem) |
| 394 return NULL; | 395 return NULL; |
| 395 return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_pDIB; | 396 return static_cast<CFWL_ComboBoxItem*>(hItem)->m_pDIB; |
| 396 } | 397 } |
| 397 | 398 |
| 398 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, | 399 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, |
| 399 FWL_HLISTITEM hItem, | 400 IFWL_ListItem* hItem, |
| 400 CFX_RectF& rtCheck) { | 401 CFX_RectF& rtCheck) { |
| 401 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 402 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>(hItem); |
| 402 rtCheck = pItem->m_rtCheckBox; | 403 rtCheck = pItem->m_rtCheckBox; |
| 403 return FWL_Error::Succeeded; | 404 return FWL_Error::Succeeded; |
| 404 } | 405 } |
| 405 | 406 |
| 406 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect( | 407 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect( |
| 407 IFWL_Widget* pWidget, | 408 IFWL_Widget* pWidget, |
| 408 FWL_HLISTITEM hItem, | 409 IFWL_ListItem* hItem, |
| 409 const CFX_RectF& rtCheck) { | 410 const CFX_RectF& rtCheck) { |
| 410 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 411 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>(hItem); |
| 411 pItem->m_rtCheckBox = rtCheck; | 412 pItem->m_rtCheckBox = rtCheck; |
| 412 return FWL_Error::Succeeded; | 413 return FWL_Error::Succeeded; |
| 413 } | 414 } |
| 414 | 415 |
| 415 uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState( | 416 uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState( |
| 416 IFWL_Widget* pWidget, | 417 IFWL_Widget* pWidget, |
| 417 FWL_HLISTITEM hItem) { | 418 IFWL_ListItem* hItem) { |
| 418 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 419 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>(hItem); |
| 419 return pItem->m_dwCheckState; | 420 return pItem->m_dwCheckState; |
| 420 } | 421 } |
| 421 | 422 |
| 422 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState( | 423 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState( |
| 423 IFWL_Widget* pWidget, | 424 IFWL_Widget* pWidget, |
| 424 FWL_HLISTITEM hItem, | 425 IFWL_ListItem* hItem, |
| 425 uint32_t dwCheckState) { | 426 uint32_t dwCheckState) { |
| 426 CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem); | 427 CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>(hItem); |
| 427 pItem->m_dwCheckState = dwCheckState; | 428 pItem->m_dwCheckState = dwCheckState; |
| 428 return FWL_Error::Succeeded; | 429 return FWL_Error::Succeeded; |
| 429 } | 430 } |
| 430 | 431 |
| 431 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { | 432 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { |
| 432 return m_fMaxListHeight; | 433 return m_fMaxListHeight; |
| 433 } | 434 } |
| OLD | NEW |