| 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/include/pdfwindow/PDFWindow.h" | 7 #include "fpdfsdk/include/pdfwindow/PDFWindow.h" |
| 8 #include "fpdfsdk/include/pdfwindow/PWL_ComboBox.h" | 8 #include "fpdfsdk/include/pdfwindow/PWL_ComboBox.h" |
| 9 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" |
| 10 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 if (!m_pList) | 464 if (!m_pList) |
| 465 return; | 465 return; |
| 466 if (bPopup == m_bPopup) | 466 if (bPopup == m_bPopup) |
| 467 return; | 467 return; |
| 468 FX_FLOAT fListHeight = m_pList->GetContentRect().Height(); | 468 FX_FLOAT fListHeight = m_pList->GetContentRect().Height(); |
| 469 if (!IsFloatBigger(fListHeight, 0.0f)) | 469 if (!IsFloatBigger(fListHeight, 0.0f)) |
| 470 return; | 470 return; |
| 471 | 471 |
| 472 if (bPopup) { | 472 if (bPopup) { |
| 473 if (m_pFillerNotify) { | 473 if (m_pFillerNotify) { |
| 474 #ifdef PDF_ENABLE_XFA |
| 475 FX_BOOL bExit = FALSE; |
| 476 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0); |
| 477 if (bExit) |
| 478 return; |
| 479 |
| 480 #endif |
| 474 int32_t nWhere = 0; | 481 int32_t nWhere = 0; |
| 475 FX_FLOAT fPopupRet = 0.0f; | 482 FX_FLOAT fPopupRet = 0.0f; |
| 476 FX_FLOAT fPopupMin = 0.0f; | 483 FX_FLOAT fPopupMin = 0.0f; |
| 477 if (m_pList->GetCount() > 3) | 484 if (m_pList->GetCount() > 3) |
| 478 fPopupMin = | 485 fPopupMin = |
| 479 m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2; | 486 m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2; |
| 480 FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2; | 487 FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2; |
| 481 m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin, fPopupMax, | 488 m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin, fPopupMax, |
| 482 nWhere, fPopupRet); | 489 nWhere, fPopupRet); |
| 483 | 490 |
| 484 if (IsFloatBigger(fPopupRet, 0.0f)) { | 491 if (IsFloatBigger(fPopupRet, 0.0f)) { |
| 485 m_bPopup = bPopup; | 492 m_bPopup = bPopup; |
| 486 | 493 |
| 487 CPDF_Rect rcWindow = CPWL_Wnd::GetWindowRect(); | 494 CPDF_Rect rcWindow = CPWL_Wnd::GetWindowRect(); |
| 488 m_rcOldWindow = rcWindow; | 495 m_rcOldWindow = rcWindow; |
| 489 switch (nWhere) { | 496 switch (nWhere) { |
| 490 default: | 497 default: |
| 491 case 0: | 498 case 0: |
| 492 rcWindow.bottom -= fPopupRet; | 499 rcWindow.bottom -= fPopupRet; |
| 493 break; | 500 break; |
| 494 case 1: | 501 case 1: |
| 495 rcWindow.top += fPopupRet; | 502 rcWindow.top += fPopupRet; |
| 496 break; | 503 break; |
| 497 } | 504 } |
| 498 | 505 |
| 499 m_nPopupWhere = nWhere; | 506 m_nPopupWhere = nWhere; |
| 500 Move(rcWindow, TRUE, TRUE); | 507 Move(rcWindow, TRUE, TRUE); |
| 508 #ifdef PDF_ENABLE_XFA |
| 509 |
| 510 bExit = FALSE; |
| 511 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0); |
| 512 if (bExit) |
| 513 return; |
| 514 #endif |
| 501 } | 515 } |
| 502 } | 516 } |
| 503 } else { | 517 } else { |
| 504 m_bPopup = bPopup; | 518 m_bPopup = bPopup; |
| 505 Move(m_rcOldWindow, TRUE, TRUE); | 519 Move(m_rcOldWindow, TRUE, TRUE); |
| 506 } | 520 } |
| 507 } | 521 } |
| 508 | 522 |
| 509 FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { | 523 FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { |
| 510 if (!m_pList) | 524 if (!m_pList) |
| 511 return FALSE; | 525 return FALSE; |
| 512 if (!m_pEdit) | 526 if (!m_pEdit) |
| 513 return FALSE; | 527 return FALSE; |
| 514 | 528 |
| 515 m_nSelectItem = -1; | 529 m_nSelectItem = -1; |
| 516 | 530 |
| 517 switch (nChar) { | 531 switch (nChar) { |
| 518 case FWL_VKEY_Up: | 532 case FWL_VKEY_Up: |
| 519 if (m_pList->GetCurSel() > 0) { | 533 if (m_pList->GetCurSel() > 0) { |
| 520 FX_BOOL bExit = FALSE; | 534 FX_BOOL bExit = FALSE; |
| 535 #ifdef PDF_ENABLE_XFA |
| 536 |
| 537 if (m_pFillerNotify) { |
| 538 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); |
| 539 if (bExit) |
| 540 return FALSE; |
| 541 bExit = FALSE; |
| 542 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); |
| 543 if (bExit) |
| 544 return FALSE; |
| 545 } |
| 546 #endif |
| 521 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { | 547 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { |
| 522 if (bExit) | 548 if (bExit) |
| 523 return FALSE; | 549 return FALSE; |
| 524 SetSelectText(); | 550 SetSelectText(); |
| 525 } | 551 } |
| 526 } | 552 } |
| 527 return TRUE; | 553 return TRUE; |
| 528 case FWL_VKEY_Down: | 554 case FWL_VKEY_Down: |
| 529 if (m_pList->GetCurSel() < m_pList->GetCount() - 1) { | 555 if (m_pList->GetCurSel() < m_pList->GetCount() - 1) { |
| 530 FX_BOOL bExit = FALSE; | 556 FX_BOOL bExit = FALSE; |
| 557 #ifdef PDF_ENABLE_XFA |
| 558 |
| 559 if (m_pFillerNotify) { |
| 560 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); |
| 561 if (bExit) |
| 562 return FALSE; |
| 563 bExit = FALSE; |
| 564 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); |
| 565 if (bExit) |
| 566 return FALSE; |
| 567 } |
| 568 #endif |
| 531 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { | 569 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { |
| 532 if (bExit) | 570 if (bExit) |
| 533 return FALSE; | 571 return FALSE; |
| 534 SetSelectText(); | 572 SetSelectText(); |
| 535 } | 573 } |
| 536 } | 574 } |
| 537 return TRUE; | 575 return TRUE; |
| 538 } | 576 } |
| 539 | 577 |
| 540 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 578 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
| 541 return m_pEdit->OnKeyDown(nChar, nFlag); | 579 return m_pEdit->OnKeyDown(nChar, nFlag); |
| 542 | 580 |
| 543 return FALSE; | 581 return FALSE; |
| 544 } | 582 } |
| 545 | 583 |
| 546 FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) { | 584 FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) { |
| 547 if (!m_pList) | 585 if (!m_pList) |
| 548 return FALSE; | 586 return FALSE; |
| 549 | 587 |
| 550 if (!m_pEdit) | 588 if (!m_pEdit) |
| 551 return FALSE; | 589 return FALSE; |
| 552 | 590 |
| 553 m_nSelectItem = -1; | 591 m_nSelectItem = -1; |
| 554 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 592 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
| 555 return m_pEdit->OnChar(nChar, nFlag); | 593 return m_pEdit->OnChar(nChar, nFlag); |
| 556 | 594 |
| 557 FX_BOOL bExit = FALSE; | 595 FX_BOOL bExit = FALSE; |
| 596 #ifdef PDF_ENABLE_XFA |
| 597 if (m_pFillerNotify) { |
| 598 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); |
| 599 if (bExit) |
| 600 return FALSE; |
| 601 |
| 602 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); |
| 603 if (bExit) |
| 604 return FALSE; |
| 605 } |
| 606 #endif |
| 558 return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE; | 607 return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE; |
| 559 } | 608 } |
| 560 | 609 |
| 561 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, | 610 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, |
| 562 FX_DWORD msg, | 611 FX_DWORD msg, |
| 563 intptr_t wParam, | 612 intptr_t wParam, |
| 564 intptr_t lParam) { | 613 intptr_t lParam) { |
| 565 switch (msg) { | 614 switch (msg) { |
| 566 case PNM_LBUTTONDOWN: | 615 case PNM_LBUTTONDOWN: |
| 567 if (pWnd == m_pButton) { | 616 if (pWnd == m_pButton) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 | 652 |
| 604 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { | 653 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { |
| 605 m_pFillerNotify = pNotify; | 654 m_pFillerNotify = pNotify; |
| 606 | 655 |
| 607 if (m_pEdit) | 656 if (m_pEdit) |
| 608 m_pEdit->SetFillerNotify(pNotify); | 657 m_pEdit->SetFillerNotify(pNotify); |
| 609 | 658 |
| 610 if (m_pList) | 659 if (m_pList) |
| 611 m_pList->SetFillerNotify(pNotify); | 660 m_pList->SetFillerNotify(pNotify); |
| 612 } | 661 } |
| OLD | NEW |