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

Side by Side Diff: xfa/fwl/basewidget/fwl_datetimepickerimp.cpp

Issue 1938163002: More define cleanup. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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
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/basewidget/fwl_datetimepickerimp.h" 7 #include "xfa/fwl/basewidget/fwl_datetimepickerimp.h"
8 8
9 #include "xfa/fwl/basewidget/fwl_editimp.h" 9 #include "xfa/fwl/basewidget/fwl_editimp.h"
10 #include "xfa/fwl/basewidget/fwl_formproxyimp.h" 10 #include "xfa/fwl/basewidget/fwl_formproxyimp.h"
11 #include "xfa/fwl/basewidget/fwl_monthcalendarimp.h" 11 #include "xfa/fwl/basewidget/fwl_monthcalendarimp.h"
12 #include "xfa/fwl/basewidget/ifwl_spinbutton.h" 12 #include "xfa/fwl/basewidget/ifwl_spinbutton.h"
13 #include "xfa/fwl/core/cfwl_message.h" 13 #include "xfa/fwl/core/cfwl_message.h"
14 #include "xfa/fwl/core/cfwl_themebackground.h" 14 #include "xfa/fwl/core/cfwl_themebackground.h"
15 #include "xfa/fwl/core/fwl_formimp.h" 15 #include "xfa/fwl/core/fwl_formimp.h"
16 #include "xfa/fwl/core/fwl_noteimp.h" 16 #include "xfa/fwl/core/fwl_noteimp.h"
17 #include "xfa/fwl/core/fwl_widgetimp.h" 17 #include "xfa/fwl/core/fwl_widgetimp.h"
18 #include "xfa/fwl/core/fwl_widgetmgrimp.h" 18 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
19 #include "xfa/fwl/core/ifwl_themeprovider.h" 19 #include "xfa/fwl/core/ifwl_themeprovider.h"
20 20
21 #define FWL_DTP_WIDTH 100 21 namespace {
22 #define FWL_DTP_HEIGHT 20 22
23 const int kDateTimePickerWidth = 100;
24 const int kDateTimePickerHeight = 20;
25
26 } // namespace
23 27
24 // static 28 // static
25 IFWL_DateTimePicker* IFWL_DateTimePicker::Create( 29 IFWL_DateTimePicker* IFWL_DateTimePicker::Create(
26 const CFWL_WidgetImpProperties& properties, 30 const CFWL_WidgetImpProperties& properties,
27 IFWL_Widget* pOuter) { 31 IFWL_Widget* pOuter) {
28 IFWL_DateTimePicker* pDateTimePicker = new IFWL_DateTimePicker; 32 IFWL_DateTimePicker* pDateTimePicker = new IFWL_DateTimePicker;
29 CFWL_DateTimePickerImp* pDateTimePickerImpl = 33 CFWL_DateTimePickerImp* pDateTimePickerImpl =
30 new CFWL_DateTimePickerImp(properties, pOuter); 34 new CFWL_DateTimePickerImp(properties, pOuter);
31 pDateTimePicker->SetImpl(pDateTimePickerImpl); 35 pDateTimePicker->SetImpl(pDateTimePickerImpl);
32 pDateTimePickerImpl->SetInterface(pDateTimePicker); 36 pDateTimePickerImpl->SetInterface(pDateTimePicker);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 186 }
183 return 1; 187 return 1;
184 } 188 }
185 189
186 int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( 190 int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage(
187 CFWL_Message* pMessage) { 191 CFWL_Message* pMessage) {
188 CFWL_MessageType dwHashCode = pMessage->GetClassID(); 192 CFWL_MessageType dwHashCode = pMessage->GetClassID();
189 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { 193 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
190 if (dwHashCode == CFWL_MessageType::Mouse) { 194 if (dwHashCode == CFWL_MessageType::Mouse) {
191 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); 195 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
192 if (pMouse->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown || 196 if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown ||
193 pMouse->m_dwCmd == FWL_MSGMOUSECMD_RButtonDown) { 197 pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) {
194 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { 198 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
195 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 199 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
196 } 200 }
197 CFWL_DateTimePickerImp* pDateTime = 201 CFWL_DateTimePickerImp* pDateTime =
198 static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl()); 202 static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl());
199 if (pDateTime->IsMonthCalendarShowed()) { 203 if (pDateTime->IsMonthCalendarShowed()) {
200 CFX_RectF rtInvalidate; 204 CFX_RectF rtInvalidate;
201 pDateTime->GetWidgetRect(rtInvalidate); 205 pDateTime->GetWidgetRect(rtInvalidate);
202 pDateTime->ShowMonthCalendar(FALSE); 206 pDateTime->ShowMonthCalendar(FALSE);
203 rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); 207 rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 int32_t CFWL_DateTimeCalendarImpDelegate::OnProcessMessage( 241 int32_t CFWL_DateTimeCalendarImpDelegate::OnProcessMessage(
238 CFWL_Message* pMessage) { 242 CFWL_Message* pMessage) {
239 CFWL_MessageType dwCode = pMessage->GetClassID(); 243 CFWL_MessageType dwCode = pMessage->GetClassID();
240 if (dwCode == CFWL_MessageType::SetFocus || 244 if (dwCode == CFWL_MessageType::SetFocus ||
241 dwCode == CFWL_MessageType::KillFocus) { 245 dwCode == CFWL_MessageType::KillFocus) {
242 IFWL_Widget* pOuter = m_pOwner->GetOuter(); 246 IFWL_Widget* pOuter = m_pOwner->GetOuter();
243 IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); 247 IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL);
244 return pDelegate->OnProcessMessage(pMessage); 248 return pDelegate->OnProcessMessage(pMessage);
245 } else if (dwCode == CFWL_MessageType::Mouse) { 249 } else if (dwCode == CFWL_MessageType::Mouse) {
246 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 250 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
247 if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) { 251 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) {
248 OnLButtonDownEx(pMsg); 252 OnLButtonDownEx(pMsg);
249 return 1; 253 return 1;
250 } else if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { 254 } else if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) {
251 OnLButtonUpEx(pMsg); 255 OnLButtonUpEx(pMsg);
252 return 1; 256 return 1;
253 } 257 }
254 } 258 }
255 return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); 259 return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
256 } 260 }
257 261
258 void CFWL_DateTimeCalendarImpDelegate::OnLButtonDownEx(CFWL_MsgMouse* pMsg) { 262 void CFWL_DateTimeCalendarImpDelegate::OnLButtonDownEx(CFWL_MsgMouse* pMsg) {
259 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 263 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
260 m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed; 264 m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 372 }
369 if (bRepaint && !rtInvalidate.IsEmpty()) { 373 if (bRepaint && !rtInvalidate.IsEmpty()) {
370 m_pOwner->Repaint(&rtInvalidate); 374 m_pOwner->Repaint(&rtInvalidate);
371 } 375 }
372 } 376 }
373 377
374 int32_t CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( 378 int32_t CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage(
375 CFWL_Message* pMessage) { 379 CFWL_Message* pMessage) {
376 if (pMessage->GetClassID() == CFWL_MessageType::Mouse) { 380 if (pMessage->GetClassID() == CFWL_MessageType::Mouse) {
377 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 381 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
378 if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { 382 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) {
379 DisForm_OnLButtonUpEx(pMsg); 383 DisForm_OnLButtonUpEx(pMsg);
380 return 1; 384 return 1;
381 } 385 }
382 } 386 }
383 return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); 387 return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
384 } 388 }
385 389
386 void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx( 390 void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx(
387 CFWL_MsgMouse* pMsg) { 391 CFWL_MsgMouse* pMsg) {
388 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 392 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 delete m_pDelegate; 484 delete m_pDelegate;
481 m_pDelegate = nullptr; 485 m_pDelegate = nullptr;
482 return CFWL_WidgetImp::Finalize(); 486 return CFWL_WidgetImp::Finalize();
483 } 487 }
484 FWL_ERR CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF& rect, 488 FWL_ERR CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF& rect,
485 FX_BOOL bAutoSize) { 489 FX_BOOL bAutoSize) {
486 if (m_pWidgetMgr->IsFormDisabled()) { 490 if (m_pWidgetMgr->IsFormDisabled()) {
487 return DisForm_GetWidgetRect(rect, bAutoSize); 491 return DisForm_GetWidgetRect(rect, bAutoSize);
488 } 492 }
489 if (bAutoSize) { 493 if (bAutoSize) {
490 rect.Set(0, 0, FWL_DTP_WIDTH, FWL_DTP_HEIGHT); 494 rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight);
491 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); 495 CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
492 } else { 496 } else {
493 rect = m_pProperties->m_rtWidget; 497 rect = m_pProperties->m_rtWidget;
494 } 498 }
495 return FWL_ERR_Succeeded; 499 return FWL_ERR_Succeeded;
496 } 500 }
497 FWL_ERR CFWL_DateTimePickerImp::Update() { 501 FWL_ERR CFWL_DateTimePickerImp::Update() {
498 if (m_pWidgetMgr->IsFormDisabled()) { 502 if (m_pWidgetMgr->IsFormDisabled()) {
499 return DisForm_Update(); 503 return DisForm_Update();
500 } 504 }
(...skipping 23 matching lines...) Expand all
524 } 528 }
525 if (m_pProperties->m_pDataProvider) { 529 if (m_pProperties->m_pDataProvider) {
526 IFWL_DateTimePickerDP* pData = 530 IFWL_DateTimePickerDP* pData =
527 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); 531 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
528 pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear, 532 pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear,
529 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); 533 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
530 } 534 }
531 CFX_RectF rtMonthCal; 535 CFX_RectF rtMonthCal;
532 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 536 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
533 CFX_RectF rtPopUp; 537 CFX_RectF rtPopUp;
534 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, 538 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
535 rtMonthCal.width, rtMonthCal.height); 539 rtMonthCal.width, rtMonthCal.height);
536 m_pMonthCal->SetWidgetRect(rtPopUp); 540 m_pMonthCal->SetWidgetRect(rtPopUp);
537 m_pMonthCal->Update(); 541 m_pMonthCal->Update();
538 return FWL_ERR_Succeeded; 542 return FWL_ERR_Succeeded;
539 } 543 }
540 uint32_t CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 544 uint32_t CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
541 if (m_pWidgetMgr->IsFormDisabled()) { 545 if (m_pWidgetMgr->IsFormDisabled()) {
542 return DisForm_HitTest(fx, fy); 546 return DisForm_HitTest(fx, fy);
543 } 547 }
544 if (m_rtClient.Contains(fx, fy)) { 548 if (m_rtClient.Contains(fx, fy)) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); 960 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
957 } 961 }
958 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>( 962 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>(
959 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 963 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
960 if (!pWidth) 964 if (!pWidth)
961 return 0; 965 return 0;
962 m_fBtn = *pWidth; 966 m_fBtn = *pWidth;
963 CFX_RectF rtMonthCal; 967 CFX_RectF rtMonthCal;
964 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 968 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
965 CFX_RectF rtPopUp; 969 CFX_RectF rtPopUp;
966 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, 970 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
967 rtMonthCal.width, rtMonthCal.height); 971 rtMonthCal.width, rtMonthCal.height);
968 m_pMonthCal->SetWidgetRect(rtPopUp); 972 m_pMonthCal->SetWidgetRect(rtPopUp);
969 m_pMonthCal->Update(); 973 m_pMonthCal->Update();
970 return FWL_ERR_Succeeded; 974 return FWL_ERR_Succeeded;
971 } 975 }
972 FWL_ERR CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect, 976 FWL_ERR CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect,
973 FX_BOOL bAutoSize) { 977 FX_BOOL bAutoSize) {
974 rect = m_pProperties->m_rtWidget; 978 rect = m_pProperties->m_rtWidget;
975 if (DisForm_IsNeedShowButton()) { 979 if (DisForm_IsNeedShowButton()) {
976 rect.width += m_fBtn; 980 rect.width += m_fBtn;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 OnFocusChanged(pMessage, TRUE); 1036 OnFocusChanged(pMessage, TRUE);
1033 break; 1037 break;
1034 } 1038 }
1035 case CFWL_MessageType::KillFocus: { 1039 case CFWL_MessageType::KillFocus: {
1036 OnFocusChanged(pMessage, FALSE); 1040 OnFocusChanged(pMessage, FALSE);
1037 break; 1041 break;
1038 } 1042 }
1039 case CFWL_MessageType::Mouse: { 1043 case CFWL_MessageType::Mouse: {
1040 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); 1044 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
1041 switch (pMouse->m_dwCmd) { 1045 switch (pMouse->m_dwCmd) {
1042 case FWL_MSGMOUSECMD_LButtonDown: { 1046 case FWL_MouseCommand::LeftButtonDown: {
1043 OnLButtonDown(pMouse); 1047 OnLButtonDown(pMouse);
1044 break; 1048 break;
1045 } 1049 }
1046 case FWL_MSGMOUSECMD_LButtonUp: { 1050 case FWL_MouseCommand::LeftButtonUp: {
1047 OnLButtonUp(pMouse); 1051 OnLButtonUp(pMouse);
1048 break; 1052 break;
1049 } 1053 }
1050 case FWL_MSGMOUSECMD_MouseMove: { 1054 case FWL_MouseCommand::Move: {
1051 OnMouseMove(pMouse); 1055 OnMouseMove(pMouse);
1052 break; 1056 break;
1053 } 1057 }
1054 case FWL_MSGMOUSECMD_MouseLeave: { 1058 case FWL_MouseCommand::Leave: {
1055 OnMouseLeave(pMouse); 1059 OnMouseLeave(pMouse);
1056 break; 1060 break;
1057 } 1061 }
1058 default: 1062 default:
1059 break; 1063 break;
1060 } 1064 }
1061 break; 1065 break;
1062 } 1066 }
1063 case CFWL_MessageType::Key: { 1067 case CFWL_MessageType::Key: {
1064 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { 1068 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 } 1174 }
1171 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { 1175 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
1172 pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get(); 1176 pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get();
1173 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); 1177 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
1174 pDelegate->OnProcessMessage(pMsg); 1178 pDelegate->OnProcessMessage(pMsg);
1175 } 1179 }
1176 } 1180 }
1177 rtInvalidate.Inflate(2, 2); 1181 rtInvalidate.Inflate(2, 2);
1178 m_pOwner->Repaint(&rtInvalidate); 1182 m_pOwner->Repaint(&rtInvalidate);
1179 } 1183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698