OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "xfa/fwl/core/ifwl_comboboxproxy.h" | 7 #include "xfa/fwl/core/ifwl_comboboxproxy.h" |
8 | 8 |
| 9 #include "xfa/fwl/core/cfwl_msgkillfocus.h" |
| 10 #include "xfa/fwl/core/cfwl_msgmouse.h" |
9 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
10 #include "xfa/fwl/core/ifwl_app.h" | 12 #include "xfa/fwl/core/ifwl_app.h" |
11 #include "xfa/fwl/core/ifwl_combobox.h" | 13 #include "xfa/fwl/core/ifwl_combobox.h" |
12 | 14 |
13 IFWL_ComboBoxProxy::IFWL_ComboBoxProxy( | 15 IFWL_ComboBoxProxy::IFWL_ComboBoxProxy( |
14 IFWL_ComboBox* pComboBox, | 16 IFWL_ComboBox* pComboBox, |
15 const IFWL_App* app, | 17 const IFWL_App* app, |
16 std::unique_ptr<CFWL_WidgetProperties> properties, | 18 std::unique_ptr<CFWL_WidgetProperties> properties, |
17 IFWL_Widget* pOuter) | 19 IFWL_Widget* pOuter) |
18 : IFWL_FormProxy(app, std::move(properties), pOuter), | 20 : IFWL_FormProxy(app, std::move(properties), pOuter), |
(...skipping 16 matching lines...) Expand all Loading... |
35 break; | 37 break; |
36 case FWL_MouseCommand::LeftButtonUp: | 38 case FWL_MouseCommand::LeftButtonUp: |
37 OnLButtonUp(pMsg); | 39 OnLButtonUp(pMsg); |
38 break; | 40 break; |
39 default: | 41 default: |
40 break; | 42 break; |
41 } | 43 } |
42 break; | 44 break; |
43 } | 45 } |
44 case CFWL_MessageType::KillFocus: | 46 case CFWL_MessageType::KillFocus: |
45 OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), false); | 47 OnFocusChanged(pMessage, false); |
46 break; | 48 break; |
47 case CFWL_MessageType::SetFocus: | 49 case CFWL_MessageType::SetFocus: |
48 OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), true); | 50 OnFocusChanged(pMessage, true); |
49 break; | 51 break; |
50 default: | 52 default: |
51 break; | 53 break; |
52 } | 54 } |
53 IFWL_Widget::OnProcessMessage(pMessage); | 55 IFWL_Widget::OnProcessMessage(pMessage); |
54 } | 56 } |
55 | 57 |
56 void IFWL_ComboBoxProxy::OnDrawWidget(CFX_Graphics* pGraphics, | 58 void IFWL_ComboBoxProxy::OnDrawWidget(CFX_Graphics* pGraphics, |
57 const CFX_Matrix* pMatrix) { | 59 const CFX_Matrix* pMatrix) { |
58 m_pComboBox->DrawStretchHandler(pGraphics, pMatrix); | 60 m_pComboBox->DrawStretchHandler(pGraphics, pMatrix); |
59 } | 61 } |
60 | 62 |
61 void IFWL_ComboBoxProxy::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 63 void IFWL_ComboBoxProxy::OnLButtonDown(CFWL_Message* pMessage) { |
62 const IFWL_App* pApp = GetOwnerApp(); | 64 const IFWL_App* pApp = GetOwnerApp(); |
63 if (!pApp) | 65 if (!pApp) |
64 return; | 66 return; |
65 | 67 |
66 CFWL_NoteDriver* pDriver = | 68 CFWL_NoteDriver* pDriver = |
67 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 69 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
68 CFX_RectF rtWidget; | 70 CFX_RectF rtWidget; |
69 GetWidgetRect(rtWidget); | 71 GetWidgetRect(rtWidget); |
70 rtWidget.left = rtWidget.top = 0; | 72 rtWidget.left = rtWidget.top = 0; |
| 73 |
| 74 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
71 if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) { | 75 if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) { |
72 m_bLButtonDown = true; | 76 m_bLButtonDown = true; |
73 pDriver->SetGrab(this, true); | 77 pDriver->SetGrab(this, true); |
74 } else { | 78 } else { |
75 m_bLButtonDown = false; | 79 m_bLButtonDown = false; |
76 pDriver->SetGrab(this, false); | 80 pDriver->SetGrab(this, false); |
77 m_pComboBox->ShowDropList(false); | 81 m_pComboBox->ShowDropList(false); |
78 } | 82 } |
79 } | 83 } |
80 | 84 |
81 void IFWL_ComboBoxProxy::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 85 void IFWL_ComboBoxProxy::OnLButtonUp(CFWL_Message* pMessage) { |
82 m_bLButtonDown = false; | 86 m_bLButtonDown = false; |
83 const IFWL_App* pApp = GetOwnerApp(); | 87 const IFWL_App* pApp = GetOwnerApp(); |
84 if (!pApp) | 88 if (!pApp) |
85 return; | 89 return; |
86 | 90 |
87 CFWL_NoteDriver* pDriver = | 91 CFWL_NoteDriver* pDriver = |
88 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 92 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
89 pDriver->SetGrab(this, false); | 93 pDriver->SetGrab(this, false); |
90 if (!m_bLButtonUpSelf) { | 94 if (!m_bLButtonUpSelf) { |
91 m_bLButtonUpSelf = true; | 95 m_bLButtonUpSelf = true; |
92 return; | 96 return; |
93 } | 97 } |
94 | 98 |
| 99 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
95 CFX_RectF rect; | 100 CFX_RectF rect; |
96 GetWidgetRect(rect); | 101 GetWidgetRect(rect); |
97 rect.left = rect.top = 0; | 102 rect.left = rect.top = 0; |
98 if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && | 103 if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && |
99 m_pComboBox->IsDropListVisible()) { | 104 m_pComboBox->IsDropListVisible()) { |
100 m_pComboBox->ShowDropList(false); | 105 m_pComboBox->ShowDropList(false); |
101 } | 106 } |
102 } | 107 } |
103 | 108 |
104 void IFWL_ComboBoxProxy::OnFocusChanged(CFWL_MsgKillFocus* pMsg, bool bSet) { | 109 void IFWL_ComboBoxProxy::OnFocusChanged(CFWL_Message* pMessage, bool bSet) { |
105 if (bSet) | 110 if (bSet) |
106 return; | 111 return; |
| 112 |
| 113 CFWL_MsgKillFocus* pMsg = static_cast<CFWL_MsgKillFocus*>(pMessage); |
107 if (!pMsg->m_pSetFocus) | 114 if (!pMsg->m_pSetFocus) |
108 m_pComboBox->ShowDropList(false); | 115 m_pComboBox->ShowDropList(false); |
109 } | 116 } |
OLD | NEW |