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/cfwl_monthcalendar.h" | 7 #include "xfa/fwl/cfwl_monthcalendar.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, | 594 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, |
595 m_szCell.x, m_szToday.y); | 595 m_szCell.x, m_szToday.y); |
596 m_rtToday.Set( | 596 m_rtToday.Set( |
597 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x + | 597 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x + |
598 MONTHCAL_HMARGIN * 2, | 598 MONTHCAL_HMARGIN * 2, |
599 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, | 599 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, |
600 m_szToday.x, m_szToday.y); | 600 m_szToday.x, m_szToday.y); |
601 } | 601 } |
602 | 602 |
603 void CFWL_MonthCalendar::Layout() { | 603 void CFWL_MonthCalendar::Layout() { |
604 GetClientRect(m_rtClient); | 604 m_rtClient = GetClientRect(); |
605 | 605 |
606 m_rtHead.Set( | 606 m_rtHead.Set( |
607 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, | 607 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, |
608 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, | 608 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, |
609 m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); | 609 m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); |
610 m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtHead.bottom(), | 610 m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtHead.bottom(), |
611 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, | 611 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, |
612 m_szCell.y + MONTHCAL_VMARGIN * 2); | 612 m_szCell.y + MONTHCAL_VMARGIN * 2); |
613 m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, | 613 m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, |
614 m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, | 614 m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_MessageMouse* 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 RepaintRect(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 RepaintRect(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 RepaintRect(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_MessageMouse* 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 RepaintRect(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; |
965 Repaint(&m_rtRBtn); | 965 RepaintRect(m_rtRBtn); |
966 return; | 966 return; |
967 } | 967 } |
968 if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) | 968 if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) |
969 return; | 969 return; |
970 | 970 |
971 int32_t iOldSel = 0; | 971 int32_t iOldSel = 0; |
972 if (m_arrSelDays.GetSize() > 0) | 972 if (m_arrSelDays.GetSize() > 0) |
973 iOldSel = m_arrSelDays[0]; | 973 iOldSel = m_arrSelDays[0]; |
974 | 974 |
975 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); | 975 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
(...skipping 15 matching lines...) Expand all Loading... |
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_MessageMouse* 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 RepaintRect(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 RepaintRect(m_rtRBtn); |
1007 return; | 1007 return; |
1008 } | 1008 } |
1009 if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) | 1009 if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) |
1010 return; | 1010 return; |
1011 | 1011 |
1012 int32_t iOldSel = 0; | 1012 int32_t iOldSel = 0; |
1013 if (m_arrSelDays.GetSize() > 0) | 1013 if (m_arrSelDays.GetSize() > 0) |
1014 iOldSel = m_arrSelDays[0]; | 1014 iOldSel = m_arrSelDays[0]; |
1015 | 1015 |
1016 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); | 1016 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 } | 1053 } |
1054 m_iHovered = iHover; | 1054 m_iHovered = iHover; |
1055 } else { | 1055 } else { |
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 RepaintRect(rtInvalidate); |
1064 } | 1064 } |
1065 | 1065 |
1066 void CFWL_MonthCalendar::OnMouseLeave(CFWL_MessageMouse* 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 RepaintRect(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 |