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