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/fxge/include/fx_ge.h" | 9 #include "core/fxge/include/fx_ge.h" |
10 #include "fpdfsdk/fxedit/include/fxet_list.h" | 10 #include "fpdfsdk/fxedit/include/fxet_list.h" |
11 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 11 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
12 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" | 12 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
13 #include "fpdfsdk/pdfwindow/PWL_ListBox.h" | 13 #include "fpdfsdk/pdfwindow/PWL_ListBox.h" |
14 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 14 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
15 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" | 15 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
16 #include "public/fpdf_fwlevent.h" | 16 #include "public/fpdf_fwlevent.h" |
17 | 17 |
18 #define PWLCB_DEFAULTFONTSIZE 12.0f | 18 #define PWLCB_DEFAULTFONTSIZE 12.0f |
19 | 19 |
20 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) | 20 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) |
21 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) | 21 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
22 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) | 22 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
23 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) | 23 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
24 | 24 |
25 FX_BOOL CPWL_CBListBox::OnLButtonUp(const CFX_FloatPoint& point, | 25 FX_BOOL CPWL_CBListBox::OnLButtonUp(const CFX_FloatPoint& point, |
26 uint32_t nFlag) { | 26 uint32_t nFlag) { |
27 CPWL_Wnd::OnLButtonUp(point, nFlag); | 27 CPWL_Wnd::OnLButtonUp(point, nFlag); |
28 | 28 |
29 if (m_bMouseDown) { | 29 if (!m_bMouseDown) |
30 ReleaseCapture(); | 30 return TRUE; |
31 m_bMouseDown = FALSE; | |
32 | 31 |
33 if (ClientHitTest(point)) { | 32 ReleaseCapture(); |
34 if (CPWL_Wnd* pParent = GetParentWindow()) { | 33 m_bMouseDown = FALSE; |
35 pParent->OnNotify(this, PNM_LBUTTONUP, 0, | |
36 PWL_MAKEDWORD(point.x, point.y)); | |
37 } | |
38 | 34 |
39 FX_BOOL bExit = FALSE; | 35 if (!ClientHitTest(point)) |
40 OnNotifySelChanged(FALSE, bExit, nFlag); | 36 return TRUE; |
41 if (bExit) | 37 if (CPWL_Wnd* pParent = GetParentWindow()) |
42 return FALSE; | 38 pParent->OnNotify(this, PNM_LBUTTONUP, 0, PWL_MAKEDWORD(point.x, point.y)); |
43 } | |
44 } | |
45 | 39 |
46 return TRUE; | 40 FX_BOOL bExit = FALSE; |
| 41 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 42 |
| 43 return !bExit; |
47 } | 44 } |
48 | 45 |
49 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(uint16_t nChar, | 46 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(uint16_t nChar, |
50 FX_BOOL& bExit, | 47 FX_BOOL& bExit, |
51 uint32_t nFlag) { | 48 uint32_t nFlag) { |
52 if (!m_pList) | |
53 return FALSE; | |
54 | |
55 switch (nChar) { | 49 switch (nChar) { |
56 default: | |
57 return FALSE; | |
58 case FWL_VKEY_Up: | 50 case FWL_VKEY_Up: |
59 case FWL_VKEY_Down: | 51 case FWL_VKEY_Down: |
60 case FWL_VKEY_Home: | 52 case FWL_VKEY_Home: |
61 case FWL_VKEY_Left: | 53 case FWL_VKEY_Left: |
62 case FWL_VKEY_End: | 54 case FWL_VKEY_End: |
63 case FWL_VKEY_Right: | 55 case FWL_VKEY_Right: |
64 break; | 56 break; |
| 57 default: |
| 58 return FALSE; |
65 } | 59 } |
66 | 60 |
67 switch (nChar) { | 61 switch (nChar) { |
68 case FWL_VKEY_Up: | 62 case FWL_VKEY_Up: |
69 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 63 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
70 break; | 64 break; |
71 case FWL_VKEY_Down: | 65 case FWL_VKEY_Down: |
72 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 66 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
73 break; | 67 break; |
74 case FWL_VKEY_Home: | 68 case FWL_VKEY_Home: |
(...skipping 13 matching lines...) Expand all Loading... |
88 } | 82 } |
89 | 83 |
90 OnNotifySelChanged(TRUE, bExit, nFlag); | 84 OnNotifySelChanged(TRUE, bExit, nFlag); |
91 | 85 |
92 return TRUE; | 86 return TRUE; |
93 } | 87 } |
94 | 88 |
95 FX_BOOL CPWL_CBListBox::OnCharWithExit(uint16_t nChar, | 89 FX_BOOL CPWL_CBListBox::OnCharWithExit(uint16_t nChar, |
96 FX_BOOL& bExit, | 90 FX_BOOL& bExit, |
97 uint32_t nFlag) { | 91 uint32_t nFlag) { |
98 if (!m_pList) | |
99 return FALSE; | |
100 | |
101 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) | 92 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) |
102 return FALSE; | 93 return FALSE; |
103 | 94 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) |
104 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) { | |
105 pComboBox->SetSelectText(); | 95 pComboBox->SetSelectText(); |
106 } | |
107 | 96 |
108 OnNotifySelChanged(TRUE, bExit, nFlag); | 97 OnNotifySelChanged(TRUE, bExit, nFlag); |
109 | 98 |
110 return TRUE; | 99 return TRUE; |
111 } | 100 } |
112 | 101 |
113 void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { | 102 void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
114 CPWL_Wnd::GetThisAppearanceStream(sAppStream); | 103 CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
115 | 104 |
116 CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect(); | 105 CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect(); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 | 633 |
645 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { | 634 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { |
646 m_pFillerNotify = pNotify; | 635 m_pFillerNotify = pNotify; |
647 | 636 |
648 if (m_pEdit) | 637 if (m_pEdit) |
649 m_pEdit->SetFillerNotify(pNotify); | 638 m_pEdit->SetFillerNotify(pNotify); |
650 | 639 |
651 if (m_pList) | 640 if (m_pList) |
652 m_pList->SetFillerNotify(pNotify); | 641 m_pList->SetFillerNotify(pNotify); |
653 } | 642 } |
OLD | NEW |