Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: xfa/fwl/core/ifwl_datetimepicker.cpp

Issue 2480233003: Fold DataProviders into parent classes (Closed)
Patch Set: Review feedback Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/ifwl_datetimepicker.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 14 matching lines...) Expand all
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 std::unique_ptr<CFWL_WidgetProperties> properties) 29 std::unique_ptr<CFWL_WidgetProperties> properties)
30 : IFWL_Widget(app, std::move(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_iCurYear(2010),
37 m_iCurMonth(3),
38 m_iCurDay(29) {
36 m_rtBtn.Set(0, 0, 0, 0); 39 m_rtBtn.Set(0, 0, 0, 0);
37 40
38 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; 41 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
39 42
40 auto monthProp = 43 auto monthProp = pdfium::MakeUnique<CFWL_WidgetProperties>(this);
41 pdfium::MakeUnique<CFWL_WidgetProperties>(&m_MonthCalendarDP);
42 monthProp->m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; 44 monthProp->m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border;
43 monthProp->m_dwStates = FWL_WGTSTATE_Invisible; 45 monthProp->m_dwStates = FWL_WGTSTATE_Invisible;
44 monthProp->m_pParent = this; 46 monthProp->m_pParent = this;
45 monthProp->m_pThemeProvider = m_pProperties->m_pThemeProvider; 47 monthProp->m_pThemeProvider = m_pProperties->m_pThemeProvider;
46 m_pMonthCal.reset( 48 m_pMonthCal.reset(
47 new IFWL_DateTimeCalendar(m_pOwnerApp, std::move(monthProp), this)); 49 new IFWL_DateTimeCalendar(m_pOwnerApp, std::move(monthProp), this));
48 50
49 CFX_RectF rtMonthCal; 51 CFX_RectF rtMonthCal;
50 m_pMonthCal->GetWidgetRect(rtMonthCal, true); 52 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
51 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); 53 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 m_rtClient.height); 107 m_rtClient.height);
106 m_pEdit->SetWidgetRect(rtEdit); 108 m_pEdit->SetWidgetRect(rtEdit);
107 ReSetEditAlignment(); 109 ReSetEditAlignment();
108 m_pEdit->Update(); 110 m_pEdit->Update();
109 if (!(m_pMonthCal->GetThemeProvider())) { 111 if (!(m_pMonthCal->GetThemeProvider())) {
110 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); 112 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
111 } 113 }
112 if (m_pProperties->m_pDataProvider) { 114 if (m_pProperties->m_pDataProvider) {
113 IFWL_DateTimePickerDP* pData = 115 IFWL_DateTimePickerDP* pData =
114 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); 116 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
115 pData->GetToday(this, m_MonthCalendarDP.m_iCurYear, 117 pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay);
116 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
117 } 118 }
118 CFX_RectF rtMonthCal; 119 CFX_RectF rtMonthCal;
119 m_pMonthCal->GetWidgetRect(rtMonthCal, true); 120 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
120 CFX_RectF rtPopUp; 121 CFX_RectF rtPopUp;
121 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, 122 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
122 rtMonthCal.width, rtMonthCal.height); 123 rtMonthCal.width, rtMonthCal.height);
123 m_pMonthCal->SetWidgetRect(rtPopUp); 124 m_pMonthCal->SetWidgetRect(rtPopUp);
124 m_pMonthCal->Update(); 125 m_pMonthCal->Update();
125 return FWL_Error::Succeeded; 126 return FWL_Error::Succeeded;
126 } 127 }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 DisForm_InitDateTimeEdit(); 458 DisForm_InitDateTimeEdit();
458 RegisterEventTarget(m_pMonthCal.get()); 459 RegisterEventTarget(m_pMonthCal.get());
459 RegisterEventTarget(m_pEdit.get()); 460 RegisterEventTarget(m_pEdit.get());
460 return FWL_Error::Succeeded; 461 return FWL_Error::Succeeded;
461 } 462 }
462 463
463 void IFWL_DateTimePicker::DisForm_InitDateTimeCalendar() { 464 void IFWL_DateTimePicker::DisForm_InitDateTimeCalendar() {
464 if (m_pMonthCal) 465 if (m_pMonthCal)
465 return; 466 return;
466 467
467 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(&m_MonthCalendarDP); 468 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(this);
468 prop->m_dwStyles = 469 prop->m_dwStyles =
469 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; 470 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken;
470 prop->m_dwStates = FWL_WGTSTATE_Invisible; 471 prop->m_dwStates = FWL_WGTSTATE_Invisible;
471 prop->m_pParent = this; 472 prop->m_pParent = this;
472 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; 473 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
473 474
474 m_pMonthCal.reset( 475 m_pMonthCal.reset(
475 new IFWL_DateTimeCalendar(m_pOwnerApp, std::move(prop), this)); 476 new IFWL_DateTimeCalendar(m_pOwnerApp, std::move(prop), this));
476 CFX_RectF rtMonthCal; 477 CFX_RectF rtMonthCal;
477 m_pMonthCal->GetWidgetRect(rtMonthCal, true); 478 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 GetClientRect(m_rtClient); 569 GetClientRect(m_rtClient);
569 m_pEdit->SetWidgetRect(m_rtClient); 570 m_pEdit->SetWidgetRect(m_rtClient);
570 ReSetEditAlignment(); 571 ReSetEditAlignment();
571 m_pEdit->Update(); 572 m_pEdit->Update();
572 if (!m_pMonthCal->GetThemeProvider()) 573 if (!m_pMonthCal->GetThemeProvider())
573 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); 574 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
574 575
575 if (m_pProperties->m_pDataProvider) { 576 if (m_pProperties->m_pDataProvider) {
576 IFWL_DateTimePickerDP* pData = 577 IFWL_DateTimePickerDP* pData =
577 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); 578 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
578 pData->GetToday(this, m_MonthCalendarDP.m_iCurYear, 579 pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay);
579 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
580 } 580 }
581 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>( 581 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>(
582 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 582 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
583 if (!pWidth) 583 if (!pWidth)
584 return FWL_Error::Succeeded; 584 return FWL_Error::Succeeded;
585 585
586 m_fBtn = *pWidth; 586 m_fBtn = *pWidth;
587 CFX_RectF rtMonthCal; 587 CFX_RectF rtMonthCal;
588 m_pMonthCal->GetWidgetRect(rtMonthCal, true); 588 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
589 CFX_RectF rtPopUp; 589 CFX_RectF rtPopUp;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 ShowMonthCalendar(false); 781 ShowMonthCalendar(false);
782 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { 782 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
783 pMsg->m_pSrcTarget = m_pEdit.get(); 783 pMsg->m_pSrcTarget = m_pEdit.get();
784 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); 784 m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
785 } 785 }
786 } 786 }
787 rtInvalidate.Inflate(2, 2); 787 rtInvalidate.Inflate(2, 2);
788 Repaint(&rtInvalidate); 788 Repaint(&rtInvalidate);
789 } 789 }
790 790
791 IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::CFWL_MonthCalendarImpDP() { 791 FWL_Error IFWL_DateTimePicker::GetCaption(IFWL_Widget* pWidget,
792 m_iCurYear = 2010; 792 CFX_WideString& wsCaption) {
793 m_iCurMonth = 3;
794 m_iCurDay = 29;
795 }
796
797 FWL_Error IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCaption(
798 IFWL_Widget* pWidget,
799 CFX_WideString& wsCaption) {
800 return FWL_Error::Succeeded; 793 return FWL_Error::Succeeded;
801 } 794 }
802 795
803 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurDay( 796 int32_t IFWL_DateTimePicker::GetCurDay(IFWL_Widget* pWidget) {
804 IFWL_Widget* pWidget) {
805 return m_iCurDay; 797 return m_iCurDay;
806 } 798 }
807 799
808 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth( 800 int32_t IFWL_DateTimePicker::GetCurMonth(IFWL_Widget* pWidget) {
809 IFWL_Widget* pWidget) {
810 return m_iCurMonth; 801 return m_iCurMonth;
811 } 802 }
812 803
813 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear( 804 int32_t IFWL_DateTimePicker::GetCurYear(IFWL_Widget* pWidget) {
814 IFWL_Widget* pWidget) {
815 return m_iCurYear; 805 return m_iCurYear;
816 } 806 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_datetimepicker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698