| 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/pdfwindow/PDFWindow.h" | 7 #include "../../include/pdfwindow/PDFWindow.h" |
| 8 #include "../../include/pdfwindow/PWL_Wnd.h" | 8 #include "../../include/pdfwindow/PWL_Wnd.h" |
| 9 #include "../../include/pdfwindow/PWL_ListBox.h" | 9 #include "../../include/pdfwindow/PWL_ListBox.h" |
| 10 #include "../../include/pdfwindow/PWL_Utils.h" | 10 #include "../../include/pdfwindow/PWL_Utils.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33
FX_FLOAT fSmallStep, FX_FLOAT fBigStep) | 33
FX_FLOAT fSmallStep, FX_FLOAT fBigStep) |
| 34 { | 34 { |
| 35 PWL_SCROLL_INFO Info; | 35 PWL_SCROLL_INFO Info; |
| 36 | 36 |
| 37 Info.fPlateWidth = fPlateMax - fPlateMin; | 37 Info.fPlateWidth = fPlateMax - fPlateMin; |
| 38 Info.fContentMin = fContentMin; | 38 Info.fContentMin = fContentMin; |
| 39 Info.fContentMax = fContentMax; | 39 Info.fContentMax = fContentMax; |
| 40 Info.fSmallStep = fSmallStep; | 40 Info.fSmallStep = fSmallStep; |
| 41 Info.fBigStep = fBigStep; | 41 Info.fBigStep = fBigStep; |
| 42 | 42 |
| 43 » m_pList->OnNotify(m_pList,PNM_SETSCROLLINFO,SBT_VSCROLL,(FX_INTPTR)&Info
); | 43 » m_pList->OnNotify(m_pList,PNM_SETSCROLLINFO,SBT_VSCROLL,(intptr_t)&Info)
; |
| 44 | 44 |
| 45 if (CPWL_ScrollBar * pScroll = m_pList->GetVScrollBar()) | 45 if (CPWL_ScrollBar * pScroll = m_pList->GetVScrollBar()) |
| 46 { | 46 { |
| 47 if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fConten
tMin) | 47 if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fConten
tMin) |
| 48 || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.f
ContentMin)) | 48 || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.f
ContentMin)) |
| 49 { | 49 { |
| 50 if (pScroll->IsVisible()) | 50 if (pScroll->IsVisible()) |
| 51 { | 51 { |
| 52 pScroll->SetVisible(FALSE); | 52 pScroll->SetVisible(FALSE); |
| 53 m_pList->RePosChildWnd(); | 53 m_pList->RePosChildWnd(); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 else | 56 else |
| 57 { | 57 { |
| 58 if (!pScroll->IsVisible()) | 58 if (!pScroll->IsVisible()) |
| 59 { | 59 { |
| 60 pScroll->SetVisible(TRUE); | 60 pScroll->SetVisible(TRUE); |
| 61 m_pList->RePosChildWnd(); | 61 m_pList->RePosChildWnd(); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) | 67 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) |
| 68 { | 68 { |
| 69 » m_pList->OnNotify(m_pList,PNM_SETSCROLLPOS,SBT_VSCROLL,(FX_INTPTR)&fy); | 69 » m_pList->OnNotify(m_pList,PNM_SETSCROLLPOS,SBT_VSCROLL,(intptr_t)&fy); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect * pRect) | 72 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect * pRect) |
| 73 { | 73 { |
| 74 m_pList->InvalidateRect(pRect); | 74 m_pList->InvalidateRect(pRect); |
| 75 } | 75 } |
| 76 | 76 |
| 77 /* --------------------------- CPWL_ListBox ---------------------------- */ | 77 /* --------------------------- CPWL_ListBox ---------------------------- */ |
| 78 | 78 |
| 79 CPWL_ListBox::CPWL_ListBox() : | 79 CPWL_ListBox::CPWL_ListBox() : |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) | 133 void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) |
| 134 { | 134 { |
| 135 CPWL_Wnd::GetThisAppearanceStream(sAppStream); | 135 CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
| 136 | 136 |
| 137 CFX_ByteTextBuf sListItems; | 137 CFX_ByteTextBuf sListItems; |
| 138 | 138 |
| 139 if (m_pList) | 139 if (m_pList) |
| 140 { | 140 { |
| 141 CPDF_Rect rcPlate = m_pList->GetPlateRect(); | 141 CPDF_Rect rcPlate = m_pList->GetPlateRect(); |
| 142 » » for (FX_INT32 i=0,sz=m_pList->GetCount(); i<sz; i++) | 142 » » for (int32_t i=0,sz=m_pList->GetCount(); i<sz; i++) |
| 143 { | 143 { |
| 144 CPDF_Rect rcItem = m_pList->GetItemRect(i); | 144 CPDF_Rect rcItem = m_pList->GetItemRect(i); |
| 145 | 145 |
| 146 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.
bottom) continue; | 146 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.
bottom) continue; |
| 147 | 147 |
| 148 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bo
ttom) * 0.5f); | 148 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bo
ttom) * 0.5f); |
| 149 if (m_pList->IsItemSelected(i)) | 149 if (m_pList->IsItemSelected(i)) |
| 150 { | 150 { |
| 151 sListItems << CPWL_Utils::GetRectFillAppStream(r
cItem,PWL_DEFAULT_SELBACKCOLOR); | 151 sListItems << CPWL_Utils::GetRectFillAppStream(r
cItem,PWL_DEFAULT_SELBACKCOLOR); |
| 152 CFX_ByteString sItem = CPWL_Utils::GetEditAppStr
eam(m_pList->GetItemEdit(i), ptOffset); | 152 CFX_ByteString sItem = CPWL_Utils::GetEditAppStr
eam(m_pList->GetItemEdit(i), ptOffset); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pU
ser2Device) | 184 void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pU
ser2Device) |
| 185 { | 185 { |
| 186 CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); | 186 CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); |
| 187 | 187 |
| 188 if (m_pList) | 188 if (m_pList) |
| 189 { | 189 { |
| 190 CPDF_Rect rcPlate = m_pList->GetPlateRect(); | 190 CPDF_Rect rcPlate = m_pList->GetPlateRect(); |
| 191 CPDF_Rect rcList = GetListRect(); | 191 CPDF_Rect rcList = GetListRect(); |
| 192 CPDF_Rect rcClient = GetClientRect(); | 192 CPDF_Rect rcClient = GetClientRect(); |
| 193 | 193 |
| 194 » » for (FX_INT32 i=0,sz=m_pList->GetCount(); i<sz; i++) | 194 » » for (int32_t i=0,sz=m_pList->GetCount(); i<sz; i++) |
| 195 { | 195 { |
| 196 CPDF_Rect rcItem = m_pList->GetItemRect(i); | 196 CPDF_Rect rcItem = m_pList->GetItemRect(i); |
| 197 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.
bottom) continue; | 197 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.
bottom) continue; |
| 198 | 198 |
| 199 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bo
ttom) * 0.5f); | 199 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bo
ttom) * 0.5f); |
| 200 if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) | 200 if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) |
| 201 { | 201 { |
| 202 CPDF_Rect rcContent = pEdit->GetContentRect(); | 202 CPDF_Rect rcContent = pEdit->GetContentRect(); |
| 203 if (rcContent.Width() > rcClient.Width()) | 203 if (rcContent.Width() > rcClient.Width()) |
| 204 rcItem.Intersect(rcList); | 204 rcItem.Intersect(rcList); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 349 |
| 350 if (m_bMouseDown) | 350 if (m_bMouseDown) |
| 351 { | 351 { |
| 352 if (m_pList) | 352 if (m_pList) |
| 353 m_pList->OnMouseMove(point,IsSHIFTpressed(nFlag),IsCTRLp
ressed(nFlag)); | 353 m_pList->OnMouseMove(point,IsSHIFTpressed(nFlag),IsCTRLp
ressed(nFlag)); |
| 354 } | 354 } |
| 355 | 355 |
| 356 return TRUE; | 356 return TRUE; |
| 357 } | 357 } |
| 358 | 358 |
| 359 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_I
NTPTR lParam) | 359 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intpt
r_t lParam) |
| 360 { | 360 { |
| 361 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); | 361 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); |
| 362 | 362 |
| 363 FX_FLOAT fPos; | 363 FX_FLOAT fPos; |
| 364 | 364 |
| 365 switch (msg) | 365 switch (msg) |
| 366 { | 366 { |
| 367 case PNM_SETSCROLLINFO: | 367 case PNM_SETSCROLLINFO: |
| 368 switch (wParam) | 368 switch (wParam) |
| 369 { | 369 { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 | 401 |
| 402 void CPWL_ListBox::KillFocus() | 402 void CPWL_ListBox::KillFocus() |
| 403 { | 403 { |
| 404 CPWL_Wnd::KillFocus(); | 404 CPWL_Wnd::KillFocus(); |
| 405 | 405 |
| 406 /* | 406 /* |
| 407 if (this->IsMultipleSel()) | 407 if (this->IsMultipleSel()) |
| 408 { | 408 { |
| 409 » » for(FX_INT32 i=0;i<this->GetCount();i++) | 409 » » for(int32_t i=0;i<this->GetCount();i++) |
| 410 { | 410 { |
| 411 if (this->IsListItemSelected(i)) | 411 if (this->IsListItemSelected(i)) |
| 412 { | 412 { |
| 413 if (!IsListItemVisible(i)) | 413 if (!IsListItemVisible(i)) |
| 414 this->ScrollToListItem(i); | 414 this->ScrollToListItem(i); |
| 415 break; | 415 break; |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 else | 419 else |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 m_pList->SetFontSize(fFontSize); | 489 m_pList->SetFontSize(fFontSize); |
| 490 } | 490 } |
| 491 | 491 |
| 492 FX_FLOAT CPWL_ListBox::GetFontSize() const | 492 FX_FLOAT CPWL_ListBox::GetFontSize() const |
| 493 { | 493 { |
| 494 if (m_pList) | 494 if (m_pList) |
| 495 return m_pList->GetFontSize(); | 495 return m_pList->GetFontSize(); |
| 496 return 0.0f; | 496 return 0.0f; |
| 497 } | 497 } |
| 498 | 498 |
| 499 void CPWL_ListBox::Select(FX_INT32 nItemIndex) | 499 void CPWL_ListBox::Select(int32_t nItemIndex) |
| 500 { | 500 { |
| 501 if (m_pList) | 501 if (m_pList) |
| 502 m_pList->Select(nItemIndex); | 502 m_pList->Select(nItemIndex); |
| 503 } | 503 } |
| 504 | 504 |
| 505 void CPWL_ListBox::SetCaret(FX_INT32 nItemIndex) | 505 void CPWL_ListBox::SetCaret(int32_t nItemIndex) |
| 506 { | 506 { |
| 507 if (m_pList) | 507 if (m_pList) |
| 508 m_pList->SetCaret(nItemIndex); | 508 m_pList->SetCaret(nItemIndex); |
| 509 } | 509 } |
| 510 | 510 |
| 511 void CPWL_ListBox::SetTopVisibleIndex(FX_INT32 nItemIndex) | 511 void CPWL_ListBox::SetTopVisibleIndex(int32_t nItemIndex) |
| 512 { | 512 { |
| 513 if (m_pList) | 513 if (m_pList) |
| 514 m_pList->SetTopItem(nItemIndex); | 514 m_pList->SetTopItem(nItemIndex); |
| 515 } | 515 } |
| 516 | 516 |
| 517 void CPWL_ListBox::ScrollToListItem(FX_INT32 nItemIndex) | 517 void CPWL_ListBox::ScrollToListItem(int32_t nItemIndex) |
| 518 { | 518 { |
| 519 if (m_pList) | 519 if (m_pList) |
| 520 m_pList->ScrollToListItem(nItemIndex); | 520 m_pList->ScrollToListItem(nItemIndex); |
| 521 } | 521 } |
| 522 | 522 |
| 523 void CPWL_ListBox::ResetContent() | 523 void CPWL_ListBox::ResetContent() |
| 524 { | 524 { |
| 525 if (m_pList) | 525 if (m_pList) |
| 526 m_pList->Empty(); | 526 m_pList->Empty(); |
| 527 } | 527 } |
| 528 | 528 |
| 529 void CPWL_ListBox::Reset() | 529 void CPWL_ListBox::Reset() |
| 530 { | 530 { |
| 531 if (m_pList) | 531 if (m_pList) |
| 532 m_pList->Cancel(); | 532 m_pList->Cancel(); |
| 533 } | 533 } |
| 534 | 534 |
| 535 FX_BOOL CPWL_ListBox::IsMultipleSel() const | 535 FX_BOOL CPWL_ListBox::IsMultipleSel() const |
| 536 { | 536 { |
| 537 if (m_pList) | 537 if (m_pList) |
| 538 return m_pList->IsMultipleSel(); | 538 return m_pList->IsMultipleSel(); |
| 539 | 539 |
| 540 return FALSE; | 540 return FALSE; |
| 541 } | 541 } |
| 542 | 542 |
| 543 FX_INT32 CPWL_ListBox::GetCaretIndex() const | 543 int32_t CPWL_ListBox::GetCaretIndex() const |
| 544 { | 544 { |
| 545 if (m_pList) | 545 if (m_pList) |
| 546 return m_pList->GetCaret(); | 546 return m_pList->GetCaret(); |
| 547 | 547 |
| 548 return -1; | 548 return -1; |
| 549 } | 549 } |
| 550 | 550 |
| 551 FX_INT32 CPWL_ListBox::GetCurSel() const | 551 int32_t CPWL_ListBox::GetCurSel() const |
| 552 { | 552 { |
| 553 if (m_pList) | 553 if (m_pList) |
| 554 return m_pList->GetSelect(); | 554 return m_pList->GetSelect(); |
| 555 | 555 |
| 556 return -1; | 556 return -1; |
| 557 } | 557 } |
| 558 | 558 |
| 559 FX_BOOL CPWL_ListBox::IsItemSelected(FX_INT32 nItemIndex) const | 559 FX_BOOL CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const |
| 560 { | 560 { |
| 561 if (m_pList) | 561 if (m_pList) |
| 562 return m_pList->IsItemSelected(nItemIndex); | 562 return m_pList->IsItemSelected(nItemIndex); |
| 563 | 563 |
| 564 return FALSE; | 564 return FALSE; |
| 565 } | 565 } |
| 566 | 566 |
| 567 FX_INT32 CPWL_ListBox::GetTopVisibleIndex() const | 567 int32_t CPWL_ListBox::GetTopVisibleIndex() const |
| 568 { | 568 { |
| 569 if (m_pList) | 569 if (m_pList) |
| 570 { | 570 { |
| 571 m_pList->ScrollToListItem(m_pList->GetFirstSelected()); | 571 m_pList->ScrollToListItem(m_pList->GetFirstSelected()); |
| 572 return m_pList->GetTopItem(); | 572 return m_pList->GetTopItem(); |
| 573 } | 573 } |
| 574 | 574 |
| 575 return -1; | 575 return -1; |
| 576 } | 576 } |
| 577 | 577 |
| 578 FX_INT32 CPWL_ListBox::GetCount() const | 578 int32_t CPWL_ListBox::GetCount() const |
| 579 { | 579 { |
| 580 if (m_pList) | 580 if (m_pList) |
| 581 return m_pList->GetCount(); | 581 return m_pList->GetCount(); |
| 582 | 582 |
| 583 return 0; | 583 return 0; |
| 584 } | 584 } |
| 585 | 585 |
| 586 FX_INT32 CPWL_ListBox::FindNext(FX_INT32 nIndex,FX_WCHAR nChar) const | 586 int32_t CPWL_ListBox::FindNext(int32_t nIndex,FX_WCHAR nChar) const |
| 587 { | 587 { |
| 588 if (m_pList) | 588 if (m_pList) |
| 589 return m_pList->FindNext(nIndex,nChar); | 589 return m_pList->FindNext(nIndex,nChar); |
| 590 | 590 |
| 591 return nIndex; | 591 return nIndex; |
| 592 } | 592 } |
| 593 | 593 |
| 594 CPDF_Rect CPWL_ListBox::GetContentRect() const | 594 CPDF_Rect CPWL_ListBox::GetContentRect() const |
| 595 { | 595 { |
| 596 if (m_pList) | 596 if (m_pList) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 623 else | 623 else |
| 624 { | 624 { |
| 625 m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); | 625 m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); |
| 626 } | 626 } |
| 627 | 627 |
| 628 FX_BOOL bExit = FALSE; | 628 FX_BOOL bExit = FALSE; |
| 629 OnNotifySelChanged(FALSE,bExit, nFlag); | 629 OnNotifySelChanged(FALSE,bExit, nFlag); |
| 630 return TRUE; | 630 return TRUE; |
| 631 } | 631 } |
| 632 | 632 |
| OLD | NEW |