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