| 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/ifwl_combobox.h" | 7 #include "xfa/fwl/core/ifwl_combobox.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 rtList.Offset(rect.left, rect.top); | 330 rtList.Offset(rect.left, rect.top); |
| 331 rect.Union(rtList); | 331 rect.Union(rtList); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, | 334 void IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, |
| 335 uint32_t dwStylesExRemoved) { | 335 uint32_t dwStylesExRemoved) { |
| 336 if (m_pEdit) | 336 if (m_pEdit) |
| 337 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 337 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 338 } | 338 } |
| 339 | 339 |
| 340 FX_FLOAT IFWL_ComboBox::GetDataProviderListHeight() { | |
| 341 return static_cast<IFWL_ComboBox::DataProvider*>( | |
| 342 m_pProperties->m_pDataProvider) | |
| 343 ->GetListHeight(this); | |
| 344 } | |
| 345 | |
| 346 void IFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics, | 340 void IFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics, |
| 347 const CFX_Matrix* pMatrix) { | 341 const CFX_Matrix* pMatrix) { |
| 348 CFWL_ThemeBackground param; | 342 CFWL_ThemeBackground param; |
| 349 param.m_pGraphics = pGraphics; | 343 param.m_pGraphics = pGraphics; |
| 350 param.m_iPart = CFWL_Part::StretchHandler; | 344 param.m_iPart = CFWL_Part::StretchHandler; |
| 351 param.m_dwStates = CFWL_PartState_Normal; | 345 param.m_dwStates = CFWL_PartState_Normal; |
| 352 param.m_pWidget = this; | 346 param.m_pWidget = this; |
| 353 if (pMatrix) | 347 if (pMatrix) |
| 354 param.m_matrix.Concat(*pMatrix); | 348 param.m_matrix.Concat(*pMatrix); |
| 355 param.m_rtPart = m_rtHandler; | 349 param.m_rtPart = m_rtHandler; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 374 return; | 368 return; |
| 375 } | 369 } |
| 376 | 370 |
| 377 m_pListBox->ChangeSelected(m_iCurSel); | 371 m_pListBox->ChangeSelected(m_iCurSel); |
| 378 ResetListItemAlignment(); | 372 ResetListItemAlignment(); |
| 379 | 373 |
| 380 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & | 374 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & |
| 381 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); | 375 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); |
| 382 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); | 376 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); |
| 383 m_pListBox->GetWidgetRect(m_rtList, true); | 377 m_pListBox->GetWidgetRect(m_rtList, true); |
| 384 FX_FLOAT fHeight = GetDataProviderListHeight(); | |
| 385 if (fHeight > 0 && m_rtList.height > fHeight) { | |
| 386 m_rtList.height = fHeight; | |
| 387 m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0); | |
| 388 } | |
| 389 | 378 |
| 390 CFX_RectF rtAnchor; | 379 CFX_RectF rtAnchor; |
| 391 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, | 380 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, |
| 392 m_pProperties->m_rtWidget.height); | 381 m_pProperties->m_rtWidget.height); |
| 393 | 382 |
| 394 m_rtList.width = std::max(m_rtList.width, m_rtClient.width); | 383 m_rtList.width = std::max(m_rtList.width, m_rtClient.width); |
| 395 m_rtProxy = m_rtList; | 384 m_rtProxy = m_rtList; |
| 396 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) | 385 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) |
| 397 m_rtProxy.height += m_fComboFormHandler; | 386 m_rtProxy.height += m_fComboFormHandler; |
| 398 | 387 |
| 399 FX_FLOAT fMinHeight = 0; | 388 GetPopupPos(0, m_rtProxy.height, rtAnchor, m_rtProxy); |
| 400 GetPopupPos(fMinHeight, m_rtProxy.height, rtAnchor, m_rtProxy); | |
| 401 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) { | 389 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) { |
| 402 FX_FLOAT fx = 0; | 390 FX_FLOAT fx = 0; |
| 403 FX_FLOAT fy = m_rtClient.top + m_rtClient.height / 2; | 391 FX_FLOAT fy = m_rtClient.top + m_rtClient.height / 2; |
| 404 TransformTo(nullptr, fx, fy); | 392 TransformTo(nullptr, fx, fy); |
| 405 | 393 |
| 406 m_bUpFormHandler = fy > m_rtProxy.top; | 394 m_bUpFormHandler = fy > m_rtProxy.top; |
| 407 if (m_bUpFormHandler) { | 395 if (m_bUpFormHandler) { |
| 408 m_rtHandler.Set(0, 0, m_rtList.width, m_fComboFormHandler); | 396 m_rtHandler.Set(0, 0, m_rtList.width, m_fComboFormHandler); |
| 409 m_rtList.top = m_fComboFormHandler; | 397 m_rtList.top = m_fComboFormHandler; |
| 410 } else { | 398 } else { |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 else | 1123 else |
| 1136 iCurSel++; | 1124 iCurSel++; |
| 1137 } | 1125 } |
| 1138 m_iCurSel = iCurSel; | 1126 m_iCurSel = iCurSel; |
| 1139 SyncEditText(m_iCurSel); | 1127 SyncEditText(m_iCurSel); |
| 1140 return; | 1128 return; |
| 1141 } | 1129 } |
| 1142 if (m_pEdit) | 1130 if (m_pEdit) |
| 1143 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 1131 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
| 1144 } | 1132 } |
| OLD | NEW |