| 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/cfwl_datetimeedit.h" | |
| 8 | |
| 9 #include <memory> | |
| 10 #include <utility> | |
| 11 | |
| 12 #include "third_party/base/ptr_util.h" | |
| 13 #include "xfa/fwl/core/cfwl_datetimepicker.h" | |
| 14 #include "xfa/fwl/core/cfwl_msgmouse.h" | |
| 15 #include "xfa/fwl/core/cfwl_widgetmgr.h" | |
| 16 | |
| 17 CFWL_DateTimeEdit::CFWL_DateTimeEdit( | |
| 18 const CFWL_App* app, | |
| 19 std::unique_ptr<CFWL_WidgetProperties> properties, | |
| 20 CFWL_Widget* pOuter) | |
| 21 : CFWL_Edit(app, std::move(properties), pOuter) {} | |
| 22 | |
| 23 void CFWL_DateTimeEdit::OnProcessMessage(CFWL_Message* pMessage) { | |
| 24 if (m_pWidgetMgr->IsFormDisabled()) { | |
| 25 DisForm_OnProcessMessage(pMessage); | |
| 26 return; | |
| 27 } | |
| 28 | |
| 29 CFWL_Message::Type type = pMessage->GetType(); | |
| 30 if (type == CFWL_Message::Type::SetFocus || | |
| 31 type == CFWL_Message::Type::KillFocus) { | |
| 32 CFWL_Widget* pOuter = GetOuter(); | |
| 33 pOuter->GetDelegate()->OnProcessMessage(pMessage); | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 void CFWL_DateTimeEdit::DisForm_OnProcessMessage(CFWL_Message* pMessage) { | |
| 38 if (!m_pWidgetMgr->IsFormDisabled() || | |
| 39 pMessage->GetType() != CFWL_Message::Type::Mouse) { | |
| 40 CFWL_Edit::OnProcessMessage(pMessage); | |
| 41 return; | |
| 42 } | |
| 43 | |
| 44 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); | |
| 45 if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown || | |
| 46 pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) { | |
| 47 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) | |
| 48 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | |
| 49 | |
| 50 CFWL_DateTimePicker* pDateTime = | |
| 51 static_cast<CFWL_DateTimePicker*>(m_pOuter); | |
| 52 if (pDateTime->IsMonthCalendarVisible()) { | |
| 53 CFX_RectF rtInvalidate = pDateTime->GetWidgetRect(); | |
| 54 pDateTime->ShowMonthCalendar(false); | |
| 55 rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); | |
| 56 pDateTime->Repaint(&rtInvalidate); | |
| 57 } | |
| 58 } | |
| 59 CFWL_Edit::OnProcessMessage(pMessage); | |
| 60 } | |
| OLD | NEW |