| 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 "../../include/fxedit/fxet_stub.h" | 7 #include "../../include/fxedit/fxet_stub.h" |
| 8 #include "../../include/fxedit/fxet_edit.h" | 8 #include "../../include/fxedit/fxet_edit.h" |
| 9 #include "../../include/fxedit/fxet_list.h" | 9 #include "../../include/fxedit/fxet_list.h" |
| 10 | 10 |
| 11 /* ------------------------------- CFX_ListItem --------------------------------
-- */ | 11 /* ------------------------------- CFX_ListItem --------------------------------
-- */ |
| 12 | 12 |
| 13 CFX_ListItem::CFX_ListItem() : m_pEdit(NULL), | 13 CFX_ListItem::CFX_ListItem() : m_pEdit(NULL), |
| 14 » m_bSelected(FALSE), | 14 » m_bSelected(false), |
| 15 » m_bCaret(FALSE), | 15 » m_bCaret(false), |
| 16 m_rcListItem(0.0f,0.0f,0.0f,0.0f) | 16 m_rcListItem(0.0f,0.0f,0.0f,0.0f) |
| 17 { | 17 { |
| 18 m_pEdit = IFX_Edit::NewEdit(); | 18 m_pEdit = IFX_Edit::NewEdit(); |
| 19 ASSERT(m_pEdit != NULL); | 19 ASSERT(m_pEdit != NULL); |
| 20 | 20 |
| 21 m_pEdit->SetAlignmentV(1); | 21 m_pEdit->SetAlignmentV(1); |
| 22 m_pEdit->Initialize(); | 22 m_pEdit->Initialize(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 CFX_ListItem::~CFX_ListItem() | 25 CFX_ListItem::~CFX_ListItem() |
| (...skipping 23 matching lines...) Expand all Loading... |
| 49 void CFX_ListItem::SetRect(const CLST_Rect & rect) | 49 void CFX_ListItem::SetRect(const CLST_Rect & rect) |
| 50 { | 50 { |
| 51 m_rcListItem = rect; | 51 m_rcListItem = rect; |
| 52 } | 52 } |
| 53 | 53 |
| 54 CLST_Rect CFX_ListItem::GetRect() const | 54 CLST_Rect CFX_ListItem::GetRect() const |
| 55 { | 55 { |
| 56 return m_rcListItem; | 56 return m_rcListItem; |
| 57 } | 57 } |
| 58 | 58 |
| 59 FX_BOOL CFX_ListItem::IsSelected() const | 59 bool CFX_ListItem::IsSelected() const |
| 60 { | 60 { |
| 61 return m_bSelected; | 61 return m_bSelected; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void CFX_ListItem::SetSelect(FX_BOOL bSelected) | 64 void CFX_ListItem::SetSelect(bool bSelected) |
| 65 { | 65 { |
| 66 m_bSelected = bSelected; | 66 m_bSelected = bSelected; |
| 67 } | 67 } |
| 68 | 68 |
| 69 FX_BOOL CFX_ListItem::IsCaret() const | 69 bool CFX_ListItem::IsCaret() const |
| 70 { | 70 { |
| 71 return m_bCaret; | 71 return m_bCaret; |
| 72 } | 72 } |
| 73 | 73 |
| 74 void CFX_ListItem::SetCaret(FX_BOOL bCaret) | 74 void CFX_ListItem::SetCaret(bool bCaret) |
| 75 { | 75 { |
| 76 m_bCaret = bCaret; | 76 m_bCaret = bCaret; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void CFX_ListItem::SetText(const FX_WCHAR* text) | 79 void CFX_ListItem::SetText(const FX_WCHAR* text) |
| 80 { | 80 { |
| 81 if (m_pEdit) | 81 if (m_pEdit) |
| 82 m_pEdit->SetText(text); | 82 m_pEdit->SetText(text); |
| 83 } | 83 } |
| 84 | 84 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 112 CFX_WideString CFX_ListItem::GetText() const | 112 CFX_WideString CFX_ListItem::GetText() const |
| 113 { | 113 { |
| 114 if (m_pEdit) | 114 if (m_pEdit) |
| 115 return m_pEdit->GetText(); | 115 return m_pEdit->GetText(); |
| 116 | 116 |
| 117 return L""; | 117 return L""; |
| 118 } | 118 } |
| 119 | 119 |
| 120 /* ------------------------------------ CFX_List -------------------------------
-- */ | 120 /* ------------------------------------ CFX_List -------------------------------
-- */ |
| 121 | 121 |
| 122 CFX_List::CFX_List() : m_fFontSize(0.0f), m_pFontMap(NULL), m_bMultiple(FALSE) | 122 CFX_List::CFX_List() : m_fFontSize(0.0f), m_pFontMap(NULL), m_bMultiple(false) |
| 123 { | 123 { |
| 124 } | 124 } |
| 125 | 125 |
| 126 CFX_List::~CFX_List() | 126 CFX_List::~CFX_List() |
| 127 { | 127 { |
| 128 Empty(); | 128 Empty(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void CFX_List::Empty() | 131 void CFX_List::Empty() |
| 132 { | 132 { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 FX_FLOAT CFX_List::GetFontSize() const | 205 FX_FLOAT CFX_List::GetFontSize() const |
| 206 { | 206 { |
| 207 return m_fFontSize; | 207 return m_fFontSize; |
| 208 } | 208 } |
| 209 | 209 |
| 210 int32_t CFX_List::GetItemIndex(const CPDF_Point & point) const | 210 int32_t CFX_List::GetItemIndex(const CPDF_Point & point) const |
| 211 { | 211 { |
| 212 CPDF_Point pt = OuterToInner(point); | 212 CPDF_Point pt = OuterToInner(point); |
| 213 | 213 |
| 214 » FX_BOOL bFirst = TRUE; | 214 » bool bFirst = true; |
| 215 » FX_BOOL bLast = TRUE; | 215 » bool bLast = true; |
| 216 | 216 |
| 217 for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++) | 217 for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++) |
| 218 { | 218 { |
| 219 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) | 219 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) |
| 220 { | 220 { |
| 221 CLST_Rect rcListItem = pListItem->GetRect(); | 221 CLST_Rect rcListItem = pListItem->GetRect(); |
| 222 | 222 |
| 223 if (FX_EDIT_IsFloatBigger(pt.y, rcListItem.top)) | 223 if (FX_EDIT_IsFloatBigger(pt.y, rcListItem.top)) |
| 224 { | 224 { |
| 225 » » » » bFirst = FALSE; | 225 » » » » bFirst = false; |
| 226 } | 226 } |
| 227 | 227 |
| 228 if (FX_EDIT_IsFloatSmaller(pt.y, rcListItem.bottom)) | 228 if (FX_EDIT_IsFloatSmaller(pt.y, rcListItem.bottom)) |
| 229 { | 229 { |
| 230 » » » » bLast = FALSE; | 230 » » » » bLast = false; |
| 231 } | 231 } |
| 232 | 232 |
| 233 if (pt.y >= rcListItem.top && pt.y < rcListItem.bottom) | 233 if (pt.y >= rcListItem.top && pt.y < rcListItem.bottom) |
| 234 { | 234 { |
| 235 return i; | 235 return i; |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 if (bFirst) return 0; | 240 if (bFirst) return 0; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 { | 311 { |
| 312 CPDF_Rect rcItem = pListItem->GetRect(); | 312 CPDF_Rect rcItem = pListItem->GetRect(); |
| 313 rcItem.left = 0.0f; | 313 rcItem.left = 0.0f; |
| 314 rcItem.right = GetPlateRect().Width(); | 314 rcItem.right = GetPlateRect().Width(); |
| 315 return InnerToOuter(rcItem); | 315 return InnerToOuter(rcItem); |
| 316 } | 316 } |
| 317 | 317 |
| 318 return CPDF_Rect(); | 318 return CPDF_Rect(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 FX_BOOL CFX_List::IsItemSelected(int32_t nIndex) const | 321 bool CFX_List::IsItemSelected(int32_t nIndex) const |
| 322 { | 322 { |
| 323 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) | 323 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) |
| 324 { | 324 { |
| 325 return pListItem->IsSelected(); | 325 return pListItem->IsSelected(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 » return FALSE; | 328 » return false; |
| 329 } | 329 } |
| 330 | 330 |
| 331 void CFX_List::SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected) | 331 void CFX_List::SetItemSelect(int32_t nItemIndex, bool bSelected) |
| 332 { | 332 { |
| 333 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex)) | 333 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex)) |
| 334 { | 334 { |
| 335 pListItem->SetSelect(bSelected); | 335 pListItem->SetSelect(bSelected); |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 void CFX_List::SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret) | 339 void CFX_List::SetItemCaret(int32_t nItemIndex, bool bCaret) |
| 340 { | 340 { |
| 341 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex)) | 341 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex)) |
| 342 { | 342 { |
| 343 pListItem->SetCaret(bCaret); | 343 pListItem->SetCaret(bCaret); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 void CFX_List::SetMultipleSel(FX_BOOL bMultiple) | 347 void CFX_List::SetMultipleSel(bool bMultiple) |
| 348 { | 348 { |
| 349 m_bMultiple = bMultiple; | 349 m_bMultiple = bMultiple; |
| 350 } | 350 } |
| 351 | 351 |
| 352 FX_BOOL CFX_List::IsMultipleSel() const | 352 bool CFX_List::IsMultipleSel() const |
| 353 { | 353 { |
| 354 return m_bMultiple; | 354 return m_bMultiple; |
| 355 } | 355 } |
| 356 | 356 |
| 357 FX_BOOL CFX_List::IsValid(int32_t nItemIndex) const | 357 bool CFX_List::IsValid(int32_t nItemIndex) const |
| 358 { | 358 { |
| 359 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize(); | 359 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 CFX_WideString CFX_List::GetItemText(int32_t nIndex) const | 362 CFX_WideString CFX_List::GetItemText(int32_t nIndex) const |
| 363 { | 363 { |
| 364 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) | 364 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) |
| 365 { | 365 { |
| 366 return pListItem->GetText(); | 366 return pListItem->GetText(); |
| 367 } | 367 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) | 439 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) |
| 440 { | 440 { |
| 441 if (pItem->nItemIndex == nItemIndex) | 441 if (pItem->nItemIndex == nItemIndex) |
| 442 return i; | 442 return i; |
| 443 } | 443 } |
| 444 } | 444 } |
| 445 | 445 |
| 446 return -1; | 446 return -1; |
| 447 } | 447 } |
| 448 | 448 |
| 449 FX_BOOL CPLST_Select::IsExist(int32_t nItemIndex) const | 449 bool CPLST_Select::IsExist(int32_t nItemIndex) const |
| 450 { | 450 { |
| 451 return Find(nItemIndex) >= 0; | 451 return Find(nItemIndex) >= 0; |
| 452 } | 452 } |
| 453 | 453 |
| 454 int32_t CPLST_Select::GetCount() const | 454 int32_t CPLST_Select::GetCount() const |
| 455 { | 455 { |
| 456 return m_aItems.GetSize(); | 456 return m_aItems.GetSize(); |
| 457 } | 457 } |
| 458 | 458 |
| 459 int32_t CPLST_Select::GetItemIndex(int32_t nIndex) const | 459 int32_t CPLST_Select::GetItemIndex(int32_t nIndex) const |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 { | 500 { |
| 501 pItem->nState = 0; | 501 pItem->nState = 0; |
| 502 } | 502 } |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 } | 505 } |
| 506 | 506 |
| 507 /* ------------------------------------ CFX_ListCtrl ---------------------------
------ */ | 507 /* ------------------------------------ CFX_ListCtrl ---------------------------
------ */ |
| 508 | 508 |
| 509 CFX_ListCtrl::CFX_ListCtrl() : m_pNotify(NULL), | 509 CFX_ListCtrl::CFX_ListCtrl() : m_pNotify(NULL), |
| 510 » m_bNotifyFlag(FALSE), | 510 » m_bNotifyFlag(false), |
| 511 m_ptScrollPos(0.0f,0.0f), | 511 m_ptScrollPos(0.0f,0.0f), |
| 512 m_nSelItem(-1), | 512 m_nSelItem(-1), |
| 513 m_nFootIndex(-1), | 513 m_nFootIndex(-1), |
| 514 » m_bCtrlSel(FALSE), | 514 » m_bCtrlSel(false), |
| 515 m_nCaretIndex(-1) | 515 m_nCaretIndex(-1) |
| 516 { | 516 { |
| 517 } | 517 } |
| 518 | 518 |
| 519 CFX_ListCtrl::~CFX_ListCtrl() | 519 CFX_ListCtrl::~CFX_ListCtrl() |
| 520 { | 520 { |
| 521 } | 521 } |
| 522 | 522 |
| 523 void CFX_ListCtrl::SetNotify(IFX_List_Notify * pNotify) | 523 void CFX_ListCtrl::SetNotify(IFX_List_Notify * pNotify) |
| 524 { | 524 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 550 } | 550 } |
| 551 | 551 |
| 552 CPDF_Rect CFX_ListCtrl::OutToIn(const CPDF_Rect & rect) const | 552 CPDF_Rect CFX_ListCtrl::OutToIn(const CPDF_Rect & rect) const |
| 553 { | 553 { |
| 554 CPDF_Point ptLeftBottom = OutToIn(CPDF_Point(rect.left,rect.bottom)); | 554 CPDF_Point ptLeftBottom = OutToIn(CPDF_Point(rect.left,rect.bottom)); |
| 555 CPDF_Point ptRightTop = OutToIn(CPDF_Point(rect.right,rect.top)); | 555 CPDF_Point ptRightTop = OutToIn(CPDF_Point(rect.right,rect.top)); |
| 556 | 556 |
| 557 return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y
); | 557 return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y
); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void CFX_ListCtrl::OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL b
Ctrl) | 560 void CFX_ListCtrl::OnMouseDown(const CPDF_Point & point,bool bShift,bool bCtrl) |
| 561 { | 561 { |
| 562 int32_t nHitIndex = GetItemIndex(point); | 562 int32_t nHitIndex = GetItemIndex(point); |
| 563 | 563 |
| 564 if (IsMultipleSel()) | 564 if (IsMultipleSel()) |
| 565 { | 565 { |
| 566 if (bCtrl) | 566 if (bCtrl) |
| 567 { | 567 { |
| 568 if (IsItemSelected(nHitIndex)) | 568 if (IsItemSelected(nHitIndex)) |
| 569 { | 569 { |
| 570 m_aSelItems.Sub(nHitIndex); | 570 m_aSelItems.Sub(nHitIndex); |
| 571 SelectItems(); | 571 SelectItems(); |
| 572 » » » » m_bCtrlSel = FALSE; | 572 » » » » m_bCtrlSel = false; |
| 573 } | 573 } |
| 574 else | 574 else |
| 575 { | 575 { |
| 576 m_aSelItems.Add(nHitIndex); | 576 m_aSelItems.Add(nHitIndex); |
| 577 SelectItems(); | 577 SelectItems(); |
| 578 » » » » m_bCtrlSel = TRUE; | 578 » » » » m_bCtrlSel = true; |
| 579 } | 579 } |
| 580 | 580 |
| 581 m_nFootIndex = nHitIndex; | 581 m_nFootIndex = nHitIndex; |
| 582 } | 582 } |
| 583 else if (bShift) | 583 else if (bShift) |
| 584 { | 584 { |
| 585 m_aSelItems.DeselectAll(); | 585 m_aSelItems.DeselectAll(); |
| 586 m_aSelItems.Add(m_nFootIndex,nHitIndex); | 586 m_aSelItems.Add(m_nFootIndex,nHitIndex); |
| 587 SelectItems(); | 587 SelectItems(); |
| 588 } | 588 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 599 } | 599 } |
| 600 else | 600 else |
| 601 { | 601 { |
| 602 SetSingleSelect(nHitIndex); | 602 SetSingleSelect(nHitIndex); |
| 603 } | 603 } |
| 604 | 604 |
| 605 if (!IsItemVisible(nHitIndex)) | 605 if (!IsItemVisible(nHitIndex)) |
| 606 ScrollToListItem(nHitIndex); | 606 ScrollToListItem(nHitIndex); |
| 607 } | 607 } |
| 608 | 608 |
| 609 void CFX_ListCtrl::OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL b
Ctrl) | 609 void CFX_ListCtrl::OnMouseMove(const CPDF_Point & point,bool bShift,bool bCtrl) |
| 610 { | 610 { |
| 611 int32_t nHitIndex = GetItemIndex(point); | 611 int32_t nHitIndex = GetItemIndex(point); |
| 612 | 612 |
| 613 if (IsMultipleSel()) | 613 if (IsMultipleSel()) |
| 614 { | 614 { |
| 615 if (bCtrl) | 615 if (bCtrl) |
| 616 { | 616 { |
| 617 if (m_bCtrlSel) | 617 if (m_bCtrlSel) |
| 618 m_aSelItems.Add(m_nFootIndex,nHitIndex); | 618 m_aSelItems.Add(m_nFootIndex,nHitIndex); |
| 619 else | 619 else |
| (...skipping 12 matching lines...) Expand all Loading... |
| 632 } | 632 } |
| 633 else | 633 else |
| 634 { | 634 { |
| 635 SetSingleSelect(nHitIndex); | 635 SetSingleSelect(nHitIndex); |
| 636 } | 636 } |
| 637 | 637 |
| 638 if (!IsItemVisible(nHitIndex)) | 638 if (!IsItemVisible(nHitIndex)) |
| 639 ScrollToListItem(nHitIndex); | 639 ScrollToListItem(nHitIndex); |
| 640 } | 640 } |
| 641 | 641 |
| 642 void CFX_ListCtrl::OnVK(int32_t nItemIndex,FX_BOOL bShift,FX_BOOL bCtrl) | 642 void CFX_ListCtrl::OnVK(int32_t nItemIndex,bool bShift,bool bCtrl) |
| 643 { | 643 { |
| 644 if (IsMultipleSel()) | 644 if (IsMultipleSel()) |
| 645 { | 645 { |
| 646 if (nItemIndex >= 0 && nItemIndex < GetCount()) | 646 if (nItemIndex >= 0 && nItemIndex < GetCount()) |
| 647 { | 647 { |
| 648 if (bCtrl) | 648 if (bCtrl) |
| 649 { | 649 { |
| 650 } | 650 } |
| 651 else if (bShift) | 651 else if (bShift) |
| 652 { | 652 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 667 } | 667 } |
| 668 else | 668 else |
| 669 { | 669 { |
| 670 SetSingleSelect(nItemIndex); | 670 SetSingleSelect(nItemIndex); |
| 671 } | 671 } |
| 672 | 672 |
| 673 if (!IsItemVisible(nItemIndex)) | 673 if (!IsItemVisible(nItemIndex)) |
| 674 ScrollToListItem(nItemIndex); | 674 ScrollToListItem(nItemIndex); |
| 675 } | 675 } |
| 676 | 676 |
| 677 void CFX_ListCtrl::OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl) | 677 void CFX_ListCtrl::OnVK_UP(bool bShift,bool bCtrl) |
| 678 { | 678 { |
| 679 OnVK(IsMultipleSel() ? GetCaret()-1 : GetSelect()-1, bShift, bCtrl); | 679 OnVK(IsMultipleSel() ? GetCaret()-1 : GetSelect()-1, bShift, bCtrl); |
| 680 } | 680 } |
| 681 | 681 |
| 682 void CFX_ListCtrl::OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl) | 682 void CFX_ListCtrl::OnVK_DOWN(bool bShift,bool bCtrl) |
| 683 { | 683 { |
| 684 OnVK(IsMultipleSel() ? GetCaret()+1 : GetSelect()+1, bShift, bCtrl); | 684 OnVK(IsMultipleSel() ? GetCaret()+1 : GetSelect()+1, bShift, bCtrl); |
| 685 } | 685 } |
| 686 | 686 |
| 687 void CFX_ListCtrl::OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl) | 687 void CFX_ListCtrl::OnVK_LEFT(bool bShift,bool bCtrl) |
| 688 { | 688 { |
| 689 OnVK(0, bShift, bCtrl); | 689 OnVK(0, bShift, bCtrl); |
| 690 } | 690 } |
| 691 | 691 |
| 692 void CFX_ListCtrl::OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl) | 692 void CFX_ListCtrl::OnVK_RIGHT(bool bShift,bool bCtrl) |
| 693 { | 693 { |
| 694 OnVK(GetCount()-1, bShift, bCtrl); | 694 OnVK(GetCount()-1, bShift, bCtrl); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void CFX_ListCtrl::OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl) | 697 void CFX_ListCtrl::OnVK_HOME(bool bShift,bool bCtrl) |
| 698 { | 698 { |
| 699 OnVK(0, bShift, bCtrl); | 699 OnVK(0, bShift, bCtrl); |
| 700 } | 700 } |
| 701 | 701 |
| 702 void CFX_ListCtrl::OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl) | 702 void CFX_ListCtrl::OnVK_END(bool bShift,bool bCtrl) |
| 703 { | 703 { |
| 704 OnVK(GetCount()-1, bShift, bCtrl); | 704 OnVK(GetCount()-1, bShift, bCtrl); |
| 705 } | 705 } |
| 706 | 706 |
| 707 FX_BOOL»CFX_ListCtrl::OnChar(FX_WORD nChar,FX_BOOL bShift,FX_BOOL bCtrl) | 707 bool» CFX_ListCtrl::OnChar(FX_WORD nChar,bool bShift,bool bCtrl) |
| 708 { | 708 { |
| 709 int32_t nIndex = GetLastSelected(); | 709 int32_t nIndex = GetLastSelected(); |
| 710 int32_t nFindIndex = FindNext(nIndex,nChar); | 710 int32_t nFindIndex = FindNext(nIndex,nChar); |
| 711 | 711 |
| 712 if (nFindIndex != nIndex) | 712 if (nFindIndex != nIndex) |
| 713 { | 713 { |
| 714 OnVK(nFindIndex, bShift, bCtrl); | 714 OnVK(nFindIndex, bShift, bCtrl); |
| 715 » » return TRUE; | 715 » » return true; |
| 716 } | 716 } |
| 717 » return FALSE; | 717 » return false; |
| 718 } | 718 } |
| 719 | 719 |
| 720 /* -------- inner methods ------- */ | 720 /* -------- inner methods ------- */ |
| 721 | 721 |
| 722 void CFX_ListCtrl::SetPlateRect(const CPDF_Rect & rect) | 722 void CFX_ListCtrl::SetPlateRect(const CPDF_Rect & rect) |
| 723 { | 723 { |
| 724 CFX_ListContainer::SetPlateRect(rect); | 724 CFX_ListContainer::SetPlateRect(rect); |
| 725 m_ptScrollPos.x = rect.left; | 725 m_ptScrollPos.x = rect.left; |
| 726 SetScrollPos(CPDF_Point(rect.left,rect.top)); | 726 SetScrollPos(CPDF_Point(rect.left,rect.top)); |
| 727 ReArrange(0); | 727 ReArrange(0); |
| 728 InvalidateItem(-1); | 728 InvalidateItem(-1); |
| 729 } | 729 } |
| 730 | 730 |
| 731 CPDF_Rect CFX_ListCtrl::GetItemRect(int32_t nIndex) const | 731 CPDF_Rect CFX_ListCtrl::GetItemRect(int32_t nIndex) const |
| 732 { | 732 { |
| 733 return InToOut(CFX_List::GetItemRect(nIndex)); | 733 return InToOut(CFX_List::GetItemRect(nIndex)); |
| 734 } | 734 } |
| 735 | 735 |
| 736 void CFX_ListCtrl::AddString(const FX_WCHAR* string) | 736 void CFX_ListCtrl::AddString(const FX_WCHAR* string) |
| 737 { | 737 { |
| 738 AddItem(string); | 738 AddItem(string); |
| 739 ReArrange(GetCount() - 1); | 739 ReArrange(GetCount() - 1); |
| 740 } | 740 } |
| 741 | 741 |
| 742 void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected) | 742 void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, bool bSelected) |
| 743 { | 743 { |
| 744 if (!IsValid(nItemIndex)) return; | 744 if (!IsValid(nItemIndex)) return; |
| 745 | 745 |
| 746 if (bSelected != IsItemSelected(nItemIndex)) | 746 if (bSelected != IsItemSelected(nItemIndex)) |
| 747 { | 747 { |
| 748 if (bSelected) | 748 if (bSelected) |
| 749 { | 749 { |
| 750 » » » SetItemSelect(nItemIndex,TRUE); | 750 » » » SetItemSelect(nItemIndex,true); |
| 751 InvalidateItem(nItemIndex); | 751 InvalidateItem(nItemIndex); |
| 752 } | 752 } |
| 753 else | 753 else |
| 754 { | 754 { |
| 755 » » » SetItemSelect(nItemIndex,FALSE); | 755 » » » SetItemSelect(nItemIndex,false); |
| 756 InvalidateItem(nItemIndex); | 756 InvalidateItem(nItemIndex); |
| 757 } | 757 } |
| 758 } | 758 } |
| 759 } | 759 } |
| 760 | 760 |
| 761 void CFX_ListCtrl::SetSingleSelect(int32_t nItemIndex) | 761 void CFX_ListCtrl::SetSingleSelect(int32_t nItemIndex) |
| 762 { | 762 { |
| 763 if (!IsValid(nItemIndex)) return; | 763 if (!IsValid(nItemIndex)) return; |
| 764 | 764 |
| 765 if (m_nSelItem != nItemIndex) | 765 if (m_nSelItem != nItemIndex) |
| 766 { | 766 { |
| 767 if (m_nSelItem >= 0) | 767 if (m_nSelItem >= 0) |
| 768 { | 768 { |
| 769 » » » SetItemSelect(m_nSelItem,FALSE); | 769 » » » SetItemSelect(m_nSelItem,false); |
| 770 InvalidateItem(m_nSelItem); | 770 InvalidateItem(m_nSelItem); |
| 771 } | 771 } |
| 772 | 772 |
| 773 » » SetItemSelect(nItemIndex,TRUE); | 773 » » SetItemSelect(nItemIndex,true); |
| 774 InvalidateItem(nItemIndex); | 774 InvalidateItem(nItemIndex); |
| 775 m_nSelItem = nItemIndex; | 775 m_nSelItem = nItemIndex; |
| 776 } | 776 } |
| 777 } | 777 } |
| 778 | 778 |
| 779 void CFX_ListCtrl::SetCaret(int32_t nItemIndex) | 779 void CFX_ListCtrl::SetCaret(int32_t nItemIndex) |
| 780 { | 780 { |
| 781 if (!IsValid(nItemIndex)) return; | 781 if (!IsValid(nItemIndex)) return; |
| 782 | 782 |
| 783 if (IsMultipleSel()) | 783 if (IsMultipleSel()) |
| 784 { | 784 { |
| 785 int32_t nOldIndex = m_nCaretIndex; | 785 int32_t nOldIndex = m_nCaretIndex; |
| 786 | 786 |
| 787 if (nOldIndex != nItemIndex) | 787 if (nOldIndex != nItemIndex) |
| 788 { | 788 { |
| 789 m_nCaretIndex = nItemIndex; | 789 m_nCaretIndex = nItemIndex; |
| 790 | 790 |
| 791 » » » SetItemCaret(nOldIndex, FALSE); | 791 » » » SetItemCaret(nOldIndex, false); |
| 792 » » » SetItemCaret(nItemIndex,TRUE); | 792 » » » SetItemCaret(nItemIndex,true); |
| 793 | 793 |
| 794 InvalidateItem(nOldIndex); | 794 InvalidateItem(nOldIndex); |
| 795 InvalidateItem(nItemIndex); | 795 InvalidateItem(nItemIndex); |
| 796 } | 796 } |
| 797 } | 797 } |
| 798 } | 798 } |
| 799 | 799 |
| 800 void CFX_ListCtrl::InvalidateItem(int32_t nItemIndex) | 800 void CFX_ListCtrl::InvalidateItem(int32_t nItemIndex) |
| 801 { | 801 { |
| 802 if (m_pNotify) | 802 if (m_pNotify) |
| 803 { | 803 { |
| 804 if (nItemIndex == -1) | 804 if (nItemIndex == -1) |
| 805 { | 805 { |
| 806 if (!m_bNotifyFlag) | 806 if (!m_bNotifyFlag) |
| 807 { | 807 { |
| 808 » » » » m_bNotifyFlag = TRUE; | 808 » » » » m_bNotifyFlag = true; |
| 809 CPDF_Rect rcRefresh = GetPlateRect(); | 809 CPDF_Rect rcRefresh = GetPlateRect(); |
| 810 m_pNotify->IOnInvalidateRect(&rcRefresh); | 810 m_pNotify->IOnInvalidateRect(&rcRefresh); |
| 811 » » » » m_bNotifyFlag = FALSE; | 811 » » » » m_bNotifyFlag = false; |
| 812 } | 812 } |
| 813 } | 813 } |
| 814 else | 814 else |
| 815 { | 815 { |
| 816 if (!m_bNotifyFlag) | 816 if (!m_bNotifyFlag) |
| 817 { | 817 { |
| 818 » » » » m_bNotifyFlag = TRUE; | 818 » » » » m_bNotifyFlag = true; |
| 819 CPDF_Rect rcRefresh = GetItemRect(nItemIndex); | 819 CPDF_Rect rcRefresh = GetItemRect(nItemIndex); |
| 820 rcRefresh.left -= 1.0f; | 820 rcRefresh.left -= 1.0f; |
| 821 rcRefresh.right += 1.0f; | 821 rcRefresh.right += 1.0f; |
| 822 rcRefresh.bottom -= 1.0f; | 822 rcRefresh.bottom -= 1.0f; |
| 823 rcRefresh.top += 1.0f; | 823 rcRefresh.top += 1.0f; |
| 824 | 824 |
| 825 m_pNotify->IOnInvalidateRect(&rcRefresh); | 825 m_pNotify->IOnInvalidateRect(&rcRefresh); |
| 826 » » » » m_bNotifyFlag = FALSE; | 826 » » » » m_bNotifyFlag = false; |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 } | 829 } |
| 830 } | 830 } |
| 831 | 831 |
| 832 void CFX_ListCtrl::SelectItems() | 832 void CFX_ListCtrl::SelectItems() |
| 833 { | 833 { |
| 834 for (int32_t i=0,sz=m_aSelItems.GetCount(); i<sz; i++) | 834 for (int32_t i=0,sz=m_aSelItems.GetCount(); i<sz; i++) |
| 835 { | 835 { |
| 836 int32_t nItemIndex = m_aSelItems.GetItemIndex(i); | 836 int32_t nItemIndex = m_aSelItems.GetItemIndex(i); |
| 837 int32_t nState = m_aSelItems.GetState(i); | 837 int32_t nState = m_aSelItems.GetState(i); |
| 838 | 838 |
| 839 switch(nState) | 839 switch(nState) |
| 840 { | 840 { |
| 841 case 1: | 841 case 1: |
| 842 » » » SetMultipleSelect(nItemIndex, TRUE); | 842 » » » SetMultipleSelect(nItemIndex, true); |
| 843 break; | 843 break; |
| 844 case -1: | 844 case -1: |
| 845 » » » SetMultipleSelect(nItemIndex, FALSE); | 845 » » » SetMultipleSelect(nItemIndex, false); |
| 846 break; | 846 break; |
| 847 } | 847 } |
| 848 } | 848 } |
| 849 | 849 |
| 850 m_aSelItems.Done(); | 850 m_aSelItems.Done(); |
| 851 } | 851 } |
| 852 | 852 |
| 853 void CFX_ListCtrl::Select(int32_t nItemIndex) | 853 void CFX_ListCtrl::Select(int32_t nItemIndex) |
| 854 { | 854 { |
| 855 if (!IsValid(nItemIndex)) return; | 855 if (!IsValid(nItemIndex)) return; |
| 856 | 856 |
| 857 if (IsMultipleSel()) | 857 if (IsMultipleSel()) |
| 858 { | 858 { |
| 859 m_aSelItems.Add(nItemIndex); | 859 m_aSelItems.Add(nItemIndex); |
| 860 SelectItems(); | 860 SelectItems(); |
| 861 } | 861 } |
| 862 else | 862 else |
| 863 SetSingleSelect(nItemIndex); | 863 SetSingleSelect(nItemIndex); |
| 864 } | 864 } |
| 865 | 865 |
| 866 FX_BOOL»CFX_ListCtrl::IsItemVisible(int32_t nItemIndex) const | 866 bool» CFX_ListCtrl::IsItemVisible(int32_t nItemIndex) const |
| 867 { | 867 { |
| 868 CPDF_Rect rcPlate = GetPlateRect(); | 868 CPDF_Rect rcPlate = GetPlateRect(); |
| 869 CPDF_Rect rcItem = GetItemRect(nItemIndex); | 869 CPDF_Rect rcItem = GetItemRect(nItemIndex); |
| 870 | 870 |
| 871 return rcItem.bottom >= rcPlate.bottom && rcItem.top <= rcPlate.top; | 871 return rcItem.bottom >= rcPlate.bottom && rcItem.top <= rcPlate.top; |
| 872 } | 872 } |
| 873 | 873 |
| 874 void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) | 874 void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) |
| 875 { | 875 { |
| 876 if (!IsValid(nItemIndex)) return; | 876 if (!IsValid(nItemIndex)) return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 897 | 897 |
| 898 void CFX_ListCtrl::SetScrollInfo() | 898 void CFX_ListCtrl::SetScrollInfo() |
| 899 { | 899 { |
| 900 if (m_pNotify) | 900 if (m_pNotify) |
| 901 { | 901 { |
| 902 CPDF_Rect rcPlate = GetPlateRect(); | 902 CPDF_Rect rcPlate = GetPlateRect(); |
| 903 CPDF_Rect rcContent = CFX_List::GetContentRect(); | 903 CPDF_Rect rcContent = CFX_List::GetContentRect(); |
| 904 | 904 |
| 905 if (!m_bNotifyFlag) | 905 if (!m_bNotifyFlag) |
| 906 { | 906 { |
| 907 » » » m_bNotifyFlag = TRUE; | 907 » » » m_bNotifyFlag = true; |
| 908 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top
, | 908 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top
, |
| 909 rcContent.bottom, rcContent.top, GetFirs
tHeight(), rcPlate.Height()); | 909 rcContent.bottom, rcContent.top, GetFirs
tHeight(), rcPlate.Height()); |
| 910 » » » m_bNotifyFlag = FALSE; | 910 » » » m_bNotifyFlag = false; |
| 911 } | 911 } |
| 912 } | 912 } |
| 913 } | 913 } |
| 914 | 914 |
| 915 void CFX_ListCtrl::SetScrollPos(const CPDF_Point & point) | 915 void CFX_ListCtrl::SetScrollPos(const CPDF_Point & point) |
| 916 { | 916 { |
| 917 SetScrollPosY(point.y); | 917 SetScrollPosY(point.y); |
| 918 } | 918 } |
| 919 | 919 |
| 920 void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) | 920 void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 940 } | 940 } |
| 941 } | 941 } |
| 942 | 942 |
| 943 m_ptScrollPos.y = fy; | 943 m_ptScrollPos.y = fy; |
| 944 InvalidateItem(-1); | 944 InvalidateItem(-1); |
| 945 | 945 |
| 946 if (m_pNotify) | 946 if (m_pNotify) |
| 947 { | 947 { |
| 948 if (!m_bNotifyFlag) | 948 if (!m_bNotifyFlag) |
| 949 { | 949 { |
| 950 » » » » m_bNotifyFlag = TRUE; | 950 » » » » m_bNotifyFlag = true; |
| 951 m_pNotify->IOnSetScrollPosY(fy); | 951 m_pNotify->IOnSetScrollPosY(fy); |
| 952 » » » » m_bNotifyFlag = FALSE; | 952 » » » » m_bNotifyFlag = false; |
| 953 } | 953 } |
| 954 } | 954 } |
| 955 } | 955 } |
| 956 } | 956 } |
| 957 | 957 |
| 958 CPDF_Rect CFX_ListCtrl::GetContentRect() const | 958 CPDF_Rect CFX_ListCtrl::GetContentRect() const |
| 959 { | 959 { |
| 960 return InToOut(CFX_List::GetContentRect()); | 960 return InToOut(CFX_List::GetContentRect()); |
| 961 } | 961 } |
| 962 | 962 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 return CFX_List::GetItemIndex(OutToIn(point)); | 1002 return CFX_List::GetItemIndex(OutToIn(point)); |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 CFX_WideString CFX_ListCtrl::GetText() const | 1005 CFX_WideString CFX_ListCtrl::GetText() const |
| 1006 { | 1006 { |
| 1007 if (IsMultipleSel()) | 1007 if (IsMultipleSel()) |
| 1008 return GetItemText(m_nCaretIndex); | 1008 return GetItemText(m_nCaretIndex); |
| 1009 return GetItemText(m_nSelItem); | 1009 return GetItemText(m_nSelItem); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| OLD | NEW |