| 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 "fpdfsdk/fxedit/include/fxet_list.h" | 7 #include "fpdfsdk/fxedit/include/fxet_list.h" |
| 8 | 8 |
| 9 #include "core/fpdfdoc/include/cpvt_word.h" | 9 #include "core/fpdfdoc/include/cpvt_word.h" |
| 10 #include "fpdfsdk/fxedit/include/fxet_edit.h" | 10 #include "fpdfsdk/fxedit/include/fxet_edit.h" |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 510 } |
| 511 | 511 |
| 512 void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) { | 512 void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) { |
| 513 if (!IsValid(nItemIndex)) | 513 if (!IsValid(nItemIndex)) |
| 514 return; | 514 return; |
| 515 | 515 |
| 516 CFX_FloatRect rcPlate = GetPlateRect(); | 516 CFX_FloatRect rcPlate = GetPlateRect(); |
| 517 CFX_FloatRect rcItem = GetItemRectInternal(nItemIndex); | 517 CFX_FloatRect rcItem = GetItemRectInternal(nItemIndex); |
| 518 CFX_FloatRect rcItemCtrl = GetItemRect(nItemIndex); | 518 CFX_FloatRect rcItemCtrl = GetItemRect(nItemIndex); |
| 519 | 519 |
| 520 if (FX_EDIT_IsFloatSmaller(rcItemCtrl.bottom, rcPlate.bottom)) { | 520 if (IsFloatSmaller(rcItemCtrl.bottom, rcPlate.bottom)) { |
| 521 if (FX_EDIT_IsFloatSmaller(rcItemCtrl.top, rcPlate.top)) { | 521 if (IsFloatSmaller(rcItemCtrl.top, rcPlate.top)) { |
| 522 SetScrollPosY(rcItem.bottom + rcPlate.Height()); | 522 SetScrollPosY(rcItem.bottom + rcPlate.Height()); |
| 523 } | 523 } |
| 524 } else if (FX_EDIT_IsFloatBigger(rcItemCtrl.top, rcPlate.top)) { | 524 } else if (IsFloatBigger(rcItemCtrl.top, rcPlate.top)) { |
| 525 if (FX_EDIT_IsFloatBigger(rcItemCtrl.bottom, rcPlate.bottom)) { | 525 if (IsFloatBigger(rcItemCtrl.bottom, rcPlate.bottom)) { |
| 526 SetScrollPosY(rcItem.top); | 526 SetScrollPosY(rcItem.top); |
| 527 } | 527 } |
| 528 } | 528 } |
| 529 } | 529 } |
| 530 | 530 |
| 531 void CFX_ListCtrl::SetScrollInfo() { | 531 void CFX_ListCtrl::SetScrollInfo() { |
| 532 if (m_pNotify) { | 532 if (m_pNotify) { |
| 533 CFX_FloatRect rcPlate = GetPlateRect(); | 533 CFX_FloatRect rcPlate = GetPlateRect(); |
| 534 CFX_FloatRect rcContent = GetContentRectInternal(); | 534 CFX_FloatRect rcContent = GetContentRectInternal(); |
| 535 | 535 |
| 536 if (!m_bNotifyFlag) { | 536 if (!m_bNotifyFlag) { |
| 537 m_bNotifyFlag = TRUE; | 537 m_bNotifyFlag = TRUE; |
| 538 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, | 538 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, |
| 539 rcContent.bottom, rcContent.top, | 539 rcContent.bottom, rcContent.top, |
| 540 GetFirstHeight(), rcPlate.Height()); | 540 GetFirstHeight(), rcPlate.Height()); |
| 541 m_bNotifyFlag = FALSE; | 541 m_bNotifyFlag = FALSE; |
| 542 } | 542 } |
| 543 } | 543 } |
| 544 } | 544 } |
| 545 | 545 |
| 546 void CFX_ListCtrl::SetScrollPos(const CFX_FloatPoint& point) { | 546 void CFX_ListCtrl::SetScrollPos(const CFX_FloatPoint& point) { |
| 547 SetScrollPosY(point.y); | 547 SetScrollPosY(point.y); |
| 548 } | 548 } |
| 549 | 549 |
| 550 void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) { | 550 void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) { |
| 551 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { | 551 if (!IsFloatEqual(m_ptScrollPos.y, fy)) { |
| 552 CFX_FloatRect rcPlate = GetPlateRect(); | 552 CFX_FloatRect rcPlate = GetPlateRect(); |
| 553 CFX_FloatRect rcContent = GetContentRectInternal(); | 553 CFX_FloatRect rcContent = GetContentRectInternal(); |
| 554 | 554 |
| 555 if (rcPlate.Height() > rcContent.Height()) { | 555 if (rcPlate.Height() > rcContent.Height()) { |
| 556 fy = rcPlate.top; | 556 fy = rcPlate.top; |
| 557 } else { | 557 } else { |
| 558 if (FX_EDIT_IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) { | 558 if (IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) { |
| 559 fy = rcContent.bottom + rcPlate.Height(); | 559 fy = rcContent.bottom + rcPlate.Height(); |
| 560 } else if (FX_EDIT_IsFloatBigger(fy, rcContent.top)) { | 560 } else if (IsFloatBigger(fy, rcContent.top)) { |
| 561 fy = rcContent.top; | 561 fy = rcContent.top; |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 | 564 |
| 565 m_ptScrollPos.y = fy; | 565 m_ptScrollPos.y = fy; |
| 566 InvalidateItem(-1); | 566 InvalidateItem(-1); |
| 567 | 567 |
| 568 if (m_pNotify) { | 568 if (m_pNotify) { |
| 569 if (!m_bNotifyFlag) { | 569 if (!m_bNotifyFlag) { |
| 570 m_bNotifyFlag = TRUE; | 570 m_bNotifyFlag = TRUE; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 int32_t CFX_ListCtrl::GetItemIndex(const CFX_FloatPoint& point) const { | 634 int32_t CFX_ListCtrl::GetItemIndex(const CFX_FloatPoint& point) const { |
| 635 CFX_FloatPoint pt = OuterToInner(OutToIn(point)); | 635 CFX_FloatPoint pt = OuterToInner(OutToIn(point)); |
| 636 | 636 |
| 637 FX_BOOL bFirst = TRUE; | 637 FX_BOOL bFirst = TRUE; |
| 638 FX_BOOL bLast = TRUE; | 638 FX_BOOL bLast = TRUE; |
| 639 | 639 |
| 640 for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++) { | 640 for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++) { |
| 641 if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) { | 641 if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) { |
| 642 CLST_Rect rcListItem = pListItem->GetRect(); | 642 CLST_Rect rcListItem = pListItem->GetRect(); |
| 643 | 643 |
| 644 if (FX_EDIT_IsFloatBigger(pt.y, rcListItem.top)) { | 644 if (IsFloatBigger(pt.y, rcListItem.top)) { |
| 645 bFirst = FALSE; | 645 bFirst = FALSE; |
| 646 } | 646 } |
| 647 | 647 |
| 648 if (FX_EDIT_IsFloatSmaller(pt.y, rcListItem.bottom)) { | 648 if (IsFloatSmaller(pt.y, rcListItem.bottom)) { |
| 649 bLast = FALSE; | 649 bLast = FALSE; |
| 650 } | 650 } |
| 651 | 651 |
| 652 if (pt.y >= rcListItem.top && pt.y < rcListItem.bottom) { | 652 if (pt.y >= rcListItem.top && pt.y < rcListItem.bottom) { |
| 653 return i; | 653 return i; |
| 654 } | 654 } |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 | 657 |
| 658 if (bFirst) | 658 if (bFirst) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize(); | 780 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize(); |
| 781 } | 781 } |
| 782 | 782 |
| 783 CFX_WideString CFX_ListCtrl::GetItemText(int32_t nIndex) const { | 783 CFX_WideString CFX_ListCtrl::GetItemText(int32_t nIndex) const { |
| 784 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) { | 784 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) { |
| 785 return pListItem->GetText(); | 785 return pListItem->GetText(); |
| 786 } | 786 } |
| 787 | 787 |
| 788 return L""; | 788 return L""; |
| 789 } | 789 } |
| OLD | NEW |