| 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" |
| 11 | 11 |
| 12 CFX_ListItem::CFX_ListItem() | 12 CFX_ListItem::CFX_ListItem() |
| 13 : m_pEdit(NULL), | 13 : m_pEdit(NULL), |
| 14 m_bSelected(FALSE), | 14 m_bSelected(FALSE), |
| 15 m_bCaret(FALSE), | |
| 16 m_rcListItem(0.0f, 0.0f, 0.0f, 0.0f) { | 15 m_rcListItem(0.0f, 0.0f, 0.0f, 0.0f) { |
| 17 m_pEdit = IFX_Edit::NewEdit(); | 16 m_pEdit = IFX_Edit::NewEdit(); |
| 18 m_pEdit->SetAlignmentV(1); | 17 m_pEdit->SetAlignmentV(1); |
| 19 m_pEdit->Initialize(); | 18 m_pEdit->Initialize(); |
| 20 } | 19 } |
| 21 | 20 |
| 22 CFX_ListItem::~CFX_ListItem() { | 21 CFX_ListItem::~CFX_ListItem() { |
| 23 IFX_Edit::DelEdit(m_pEdit); | 22 IFX_Edit::DelEdit(m_pEdit); |
| 24 } | 23 } |
| 25 | 24 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 48 } | 47 } |
| 49 | 48 |
| 50 FX_BOOL CFX_ListItem::IsSelected() const { | 49 FX_BOOL CFX_ListItem::IsSelected() const { |
| 51 return m_bSelected; | 50 return m_bSelected; |
| 52 } | 51 } |
| 53 | 52 |
| 54 void CFX_ListItem::SetSelect(FX_BOOL bSelected) { | 53 void CFX_ListItem::SetSelect(FX_BOOL bSelected) { |
| 55 m_bSelected = bSelected; | 54 m_bSelected = bSelected; |
| 56 } | 55 } |
| 57 | 56 |
| 58 FX_BOOL CFX_ListItem::IsCaret() const { | |
| 59 return m_bCaret; | |
| 60 } | |
| 61 | |
| 62 void CFX_ListItem::SetCaret(FX_BOOL bCaret) { | |
| 63 m_bCaret = bCaret; | |
| 64 } | |
| 65 | |
| 66 void CFX_ListItem::SetText(const FX_WCHAR* text) { | 57 void CFX_ListItem::SetText(const FX_WCHAR* text) { |
| 67 if (m_pEdit) | 58 if (m_pEdit) |
| 68 m_pEdit->SetText(text); | 59 m_pEdit->SetText(text); |
| 69 } | 60 } |
| 70 | 61 |
| 71 void CFX_ListItem::SetFontSize(FX_FLOAT fFontSize) { | 62 void CFX_ListItem::SetFontSize(FX_FLOAT fFontSize) { |
| 72 if (m_pEdit) | 63 if (m_pEdit) |
| 73 m_pEdit->SetFontSize(fFontSize); | 64 m_pEdit->SetFontSize(fFontSize); |
| 74 } | 65 } |
| 75 | 66 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 241 } |
| 251 | 242 |
| 252 return nCircleIndex; | 243 return nCircleIndex; |
| 253 } | 244 } |
| 254 | 245 |
| 255 CFX_FloatRect CFX_List::GetItemRect(int32_t nIndex) const { | 246 CFX_FloatRect CFX_List::GetItemRect(int32_t nIndex) const { |
| 256 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) { | 247 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) { |
| 257 CFX_FloatRect rcItem = pListItem->GetRect(); | 248 CFX_FloatRect rcItem = pListItem->GetRect(); |
| 258 rcItem.left = 0.0f; | 249 rcItem.left = 0.0f; |
| 259 rcItem.right = GetPlateRect().Width(); | 250 rcItem.right = GetPlateRect().Width(); |
| 260 return InnerToOuter(rcItem); | 251 return InnerToOuter(CLST_Rect(rcItem)); |
| 261 } | 252 } |
| 262 | 253 |
| 263 return CFX_FloatRect(); | 254 return CFX_FloatRect(); |
| 264 } | 255 } |
| 265 | 256 |
| 266 FX_BOOL CFX_List::IsItemSelected(int32_t nIndex) const { | 257 FX_BOOL CFX_List::IsItemSelected(int32_t nIndex) const { |
| 267 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) { | 258 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) |
| 268 return pListItem->IsSelected(); | 259 return pListItem->IsSelected(); |
| 269 } | |
| 270 | |
| 271 return FALSE; | 260 return FALSE; |
| 272 } | 261 } |
| 273 | 262 |
| 274 void CFX_List::SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected) { | 263 void CFX_List::SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected) { |
| 275 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nItemIndex)) { | 264 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nItemIndex)) { |
| 276 pListItem->SetSelect(bSelected); | 265 pListItem->SetSelect(bSelected); |
| 277 } | 266 } |
| 278 } | 267 } |
| 279 | 268 |
| 280 void CFX_List::SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret) { | |
| 281 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nItemIndex)) { | |
| 282 pListItem->SetCaret(bCaret); | |
| 283 } | |
| 284 } | |
| 285 | |
| 286 void CFX_List::SetMultipleSel(FX_BOOL bMultiple) { | 269 void CFX_List::SetMultipleSel(FX_BOOL bMultiple) { |
| 287 m_bMultiple = bMultiple; | 270 m_bMultiple = bMultiple; |
| 288 } | 271 } |
| 289 | 272 |
| 290 FX_BOOL CFX_List::IsMultipleSel() const { | 273 FX_BOOL CFX_List::IsMultipleSel() const { |
| 291 return m_bMultiple; | 274 return m_bMultiple; |
| 292 } | 275 } |
| 293 | 276 |
| 294 FX_BOOL CFX_List::IsValid(int32_t nItemIndex) const { | 277 FX_BOOL CFX_List::IsValid(int32_t nItemIndex) const { |
| 295 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize(); | 278 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize(); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 615 |
| 633 void CFX_ListCtrl::SetCaret(int32_t nItemIndex) { | 616 void CFX_ListCtrl::SetCaret(int32_t nItemIndex) { |
| 634 if (!IsValid(nItemIndex)) | 617 if (!IsValid(nItemIndex)) |
| 635 return; | 618 return; |
| 636 | 619 |
| 637 if (IsMultipleSel()) { | 620 if (IsMultipleSel()) { |
| 638 int32_t nOldIndex = m_nCaretIndex; | 621 int32_t nOldIndex = m_nCaretIndex; |
| 639 | 622 |
| 640 if (nOldIndex != nItemIndex) { | 623 if (nOldIndex != nItemIndex) { |
| 641 m_nCaretIndex = nItemIndex; | 624 m_nCaretIndex = nItemIndex; |
| 642 | |
| 643 SetItemCaret(nOldIndex, FALSE); | |
| 644 SetItemCaret(nItemIndex, TRUE); | |
| 645 | |
| 646 InvalidateItem(nOldIndex); | 625 InvalidateItem(nOldIndex); |
| 647 InvalidateItem(nItemIndex); | 626 InvalidateItem(nItemIndex); |
| 648 } | 627 } |
| 649 } | 628 } |
| 650 } | 629 } |
| 651 | 630 |
| 652 void CFX_ListCtrl::InvalidateItem(int32_t nItemIndex) { | 631 void CFX_ListCtrl::InvalidateItem(int32_t nItemIndex) { |
| 653 if (m_pNotify) { | 632 if (m_pNotify) { |
| 654 if (nItemIndex == -1) { | 633 if (nItemIndex == -1) { |
| 655 if (!m_bNotifyFlag) { | 634 if (!m_bNotifyFlag) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 | 793 |
| 815 int32_t CFX_ListCtrl::GetItemIndex(const CFX_FloatPoint& point) const { | 794 int32_t CFX_ListCtrl::GetItemIndex(const CFX_FloatPoint& point) const { |
| 816 return CFX_List::GetItemIndex(OutToIn(point)); | 795 return CFX_List::GetItemIndex(OutToIn(point)); |
| 817 } | 796 } |
| 818 | 797 |
| 819 CFX_WideString CFX_ListCtrl::GetText() const { | 798 CFX_WideString CFX_ListCtrl::GetText() const { |
| 820 if (IsMultipleSel()) | 799 if (IsMultipleSel()) |
| 821 return GetItemText(m_nCaretIndex); | 800 return GetItemText(m_nCaretIndex); |
| 822 return GetItemText(m_nSelItem); | 801 return GetItemText(m_nSelItem); |
| 823 } | 802 } |
| OLD | NEW |