| 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/core/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/core/cfwl_formproxy.h" | 16 #include "xfa/fwl/core/cfwl_formproxy.h" |
| 16 #include "xfa/fwl/core/cfwl_msgmouse.h" | 17 #include "xfa/fwl/core/cfwl_msgmouse.h" |
| 17 #include "xfa/fwl/core/cfwl_notedriver.h" | 18 #include "xfa/fwl/core/cfwl_notedriver.h" |
| 18 #include "xfa/fwl/core/cfwl_themebackground.h" | 19 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 19 #include "xfa/fwl/core/cfwl_themetext.h" | 20 #include "xfa/fwl/core/cfwl_themetext.h" |
| 20 #include "xfa/fwl/core/ifwl_datetimepicker.h" | |
| 21 #include "xfa/fwl/core/ifwl_themeprovider.h" | 21 #include "xfa/fwl/core/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 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 return static_cast<CFX_WideString*>( | 118 return static_cast<CFX_WideString*>( |
| 119 pTheme->GetCapacity(¶ms, CFWL_WidgetCapacity::December)); | 119 pTheme->GetCapacity(¶ms, CFWL_WidgetCapacity::December)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace | 122 } // namespace |
| 123 | 123 |
| 124 CFWL_MonthCalendar::CFWL_MonthCalendar( | 124 CFWL_MonthCalendar::CFWL_MonthCalendar( |
| 125 const CFWL_App* app, | 125 const CFWL_App* app, |
| 126 std::unique_ptr<CFWL_WidgetProperties> properties, | 126 std::unique_ptr<CFWL_WidgetProperties> properties, |
| 127 IFWL_Widget* pOuter) | 127 CFWL_Widget* pOuter) |
| 128 : IFWL_Widget(app, std::move(properties), pOuter), | 128 : CFWL_Widget(app, std::move(properties), pOuter), |
| 129 m_bInitialized(false), | 129 m_bInitialized(false), |
| 130 m_pDateTime(new CFX_DateTime), | 130 m_pDateTime(new CFX_DateTime), |
| 131 m_iCurYear(2011), | 131 m_iCurYear(2011), |
| 132 m_iCurMonth(1), | 132 m_iCurMonth(1), |
| 133 m_iYear(2011), | 133 m_iYear(2011), |
| 134 m_iMonth(1), | 134 m_iMonth(1), |
| 135 m_iDay(1), | 135 m_iDay(1), |
| 136 m_iHovered(-1), | 136 m_iHovered(-1), |
| 137 m_iLBtnPartStates(CFWL_PartState_Normal), | 137 m_iLBtnPartStates(CFWL_PartState_Normal), |
| 138 m_iRBtnPartStates(CFWL_PartState_Normal), | 138 m_iRBtnPartStates(CFWL_PartState_Normal), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 161 } | 161 } |
| 162 | 162 |
| 163 void CFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 163 void CFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
| 164 if (!bAutoSize) { | 164 if (!bAutoSize) { |
| 165 rect = m_pProperties->m_rtWidget; | 165 rect = m_pProperties->m_rtWidget; |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 | 168 |
| 169 CFX_SizeF fs = CalcSize(true); | 169 CFX_SizeF fs = CalcSize(true); |
| 170 rect.Set(0, 0, fs.x, fs.y); | 170 rect.Set(0, 0, fs.x, fs.y); |
| 171 IFWL_Widget::GetWidgetRect(rect, true); | 171 CFWL_Widget::GetWidgetRect(rect, true); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void CFWL_MonthCalendar::Update() { | 174 void CFWL_MonthCalendar::Update() { |
| 175 if (IsLocked()) | 175 if (IsLocked()) |
| 176 return; | 176 return; |
| 177 if (!m_pProperties->m_pThemeProvider) | 177 if (!m_pProperties->m_pThemeProvider) |
| 178 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 178 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 179 | 179 |
| 180 GetCapValue(); | 180 GetCapValue(); |
| 181 if (!m_bInitialized) { | 181 if (!m_bInitialized) { |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 OnMouseLeave(pMouse); | 936 OnMouseLeave(pMouse); |
| 937 break; | 937 break; |
| 938 default: | 938 default: |
| 939 break; | 939 break; |
| 940 } | 940 } |
| 941 break; | 941 break; |
| 942 } | 942 } |
| 943 default: | 943 default: |
| 944 break; | 944 break; |
| 945 } | 945 } |
| 946 IFWL_Widget::OnProcessMessage(pMessage); | 946 CFWL_Widget::OnProcessMessage(pMessage); |
| 947 } | 947 } |
| 948 | 948 |
| 949 void CFWL_MonthCalendar::OnDrawWidget(CFX_Graphics* pGraphics, | 949 void CFWL_MonthCalendar::OnDrawWidget(CFX_Graphics* pGraphics, |
| 950 const CFX_Matrix* pMatrix) { | 950 const CFX_Matrix* pMatrix) { |
| 951 DrawWidget(pGraphics, pMatrix); | 951 DrawWidget(pGraphics, pMatrix); |
| 952 } | 952 } |
| 953 | 953 |
| 954 void CFWL_MonthCalendar::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 954 void CFWL_MonthCalendar::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
| 955 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 955 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 956 m_iLBtnPartStates = CFWL_PartState_Pressed; | 956 m_iLBtnPartStates = CFWL_PartState_Pressed; |
| 957 PrevMonth(); | 957 PrevMonth(); |
| 958 Repaint(&m_rtClient); | 958 Repaint(&m_rtClient); |
| 959 } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 959 } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 960 m_iRBtnPartStates |= CFWL_PartState_Pressed; | 960 m_iRBtnPartStates |= CFWL_PartState_Pressed; |
| 961 NextMonth(); | 961 NextMonth(); |
| 962 Repaint(&m_rtClient); | 962 Repaint(&m_rtClient); |
| 963 } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { | 963 } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 964 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 0) { | 964 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 0) { |
| 965 JumpToToday(); | 965 JumpToToday(); |
| 966 Repaint(&m_rtClient); | 966 Repaint(&m_rtClient); |
| 967 } | 967 } |
| 968 } else { | 968 } else { |
| 969 IFWL_DateTimePicker* pIPicker = static_cast<IFWL_DateTimePicker*>(m_pOuter); | 969 CFWL_DateTimePicker* pIPicker = static_cast<CFWL_DateTimePicker*>(m_pOuter); |
| 970 if (pIPicker->IsMonthCalendarVisible()) | 970 if (pIPicker->IsMonthCalendarVisible()) |
| 971 m_bFlag = 1; | 971 m_bFlag = 1; |
| 972 } | 972 } |
| 973 } | 973 } |
| 974 | 974 |
| 975 void CFWL_MonthCalendar::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 975 void CFWL_MonthCalendar::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
| 976 if (m_pWidgetMgr->IsFormDisabled()) | 976 if (m_pWidgetMgr->IsFormDisabled()) |
| 977 return DisForm_OnLButtonUp(pMsg); | 977 return DisForm_OnLButtonUp(pMsg); |
| 978 | 978 |
| 979 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 979 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 980 m_iLBtnPartStates = 0; | 980 m_iLBtnPartStates = 0; |
| 981 Repaint(&m_rtLBtn); | 981 Repaint(&m_rtLBtn); |
| 982 return; | 982 return; |
| 983 } | 983 } |
| 984 if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 984 if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 985 m_iRBtnPartStates = 0; | 985 m_iRBtnPartStates = 0; |
| 986 Repaint(&m_rtRBtn); | 986 Repaint(&m_rtRBtn); |
| 987 return; | 987 return; |
| 988 } | 988 } |
| 989 if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) | 989 if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) |
| 990 return; | 990 return; |
| 991 | 991 |
| 992 int32_t iOldSel = 0; | 992 int32_t iOldSel = 0; |
| 993 if (m_arrSelDays.GetSize() > 0) | 993 if (m_arrSelDays.GetSize() > 0) |
| 994 iOldSel = m_arrSelDays[0]; | 994 iOldSel = m_arrSelDays[0]; |
| 995 | 995 |
| 996 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); | 996 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 997 CFX_RectF rt; | 997 CFX_RectF rt; |
| 998 IFWL_DateTimePicker* pIPicker = static_cast<IFWL_DateTimePicker*>(m_pOuter); | 998 CFWL_DateTimePicker* pIPicker = static_cast<CFWL_DateTimePicker*>(m_pOuter); |
| 999 pIPicker->GetFormProxy()->GetWidgetRect(rt); | 999 pIPicker->GetFormProxy()->GetWidgetRect(rt); |
| 1000 rt.Set(0, 0, rt.width, rt.height); | 1000 rt.Set(0, 0, rt.width, rt.height); |
| 1001 if (iCurSel > 0) { | 1001 if (iCurSel > 0) { |
| 1002 DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1); | 1002 DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1); |
| 1003 CFX_RectF rtInvalidate(lpDatesInfo->rect); | 1003 CFX_RectF rtInvalidate(lpDatesInfo->rect); |
| 1004 if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) { | 1004 if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) { |
| 1005 lpDatesInfo = m_arrDates.GetAt(iOldSel - 1); | 1005 lpDatesInfo = m_arrDates.GetAt(iOldSel - 1); |
| 1006 rtInvalidate.Union(lpDatesInfo->rect); | 1006 rtInvalidate.Union(lpDatesInfo->rect); |
| 1007 } | 1007 } |
| 1008 AddSelDay(iCurSel); | 1008 AddSelDay(iCurSel); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1037 | 1037 |
| 1038 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); | 1038 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 1039 if (iCurSel > 0) { | 1039 if (iCurSel > 0) { |
| 1040 DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1); | 1040 DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1); |
| 1041 CFX_RectF rtInvalidate(lpDatesInfo->rect); | 1041 CFX_RectF rtInvalidate(lpDatesInfo->rect); |
| 1042 if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) { | 1042 if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) { |
| 1043 lpDatesInfo = m_arrDates.GetAt(iOldSel - 1); | 1043 lpDatesInfo = m_arrDates.GetAt(iOldSel - 1); |
| 1044 rtInvalidate.Union(lpDatesInfo->rect); | 1044 rtInvalidate.Union(lpDatesInfo->rect); |
| 1045 } | 1045 } |
| 1046 AddSelDay(iCurSel); | 1046 AddSelDay(iCurSel); |
| 1047 IFWL_DateTimePicker* pDateTime = | 1047 CFWL_DateTimePicker* pDateTime = |
| 1048 static_cast<IFWL_DateTimePicker*>(m_pOuter); | 1048 static_cast<CFWL_DateTimePicker*>(m_pOuter); |
| 1049 pDateTime->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel); | 1049 pDateTime->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel); |
| 1050 pDateTime->ShowMonthCalendar(false); | 1050 pDateTime->ShowMonthCalendar(false); |
| 1051 } | 1051 } |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 void CFWL_MonthCalendar::OnMouseMove(CFWL_MsgMouse* pMsg) { | 1054 void CFWL_MonthCalendar::OnMouseMove(CFWL_MsgMouse* pMsg) { |
| 1055 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) | 1055 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) |
| 1056 return; | 1056 return; |
| 1057 | 1057 |
| 1058 bool bRepaint = false; | 1058 bool bRepaint = false; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 uint32_t dwSt, | 1102 uint32_t dwSt, |
| 1103 CFX_RectF rc, | 1103 CFX_RectF rc, |
| 1104 CFX_WideString& wsday) | 1104 CFX_WideString& wsday) |
| 1105 : iDay(day), | 1105 : iDay(day), |
| 1106 iDayOfWeek(dayofweek), | 1106 iDayOfWeek(dayofweek), |
| 1107 dwStates(dwSt), | 1107 dwStates(dwSt), |
| 1108 rect(rc), | 1108 rect(rc), |
| 1109 wsDay(wsday) {} | 1109 wsDay(wsday) {} |
| 1110 | 1110 |
| 1111 CFWL_MonthCalendar::DATEINFO::~DATEINFO() {} | 1111 CFWL_MonthCalendar::DATEINFO::~DATEINFO() {} |
| OLD | NEW |