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

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

Issue 2433133002: Remove IFWL_*::Create methods, use new (Closed)
Patch Set: Rebase to master Created 4 years, 2 months 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') | xfa/fwl/core/ifwl_edit.h » ('j') | 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 "xfa/fwl/core/cfwl_message.h" 9 #include "xfa/fwl/core/cfwl_message.h"
10 #include "xfa/fwl/core/cfwl_themebackground.h" 10 #include "xfa/fwl/core/cfwl_themebackground.h"
11 #include "xfa/fwl/core/cfwl_widgetmgr.h" 11 #include "xfa/fwl/core/cfwl_widgetmgr.h"
12 #include "xfa/fwl/core/fwl_noteimp.h" 12 #include "xfa/fwl/core/fwl_noteimp.h"
13 #include "xfa/fwl/core/ifwl_datetimecalendar.h" 13 #include "xfa/fwl/core/ifwl_datetimecalendar.h"
14 #include "xfa/fwl/core/ifwl_datetimeedit.h" 14 #include "xfa/fwl/core/ifwl_datetimeedit.h"
15 #include "xfa/fwl/core/ifwl_formproxy.h" 15 #include "xfa/fwl/core/ifwl_formproxy.h"
16 #include "xfa/fwl/core/ifwl_spinbutton.h" 16 #include "xfa/fwl/core/ifwl_spinbutton.h"
17 #include "xfa/fwl/core/ifwl_themeprovider.h" 17 #include "xfa/fwl/core/ifwl_themeprovider.h"
18 18
19 namespace { 19 namespace {
20 20
21 const int kDateTimePickerWidth = 100; 21 const int kDateTimePickerWidth = 100;
22 const int kDateTimePickerHeight = 20; 22 const int kDateTimePickerHeight = 20;
23 23
24 } // namespace 24 } // namespace
25 25
26 // static
27 IFWL_DateTimePicker* IFWL_DateTimePicker::Create(
28 const CFWL_WidgetImpProperties& properties,
29 IFWL_Widget* pOuter) {
30 return new IFWL_DateTimePicker(properties, pOuter);
31 }
32
33 IFWL_DateTimePicker::IFWL_DateTimePicker( 26 IFWL_DateTimePicker::IFWL_DateTimePicker(
34 const CFWL_WidgetImpProperties& properties, 27 const CFWL_WidgetImpProperties& properties)
35 IFWL_Widget* pOuter) 28 : IFWL_Widget(properties, nullptr),
36 : IFWL_Widget(properties, pOuter),
37 m_iBtnState(1), 29 m_iBtnState(1),
38 m_iYear(-1), 30 m_iYear(-1),
39 m_iMonth(-1), 31 m_iMonth(-1),
40 m_iDay(-1), 32 m_iDay(-1),
41 m_bLBtnDown(FALSE) { 33 m_bLBtnDown(FALSE) {
42 m_rtBtn.Set(0, 0, 0, 0); 34 m_rtBtn.Set(0, 0, 0, 0);
43 } 35 }
44 36
45 IFWL_DateTimePicker::~IFWL_DateTimePicker() {} 37 IFWL_DateTimePicker::~IFWL_DateTimePicker() {}
46 38
(...skipping 11 matching lines...) Expand all
58 return FWL_Error::Indefinite; 50 return FWL_Error::Indefinite;
59 51
60 m_pDelegate = new CFWL_DateTimePickerImpDelegate(this); 52 m_pDelegate = new CFWL_DateTimePickerImpDelegate(this);
61 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; 53 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
62 CFWL_WidgetImpProperties propMonth; 54 CFWL_WidgetImpProperties propMonth;
63 propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; 55 propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border;
64 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; 56 propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
65 propMonth.m_pDataProvider = &m_MonthCalendarDP; 57 propMonth.m_pDataProvider = &m_MonthCalendarDP;
66 propMonth.m_pParent = this; 58 propMonth.m_pParent = this;
67 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; 59 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
68 m_pMonthCal.reset(IFWL_DateTimeCalendar::Create(propMonth, this)); 60
61 m_pMonthCal.reset(new IFWL_DateTimeCalendar(propMonth, this));
69 m_pMonthCal->Initialize(); 62 m_pMonthCal->Initialize();
70 CFX_RectF rtMonthCal; 63 CFX_RectF rtMonthCal;
71 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 64 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
72 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); 65 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
73 m_pMonthCal->SetWidgetRect(rtMonthCal); 66 m_pMonthCal->SetWidgetRect(rtMonthCal);
74 CFWL_WidgetImpProperties propEdit; 67 CFWL_WidgetImpProperties propEdit;
75 propEdit.m_pParent = this; 68 propEdit.m_pParent = this;
76 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; 69 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
77 m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, this)); 70
71 m_pEdit.reset(new IFWL_DateTimeEdit(propEdit, this));
78 m_pEdit->Initialize(); 72 m_pEdit->Initialize();
79 RegisterEventTarget(m_pMonthCal.get()); 73 RegisterEventTarget(m_pMonthCal.get());
80 RegisterEventTarget(m_pEdit.get()); 74 RegisterEventTarget(m_pEdit.get());
81 return FWL_Error::Succeeded; 75 return FWL_Error::Succeeded;
82 } 76 }
83 77
84 FWL_Error IFWL_DateTimePicker::Finalize() { 78 FWL_Error IFWL_DateTimePicker::Finalize() {
85 if (m_pEdit) { 79 if (m_pEdit) {
86 m_pEdit->Finalize(); 80 m_pEdit->Finalize();
87 } 81 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 328
335 void IFWL_DateTimePicker::DrawDropDownButton(CFX_Graphics* pGraphics, 329 void IFWL_DateTimePicker::DrawDropDownButton(CFX_Graphics* pGraphics,
336 IFWL_ThemeProvider* pTheme, 330 IFWL_ThemeProvider* pTheme,
337 const CFX_Matrix* pMatrix) { 331 const CFX_Matrix* pMatrix) {
338 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) == 332 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) ==
339 FWL_STYLEEXT_DTP_Spin) { 333 FWL_STYLEEXT_DTP_Spin) {
340 CFWL_WidgetImpProperties prop; 334 CFWL_WidgetImpProperties prop;
341 prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; 335 prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
342 prop.m_pParent = this; 336 prop.m_pParent = this;
343 prop.m_rtWidget = m_rtBtn; 337 prop.m_rtWidget = m_rtBtn;
344 IFWL_SpinButton* pSpin = IFWL_SpinButton::Create(prop, this); 338 IFWL_SpinButton* pSpin = new IFWL_SpinButton(prop);
345 pSpin->Initialize(); 339 pSpin->Initialize();
346 } else { 340 } else {
347 CFWL_ThemeBackground param; 341 CFWL_ThemeBackground param;
348 param.m_pWidget = this; 342 param.m_pWidget = this;
349 param.m_iPart = CFWL_Part::DropDownButton; 343 param.m_iPart = CFWL_Part::DropDownButton;
350 param.m_dwStates = m_iBtnState; 344 param.m_dwStates = m_iBtnState;
351 param.m_pGraphics = pGraphics; 345 param.m_pGraphics = pGraphics;
352 param.m_rtPart = m_rtBtn; 346 param.m_rtPart = m_rtBtn;
353 if (pMatrix) { 347 if (pMatrix) {
354 param.m_matrix.Concat(*pMatrix); 348 param.m_matrix.Concat(*pMatrix);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 462
469 void IFWL_DateTimePicker::InitProxyForm() { 463 void IFWL_DateTimePicker::InitProxyForm() {
470 if (m_pForm) 464 if (m_pForm)
471 return; 465 return;
472 if (!m_pMonthCal) 466 if (!m_pMonthCal)
473 return; 467 return;
474 CFWL_WidgetImpProperties propForm; 468 CFWL_WidgetImpProperties propForm;
475 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; 469 propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
476 propForm.m_dwStates = FWL_WGTSTATE_Invisible; 470 propForm.m_dwStates = FWL_WGTSTATE_Invisible;
477 propForm.m_pOwner = this; 471 propForm.m_pOwner = this;
478 m_pForm.reset(IFWL_FormProxy::Create(propForm, m_pMonthCal.get())); 472
473 m_pForm.reset(new IFWL_FormProxy(propForm, m_pMonthCal.get()));
479 m_pForm->Initialize(); 474 m_pForm->Initialize();
480 m_pMonthCal->SetParent(m_pForm.get()); 475 m_pMonthCal->SetParent(m_pForm.get());
481 } 476 }
482 477
483 IFWL_DateTimeEdit* IFWL_DateTimePicker::GetDataTimeEdit() { 478 IFWL_DateTimeEdit* IFWL_DateTimePicker::GetDataTimeEdit() {
484 return m_pEdit.get(); 479 return m_pEdit.get();
485 } 480 }
486 481
487 FWL_Error IFWL_DateTimePicker::DisForm_Initialize() { 482 FWL_Error IFWL_DateTimePicker::DisForm_Initialize() {
488 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; 483 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
489 DisForm_InitDateTimeCalendar(); 484 DisForm_InitDateTimeCalendar();
490 DisForm_InitDateTimeEdit(); 485 DisForm_InitDateTimeEdit();
491 RegisterEventTarget(m_pMonthCal.get()); 486 RegisterEventTarget(m_pMonthCal.get());
492 RegisterEventTarget(m_pEdit.get()); 487 RegisterEventTarget(m_pEdit.get());
493 return FWL_Error::Succeeded; 488 return FWL_Error::Succeeded;
494 } 489 }
495 490
496 void IFWL_DateTimePicker::DisForm_InitDateTimeCalendar() { 491 void IFWL_DateTimePicker::DisForm_InitDateTimeCalendar() {
497 if (m_pMonthCal) { 492 if (m_pMonthCal) {
498 return; 493 return;
499 } 494 }
500 CFWL_WidgetImpProperties propMonth; 495 CFWL_WidgetImpProperties propMonth;
501 propMonth.m_dwStyles = 496 propMonth.m_dwStyles =
502 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; 497 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken;
503 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; 498 propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
504 propMonth.m_pParent = this; 499 propMonth.m_pParent = this;
505 propMonth.m_pDataProvider = &m_MonthCalendarDP; 500 propMonth.m_pDataProvider = &m_MonthCalendarDP;
506 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; 501 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
507 m_pMonthCal.reset(IFWL_DateTimeCalendar::Create(propMonth, this)); 502
503 m_pMonthCal.reset(new IFWL_DateTimeCalendar(propMonth, this));
508 m_pMonthCal->Initialize(); 504 m_pMonthCal->Initialize();
509 CFX_RectF rtMonthCal; 505 CFX_RectF rtMonthCal;
510 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 506 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
511 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); 507 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
512 m_pMonthCal->SetWidgetRect(rtMonthCal); 508 m_pMonthCal->SetWidgetRect(rtMonthCal);
513 } 509 }
514 510
515 void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() { 511 void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() {
516 if (m_pEdit) { 512 if (m_pEdit) {
517 return; 513 return;
518 } 514 }
519 CFWL_WidgetImpProperties propEdit; 515 CFWL_WidgetImpProperties propEdit;
520 propEdit.m_pParent = this; 516 propEdit.m_pParent = this;
521 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; 517 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
522 m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, this)); 518
519 m_pEdit.reset(new IFWL_DateTimeEdit(propEdit, this));
523 m_pEdit->Initialize(); 520 m_pEdit->Initialize();
524 } 521 }
525 522
526 FX_BOOL IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() { 523 FX_BOOL IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() {
527 if (!m_pMonthCal) 524 if (!m_pMonthCal)
528 return FALSE; 525 return FALSE;
529 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); 526 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible);
530 } 527 }
531 528
532 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(FX_BOOL bActivate) { 529 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(FX_BOOL bActivate) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 861
865 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth( 862 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth(
866 IFWL_Widget* pWidget) { 863 IFWL_Widget* pWidget) {
867 return m_iCurMonth; 864 return m_iCurMonth;
868 } 865 }
869 866
870 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear( 867 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear(
871 IFWL_Widget* pWidget) { 868 IFWL_Widget* pWidget) {
872 return m_iCurYear; 869 return m_iCurYear;
873 } 870 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_datetimepicker.h ('k') | xfa/fwl/core/ifwl_edit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698