| 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/cfwl_comboboxproxy.h" | 7 #include "xfa/fwl/cfwl_comboboxproxy.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "xfa/fwl/core/cfwl_app.h" | 12 #include "xfa/fwl/cfwl_app.h" |
| 13 #include "xfa/fwl/core/cfwl_combobox.h" | 13 #include "xfa/fwl/cfwl_combobox.h" |
| 14 #include "xfa/fwl/core/cfwl_msgkillfocus.h" | 14 #include "xfa/fwl/cfwl_messagekillfocus.h" |
| 15 #include "xfa/fwl/core/cfwl_msgmouse.h" | 15 #include "xfa/fwl/cfwl_messagemouse.h" |
| 16 #include "xfa/fwl/core/cfwl_notedriver.h" | 16 #include "xfa/fwl/cfwl_notedriver.h" |
| 17 | 17 |
| 18 CFWL_ComboBoxProxy::CFWL_ComboBoxProxy( | 18 CFWL_ComboBoxProxy::CFWL_ComboBoxProxy( |
| 19 CFWL_ComboBox* pComboBox, | 19 CFWL_ComboBox* pComboBox, |
| 20 const CFWL_App* app, | 20 const CFWL_App* app, |
| 21 std::unique_ptr<CFWL_WidgetProperties> properties, | 21 std::unique_ptr<CFWL_WidgetProperties> properties, |
| 22 CFWL_Widget* pOuter) | 22 CFWL_Widget* pOuter) |
| 23 : CFWL_FormProxy(app, std::move(properties), pOuter), | 23 : CFWL_FormProxy(app, std::move(properties), pOuter), |
| 24 m_bLButtonDown(false), | 24 m_bLButtonDown(false), |
| 25 m_bLButtonUpSelf(false), | 25 m_bLButtonUpSelf(false), |
| 26 m_pComboBox(pComboBox) {} | 26 m_pComboBox(pComboBox) {} |
| 27 | 27 |
| 28 CFWL_ComboBoxProxy::~CFWL_ComboBoxProxy() {} | 28 CFWL_ComboBoxProxy::~CFWL_ComboBoxProxy() {} |
| 29 | 29 |
| 30 void CFWL_ComboBoxProxy::OnProcessMessage(CFWL_Message* pMessage) { | 30 void CFWL_ComboBoxProxy::OnProcessMessage(CFWL_Message* pMessage) { |
| 31 if (!pMessage) | 31 if (!pMessage) |
| 32 return; | 32 return; |
| 33 | 33 |
| 34 switch (pMessage->GetType()) { | 34 switch (pMessage->GetType()) { |
| 35 case CFWL_Message::Type::Mouse: { | 35 case CFWL_Message::Type::Mouse: { |
| 36 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 36 CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); |
| 37 switch (pMsg->m_dwCmd) { | 37 switch (pMsg->m_dwCmd) { |
| 38 case FWL_MouseCommand::LeftButtonDown: | 38 case FWL_MouseCommand::LeftButtonDown: |
| 39 OnLButtonDown(pMsg); | 39 OnLButtonDown(pMsg); |
| 40 break; | 40 break; |
| 41 case FWL_MouseCommand::LeftButtonUp: | 41 case FWL_MouseCommand::LeftButtonUp: |
| 42 OnLButtonUp(pMsg); | 42 OnLButtonUp(pMsg); |
| 43 break; | 43 break; |
| 44 default: | 44 default: |
| 45 break; | 45 break; |
| 46 } | 46 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 66 void CFWL_ComboBoxProxy::OnLButtonDown(CFWL_Message* pMessage) { | 66 void CFWL_ComboBoxProxy::OnLButtonDown(CFWL_Message* pMessage) { |
| 67 const CFWL_App* pApp = GetOwnerApp(); | 67 const CFWL_App* pApp = GetOwnerApp(); |
| 68 if (!pApp) | 68 if (!pApp) |
| 69 return; | 69 return; |
| 70 | 70 |
| 71 CFWL_NoteDriver* pDriver = | 71 CFWL_NoteDriver* pDriver = |
| 72 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 72 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 73 CFX_RectF rtWidget = GetWidgetRect(); | 73 CFX_RectF rtWidget = GetWidgetRect(); |
| 74 rtWidget.left = rtWidget.top = 0; | 74 rtWidget.left = rtWidget.top = 0; |
| 75 | 75 |
| 76 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 76 CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); |
| 77 if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) { | 77 if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 78 m_bLButtonDown = true; | 78 m_bLButtonDown = true; |
| 79 pDriver->SetGrab(this, true); | 79 pDriver->SetGrab(this, true); |
| 80 } else { | 80 } else { |
| 81 m_bLButtonDown = false; | 81 m_bLButtonDown = false; |
| 82 pDriver->SetGrab(this, false); | 82 pDriver->SetGrab(this, false); |
| 83 m_pComboBox->ShowDropList(false); | 83 m_pComboBox->ShowDropList(false); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 void CFWL_ComboBoxProxy::OnLButtonUp(CFWL_Message* pMessage) { | 87 void CFWL_ComboBoxProxy::OnLButtonUp(CFWL_Message* pMessage) { |
| 88 m_bLButtonDown = false; | 88 m_bLButtonDown = false; |
| 89 const CFWL_App* pApp = GetOwnerApp(); | 89 const CFWL_App* pApp = GetOwnerApp(); |
| 90 if (!pApp) | 90 if (!pApp) |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 CFWL_NoteDriver* pDriver = | 93 CFWL_NoteDriver* pDriver = |
| 94 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 94 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 95 pDriver->SetGrab(this, false); | 95 pDriver->SetGrab(this, false); |
| 96 if (!m_bLButtonUpSelf) { | 96 if (!m_bLButtonUpSelf) { |
| 97 m_bLButtonUpSelf = true; | 97 m_bLButtonUpSelf = true; |
| 98 return; | 98 return; |
| 99 } | 99 } |
| 100 | 100 |
| 101 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 101 CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); |
| 102 CFX_RectF rect = GetWidgetRect(); | 102 CFX_RectF rect = GetWidgetRect(); |
| 103 rect.left = rect.top = 0; | 103 rect.left = rect.top = 0; |
| 104 if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && | 104 if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && |
| 105 m_pComboBox->IsDropListVisible()) { | 105 m_pComboBox->IsDropListVisible()) { |
| 106 m_pComboBox->ShowDropList(false); | 106 m_pComboBox->ShowDropList(false); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 void CFWL_ComboBoxProxy::OnFocusChanged(CFWL_Message* pMessage, bool bSet) { | 110 void CFWL_ComboBoxProxy::OnFocusChanged(CFWL_Message* pMessage, bool bSet) { |
| 111 if (bSet) | 111 if (bSet) |
| 112 return; | 112 return; |
| 113 | 113 |
| 114 CFWL_MsgKillFocus* pMsg = static_cast<CFWL_MsgKillFocus*>(pMessage); | 114 CFWL_MessageKillFocus* pMsg = static_cast<CFWL_MessageKillFocus*>(pMessage); |
| 115 if (!pMsg->m_pSetFocus) | 115 if (!pMsg->m_pSetFocus) |
| 116 m_pComboBox->ShowDropList(false); | 116 m_pComboBox->ShowDropList(false); |
| 117 } | 117 } |
| OLD | NEW |