diff options
author | dsinclair <dsinclair@chromium.org> | 2016-11-01 18:48:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-01 18:48:20 -0700 |
commit | 6fe8795d9022105a0061a0a81be9a49d49fda345 (patch) | |
tree | b1fc8d51560fbf0a9e4a163f887e763f565d5234 /xfa/fwl/core/ifwl_datetimepicker.cpp | |
parent | 919e48d877e503f1ca250bc37324c9f7dc96d7a9 (diff) | |
download | pdfium-6fe8795d9022105a0061a0a81be9a49d49fda345.tar.xz |
Fold IFWL*::{Initialize|Finalize} into constructor/destructor
This Cl moves the ::Initialize method into the constructors and the
::Finalize method into the destructors. The |m_pDelegate| is made private and
a unique_ptr. A |SetDelegate| and |GetDelegate| method are added.
Review-Url: https://codereview.chromium.org/2464703006
Diffstat (limited to 'xfa/fwl/core/ifwl_datetimepicker.cpp')
-rw-r--r-- | xfa/fwl/core/ifwl_datetimepicker.cpp | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/xfa/fwl/core/ifwl_datetimepicker.cpp b/xfa/fwl/core/ifwl_datetimepicker.cpp index 148a85cfe6..844eb9ebe6 100644 --- a/xfa/fwl/core/ifwl_datetimepicker.cpp +++ b/xfa/fwl/core/ifwl_datetimepicker.cpp @@ -6,6 +6,7 @@ #include "xfa/fwl/core/ifwl_datetimepicker.h" +#include "third_party/base/ptr_util.h" #include "xfa/fwl/core/cfwl_message.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" @@ -33,14 +34,8 @@ IFWL_DateTimePicker::IFWL_DateTimePicker( m_iDay(-1), m_bLBtnDown(FALSE) { m_rtBtn.Set(0, 0, 0, 0); -} - -IFWL_DateTimePicker::~IFWL_DateTimePicker() {} - -void IFWL_DateTimePicker::Initialize() { - IFWL_Widget::Initialize(); - m_pDelegate = new CFWL_DateTimePickerImpDelegate(this); + SetDelegate(pdfium::MakeUnique<CFWL_DateTimePickerImpDelegate>(this)); m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; CFWL_WidgetImpProperties propMonth; @@ -51,7 +46,6 @@ void IFWL_DateTimePicker::Initialize() { propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this)); - m_pMonthCal->Initialize(); CFX_RectF rtMonthCal; m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); @@ -61,23 +55,12 @@ void IFWL_DateTimePicker::Initialize() { propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this)); - m_pEdit->Initialize(); RegisterEventTarget(m_pMonthCal.get()); RegisterEventTarget(m_pEdit.get()); } -void IFWL_DateTimePicker::Finalize() { - if (m_pEdit) - m_pEdit->Finalize(); - if (m_pMonthCal) - m_pMonthCal->Finalize(); - if (m_pForm) - m_pForm->Finalize(); - +IFWL_DateTimePicker::~IFWL_DateTimePicker() { UnregisterEventTarget(); - delete m_pDelegate; - m_pDelegate = nullptr; - IFWL_Widget::Finalize(); } FWL_Type IFWL_DateTimePicker::GetClassID() const { @@ -324,24 +307,19 @@ void IFWL_DateTimePicker::DrawDropDownButton(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) == FWL_STYLEEXT_DTP_Spin) { - CFWL_WidgetImpProperties prop; - prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; - prop.m_pParent = this; - prop.m_rtWidget = m_rtBtn; - IFWL_SpinButton* pSpin = new IFWL_SpinButton(m_pOwnerApp, prop); - pSpin->Initialize(); - } else { - CFWL_ThemeBackground param; - param.m_pWidget = this; - param.m_iPart = CFWL_Part::DropDownButton; - param.m_dwStates = m_iBtnState; - param.m_pGraphics = pGraphics; - param.m_rtPart = m_rtBtn; - if (pMatrix) { - param.m_matrix.Concat(*pMatrix); - } - pTheme->DrawBackground(¶m); + return; } + + CFWL_ThemeBackground param; + param.m_pWidget = this; + param.m_iPart = CFWL_Part::DropDownButton; + param.m_dwStates = m_iBtnState; + param.m_pGraphics = pGraphics; + param.m_rtPart = m_rtBtn; + if (pMatrix) + param.m_matrix.Concat(*pMatrix); + + pTheme->DrawBackground(¶m); } void IFWL_DateTimePicker::FormatDateString(int32_t iYear, @@ -464,7 +442,6 @@ void IFWL_DateTimePicker::InitProxyForm() { propForm.m_pOwner = this; m_pForm.reset(new IFWL_FormProxy(m_pOwnerApp, propForm, m_pMonthCal.get())); - m_pForm->Initialize(); m_pMonthCal->SetParent(m_pForm.get()); } @@ -494,7 +471,6 @@ void IFWL_DateTimePicker::DisForm_InitDateTimeCalendar() { propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this)); - m_pMonthCal->Initialize(); CFX_RectF rtMonthCal; m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); @@ -510,7 +486,6 @@ void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() { propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this)); - m_pEdit->Initialize(); } FX_BOOL IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() { |