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

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

Issue 2469893004: Unify CFWL_WidgetProperties and CFWL_WidgetImpProperties. (Closed)
Patch Set: review cleanup 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') | 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 "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 monthProp =
41 pdfium::MakeUnique<CFWL_WidgetProperties>(&m_MonthCalendarDP);
42 monthProp->m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border;
43 monthProp->m_dwStates = FWL_WGTSTATE_Invisible;
44 monthProp->m_pParent = this;
45 monthProp->m_pThemeProvider = m_pProperties->m_pThemeProvider;
46 m_pMonthCal.reset(
47 new IFWL_DateTimeCalendar(m_pOwnerApp, std::move(monthProp), 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 editProp = pdfium::MakeUnique<CFWL_WidgetProperties>();
55 editProp->m_pParent = this;
56 editProp->m_pThemeProvider = m_pProperties->m_pThemeProvider;
57
58 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, std::move(editProp), 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
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 prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
441 prop->m_dwStyles = FWL_WGTSTYLE_Popup;
442 prop->m_dwStates = FWL_WGTSTATE_Invisible;
443 prop->m_pOwner = this;
444
445 m_pForm.reset(
446 new IFWL_FormProxy(m_pOwnerApp, std::move(prop), 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)
460 return; 465 return;
461 } 466
462 CFWL_WidgetImpProperties propMonth; 467 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(&m_MonthCalendarDP);
463 propMonth.m_dwStyles = 468 prop->m_dwStyles =
464 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; 469 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken;
465 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; 470 prop->m_dwStates = FWL_WGTSTATE_Invisible;
466 propMonth.m_pParent = this; 471 prop->m_pParent = this;
467 propMonth.m_pDataProvider = &m_MonthCalendarDP; 472 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
468 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
469 473
470 m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this)); 474 m_pMonthCal.reset(
475 new IFWL_DateTimeCalendar(m_pOwnerApp, std::move(prop), this));
471 CFX_RectF rtMonthCal; 476 CFX_RectF rtMonthCal;
472 m_pMonthCal->GetWidgetRect(rtMonthCal, true); 477 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
473 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); 478 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
474 m_pMonthCal->SetWidgetRect(rtMonthCal); 479 m_pMonthCal->SetWidgetRect(rtMonthCal);
475 } 480 }
476 481
477 void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() { 482 void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() {
478 if (m_pEdit) { 483 if (m_pEdit)
479 return; 484 return;
480 }
481 CFWL_WidgetImpProperties propEdit;
482 propEdit.m_pParent = this;
483 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
484 485
485 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this)); 486 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
487 prop->m_pParent = this;
488 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
489
490 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, std::move(prop), this));
486 } 491 }
487 492
488 bool IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() { 493 bool IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() {
489 if (!m_pMonthCal) 494 if (!m_pMonthCal)
490 return false; 495 return false;
491 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); 496 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible);
492 } 497 }
493 498
494 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) { 499 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) {
495 bool bShowed = IsMonthCalendarShowed(); 500 bool bShowed = IsMonthCalendarShowed();
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 807
803 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth( 808 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth(
804 IFWL_Widget* pWidget) { 809 IFWL_Widget* pWidget) {
805 return m_iCurMonth; 810 return m_iCurMonth;
806 } 811 }
807 812
808 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear( 813 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear(
809 IFWL_Widget* pWidget) { 814 IFWL_Widget* pWidget) {
810 return m_iCurYear; 815 return m_iCurYear;
811 } 816 }
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