| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 FWL_WidgetHit CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 544 FWL_WidgetHit 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 if (m_rtClient.Contains(fx, fy)) | 547 if (m_rtClient.Contains(fx, fy)) |
| 544 return FWL_WidgetHit::Client; | 548 return FWL_WidgetHit::Client; |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); | 954 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); |
| 951 } | 955 } |
| 952 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>( | 956 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>( |
| 953 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 957 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| 954 if (!pWidth) | 958 if (!pWidth) |
| 955 return 0; | 959 return 0; |
| 956 m_fBtn = *pWidth; | 960 m_fBtn = *pWidth; |
| 957 CFX_RectF rtMonthCal; | 961 CFX_RectF rtMonthCal; |
| 958 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); | 962 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); |
| 959 CFX_RectF rtPopUp; | 963 CFX_RectF rtPopUp; |
| 960 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, | 964 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, |
| 961 rtMonthCal.width, rtMonthCal.height); | 965 rtMonthCal.width, rtMonthCal.height); |
| 962 m_pMonthCal->SetWidgetRect(rtPopUp); | 966 m_pMonthCal->SetWidgetRect(rtPopUp); |
| 963 m_pMonthCal->Update(); | 967 m_pMonthCal->Update(); |
| 964 return FWL_ERR_Succeeded; | 968 return FWL_ERR_Succeeded; |
| 965 } | 969 } |
| 966 FWL_ERR CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect, | 970 FWL_ERR CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect, |
| 967 FX_BOOL bAutoSize) { | 971 FX_BOOL bAutoSize) { |
| 968 rect = m_pProperties->m_rtWidget; | 972 rect = m_pProperties->m_rtWidget; |
| 969 if (DisForm_IsNeedShowButton()) { | 973 if (DisForm_IsNeedShowButton()) { |
| 970 rect.width += m_fBtn; | 974 rect.width += m_fBtn; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 OnFocusChanged(pMessage, TRUE); | 1030 OnFocusChanged(pMessage, TRUE); |
| 1027 break; | 1031 break; |
| 1028 } | 1032 } |
| 1029 case CFWL_MessageType::KillFocus: { | 1033 case CFWL_MessageType::KillFocus: { |
| 1030 OnFocusChanged(pMessage, FALSE); | 1034 OnFocusChanged(pMessage, FALSE); |
| 1031 break; | 1035 break; |
| 1032 } | 1036 } |
| 1033 case CFWL_MessageType::Mouse: { | 1037 case CFWL_MessageType::Mouse: { |
| 1034 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); | 1038 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); |
| 1035 switch (pMouse->m_dwCmd) { | 1039 switch (pMouse->m_dwCmd) { |
| 1036 case FWL_MSGMOUSECMD_LButtonDown: { | 1040 case FWL_MouseCommand::LeftButtonDown: { |
| 1037 OnLButtonDown(pMouse); | 1041 OnLButtonDown(pMouse); |
| 1038 break; | 1042 break; |
| 1039 } | 1043 } |
| 1040 case FWL_MSGMOUSECMD_LButtonUp: { | 1044 case FWL_MouseCommand::LeftButtonUp: { |
| 1041 OnLButtonUp(pMouse); | 1045 OnLButtonUp(pMouse); |
| 1042 break; | 1046 break; |
| 1043 } | 1047 } |
| 1044 case FWL_MSGMOUSECMD_MouseMove: { | 1048 case FWL_MouseCommand::Move: { |
| 1045 OnMouseMove(pMouse); | 1049 OnMouseMove(pMouse); |
| 1046 break; | 1050 break; |
| 1047 } | 1051 } |
| 1048 case FWL_MSGMOUSECMD_MouseLeave: { | 1052 case FWL_MouseCommand::Leave: { |
| 1049 OnMouseLeave(pMouse); | 1053 OnMouseLeave(pMouse); |
| 1050 break; | 1054 break; |
| 1051 } | 1055 } |
| 1052 default: | 1056 default: |
| 1053 break; | 1057 break; |
| 1054 } | 1058 } |
| 1055 break; | 1059 break; |
| 1056 } | 1060 } |
| 1057 case CFWL_MessageType::Key: { | 1061 case CFWL_MessageType::Key: { |
| 1058 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { | 1062 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 } | 1168 } |
| 1165 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { | 1169 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { |
| 1166 pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get(); | 1170 pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get(); |
| 1167 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); | 1171 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); |
| 1168 pDelegate->OnProcessMessage(pMsg); | 1172 pDelegate->OnProcessMessage(pMsg); |
| 1169 } | 1173 } |
| 1170 } | 1174 } |
| 1171 rtInvalidate.Inflate(2, 2); | 1175 rtInvalidate.Inflate(2, 2); |
| 1172 m_pOwner->Repaint(&rtInvalidate); | 1176 m_pOwner->Repaint(&rtInvalidate); |
| 1173 } | 1177 } |
| OLD | NEW |