| 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/core/cfwl_monthcalendar.h" | 7 #include "xfa/fwl/cfwl_monthcalendar.h" | 
| 8 | 8 | 
| 9 #include <algorithm> | 9 #include <algorithm> | 
| 10 #include <memory> | 10 #include <memory> | 
| 11 #include <utility> | 11 #include <utility> | 
| 12 | 12 | 
| 13 #include "third_party/base/ptr_util.h" | 13 #include "third_party/base/ptr_util.h" | 
| 14 #include "xfa/fde/tto/fde_textout.h" | 14 #include "xfa/fde/tto/fde_textout.h" | 
| 15 #include "xfa/fwl/core/cfwl_datetimepicker.h" | 15 #include "xfa/fwl/cfwl_datetimepicker.h" | 
| 16 #include "xfa/fwl/core/cfwl_formproxy.h" | 16 #include "xfa/fwl/cfwl_formproxy.h" | 
| 17 #include "xfa/fwl/core/cfwl_msgmouse.h" | 17 #include "xfa/fwl/cfwl_messagemouse.h" | 
| 18 #include "xfa/fwl/core/cfwl_notedriver.h" | 18 #include "xfa/fwl/cfwl_notedriver.h" | 
| 19 #include "xfa/fwl/core/cfwl_themebackground.h" | 19 #include "xfa/fwl/cfwl_themebackground.h" | 
| 20 #include "xfa/fwl/core/cfwl_themetext.h" | 20 #include "xfa/fwl/cfwl_themetext.h" | 
| 21 #include "xfa/fwl/core/ifwl_themeprovider.h" | 21 #include "xfa/fwl/ifwl_themeprovider.h" | 
| 22 | 22 | 
| 23 #define MONTHCAL_HSEP_HEIGHT 1 | 23 #define MONTHCAL_HSEP_HEIGHT 1 | 
| 24 #define MONTHCAL_VSEP_WIDTH 1 | 24 #define MONTHCAL_VSEP_WIDTH 1 | 
| 25 #define MONTHCAL_HMARGIN 3 | 25 #define MONTHCAL_HMARGIN 3 | 
| 26 #define MONTHCAL_VMARGIN 2 | 26 #define MONTHCAL_VMARGIN 2 | 
| 27 #define MONTHCAL_ROWS 9 | 27 #define MONTHCAL_ROWS 9 | 
| 28 #define MONTHCAL_COLUMNS 7 | 28 #define MONTHCAL_COLUMNS 7 | 
| 29 #define MONTHCAL_HEADER_BTN_VMARGIN 7 | 29 #define MONTHCAL_HEADER_BTN_VMARGIN 7 | 
| 30 #define MONTHCAL_HEADER_BTN_HMARGIN 5 | 30 #define MONTHCAL_HEADER_BTN_HMARGIN 5 | 
| 31 | 31 | 
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 893     return; | 893     return; | 
| 894 | 894 | 
| 895   switch (pMessage->GetType()) { | 895   switch (pMessage->GetType()) { | 
| 896     case CFWL_Message::Type::SetFocus: | 896     case CFWL_Message::Type::SetFocus: | 
| 897     case CFWL_Message::Type::KillFocus: | 897     case CFWL_Message::Type::KillFocus: | 
| 898       GetOuter()->GetDelegate()->OnProcessMessage(pMessage); | 898       GetOuter()->GetDelegate()->OnProcessMessage(pMessage); | 
| 899       break; | 899       break; | 
| 900     case CFWL_Message::Type::Key: | 900     case CFWL_Message::Type::Key: | 
| 901       break; | 901       break; | 
| 902     case CFWL_Message::Type::Mouse: { | 902     case CFWL_Message::Type::Mouse: { | 
| 903       CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); | 903       CFWL_MessageMouse* pMouse = static_cast<CFWL_MessageMouse*>(pMessage); | 
| 904       switch (pMouse->m_dwCmd) { | 904       switch (pMouse->m_dwCmd) { | 
| 905         case FWL_MouseCommand::LeftButtonDown: | 905         case FWL_MouseCommand::LeftButtonDown: | 
| 906           OnLButtonDown(pMouse); | 906           OnLButtonDown(pMouse); | 
| 907           break; | 907           break; | 
| 908         case FWL_MouseCommand::LeftButtonUp: | 908         case FWL_MouseCommand::LeftButtonUp: | 
| 909           OnLButtonUp(pMouse); | 909           OnLButtonUp(pMouse); | 
| 910           break; | 910           break; | 
| 911         case FWL_MouseCommand::Move: | 911         case FWL_MouseCommand::Move: | 
| 912           OnMouseMove(pMouse); | 912           OnMouseMove(pMouse); | 
| 913           break; | 913           break; | 
| 914         case FWL_MouseCommand::Leave: | 914         case FWL_MouseCommand::Leave: | 
| 915           OnMouseLeave(pMouse); | 915           OnMouseLeave(pMouse); | 
| 916           break; | 916           break; | 
| 917         default: | 917         default: | 
| 918           break; | 918           break; | 
| 919       } | 919       } | 
| 920       break; | 920       break; | 
| 921     } | 921     } | 
| 922     default: | 922     default: | 
| 923       break; | 923       break; | 
| 924   } | 924   } | 
| 925   CFWL_Widget::OnProcessMessage(pMessage); | 925   CFWL_Widget::OnProcessMessage(pMessage); | 
| 926 } | 926 } | 
| 927 | 927 | 
| 928 void CFWL_MonthCalendar::OnDrawWidget(CFX_Graphics* pGraphics, | 928 void CFWL_MonthCalendar::OnDrawWidget(CFX_Graphics* pGraphics, | 
| 929                                       const CFX_Matrix* pMatrix) { | 929                                       const CFX_Matrix* pMatrix) { | 
| 930   DrawWidget(pGraphics, pMatrix); | 930   DrawWidget(pGraphics, pMatrix); | 
| 931 } | 931 } | 
| 932 | 932 | 
| 933 void CFWL_MonthCalendar::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 933 void CFWL_MonthCalendar::OnLButtonDown(CFWL_MessageMouse* pMsg) { | 
| 934   if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 934   if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 
| 935     m_iLBtnPartStates = CFWL_PartState_Pressed; | 935     m_iLBtnPartStates = CFWL_PartState_Pressed; | 
| 936     PrevMonth(); | 936     PrevMonth(); | 
| 937     Repaint(&m_rtClient); | 937     Repaint(&m_rtClient); | 
| 938   } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 938   } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 
| 939     m_iRBtnPartStates |= CFWL_PartState_Pressed; | 939     m_iRBtnPartStates |= CFWL_PartState_Pressed; | 
| 940     NextMonth(); | 940     NextMonth(); | 
| 941     Repaint(&m_rtClient); | 941     Repaint(&m_rtClient); | 
| 942   } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { | 942   } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { | 
| 943     if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 0) { | 943     if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 0) { | 
| 944       JumpToToday(); | 944       JumpToToday(); | 
| 945       Repaint(&m_rtClient); | 945       Repaint(&m_rtClient); | 
| 946     } | 946     } | 
| 947   } else { | 947   } else { | 
| 948     CFWL_DateTimePicker* pIPicker = static_cast<CFWL_DateTimePicker*>(m_pOuter); | 948     CFWL_DateTimePicker* pIPicker = static_cast<CFWL_DateTimePicker*>(m_pOuter); | 
| 949     if (pIPicker->IsMonthCalendarVisible()) | 949     if (pIPicker->IsMonthCalendarVisible()) | 
| 950       m_bFlag = 1; | 950       m_bFlag = 1; | 
| 951   } | 951   } | 
| 952 } | 952 } | 
| 953 | 953 | 
| 954 void CFWL_MonthCalendar::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 954 void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) { | 
| 955   if (m_pWidgetMgr->IsFormDisabled()) | 955   if (m_pWidgetMgr->IsFormDisabled()) | 
| 956     return DisForm_OnLButtonUp(pMsg); | 956     return DisForm_OnLButtonUp(pMsg); | 
| 957 | 957 | 
| 958   if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 958   if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 
| 959     m_iLBtnPartStates = 0; | 959     m_iLBtnPartStates = 0; | 
| 960     Repaint(&m_rtLBtn); | 960     Repaint(&m_rtLBtn); | 
| 961     return; | 961     return; | 
| 962   } | 962   } | 
| 963   if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 963   if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 
| 964     m_iRBtnPartStates = 0; | 964     m_iRBtnPartStates = 0; | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 988       return; | 988       return; | 
| 989 | 989 | 
| 990     pIPicker->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel); | 990     pIPicker->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel); | 
| 991     pIPicker->ShowMonthCalendar(false); | 991     pIPicker->ShowMonthCalendar(false); | 
| 992   } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) { | 992   } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) { | 
| 993     pIPicker->ShowMonthCalendar(false); | 993     pIPicker->ShowMonthCalendar(false); | 
| 994   } | 994   } | 
| 995   m_bFlag = 0; | 995   m_bFlag = 0; | 
| 996 } | 996 } | 
| 997 | 997 | 
| 998 void CFWL_MonthCalendar::DisForm_OnLButtonUp(CFWL_MsgMouse* pMsg) { | 998 void CFWL_MonthCalendar::DisForm_OnLButtonUp(CFWL_MessageMouse* pMsg) { | 
| 999   if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 999   if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 
| 1000     m_iLBtnPartStates = 0; | 1000     m_iLBtnPartStates = 0; | 
| 1001     Repaint(&(m_rtLBtn)); | 1001     Repaint(&(m_rtLBtn)); | 
| 1002     return; | 1002     return; | 
| 1003   } | 1003   } | 
| 1004   if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 1004   if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 
| 1005     m_iRBtnPartStates = 0; | 1005     m_iRBtnPartStates = 0; | 
| 1006     Repaint(&(m_rtRBtn)); | 1006     Repaint(&(m_rtRBtn)); | 
| 1007     return; | 1007     return; | 
| 1008   } | 1008   } | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 1022       rtInvalidate.Union(lpDatesInfo->rect); | 1022       rtInvalidate.Union(lpDatesInfo->rect); | 
| 1023     } | 1023     } | 
| 1024     AddSelDay(iCurSel); | 1024     AddSelDay(iCurSel); | 
| 1025     CFWL_DateTimePicker* pDateTime = | 1025     CFWL_DateTimePicker* pDateTime = | 
| 1026         static_cast<CFWL_DateTimePicker*>(m_pOuter); | 1026         static_cast<CFWL_DateTimePicker*>(m_pOuter); | 
| 1027     pDateTime->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel); | 1027     pDateTime->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel); | 
| 1028     pDateTime->ShowMonthCalendar(false); | 1028     pDateTime->ShowMonthCalendar(false); | 
| 1029   } | 1029   } | 
| 1030 } | 1030 } | 
| 1031 | 1031 | 
| 1032 void CFWL_MonthCalendar::OnMouseMove(CFWL_MsgMouse* pMsg) { | 1032 void CFWL_MonthCalendar::OnMouseMove(CFWL_MessageMouse* pMsg) { | 
| 1033   if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) | 1033   if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) | 
| 1034     return; | 1034     return; | 
| 1035 | 1035 | 
| 1036   bool bRepaint = false; | 1036   bool bRepaint = false; | 
| 1037   CFX_RectF rtInvalidate; | 1037   CFX_RectF rtInvalidate; | 
| 1038   rtInvalidate.Set(0, 0, 0, 0); | 1038   rtInvalidate.Set(0, 0, 0, 0); | 
| 1039   if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { | 1039   if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { | 
| 1040     int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); | 1040     int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); | 
| 1041     bRepaint = m_iHovered != iHover; | 1041     bRepaint = m_iHovered != iHover; | 
| 1042     if (bRepaint) { | 1042     if (bRepaint) { | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 1056     bRepaint = m_iHovered > 0; | 1056     bRepaint = m_iHovered > 0; | 
| 1057     if (bRepaint) | 1057     if (bRepaint) | 
| 1058       GetDayRect(m_iHovered, rtInvalidate); | 1058       GetDayRect(m_iHovered, rtInvalidate); | 
| 1059 | 1059 | 
| 1060     m_iHovered = -1; | 1060     m_iHovered = -1; | 
| 1061   } | 1061   } | 
| 1062   if (bRepaint && !rtInvalidate.IsEmpty()) | 1062   if (bRepaint && !rtInvalidate.IsEmpty()) | 
| 1063     Repaint(&rtInvalidate); | 1063     Repaint(&rtInvalidate); | 
| 1064 } | 1064 } | 
| 1065 | 1065 | 
| 1066 void CFWL_MonthCalendar::OnMouseLeave(CFWL_MsgMouse* pMsg) { | 1066 void CFWL_MonthCalendar::OnMouseLeave(CFWL_MessageMouse* pMsg) { | 
| 1067   if (m_iHovered <= 0) | 1067   if (m_iHovered <= 0) | 
| 1068     return; | 1068     return; | 
| 1069 | 1069 | 
| 1070   CFX_RectF rtInvalidate; | 1070   CFX_RectF rtInvalidate; | 
| 1071   rtInvalidate.Set(0, 0, 0, 0); | 1071   rtInvalidate.Set(0, 0, 0, 0); | 
| 1072   GetDayRect(m_iHovered, rtInvalidate); | 1072   GetDayRect(m_iHovered, rtInvalidate); | 
| 1073   m_iHovered = -1; | 1073   m_iHovered = -1; | 
| 1074   if (!rtInvalidate.IsEmpty()) | 1074   if (!rtInvalidate.IsEmpty()) | 
| 1075     Repaint(&rtInvalidate); | 1075     Repaint(&rtInvalidate); | 
| 1076 } | 1076 } | 
| 1077 | 1077 | 
| 1078 CFWL_MonthCalendar::DATEINFO::DATEINFO(int32_t day, | 1078 CFWL_MonthCalendar::DATEINFO::DATEINFO(int32_t day, | 
| 1079                                        int32_t dayofweek, | 1079                                        int32_t dayofweek, | 
| 1080                                        uint32_t dwSt, | 1080                                        uint32_t dwSt, | 
| 1081                                        CFX_RectF rc, | 1081                                        CFX_RectF rc, | 
| 1082                                        CFX_WideString& wsday) | 1082                                        CFX_WideString& wsday) | 
| 1083     : iDay(day), | 1083     : iDay(day), | 
| 1084       iDayOfWeek(dayofweek), | 1084       iDayOfWeek(dayofweek), | 
| 1085       dwStates(dwSt), | 1085       dwStates(dwSt), | 
| 1086       rect(rc), | 1086       rect(rc), | 
| 1087       wsDay(wsday) {} | 1087       wsDay(wsday) {} | 
| 1088 | 1088 | 
| 1089 CFWL_MonthCalendar::DATEINFO::~DATEINFO() {} | 1089 CFWL_MonthCalendar::DATEINFO::~DATEINFO() {} | 
| OLD | NEW | 
|---|