| 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/pdfwindow/PWL_ComboBox.h" | 7 #include "fpdfsdk/pdfwindow/PWL_ComboBox.h" |
| 8 | 8 |
| 9 #include "core/include/fxge/fx_ge.h" | 9 #include "core/include/fxge/fx_ge.h" |
| 10 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 10 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 11 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" | 11 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
| 12 #include "fpdfsdk/pdfwindow/PWL_ListBox.h" | 12 #include "fpdfsdk/pdfwindow/PWL_ListBox.h" |
| 13 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 13 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 14 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" | 14 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
| 15 #include "public/fpdf_fwlevent.h" | 15 #include "public/fpdf_fwlevent.h" |
| 16 | 16 |
| 17 #define PWLCB_DEFAULTFONTSIZE 12.0f | 17 #define PWLCB_DEFAULTFONTSIZE 12.0f |
| 18 | 18 |
| 19 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) | 19 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) |
| 20 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) | 20 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
| 21 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) | 21 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
| 22 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) | 22 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
| 23 | 23 |
| 24 FX_BOOL CPWL_CBListBox::OnLButtonUp(const CFX_FloatPoint& point, | 24 FX_BOOL CPWL_CBListBox::OnLButtonUp(const CFX_FloatPoint& point, |
| 25 FX_DWORD nFlag) { | 25 uint32_t nFlag) { |
| 26 CPWL_Wnd::OnLButtonUp(point, nFlag); | 26 CPWL_Wnd::OnLButtonUp(point, nFlag); |
| 27 | 27 |
| 28 if (m_bMouseDown) { | 28 if (m_bMouseDown) { |
| 29 ReleaseCapture(); | 29 ReleaseCapture(); |
| 30 m_bMouseDown = FALSE; | 30 m_bMouseDown = FALSE; |
| 31 | 31 |
| 32 if (ClientHitTest(point)) { | 32 if (ClientHitTest(point)) { |
| 33 if (CPWL_Wnd* pParent = GetParentWindow()) { | 33 if (CPWL_Wnd* pParent = GetParentWindow()) { |
| 34 pParent->OnNotify(this, PNM_LBUTTONUP, 0, | 34 pParent->OnNotify(this, PNM_LBUTTONUP, 0, |
| 35 PWL_MAKEDWORD(point.x, point.y)); | 35 PWL_MAKEDWORD(point.x, point.y)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 FX_BOOL bExit = FALSE; | 38 FX_BOOL bExit = FALSE; |
| 39 OnNotifySelChanged(FALSE, bExit, nFlag); | 39 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 40 if (bExit) | 40 if (bExit) |
| 41 return FALSE; | 41 return FALSE; |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 return TRUE; | 45 return TRUE; |
| 46 } | 46 } |
| 47 | 47 |
| 48 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(uint16_t nChar, | 48 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(uint16_t nChar, |
| 49 FX_BOOL& bExit, | 49 FX_BOOL& bExit, |
| 50 FX_DWORD nFlag) { | 50 uint32_t nFlag) { |
| 51 if (!m_pList) | 51 if (!m_pList) |
| 52 return FALSE; | 52 return FALSE; |
| 53 | 53 |
| 54 switch (nChar) { | 54 switch (nChar) { |
| 55 default: | 55 default: |
| 56 return FALSE; | 56 return FALSE; |
| 57 case FWL_VKEY_Up: | 57 case FWL_VKEY_Up: |
| 58 case FWL_VKEY_Down: | 58 case FWL_VKEY_Down: |
| 59 case FWL_VKEY_Home: | 59 case FWL_VKEY_Home: |
| 60 case FWL_VKEY_Left: | 60 case FWL_VKEY_Left: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 86 break; | 86 break; |
| 87 } | 87 } |
| 88 | 88 |
| 89 OnNotifySelChanged(TRUE, bExit, nFlag); | 89 OnNotifySelChanged(TRUE, bExit, nFlag); |
| 90 | 90 |
| 91 return TRUE; | 91 return TRUE; |
| 92 } | 92 } |
| 93 | 93 |
| 94 FX_BOOL CPWL_CBListBox::OnCharWithExit(uint16_t nChar, | 94 FX_BOOL CPWL_CBListBox::OnCharWithExit(uint16_t nChar, |
| 95 FX_BOOL& bExit, | 95 FX_BOOL& bExit, |
| 96 FX_DWORD nFlag) { | 96 uint32_t nFlag) { |
| 97 if (!m_pList) | 97 if (!m_pList) |
| 98 return FALSE; | 98 return FALSE; |
| 99 | 99 |
| 100 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) | 100 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) |
| 101 return FALSE; | 101 return FALSE; |
| 102 | 102 |
| 103 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) { | 103 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) { |
| 104 pComboBox->SetSelectText(); | 104 pComboBox->SetSelectText(); |
| 105 } | 105 } |
| 106 | 106 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 pDevice->DrawPath(&path, pUser2Device, NULL, | 172 pDevice->DrawPath(&path, pUser2Device, NULL, |
| 173 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR, | 173 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR, |
| 174 GetTransparency()), | 174 GetTransparency()), |
| 175 0, FXFILL_ALTERNATE); | 175 0, FXFILL_ALTERNATE); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 FX_BOOL CPWL_CBButton::OnLButtonDown(const CFX_FloatPoint& point, | 180 FX_BOOL CPWL_CBButton::OnLButtonDown(const CFX_FloatPoint& point, |
| 181 FX_DWORD nFlag) { | 181 uint32_t nFlag) { |
| 182 CPWL_Wnd::OnLButtonDown(point, nFlag); | 182 CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 183 | 183 |
| 184 SetCapture(); | 184 SetCapture(); |
| 185 | 185 |
| 186 if (CPWL_Wnd* pParent = GetParentWindow()) { | 186 if (CPWL_Wnd* pParent = GetParentWindow()) { |
| 187 pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, | 187 pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, |
| 188 PWL_MAKEDWORD(point.x, point.y)); | 188 PWL_MAKEDWORD(point.x, point.y)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 return TRUE; | 191 return TRUE; |
| 192 } | 192 } |
| 193 | 193 |
| 194 FX_BOOL CPWL_CBButton::OnLButtonUp(const CFX_FloatPoint& point, | 194 FX_BOOL CPWL_CBButton::OnLButtonUp(const CFX_FloatPoint& point, |
| 195 FX_DWORD nFlag) { | 195 uint32_t nFlag) { |
| 196 CPWL_Wnd::OnLButtonUp(point, nFlag); | 196 CPWL_Wnd::OnLButtonUp(point, nFlag); |
| 197 | 197 |
| 198 ReleaseCapture(); | 198 ReleaseCapture(); |
| 199 | 199 |
| 200 return TRUE; | 200 return TRUE; |
| 201 } | 201 } |
| 202 | 202 |
| 203 CPWL_ComboBox::CPWL_ComboBox() | 203 CPWL_ComboBox::CPWL_ComboBox() |
| 204 : m_pEdit(NULL), | 204 : m_pEdit(NULL), |
| 205 m_pButton(NULL), | 205 m_pButton(NULL), |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 return; | 510 return; |
| 511 #endif // PDF_ENABLE_XFA | 511 #endif // PDF_ENABLE_XFA |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 } else { | 514 } else { |
| 515 m_bPopup = bPopup; | 515 m_bPopup = bPopup; |
| 516 Move(m_rcOldWindow, TRUE, TRUE); | 516 Move(m_rcOldWindow, TRUE, TRUE); |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 FX_BOOL CPWL_ComboBox::OnKeyDown(uint16_t nChar, FX_DWORD nFlag) { | 520 FX_BOOL CPWL_ComboBox::OnKeyDown(uint16_t nChar, uint32_t nFlag) { |
| 521 if (!m_pList) | 521 if (!m_pList) |
| 522 return FALSE; | 522 return FALSE; |
| 523 if (!m_pEdit) | 523 if (!m_pEdit) |
| 524 return FALSE; | 524 return FALSE; |
| 525 | 525 |
| 526 m_nSelectItem = -1; | 526 m_nSelectItem = -1; |
| 527 | 527 |
| 528 switch (nChar) { | 528 switch (nChar) { |
| 529 case FWL_VKEY_Up: | 529 case FWL_VKEY_Up: |
| 530 if (m_pList->GetCurSel() > 0) { | 530 if (m_pList->GetCurSel() > 0) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 } | 569 } |
| 570 return TRUE; | 570 return TRUE; |
| 571 } | 571 } |
| 572 | 572 |
| 573 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 573 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
| 574 return m_pEdit->OnKeyDown(nChar, nFlag); | 574 return m_pEdit->OnKeyDown(nChar, nFlag); |
| 575 | 575 |
| 576 return FALSE; | 576 return FALSE; |
| 577 } | 577 } |
| 578 | 578 |
| 579 FX_BOOL CPWL_ComboBox::OnChar(uint16_t nChar, FX_DWORD nFlag) { | 579 FX_BOOL CPWL_ComboBox::OnChar(uint16_t nChar, uint32_t nFlag) { |
| 580 if (!m_pList) | 580 if (!m_pList) |
| 581 return FALSE; | 581 return FALSE; |
| 582 | 582 |
| 583 if (!m_pEdit) | 583 if (!m_pEdit) |
| 584 return FALSE; | 584 return FALSE; |
| 585 | 585 |
| 586 m_nSelectItem = -1; | 586 m_nSelectItem = -1; |
| 587 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 587 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
| 588 return m_pEdit->OnChar(nChar, nFlag); | 588 return m_pEdit->OnChar(nChar, nFlag); |
| 589 | 589 |
| 590 FX_BOOL bExit = FALSE; | 590 FX_BOOL bExit = FALSE; |
| 591 #ifdef PDF_ENABLE_XFA | 591 #ifdef PDF_ENABLE_XFA |
| 592 if (m_pFillerNotify) { | 592 if (m_pFillerNotify) { |
| 593 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); | 593 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); |
| 594 if (bExit) | 594 if (bExit) |
| 595 return FALSE; | 595 return FALSE; |
| 596 | 596 |
| 597 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); | 597 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag); |
| 598 if (bExit) | 598 if (bExit) |
| 599 return FALSE; | 599 return FALSE; |
| 600 } | 600 } |
| 601 #endif // PDF_ENABLE_XFA | 601 #endif // PDF_ENABLE_XFA |
| 602 return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE; | 602 return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE; |
| 603 } | 603 } |
| 604 | 604 |
| 605 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, | 605 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, |
| 606 FX_DWORD msg, | 606 uint32_t msg, |
| 607 intptr_t wParam, | 607 intptr_t wParam, |
| 608 intptr_t lParam) { | 608 intptr_t lParam) { |
| 609 switch (msg) { | 609 switch (msg) { |
| 610 case PNM_LBUTTONDOWN: | 610 case PNM_LBUTTONDOWN: |
| 611 if (pWnd == m_pButton) { | 611 if (pWnd == m_pButton) { |
| 612 SetPopup(!m_bPopup); | 612 SetPopup(!m_bPopup); |
| 613 return; | 613 return; |
| 614 } | 614 } |
| 615 break; | 615 break; |
| 616 case PNM_LBUTTONUP: | 616 case PNM_LBUTTONUP: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 643 | 643 |
| 644 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { | 644 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { |
| 645 m_pFillerNotify = pNotify; | 645 m_pFillerNotify = pNotify; |
| 646 | 646 |
| 647 if (m_pEdit) | 647 if (m_pEdit) |
| 648 m_pEdit->SetFillerNotify(pNotify); | 648 m_pEdit->SetFillerNotify(pNotify); |
| 649 | 649 |
| 650 if (m_pList) | 650 if (m_pList) |
| 651 m_pList->SetFillerNotify(pNotify); | 651 m_pList->SetFillerNotify(pNotify); |
| 652 } | 652 } |
| OLD | NEW |