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

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

Issue 2488953003: Cleanup IFWL_Widget visibility and virtual parameters (Closed)
Patch Set: 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
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 IFWL_DateTimePicker::~IFWL_DateTimePicker() { 65 IFWL_DateTimePicker::~IFWL_DateTimePicker() {
66 UnregisterEventTarget(); 66 UnregisterEventTarget();
67 } 67 }
68 68
69 FWL_Type IFWL_DateTimePicker::GetClassID() const { 69 FWL_Type IFWL_DateTimePicker::GetClassID() const {
70 return FWL_Type::DateTimePicker; 70 return FWL_Type::DateTimePicker;
71 } 71 }
72 72
73 FWL_Error IFWL_DateTimePicker::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 73 void IFWL_DateTimePicker::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
74 if (m_pWidgetMgr->IsFormDisabled()) { 74 if (m_pWidgetMgr->IsFormDisabled()) {
75 return DisForm_GetWidgetRect(rect, bAutoSize); 75 DisForm_GetWidgetRect(rect, bAutoSize);
76 return;
76 } 77 }
77 if (bAutoSize) { 78 if (bAutoSize) {
78 rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight); 79 rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight);
79 IFWL_Widget::GetWidgetRect(rect, true); 80 IFWL_Widget::GetWidgetRect(rect, true);
80 } else { 81 } else {
81 rect = m_pProperties->m_rtWidget; 82 rect = m_pProperties->m_rtWidget;
82 } 83 }
83 return FWL_Error::Succeeded;
84 } 84 }
85 85
86 FWL_Error IFWL_DateTimePicker::Update() { 86 void IFWL_DateTimePicker::Update() {
87 if (m_pWidgetMgr->IsFormDisabled()) { 87 if (m_pWidgetMgr->IsFormDisabled()) {
88 return DisForm_Update(); 88 return;
89 } 89 }
90 if (m_iLock) { 90 if (m_iLock) {
91 return FWL_Error::Indefinite; 91 return;
92 } 92 }
93 if (!m_pProperties->m_pThemeProvider) { 93 if (!m_pProperties->m_pThemeProvider) {
94 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 94 m_pProperties->m_pThemeProvider = GetAvailableTheme();
95 } 95 }
96 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); 96 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
97 GetClientRect(m_rtClient); 97 GetClientRect(m_rtClient);
98 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( 98 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
99 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 99 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
100 if (!pFWidth) 100 if (!pFWidth)
101 return FWL_Error::Indefinite; 101 return;
102 FX_FLOAT fBtn = *pFWidth; 102 FX_FLOAT fBtn = *pFWidth;
103 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1, 103 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1,
104 m_rtClient.height - 1); 104 m_rtClient.height - 1);
105 CFX_RectF rtEdit; 105 CFX_RectF rtEdit;
106 rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, 106 rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn,
107 m_rtClient.height); 107 m_rtClient.height);
108 m_pEdit->SetWidgetRect(rtEdit); 108 m_pEdit->SetWidgetRect(rtEdit);
109 ReSetEditAlignment(); 109 ReSetEditAlignment();
110 m_pEdit->Update(); 110 m_pEdit->Update();
111 if (!(m_pMonthCal->GetThemeProvider())) { 111 if (!(m_pMonthCal->GetThemeProvider())) {
112 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); 112 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
113 } 113 }
114 if (m_pProperties->m_pDataProvider) { 114 if (m_pProperties->m_pDataProvider) {
115 IFWL_DateTimePickerDP* pData = 115 IFWL_DateTimePickerDP* pData =
116 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); 116 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
117 pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay); 117 pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay);
118 } 118 }
119 CFX_RectF rtMonthCal; 119 CFX_RectF rtMonthCal;
120 m_pMonthCal->GetWidgetRect(rtMonthCal, true); 120 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
121 CFX_RectF rtPopUp; 121 CFX_RectF rtPopUp;
122 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, 122 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
123 rtMonthCal.width, rtMonthCal.height); 123 rtMonthCal.width, rtMonthCal.height);
124 m_pMonthCal->SetWidgetRect(rtPopUp); 124 m_pMonthCal->SetWidgetRect(rtPopUp);
125 m_pMonthCal->Update(); 125 m_pMonthCal->Update();
126 return FWL_Error::Succeeded; 126 return;
127 } 127 }
128 128
129 int32_t IFWL_DateTimePicker::CountSelRanges() { 129 int32_t IFWL_DateTimePicker::CountSelRanges() {
130 return GetDataTimeEdit()->CountSelRanges(); 130 return GetDataTimeEdit()->CountSelRanges();
131 } 131 }
132 132
133 int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { 133 int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
134 return GetDataTimeEdit()->GetSelRange(nIndex, nStart); 134 return GetDataTimeEdit()->GetSelRange(nIndex, nStart);
135 } 135 }
136 136
137 FWL_WidgetHit IFWL_DateTimePicker::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 137 FWL_WidgetHit IFWL_DateTimePicker::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
138 if (m_pWidgetMgr->IsFormDisabled()) 138 if (m_pWidgetMgr->IsFormDisabled())
139 return DisForm_HitTest(fx, fy); 139 return DisForm_HitTest(fx, fy);
140 if (m_rtClient.Contains(fx, fy)) 140 if (m_rtClient.Contains(fx, fy))
141 return FWL_WidgetHit::Client; 141 return FWL_WidgetHit::Client;
142 if (IsMonthCalendarShowed()) { 142 if (IsMonthCalendarShowed()) {
143 CFX_RectF rect; 143 CFX_RectF rect;
144 m_pMonthCal->GetWidgetRect(rect); 144 m_pMonthCal->GetWidgetRect(rect);
145 if (rect.Contains(fx, fy)) 145 if (rect.Contains(fx, fy))
146 return FWL_WidgetHit::Client; 146 return FWL_WidgetHit::Client;
147 } 147 }
148 return FWL_WidgetHit::Unknown; 148 return FWL_WidgetHit::Unknown;
149 } 149 }
150 150
151 FWL_Error IFWL_DateTimePicker::DrawWidget(CFX_Graphics* pGraphics, 151 void IFWL_DateTimePicker::DrawWidget(CFX_Graphics* pGraphics,
152 const CFX_Matrix* pMatrix) { 152 const CFX_Matrix* pMatrix) {
153 if (!pGraphics) 153 if (!pGraphics)
154 return FWL_Error::Indefinite; 154 return;
155 if (!m_pProperties->m_pThemeProvider) 155 if (!m_pProperties->m_pThemeProvider)
156 return FWL_Error::Indefinite; 156 return;
157 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 157 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
158 if (HasBorder()) { 158 if (HasBorder()) {
159 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 159 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
160 } 160 }
161 if (HasEdge()) { 161 if (HasEdge()) {
162 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); 162 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
163 } 163 }
164 if (!m_rtBtn.IsEmpty()) { 164 if (!m_rtBtn.IsEmpty()) {
165 DrawDropDownButton(pGraphics, pTheme, pMatrix); 165 DrawDropDownButton(pGraphics, pTheme, pMatrix);
166 } 166 }
167 if (m_pWidgetMgr->IsFormDisabled()) { 167 if (m_pWidgetMgr->IsFormDisabled()) {
168 return DisForm_DrawWidget(pGraphics, pMatrix); 168 DisForm_DrawWidget(pGraphics, pMatrix);
169 return;
169 } 170 }
170 return FWL_Error::Succeeded;
171 } 171 }
172 172
173 FWL_Error IFWL_DateTimePicker::SetThemeProvider(IFWL_ThemeProvider* pTP) { 173 void IFWL_DateTimePicker::SetThemeProvider(IFWL_ThemeProvider* pTP) {
174 m_pProperties->m_pThemeProvider = pTP; 174 m_pProperties->m_pThemeProvider = pTP;
175 m_pMonthCal->SetThemeProvider(pTP); 175 m_pMonthCal->SetThemeProvider(pTP);
176 return FWL_Error::Succeeded;
177 } 176 }
178 177
179 FWL_Error IFWL_DateTimePicker::GetCurSel(int32_t& iYear, 178 FWL_Error IFWL_DateTimePicker::GetCurSel(int32_t& iYear,
180 int32_t& iMonth, 179 int32_t& iMonth,
181 int32_t& iDay) { 180 int32_t& iDay) {
182 iYear = m_iYear; 181 iYear = m_iYear;
183 iMonth = m_iMonth; 182 iMonth = m_iMonth;
184 iDay = m_iDay; 183 iDay = m_iDay;
185 return FWL_Error::Succeeded; 184 return FWL_Error::Succeeded;
186 } 185 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 m_pProperties->m_rtWidget.top); 290 m_pProperties->m_rtWidget.top);
292 rect.Union(rtMonth); 291 rect.Union(rtMonth);
293 } 292 }
294 return FWL_Error::Succeeded; 293 return FWL_Error::Succeeded;
295 } 294 }
296 295
297 FWL_Error IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { 296 FWL_Error IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
298 return m_pEdit->SetLimit(nLimit); 297 return m_pEdit->SetLimit(nLimit);
299 } 298 }
300 299
301 FWL_Error IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, 300 void IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
302 uint32_t dwStylesExRemoved) { 301 uint32_t dwStylesExRemoved) {
303 return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 302 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
304 } 303 }
305 304
306 void IFWL_DateTimePicker::DrawDropDownButton(CFX_Graphics* pGraphics, 305 void IFWL_DateTimePicker::DrawDropDownButton(CFX_Graphics* pGraphics,
307 IFWL_ThemeProvider* pTheme, 306 IFWL_ThemeProvider* pTheme,
308 const CFX_Matrix* pMatrix) { 307 const CFX_Matrix* pMatrix) {
309 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) == 308 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) ==
310 FWL_STYLEEXT_DTP_Spin) { 309 FWL_STYLEEXT_DTP_Spin) {
311 return; 310 return;
312 } 311 }
313 312
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 return FWL_WidgetHit::Unknown; 551 return FWL_WidgetHit::Unknown;
553 } 552 }
554 553
555 bool IFWL_DateTimePicker::DisForm_IsNeedShowButton() { 554 bool IFWL_DateTimePicker::DisForm_IsNeedShowButton() {
556 bool bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused || 555 bool bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused ||
557 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || 556 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused ||
558 m_pEdit->GetStates() & FWL_WGTSTATE_Focused; 557 m_pEdit->GetStates() & FWL_WGTSTATE_Focused;
559 return bFocus; 558 return bFocus;
560 } 559 }
561 560
562 FWL_Error IFWL_DateTimePicker::DisForm_Update() { 561 void IFWL_DateTimePicker::DisForm_Update() {
563 if (m_iLock) 562 if (m_iLock)
564 return FWL_Error::Indefinite; 563 return;
565 if (!m_pProperties->m_pThemeProvider) 564 if (!m_pProperties->m_pThemeProvider)
566 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 565 m_pProperties->m_pThemeProvider = GetAvailableTheme();
567 566
568 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); 567 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
569 GetClientRect(m_rtClient); 568 GetClientRect(m_rtClient);
570 m_pEdit->SetWidgetRect(m_rtClient); 569 m_pEdit->SetWidgetRect(m_rtClient);
571 ReSetEditAlignment(); 570 ReSetEditAlignment();
572 m_pEdit->Update(); 571 m_pEdit->Update();
573 if (!m_pMonthCal->GetThemeProvider()) 572 if (!m_pMonthCal->GetThemeProvider())
574 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); 573 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
575 574
576 if (m_pProperties->m_pDataProvider) { 575 if (m_pProperties->m_pDataProvider) {
577 IFWL_DateTimePickerDP* pData = 576 IFWL_DateTimePickerDP* pData =
578 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); 577 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
579 pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay); 578 pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay);
580 } 579 }
581 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>( 580 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>(
582 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 581 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
583 if (!pWidth) 582 if (!pWidth)
584 return FWL_Error::Succeeded; 583 return;
585 584
586 m_fBtn = *pWidth; 585 m_fBtn = *pWidth;
587 CFX_RectF rtMonthCal; 586 CFX_RectF rtMonthCal;
588 m_pMonthCal->GetWidgetRect(rtMonthCal, true); 587 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
589 CFX_RectF rtPopUp; 588 CFX_RectF rtPopUp;
590 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, 589 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
591 rtMonthCal.width, rtMonthCal.height); 590 rtMonthCal.width, rtMonthCal.height);
592 m_pMonthCal->SetWidgetRect(rtPopUp); 591 m_pMonthCal->SetWidgetRect(rtPopUp);
593 m_pMonthCal->Update(); 592 m_pMonthCal->Update();
594 return FWL_Error::Succeeded;
595 } 593 }
596 594
597 FWL_Error IFWL_DateTimePicker::DisForm_GetWidgetRect(CFX_RectF& rect, 595 void IFWL_DateTimePicker::DisForm_GetWidgetRect(CFX_RectF& rect,
598 bool bAutoSize) { 596 bool bAutoSize) {
599 rect = m_pProperties->m_rtWidget; 597 rect = m_pProperties->m_rtWidget;
600 if (DisForm_IsNeedShowButton()) { 598 if (DisForm_IsNeedShowButton()) {
601 rect.width += m_fBtn; 599 rect.width += m_fBtn;
602 } 600 }
603 return FWL_Error::Succeeded;
604 } 601 }
605 602
606 FWL_Error IFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) { 603 FWL_Error IFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) {
607 rect = m_pProperties->m_rtWidget; 604 rect = m_pProperties->m_rtWidget;
608 if (DisForm_IsNeedShowButton()) { 605 if (DisForm_IsNeedShowButton()) {
609 rect.width += m_fBtn; 606 rect.width += m_fBtn;
610 } 607 }
611 if (IsMonthCalendarShowed()) { 608 if (IsMonthCalendarShowed()) {
612 CFX_RectF rtMonth; 609 CFX_RectF rtMonth;
613 m_pMonthCal->GetWidgetRect(rtMonth); 610 m_pMonthCal->GetWidgetRect(rtMonth);
614 rtMonth.Offset(m_pProperties->m_rtWidget.left, 611 rtMonth.Offset(m_pProperties->m_rtWidget.left,
615 m_pProperties->m_rtWidget.top); 612 m_pProperties->m_rtWidget.top);
616 rect.Union(rtMonth); 613 rect.Union(rtMonth);
617 } 614 }
618 return FWL_Error::Succeeded; 615 return FWL_Error::Succeeded;
619 } 616 }
620 617
621 FWL_Error IFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics, 618 void IFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics,
622 const CFX_Matrix* pMatrix) { 619 const CFX_Matrix* pMatrix) {
623 if (!pGraphics) 620 if (!pGraphics)
624 return FWL_Error::Indefinite; 621 return;
625 if (m_pEdit) { 622 if (m_pEdit) {
626 CFX_RectF rtEdit; 623 CFX_RectF rtEdit;
627 m_pEdit->GetWidgetRect(rtEdit); 624 m_pEdit->GetWidgetRect(rtEdit);
628 CFX_Matrix mt; 625 CFX_Matrix mt;
629 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); 626 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top);
630 if (pMatrix) { 627 if (pMatrix) {
631 mt.Concat(*pMatrix); 628 mt.Concat(*pMatrix);
632 } 629 }
633 m_pEdit->DrawWidget(pGraphics, &mt); 630 m_pEdit->DrawWidget(pGraphics, &mt);
634 } 631 }
635 if (IsMonthCalendarShowed()) { 632 if (IsMonthCalendarShowed()) {
636 CFX_RectF rtMonth; 633 CFX_RectF rtMonth;
637 m_pMonthCal->GetWidgetRect(rtMonth); 634 m_pMonthCal->GetWidgetRect(rtMonth);
638 CFX_Matrix mt; 635 CFX_Matrix mt;
639 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); 636 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top);
640 if (pMatrix) { 637 if (pMatrix) {
641 mt.Concat(*pMatrix); 638 mt.Concat(*pMatrix);
642 } 639 }
643 m_pMonthCal->DrawWidget(pGraphics, &mt); 640 m_pMonthCal->DrawWidget(pGraphics, &mt);
644 } 641 }
645 return FWL_Error::Succeeded; 642 return;
646 } 643 }
647 644
648 void IFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) { 645 void IFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) {
649 if (!pMessage) 646 if (!pMessage)
650 return; 647 return;
651 648
652 switch (pMessage->GetClassID()) { 649 switch (pMessage->GetClassID()) {
653 case CFWL_MessageType::SetFocus: 650 case CFWL_MessageType::SetFocus:
654 OnFocusChanged(pMessage, true); 651 OnFocusChanged(pMessage, true);
655 break; 652 break;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 return m_iCurDay; 794 return m_iCurDay;
798 } 795 }
799 796
800 int32_t IFWL_DateTimePicker::GetCurMonth(IFWL_Widget* pWidget) { 797 int32_t IFWL_DateTimePicker::GetCurMonth(IFWL_Widget* pWidget) {
801 return m_iCurMonth; 798 return m_iCurMonth;
802 } 799 }
803 800
804 int32_t IFWL_DateTimePicker::GetCurYear(IFWL_Widget* pWidget) { 801 int32_t IFWL_DateTimePicker::GetCurYear(IFWL_Widget* pWidget) {
805 return m_iCurYear; 802 return m_iCurYear;
806 } 803 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698