| 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 "xfa/fwl/core/ifwl_datetimeedit.h" | 7 #include "xfa/fwl/core/ifwl_datetimeedit.h" |
| 8 | 8 |
| 9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
| 10 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 10 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
| 11 #include "xfa/fwl/core/ifwl_datetimepicker.h" | 11 #include "xfa/fwl/core/ifwl_datetimepicker.h" |
| 12 | 12 |
| 13 IFWL_DateTimeEdit::IFWL_DateTimeEdit(const IFWL_App* app, | 13 IFWL_DateTimeEdit::IFWL_DateTimeEdit(const IFWL_App* app, |
| 14 const CFWL_WidgetImpProperties& properties, | 14 const CFWL_WidgetImpProperties& properties, |
| 15 IFWL_Widget* pOuter) | 15 IFWL_Widget* pOuter) |
| 16 : IFWL_Edit(app, properties, pOuter) { | 16 : IFWL_Edit(app, properties, pOuter) {} |
| 17 SetDelegate(pdfium::MakeUnique<CFWL_DateTimeEditImpDelegate>(this)); | |
| 18 } | |
| 19 | 17 |
| 20 CFWL_DateTimeEditImpDelegate::CFWL_DateTimeEditImpDelegate( | 18 void IFWL_DateTimeEdit::OnProcessMessage(CFWL_Message* pMessage) { |
| 21 IFWL_DateTimeEdit* pOwner) | 19 if (m_pWidgetMgr->IsFormDisabled()) { |
| 22 : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {} | |
| 23 | |
| 24 void CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | |
| 25 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { | |
| 26 DisForm_OnProcessMessage(pMessage); | 20 DisForm_OnProcessMessage(pMessage); |
| 27 return; | 21 return; |
| 28 } | 22 } |
| 29 | 23 |
| 30 CFWL_MessageType dwHashCode = pMessage->GetClassID(); | 24 CFWL_MessageType dwHashCode = pMessage->GetClassID(); |
| 31 if (dwHashCode == CFWL_MessageType::SetFocus || | 25 if (dwHashCode == CFWL_MessageType::SetFocus || |
| 32 dwHashCode == CFWL_MessageType::KillFocus) { | 26 dwHashCode == CFWL_MessageType::KillFocus) { |
| 33 IFWL_Widget* pOuter = m_pOwner->GetOuter(); | 27 IFWL_Widget* pOuter = GetOuter(); |
| 34 pOuter->GetCurrentDelegate()->OnProcessMessage(pMessage); | 28 pOuter->GetDelegate()->OnProcessMessage(pMessage); |
| 35 } | 29 } |
| 36 } | 30 } |
| 37 | 31 |
| 38 void CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( | 32 void IFWL_DateTimeEdit::DisForm_OnProcessMessage(CFWL_Message* pMessage) { |
| 39 CFWL_Message* pMessage) { | |
| 40 CFWL_MessageType dwHashCode = pMessage->GetClassID(); | 33 CFWL_MessageType dwHashCode = pMessage->GetClassID(); |
| 41 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { | 34 if (m_pWidgetMgr->IsFormDisabled()) { |
| 42 if (dwHashCode == CFWL_MessageType::Mouse) { | 35 if (dwHashCode == CFWL_MessageType::Mouse) { |
| 43 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); | 36 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); |
| 44 if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown || | 37 if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown || |
| 45 pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) { | 38 pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) { |
| 46 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { | 39 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) |
| 47 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 40 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
| 48 } | 41 |
| 49 IFWL_DateTimePicker* pDateTime = | 42 IFWL_DateTimePicker* pDateTime = |
| 50 static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); | 43 static_cast<IFWL_DateTimePicker*>(m_pOuter); |
| 51 if (pDateTime->IsMonthCalendarShowed()) { | 44 if (pDateTime->IsMonthCalendarShowed()) { |
| 52 CFX_RectF rtInvalidate; | 45 CFX_RectF rtInvalidate; |
| 53 pDateTime->GetWidgetRect(rtInvalidate); | 46 pDateTime->GetWidgetRect(rtInvalidate); |
| 54 pDateTime->ShowMonthCalendar(FALSE); | 47 pDateTime->ShowMonthCalendar(FALSE); |
| 55 rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); | 48 rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); |
| 56 pDateTime->Repaint(&rtInvalidate); | 49 pDateTime->Repaint(&rtInvalidate); |
| 57 } | 50 } |
| 58 } | 51 } |
| 59 } | 52 } |
| 60 } | 53 } |
| 61 CFWL_EditImpDelegate::OnProcessMessage(pMessage); | 54 IFWL_Edit::OnProcessMessage(pMessage); |
| 62 } | 55 } |
| OLD | NEW |