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_datetimepicker.h" | 7 #include "xfa/fwl/core/ifwl_datetimepicker.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "third_party/base/ptr_util.h" | 12 #include "third_party/base/ptr_util.h" |
13 #include "xfa/fwl/core/cfwl_evteditchanged.h" | 13 #include "xfa/fwl/core/cfwl_evteditchanged.h" |
14 #include "xfa/fwl/core/cfwl_evtselectchanged.h" | 14 #include "xfa/fwl/core/cfwl_evtselectchanged.h" |
| 15 #include "xfa/fwl/core/cfwl_formproxy.h" |
15 #include "xfa/fwl/core/cfwl_msgmouse.h" | 16 #include "xfa/fwl/core/cfwl_msgmouse.h" |
16 #include "xfa/fwl/core/cfwl_msgsetfocus.h" | 17 #include "xfa/fwl/core/cfwl_msgsetfocus.h" |
17 #include "xfa/fwl/core/cfwl_notedriver.h" | 18 #include "xfa/fwl/core/cfwl_notedriver.h" |
| 19 #include "xfa/fwl/core/cfwl_spinbutton.h" |
18 #include "xfa/fwl/core/cfwl_themebackground.h" | 20 #include "xfa/fwl/core/cfwl_themebackground.h" |
19 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 21 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
20 #include "xfa/fwl/core/ifwl_formproxy.h" | |
21 #include "xfa/fwl/core/ifwl_spinbutton.h" | |
22 #include "xfa/fwl/core/ifwl_themeprovider.h" | 22 #include "xfa/fwl/core/ifwl_themeprovider.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 const int kDateTimePickerWidth = 100; | 26 const int kDateTimePickerWidth = 100; |
27 const int kDateTimePickerHeight = 20; | 27 const int kDateTimePickerHeight = 20; |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 IFWL_DateTimePicker::IFWL_DateTimePicker( | 31 IFWL_DateTimePicker::IFWL_DateTimePicker( |
32 const CFWL_App* app, | 32 const CFWL_App* app, |
33 std::unique_ptr<CFWL_WidgetProperties> properties) | 33 std::unique_ptr<CFWL_WidgetProperties> properties) |
34 : IFWL_Widget(app, std::move(properties), nullptr), | 34 : IFWL_Widget(app, std::move(properties), nullptr), |
35 m_iBtnState(1), | 35 m_iBtnState(1), |
36 m_iYear(-1), | 36 m_iYear(-1), |
37 m_iMonth(-1), | 37 m_iMonth(-1), |
38 m_iDay(-1), | 38 m_iDay(-1), |
39 m_bLBtnDown(false) { | 39 m_bLBtnDown(false) { |
40 m_rtBtn.Set(0, 0, 0, 0); | 40 m_rtBtn.Set(0, 0, 0, 0); |
41 | 41 |
42 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; | 42 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; |
43 | 43 |
44 auto monthProp = pdfium::MakeUnique<CFWL_WidgetProperties>(); | 44 auto monthProp = pdfium::MakeUnique<CFWL_WidgetProperties>(); |
45 monthProp->m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; | 45 monthProp->m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; |
46 monthProp->m_dwStates = FWL_WGTSTATE_Invisible; | 46 monthProp->m_dwStates = FWL_WGTSTATE_Invisible; |
47 monthProp->m_pParent = this; | 47 monthProp->m_pParent = this; |
48 monthProp->m_pThemeProvider = m_pProperties->m_pThemeProvider; | 48 monthProp->m_pThemeProvider = m_pProperties->m_pThemeProvider; |
49 m_pMonthCal.reset( | 49 m_pMonthCal.reset( |
50 new IFWL_MonthCalendar(m_pOwnerApp, std::move(monthProp), this)); | 50 new CFWL_MonthCalendar(m_pOwnerApp, std::move(monthProp), this)); |
51 | 51 |
52 CFX_RectF rtMonthCal; | 52 CFX_RectF rtMonthCal; |
53 m_pMonthCal->GetWidgetRect(rtMonthCal, true); | 53 m_pMonthCal->GetWidgetRect(rtMonthCal, true); |
54 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); | 54 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); |
55 m_pMonthCal->SetWidgetRect(rtMonthCal); | 55 m_pMonthCal->SetWidgetRect(rtMonthCal); |
56 | 56 |
57 auto editProp = pdfium::MakeUnique<CFWL_WidgetProperties>(); | 57 auto editProp = pdfium::MakeUnique<CFWL_WidgetProperties>(); |
58 editProp->m_pParent = this; | 58 editProp->m_pParent = this; |
59 editProp->m_pThemeProvider = m_pProperties->m_pThemeProvider; | 59 editProp->m_pThemeProvider = m_pProperties->m_pThemeProvider; |
60 | 60 |
61 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, std::move(editProp), this)); | 61 m_pEdit.reset(new CFWL_DateTimeEdit(m_pOwnerApp, std::move(editProp), this)); |
62 RegisterEventTarget(m_pMonthCal.get()); | 62 RegisterEventTarget(m_pMonthCal.get()); |
63 RegisterEventTarget(m_pEdit.get()); | 63 RegisterEventTarget(m_pEdit.get()); |
64 } | 64 } |
65 | 65 |
66 IFWL_DateTimePicker::~IFWL_DateTimePicker() { | 66 IFWL_DateTimePicker::~IFWL_DateTimePicker() { |
67 UnregisterEventTarget(); | 67 UnregisterEventTarget(); |
68 } | 68 } |
69 | 69 |
70 FWL_Type IFWL_DateTimePicker::GetClassID() const { | 70 FWL_Type IFWL_DateTimePicker::GetClassID() const { |
71 return FWL_Type::DateTimePicker; | 71 return FWL_Type::DateTimePicker; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if (m_pForm) | 364 if (m_pForm) |
365 return; | 365 return; |
366 if (!m_pMonthCal) | 366 if (!m_pMonthCal) |
367 return; | 367 return; |
368 | 368 |
369 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); | 369 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); |
370 prop->m_dwStyles = FWL_WGTSTYLE_Popup; | 370 prop->m_dwStyles = FWL_WGTSTYLE_Popup; |
371 prop->m_dwStates = FWL_WGTSTATE_Invisible; | 371 prop->m_dwStates = FWL_WGTSTATE_Invisible; |
372 prop->m_pOwner = this; | 372 prop->m_pOwner = this; |
373 | 373 |
374 m_pForm = pdfium::MakeUnique<IFWL_FormProxy>(m_pOwnerApp, std::move(prop), | 374 m_pForm = pdfium::MakeUnique<CFWL_FormProxy>(m_pOwnerApp, std::move(prop), |
375 m_pMonthCal.get()); | 375 m_pMonthCal.get()); |
376 m_pMonthCal->SetParent(m_pForm.get()); | 376 m_pMonthCal->SetParent(m_pForm.get()); |
377 } | 377 } |
378 | 378 |
379 bool IFWL_DateTimePicker::DisForm_IsMonthCalendarVisible() const { | 379 bool IFWL_DateTimePicker::DisForm_IsMonthCalendarVisible() const { |
380 if (!m_pMonthCal) | 380 if (!m_pMonthCal) |
381 return false; | 381 return false; |
382 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); | 382 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); |
383 } | 383 } |
384 | 384 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 if (DisForm_IsMonthCalendarVisible()) | 652 if (DisForm_IsMonthCalendarVisible()) |
653 ShowMonthCalendar(false); | 653 ShowMonthCalendar(false); |
654 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { | 654 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { |
655 pMsg->m_pSrcTarget = m_pEdit.get(); | 655 pMsg->m_pSrcTarget = m_pEdit.get(); |
656 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 656 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
657 } | 657 } |
658 } | 658 } |
659 rtInvalidate.Inflate(2, 2); | 659 rtInvalidate.Inflate(2, 2); |
660 Repaint(&rtInvalidate); | 660 Repaint(&rtInvalidate); |
661 } | 661 } |
OLD | NEW |