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 "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fwl/core/cfwl_message.h" | 10 #include "xfa/fwl/core/cfwl_message.h" |
11 #include "xfa/fwl/core/cfwl_themebackground.h" | 11 #include "xfa/fwl/core/cfwl_themebackground.h" |
12 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 12 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
13 #include "xfa/fwl/core/fwl_noteimp.h" | 13 #include "xfa/fwl/core/fwl_noteimp.h" |
14 #include "xfa/fwl/core/ifwl_datetimecalendar.h" | 14 #include "xfa/fwl/core/ifwl_datetimecalendar.h" |
15 #include "xfa/fwl/core/ifwl_datetimeedit.h" | 15 #include "xfa/fwl/core/ifwl_datetimeedit.h" |
16 #include "xfa/fwl/core/ifwl_formproxy.h" | 16 #include "xfa/fwl/core/ifwl_formproxy.h" |
17 #include "xfa/fwl/core/ifwl_spinbutton.h" | 17 #include "xfa/fwl/core/ifwl_spinbutton.h" |
18 #include "xfa/fwl/core/ifwl_themeprovider.h" | 18 #include "xfa/fwl/core/ifwl_themeprovider.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 const int kDateTimePickerWidth = 100; | 22 const int kDateTimePickerWidth = 100; |
23 const int kDateTimePickerHeight = 20; | 23 const int kDateTimePickerHeight = 20; |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 IFWL_DateTimePicker::IFWL_DateTimePicker( | 27 IFWL_DateTimePicker::IFWL_DateTimePicker( |
28 const IFWL_App* app, | 28 const IFWL_App* app, |
29 const CFWL_WidgetImpProperties& properties) | 29 std::unique_ptr<CFWL_WidgetProperties> properties) |
30 : IFWL_Widget(app, properties, nullptr), | 30 : IFWL_Widget(app, std::move(properties), nullptr), |
31 m_iBtnState(1), | 31 m_iBtnState(1), |
32 m_iYear(-1), | 32 m_iYear(-1), |
33 m_iMonth(-1), | 33 m_iMonth(-1), |
34 m_iDay(-1), | 34 m_iDay(-1), |
35 m_bLBtnDown(false) { | 35 m_bLBtnDown(false) { |
36 m_rtBtn.Set(0, 0, 0, 0); | 36 m_rtBtn.Set(0, 0, 0, 0); |
37 | 37 |
38 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; | 38 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; |
39 CFWL_WidgetImpProperties propMonth; | |
40 propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; | |
41 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; | |
42 propMonth.m_pDataProvider = &m_MonthCalendarDP; | |
43 propMonth.m_pParent = this; | |
44 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; | |
45 | 39 |
46 m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this)); | 40 auto propMonth = |
Tom Sepez
2016/11/03 18:22:44
nit: same, monthProp.
dsinclair
2016/11/03 19:10:18
Done.
| |
41 pdfium::MakeUnique<CFWL_WidgetProperties>(&m_MonthCalendarDP); | |
42 propMonth->m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; | |
43 propMonth->m_dwStates = FWL_WGTSTATE_Invisible; | |
44 propMonth->m_pParent = this; | |
45 propMonth->m_pThemeProvider = m_pProperties->m_pThemeProvider; | |
46 m_pMonthCal.reset( | |
47 new IFWL_DateTimeCalendar(m_pOwnerApp, std::move(propMonth), this)); | |
48 | |
47 CFX_RectF rtMonthCal; | 49 CFX_RectF rtMonthCal; |
48 m_pMonthCal->GetWidgetRect(rtMonthCal, true); | 50 m_pMonthCal->GetWidgetRect(rtMonthCal, true); |
49 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); | 51 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); |
50 m_pMonthCal->SetWidgetRect(rtMonthCal); | 52 m_pMonthCal->SetWidgetRect(rtMonthCal); |
51 CFWL_WidgetImpProperties propEdit; | |
52 propEdit.m_pParent = this; | |
53 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; | |
54 | 53 |
55 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this)); | 54 auto propEdit = pdfium::MakeUnique<CFWL_WidgetProperties>(); |
55 propEdit->m_pParent = this; | |
56 propEdit->m_pThemeProvider = m_pProperties->m_pThemeProvider; | |
57 | |
58 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, std::move(propEdit), this)); | |
56 RegisterEventTarget(m_pMonthCal.get()); | 59 RegisterEventTarget(m_pMonthCal.get()); |
57 RegisterEventTarget(m_pEdit.get()); | 60 RegisterEventTarget(m_pEdit.get()); |
58 } | 61 } |
59 | 62 |
60 IFWL_DateTimePicker::~IFWL_DateTimePicker() { | 63 IFWL_DateTimePicker::~IFWL_DateTimePicker() { |
61 UnregisterEventTarget(); | 64 UnregisterEventTarget(); |
62 } | 65 } |
63 | 66 |
64 FWL_Type IFWL_DateTimePicker::GetClassID() const { | 67 FWL_Type IFWL_DateTimePicker::GetClassID() const { |
65 return FWL_Type::DateTimePicker; | 68 return FWL_Type::DateTimePicker; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 ev.iMonth = m_iMonth; | 429 ev.iMonth = m_iMonth; |
427 ev.iDay = m_iDay; | 430 ev.iDay = m_iDay; |
428 DispatchEvent(&ev); | 431 DispatchEvent(&ev); |
429 } | 432 } |
430 | 433 |
431 void IFWL_DateTimePicker::InitProxyForm() { | 434 void IFWL_DateTimePicker::InitProxyForm() { |
432 if (m_pForm) | 435 if (m_pForm) |
433 return; | 436 return; |
434 if (!m_pMonthCal) | 437 if (!m_pMonthCal) |
435 return; | 438 return; |
436 CFWL_WidgetImpProperties propForm; | |
437 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; | |
438 propForm.m_dwStates = FWL_WGTSTATE_Invisible; | |
439 propForm.m_pOwner = this; | |
440 | 439 |
441 m_pForm.reset(new IFWL_FormProxy(m_pOwnerApp, propForm, m_pMonthCal.get())); | 440 auto propForm = pdfium::MakeUnique<CFWL_WidgetProperties>(); |
Tom Sepez
2016/11/03 18:22:44
ditto and below.
dsinclair
2016/11/03 19:10:18
Done.
| |
441 propForm->m_dwStyles = FWL_WGTSTYLE_Popup; | |
442 propForm->m_dwStates = FWL_WGTSTATE_Invisible; | |
443 propForm->m_pOwner = this; | |
444 | |
445 m_pForm.reset( | |
446 new IFWL_FormProxy(m_pOwnerApp, std::move(propForm), m_pMonthCal.get())); | |
442 m_pMonthCal->SetParent(m_pForm.get()); | 447 m_pMonthCal->SetParent(m_pForm.get()); |
443 } | 448 } |
444 | 449 |
445 IFWL_DateTimeEdit* IFWL_DateTimePicker::GetDataTimeEdit() { | 450 IFWL_DateTimeEdit* IFWL_DateTimePicker::GetDataTimeEdit() { |
446 return m_pEdit.get(); | 451 return m_pEdit.get(); |
447 } | 452 } |
448 | 453 |
449 FWL_Error IFWL_DateTimePicker::DisForm_Initialize() { | 454 FWL_Error IFWL_DateTimePicker::DisForm_Initialize() { |
450 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; | 455 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; |
451 DisForm_InitDateTimeCalendar(); | 456 DisForm_InitDateTimeCalendar(); |
452 DisForm_InitDateTimeEdit(); | 457 DisForm_InitDateTimeEdit(); |
453 RegisterEventTarget(m_pMonthCal.get()); | 458 RegisterEventTarget(m_pMonthCal.get()); |
454 RegisterEventTarget(m_pEdit.get()); | 459 RegisterEventTarget(m_pEdit.get()); |
455 return FWL_Error::Succeeded; | 460 return FWL_Error::Succeeded; |
456 } | 461 } |
457 | 462 |
458 void IFWL_DateTimePicker::DisForm_InitDateTimeCalendar() { | 463 void IFWL_DateTimePicker::DisForm_InitDateTimeCalendar() { |
459 if (m_pMonthCal) { | 464 if (m_pMonthCal) { |
Tom Sepez
2016/11/03 18:22:44
nit: no {} while were at it.
dsinclair
2016/11/03 19:10:18
Done.
| |
460 return; | 465 return; |
461 } | 466 } |
462 CFWL_WidgetImpProperties propMonth; | 467 auto propMonth = |
463 propMonth.m_dwStyles = | 468 pdfium::MakeUnique<CFWL_WidgetProperties>(&m_MonthCalendarDP); |
469 propMonth->m_dwStyles = | |
464 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; | 470 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; |
465 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; | 471 propMonth->m_dwStates = FWL_WGTSTATE_Invisible; |
466 propMonth.m_pParent = this; | 472 propMonth->m_pParent = this; |
467 propMonth.m_pDataProvider = &m_MonthCalendarDP; | 473 propMonth->m_pThemeProvider = m_pProperties->m_pThemeProvider; |
468 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; | |
469 | 474 |
470 m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this)); | 475 m_pMonthCal.reset( |
476 new IFWL_DateTimeCalendar(m_pOwnerApp, std::move(propMonth), this)); | |
471 CFX_RectF rtMonthCal; | 477 CFX_RectF rtMonthCal; |
472 m_pMonthCal->GetWidgetRect(rtMonthCal, true); | 478 m_pMonthCal->GetWidgetRect(rtMonthCal, true); |
473 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); | 479 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); |
474 m_pMonthCal->SetWidgetRect(rtMonthCal); | 480 m_pMonthCal->SetWidgetRect(rtMonthCal); |
475 } | 481 } |
476 | 482 |
477 void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() { | 483 void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() { |
478 if (m_pEdit) { | 484 if (m_pEdit) { |
Tom Sepez
2016/11/03 18:22:44
nit: no {}
dsinclair
2016/11/03 19:10:17
Done.
| |
479 return; | 485 return; |
480 } | 486 } |
481 CFWL_WidgetImpProperties propEdit; | 487 auto propEdit = pdfium::MakeUnique<CFWL_WidgetProperties>(); |
482 propEdit.m_pParent = this; | 488 propEdit->m_pParent = this; |
483 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 489 propEdit->m_pThemeProvider = m_pProperties->m_pThemeProvider; |
484 | 490 |
485 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this)); | 491 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, std::move(propEdit), this)); |
486 } | 492 } |
487 | 493 |
488 bool IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() { | 494 bool IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() { |
489 if (!m_pMonthCal) | 495 if (!m_pMonthCal) |
490 return false; | 496 return false; |
491 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); | 497 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); |
492 } | 498 } |
493 | 499 |
494 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) { | 500 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) { |
495 bool bShowed = IsMonthCalendarShowed(); | 501 bool bShowed = IsMonthCalendarShowed(); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
802 | 808 |
803 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth( | 809 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth( |
804 IFWL_Widget* pWidget) { | 810 IFWL_Widget* pWidget) { |
805 return m_iCurMonth; | 811 return m_iCurMonth; |
806 } | 812 } |
807 | 813 |
808 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear( | 814 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear( |
809 IFWL_Widget* pWidget) { | 815 IFWL_Widget* pWidget) { |
810 return m_iCurYear; | 816 return m_iCurYear; |
811 } | 817 } |
OLD | NEW |