OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 |
| 7 #include "xfa/fwl/core/ifwl_datetimeedit.h" |
| 8 |
| 9 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
| 10 #include "xfa/fwl/core/ifwl_datetimepicker.h" |
| 11 |
| 12 // static |
| 13 IFWL_DateTimeEdit* IFWL_DateTimeEdit::Create( |
| 14 const CFWL_WidgetImpProperties& properties, |
| 15 IFWL_Widget* pOuter) { |
| 16 return new IFWL_DateTimeEdit(properties, pOuter); |
| 17 } |
| 18 |
| 19 IFWL_DateTimeEdit::IFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties, |
| 20 IFWL_Widget* pOuter) |
| 21 : IFWL_Edit(properties, pOuter) {} |
| 22 |
| 23 FWL_Error IFWL_DateTimeEdit::Initialize() { |
| 24 m_pDelegate = new CFWL_DateTimeEditImpDelegate(this); |
| 25 if (IFWL_Edit::Initialize() != FWL_Error::Succeeded) |
| 26 return FWL_Error::Indefinite; |
| 27 return FWL_Error::Succeeded; |
| 28 } |
| 29 |
| 30 FWL_Error IFWL_DateTimeEdit::Finalize() { |
| 31 delete m_pDelegate; |
| 32 m_pDelegate = nullptr; |
| 33 return IFWL_Edit::Finalize(); |
| 34 } |
| 35 |
| 36 CFWL_DateTimeEditImpDelegate::CFWL_DateTimeEditImpDelegate( |
| 37 IFWL_DateTimeEdit* pOwner) |
| 38 : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {} |
| 39 |
| 40 void CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 41 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { |
| 42 DisForm_OnProcessMessage(pMessage); |
| 43 return; |
| 44 } |
| 45 |
| 46 CFWL_MessageType dwHashCode = pMessage->GetClassID(); |
| 47 if (dwHashCode == CFWL_MessageType::SetFocus || |
| 48 dwHashCode == CFWL_MessageType::KillFocus) { |
| 49 IFWL_Widget* pOuter = m_pOwner->GetOuter(); |
| 50 IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(nullptr); |
| 51 pDelegate->OnProcessMessage(pMessage); |
| 52 } |
| 53 } |
| 54 |
| 55 void CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( |
| 56 CFWL_Message* pMessage) { |
| 57 CFWL_MessageType dwHashCode = pMessage->GetClassID(); |
| 58 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { |
| 59 if (dwHashCode == CFWL_MessageType::Mouse) { |
| 60 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); |
| 61 if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown || |
| 62 pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) { |
| 63 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { |
| 64 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
| 65 } |
| 66 IFWL_DateTimePicker* pDateTime = |
| 67 static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); |
| 68 if (pDateTime->IsMonthCalendarShowed()) { |
| 69 CFX_RectF rtInvalidate; |
| 70 pDateTime->GetWidgetRect(rtInvalidate); |
| 71 pDateTime->ShowMonthCalendar(FALSE); |
| 72 rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); |
| 73 pDateTime->Repaint(&rtInvalidate); |
| 74 } |
| 75 } |
| 76 } |
| 77 } |
| 78 CFWL_EditImpDelegate::OnProcessMessage(pMessage); |
| 79 } |
OLD | NEW |