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/cfwl_combobox.h" | 7 #include "xfa/fwl/cfwl_combobox.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); | 335 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); |
336 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); | 336 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); |
337 m_rtList = m_pListBox->GetAutosizedWidgetRect(); | 337 m_rtList = m_pListBox->GetAutosizedWidgetRect(); |
338 | 338 |
339 CFX_RectF rtAnchor; | 339 CFX_RectF rtAnchor; |
340 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, | 340 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, |
341 m_pProperties->m_rtWidget.height); | 341 m_pProperties->m_rtWidget.height); |
342 | 342 |
343 m_rtList.width = std::max(m_rtList.width, m_rtClient.width); | 343 m_rtList.width = std::max(m_rtList.width, m_rtClient.width); |
344 m_rtProxy = m_rtList; | 344 m_rtProxy = m_rtList; |
345 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) | |
346 m_rtProxy.height += m_fComboFormHandler; | |
347 | 345 |
348 GetPopupPos(0, m_rtProxy.height, rtAnchor, m_rtProxy); | 346 GetPopupPos(0, m_rtProxy.height, rtAnchor, m_rtProxy); |
349 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) { | |
350 FX_FLOAT fx = 0; | |
351 FX_FLOAT fy = m_rtClient.top + m_rtClient.height / 2; | |
352 TransformTo(nullptr, fx, fy); | |
353 | 347 |
354 m_bUpFormHandler = fy > m_rtProxy.top; | |
355 if (m_bUpFormHandler) { | |
356 m_rtHandler.Set(0, 0, m_rtList.width, m_fComboFormHandler); | |
357 m_rtList.top = m_fComboFormHandler; | |
358 } else { | |
359 m_rtHandler.Set(0, m_rtList.height, m_rtList.width, m_fComboFormHandler); | |
360 } | |
361 } | |
362 m_pComboBoxProxy->SetWidgetRect(m_rtProxy); | 348 m_pComboBoxProxy->SetWidgetRect(m_rtProxy); |
363 m_pComboBoxProxy->Update(); | 349 m_pComboBoxProxy->Update(); |
364 m_pListBox->SetWidgetRect(m_rtList); | 350 m_pListBox->SetWidgetRect(m_rtList); |
365 m_pListBox->Update(); | 351 m_pListBox->Update(); |
366 | 352 |
367 CFWL_Event ev(CFWL_Event::Type::PreDropDown, this); | 353 CFWL_Event ev(CFWL_Event::Type::PreDropDown, this); |
368 DispatchEvent(&ev); | 354 DispatchEvent(&ev); |
369 | 355 |
370 m_fItemHeight = m_pListBox->GetItemHeight(); | 356 m_fItemHeight = m_pListBox->GetItemHeight(); |
371 m_pListBox->SetFocus(true); | 357 m_pListBox->SetFocus(true); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 void CFWL_ComboBox::ResetEditAlignment() { | 426 void CFWL_ComboBox::ResetEditAlignment() { |
441 if (!m_pEdit) | 427 if (!m_pEdit) |
442 return; | 428 return; |
443 | 429 |
444 uint32_t dwAdd = 0; | 430 uint32_t dwAdd = 0; |
445 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditHAlignMask) { | 431 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditHAlignMask) { |
446 case FWL_STYLEEXT_CMB_EditHCenter: { | 432 case FWL_STYLEEXT_CMB_EditHCenter: { |
447 dwAdd |= FWL_STYLEEXT_EDT_HCenter; | 433 dwAdd |= FWL_STYLEEXT_EDT_HCenter; |
448 break; | 434 break; |
449 } | 435 } |
450 case FWL_STYLEEXT_CMB_EditHFar: { | 436 default: { |
451 dwAdd |= FWL_STYLEEXT_EDT_HFar; | 437 dwAdd |= FWL_STYLEEXT_EDT_HNear; |
452 break; | 438 break; |
453 } | 439 } |
454 default: { dwAdd |= FWL_STYLEEXT_EDT_HNear; } | |
455 } | 440 } |
456 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditVAlignMask) { | 441 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditVAlignMask) { |
457 case FWL_STYLEEXT_CMB_EditVCenter: { | 442 case FWL_STYLEEXT_CMB_EditVCenter: { |
458 dwAdd |= FWL_STYLEEXT_EDT_VCenter; | 443 dwAdd |= FWL_STYLEEXT_EDT_VCenter; |
459 break; | 444 break; |
460 } | 445 } |
461 case FWL_STYLEEXT_CMB_EditVFar: { | 446 case FWL_STYLEEXT_CMB_EditVFar: { |
462 dwAdd |= FWL_STYLEEXT_EDT_VFar; | 447 dwAdd |= FWL_STYLEEXT_EDT_VFar; |
463 break; | 448 break; |
464 } | 449 } |
465 default: { | 450 default: { |
466 dwAdd |= FWL_STYLEEXT_EDT_VNear; | 451 dwAdd |= FWL_STYLEEXT_EDT_VNear; |
467 break; | 452 break; |
468 } | 453 } |
469 } | 454 } |
470 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditJustified) | 455 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditJustified) |
471 dwAdd |= FWL_STYLEEXT_EDT_Justified; | 456 dwAdd |= FWL_STYLEEXT_EDT_Justified; |
472 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_EditDistributed) | |
473 dwAdd |= FWL_STYLEEXT_EDT_Distributed; | |
474 | 457 |
475 m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | | 458 m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | |
476 FWL_STYLEEXT_EDT_HAlignModeMask | | 459 FWL_STYLEEXT_EDT_HAlignModeMask | |
477 FWL_STYLEEXT_EDT_VAlignMask); | 460 FWL_STYLEEXT_EDT_VAlignMask); |
478 } | 461 } |
479 | 462 |
480 void CFWL_ComboBox::ResetListItemAlignment() { | 463 void CFWL_ComboBox::ResetListItemAlignment() { |
481 if (!m_pListBox) | 464 if (!m_pListBox) |
482 return; | 465 return; |
483 | 466 |
484 uint32_t dwAdd = 0; | 467 uint32_t dwAdd = 0; |
485 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemAlignMask) { | 468 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemAlignMask) { |
486 case FWL_STYLEEXT_CMB_ListItemCenterAlign: { | 469 case FWL_STYLEEXT_CMB_ListItemCenterAlign: { |
487 dwAdd |= FWL_STYLEEXT_LTB_CenterAlign; | 470 dwAdd |= FWL_STYLEEXT_LTB_CenterAlign; |
488 break; | 471 break; |
489 } | 472 } |
490 case FWL_STYLEEXT_CMB_ListItemRightAlign: { | |
491 dwAdd |= FWL_STYLEEXT_LTB_RightAlign; | |
492 break; | |
493 } | |
494 default: { | 473 default: { |
495 dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; | 474 dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; |
496 break; | 475 break; |
497 } | 476 } |
498 } | 477 } |
499 m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask); | 478 m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask); |
500 } | 479 } |
501 | 480 |
502 void CFWL_ComboBox::ProcessSelChanged(bool bLButtonUp) { | 481 void CFWL_ComboBox::ProcessSelChanged(bool bLButtonUp) { |
503 m_iCurSel = m_pListBox->GetItemIndex(this, m_pListBox->GetSelItem(0)); | 482 m_iCurSel = m_pListBox->GetItemIndex(this, m_pListBox->GetSelItem(0)); |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 else | 1036 else |
1058 iCurSel++; | 1037 iCurSel++; |
1059 } | 1038 } |
1060 m_iCurSel = iCurSel; | 1039 m_iCurSel = iCurSel; |
1061 SyncEditText(m_iCurSel); | 1040 SyncEditText(m_iCurSel); |
1062 return; | 1041 return; |
1063 } | 1042 } |
1064 if (m_pEdit) | 1043 if (m_pEdit) |
1065 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 1044 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
1066 } | 1045 } |
OLD | NEW |