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

Side by Side Diff: xfa/fwl/core/ifwl_monthcalendar.cpp

Issue 2467993003: Merge delegates into IFWL_* classes. (Closed)
Patch Set: Add const version Created 4 years, 1 month 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
« no previous file with comments | « xfa/fwl/core/ifwl_monthcalendar.h ('k') | xfa/fwl/core/ifwl_picturebox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/core/ifwl_monthcalendar.h" 7 #include "xfa/fwl/core/ifwl_monthcalendar.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 m_rtLBtn.Reset(); 139 m_rtLBtn.Reset();
140 m_rtRBtn.Reset(); 140 m_rtRBtn.Reset();
141 m_rtDates.Reset(); 141 m_rtDates.Reset();
142 m_rtHSep.Reset(); 142 m_rtHSep.Reset();
143 m_rtHeadText.Reset(); 143 m_rtHeadText.Reset();
144 m_rtToday.Reset(); 144 m_rtToday.Reset();
145 m_rtTodayFlag.Reset(); 145 m_rtTodayFlag.Reset();
146 m_rtClient.Reset(); 146 m_rtClient.Reset();
147 m_rtWeekNum.Reset(); 147 m_rtWeekNum.Reset();
148 m_rtWeekNumSep.Reset(); 148 m_rtWeekNumSep.Reset();
149
150 SetDelegate(pdfium::MakeUnique<CFWL_MonthCalendarImpDelegate>(this));
151 } 149 }
152 150
153 IFWL_MonthCalendar::~IFWL_MonthCalendar() { 151 IFWL_MonthCalendar::~IFWL_MonthCalendar() {
154 ClearDateItem(); 152 ClearDateItem();
155 m_arrSelDays.RemoveAll(); 153 m_arrSelDays.RemoveAll();
156 } 154 }
157 155
158 FWL_Type IFWL_MonthCalendar::GetClassID() const { 156 FWL_Type IFWL_MonthCalendar::GetClassID() const {
159 return FWL_Type::MonthCalendar; 157 return FWL_Type::MonthCalendar;
160 } 158 }
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 if (iDay <= 0 || iDay > m_arrDates.GetSize()) { 1006 if (iDay <= 0 || iDay > m_arrDates.GetSize()) {
1009 return FALSE; 1007 return FALSE;
1010 } 1008 }
1011 FWL_DATEINFO* pDateInfo = m_arrDates[iDay - 1]; 1009 FWL_DATEINFO* pDateInfo = m_arrDates[iDay - 1];
1012 if (!pDateInfo) 1010 if (!pDateInfo)
1013 return FALSE; 1011 return FALSE;
1014 rtDay = pDateInfo->rect; 1012 rtDay = pDateInfo->rect;
1015 return TRUE; 1013 return TRUE;
1016 } 1014 }
1017 1015
1018 CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate( 1016 void IFWL_MonthCalendar::OnProcessMessage(CFWL_Message* pMessage) {
1019 IFWL_MonthCalendar* pOwner)
1020 : m_pOwner(pOwner) {}
1021
1022 void CFWL_MonthCalendarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
1023 if (!pMessage) 1017 if (!pMessage)
1024 return; 1018 return;
1025 1019
1026 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 1020 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
1027 switch (dwMsgCode) { 1021 switch (dwMsgCode) {
1028 case CFWL_MessageType::SetFocus: { 1022 case CFWL_MessageType::SetFocus:
1029 OnFocusChanged(pMessage, TRUE); 1023 OnFocusChanged(pMessage, TRUE);
1030 break; 1024 break;
1031 } 1025 case CFWL_MessageType::KillFocus:
1032 case CFWL_MessageType::KillFocus: {
1033 OnFocusChanged(pMessage, FALSE); 1026 OnFocusChanged(pMessage, FALSE);
1034 break; 1027 break;
1035 } 1028 case CFWL_MessageType::Key:
1036 case CFWL_MessageType::Key: {
1037 break; 1029 break;
1038 }
1039 case CFWL_MessageType::Mouse: { 1030 case CFWL_MessageType::Mouse: {
1040 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); 1031 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
1041 switch (pMouse->m_dwCmd) { 1032 switch (pMouse->m_dwCmd) {
1042 case FWL_MouseCommand::LeftButtonDown: { 1033 case FWL_MouseCommand::LeftButtonDown:
1043 OnLButtonDown(pMouse); 1034 OnLButtonDown(pMouse);
1044 break; 1035 break;
1045 } 1036 case FWL_MouseCommand::LeftButtonUp:
1046 case FWL_MouseCommand::LeftButtonUp: {
1047 OnLButtonUp(pMouse); 1037 OnLButtonUp(pMouse);
1048 break; 1038 break;
1049 } 1039 case FWL_MouseCommand::Move:
1050 case FWL_MouseCommand::Move: {
1051 OnMouseMove(pMouse); 1040 OnMouseMove(pMouse);
1052 break; 1041 break;
1053 } 1042 case FWL_MouseCommand::Leave:
1054 case FWL_MouseCommand::Leave: {
1055 OnMouseLeave(pMouse); 1043 OnMouseLeave(pMouse);
1056 break; 1044 break;
1057 }
1058 default: 1045 default:
1059 break; 1046 break;
1060 } 1047 }
1061 break; 1048 break;
1062 } 1049 }
1063 default: { break; } 1050 default:
1051 break;
1064 } 1052 }
1065 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); 1053 IFWL_Widget::OnProcessMessage(pMessage);
1066 } 1054 }
1067 1055
1068 void CFWL_MonthCalendarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, 1056 void IFWL_MonthCalendar::OnDrawWidget(CFX_Graphics* pGraphics,
1069 const CFX_Matrix* pMatrix) { 1057 const CFX_Matrix* pMatrix) {
1070 m_pOwner->DrawWidget(pGraphics, pMatrix); 1058 DrawWidget(pGraphics, pMatrix);
1071 } 1059 }
1072 1060
1073 void CFWL_MonthCalendarImpDelegate::OnActivate(CFWL_Message* pMsg) {} 1061 void IFWL_MonthCalendar::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
1062 if (bSet)
1063 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1064 else
1065 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
1074 1066
1075 void CFWL_MonthCalendarImpDelegate::OnFocusChanged(CFWL_Message* pMsg, 1067 Repaint(&m_rtClient);
1076 FX_BOOL bSet) {
1077 if (bSet) {
1078 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1079 } else {
1080 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
1081 }
1082 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1083 } 1068 }
1084 1069
1085 void CFWL_MonthCalendarImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { 1070 void IFWL_MonthCalendar::OnLButtonDown(CFWL_MsgMouse* pMsg) {
1086 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1071 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1087 m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed; 1072 m_iLBtnPartStates = CFWL_PartState_Pressed;
1088 m_pOwner->PrevMonth(); 1073 PrevMonth();
1089 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1074 Repaint(&m_rtClient);
1090 } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1075 } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1091 m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed; 1076 m_iRBtnPartStates |= CFWL_PartState_Pressed;
1092 m_pOwner->NextMonth(); 1077 NextMonth();
1093 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1078 Repaint(&m_rtClient);
1094 } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { 1079 } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
1095 if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 1080 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 0) {
1096 0) { 1081 JumpToToday();
1097 m_pOwner->JumpToToday(); 1082 Repaint(&m_rtClient);
1098 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1099 } 1083 }
1100 } else { 1084 } else {
1101 if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { 1085 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)) {
1102 } else {
1103 int32_t iOldSel = 0; 1086 int32_t iOldSel = 0;
1104 if (m_pOwner->m_arrSelDays.GetSize() > 0) { 1087 if (m_arrSelDays.GetSize() <= 0)
1105 iOldSel = m_pOwner->m_arrSelDays[0];
1106 } else {
1107 return; 1088 return;
1108 } 1089 iOldSel = m_arrSelDays[0];
1109 int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); 1090
1091 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
1110 FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel; 1092 FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel;
1111 if (bSelChanged) { 1093 if (bSelChanged) {
1112 FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1); 1094 FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1);
1113 CFX_RectF rtInvalidate(lpDatesInfo->rect); 1095 CFX_RectF rtInvalidate(lpDatesInfo->rect);
1114 if (iOldSel > 0) { 1096 if (iOldSel > 0) {
1115 lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1); 1097 lpDatesInfo = m_arrDates.GetAt(iOldSel - 1);
1116 rtInvalidate.Union(lpDatesInfo->rect); 1098 rtInvalidate.Union(lpDatesInfo->rect);
1117 } 1099 }
1118 m_pOwner->AddSelDay(iCurSel); 1100 AddSelDay(iCurSel);
1119 CFWL_EvtClick wmClick; 1101 CFWL_EvtClick wmClick;
1120 wmClick.m_pSrcTarget = m_pOwner; 1102 wmClick.m_pSrcTarget = this;
1121 m_pOwner->DispatchEvent(&wmClick); 1103 DispatchEvent(&wmClick);
1122 CFWL_EventMcdDateChanged wmDateSelected; 1104 CFWL_EventMcdDateChanged wmDateSelected;
1123 wmDateSelected.m_iStartDay = iCurSel; 1105 wmDateSelected.m_iStartDay = iCurSel;
1124 wmDateSelected.m_iEndDay = iCurSel; 1106 wmDateSelected.m_iEndDay = iCurSel;
1125 wmDateSelected.m_iOldMonth = m_pOwner->m_iCurMonth; 1107 wmDateSelected.m_iOldMonth = m_iCurMonth;
1126 wmDateSelected.m_iOldYear = m_pOwner->m_iCurYear; 1108 wmDateSelected.m_iOldYear = m_iCurYear;
1127 wmDateSelected.m_pSrcTarget = m_pOwner; 1109 wmDateSelected.m_pSrcTarget = this;
1128 m_pOwner->DispatchEvent(&wmDateSelected); 1110 DispatchEvent(&wmDateSelected);
1129 m_pOwner->Repaint(&rtInvalidate); 1111 Repaint(&rtInvalidate);
1130 } 1112 }
1131 } 1113 }
1132 } 1114 }
1133 } 1115 }
1134 1116
1135 void CFWL_MonthCalendarImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { 1117 void IFWL_MonthCalendar::OnLButtonUp(CFWL_MsgMouse* pMsg) {
1136 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1118 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1137 m_pOwner->m_iLBtnPartStates = 0; 1119 m_iLBtnPartStates = 0;
1138 m_pOwner->Repaint(&m_pOwner->m_rtLBtn); 1120 Repaint(&m_rtLBtn);
1139 } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1121 } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1140 m_pOwner->m_iRBtnPartStates = 0; 1122 m_iRBtnPartStates = 0;
1141 m_pOwner->Repaint(&m_pOwner->m_rtRBtn); 1123 Repaint(&m_rtRBtn);
1142 } else if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { 1124 } else if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
1143 int32_t iDay = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); 1125 int32_t iDay = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
1144 if (iDay != -1) { 1126 if (iDay != -1)
1145 m_pOwner->AddSelDay(iDay); 1127 AddSelDay(iDay);
1146 }
1147 } 1128 }
1148 } 1129 }
1149 1130
1150 void CFWL_MonthCalendarImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { 1131 void IFWL_MonthCalendar::OnMouseMove(CFWL_MsgMouse* pMsg) {
1151 if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { 1132 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)
1152 return; 1133 return;
1153 } 1134
1154 FX_BOOL bRepaint = FALSE; 1135 FX_BOOL bRepaint = FALSE;
1155 CFX_RectF rtInvalidate; 1136 CFX_RectF rtInvalidate;
1156 rtInvalidate.Set(0, 0, 0, 0); 1137 rtInvalidate.Set(0, 0, 0, 0);
1157 if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { 1138 if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
1158 int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); 1139 int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
1159 bRepaint = m_pOwner->m_iHovered != iHover; 1140 bRepaint = m_iHovered != iHover;
1160 if (bRepaint) { 1141 if (bRepaint) {
1161 if (m_pOwner->m_iHovered > 0) { 1142 if (m_iHovered > 0)
1162 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); 1143 GetDayRect(m_iHovered, rtInvalidate);
1163 }
1164 if (iHover > 0) { 1144 if (iHover > 0) {
1165 CFX_RectF rtDay; 1145 CFX_RectF rtDay;
1166 m_pOwner->GetDayRect(iHover, rtDay); 1146 GetDayRect(iHover, rtDay);
1167 if (rtInvalidate.IsEmpty()) { 1147 if (rtInvalidate.IsEmpty())
1168 rtInvalidate = rtDay; 1148 rtInvalidate = rtDay;
1169 } else { 1149 else
1170 rtInvalidate.Union(rtDay); 1150 rtInvalidate.Union(rtDay);
1171 }
1172 } 1151 }
1173 } 1152 }
1174 m_pOwner->m_iHovered = iHover; 1153 m_iHovered = iHover;
1175 } else { 1154 } else {
1176 bRepaint = m_pOwner->m_iHovered > 0; 1155 bRepaint = m_iHovered > 0;
1177 if (bRepaint) { 1156 if (bRepaint)
1178 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); 1157 GetDayRect(m_iHovered, rtInvalidate);
1179 } 1158
1180 m_pOwner->m_iHovered = -1; 1159 m_iHovered = -1;
1181 } 1160 }
1182 if (bRepaint && !rtInvalidate.IsEmpty()) { 1161 if (bRepaint && !rtInvalidate.IsEmpty())
1183 m_pOwner->Repaint(&rtInvalidate); 1162 Repaint(&rtInvalidate);
1184 }
1185 } 1163 }
1186 1164
1187 void CFWL_MonthCalendarImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { 1165 void IFWL_MonthCalendar::OnMouseLeave(CFWL_MsgMouse* pMsg) {
1188 if (m_pOwner->m_iHovered > 0) { 1166 if (m_iHovered <= 0)
1189 CFX_RectF rtInvalidate; 1167 return;
1190 rtInvalidate.Set(0, 0, 0, 0); 1168
1191 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); 1169 CFX_RectF rtInvalidate;
1192 m_pOwner->m_iHovered = -1; 1170 rtInvalidate.Set(0, 0, 0, 0);
1193 if (!rtInvalidate.IsEmpty()) { 1171 GetDayRect(m_iHovered, rtInvalidate);
1194 m_pOwner->Repaint(&rtInvalidate); 1172 m_iHovered = -1;
1195 } 1173 if (!rtInvalidate.IsEmpty())
1196 } 1174 Repaint(&rtInvalidate);
1197 } 1175 }
1198 1176
1199 FWL_DATEINFO::FWL_DATEINFO(int32_t day, 1177 FWL_DATEINFO::FWL_DATEINFO(int32_t day,
1200 int32_t dayofweek, 1178 int32_t dayofweek,
1201 uint32_t dwSt, 1179 uint32_t dwSt,
1202 CFX_RectF rc, 1180 CFX_RectF rc,
1203 CFX_WideString& wsday) 1181 CFX_WideString& wsday)
1204 : iDay(day), 1182 : iDay(day),
1205 iDayOfWeek(dayofweek), 1183 iDayOfWeek(dayofweek),
1206 dwStates(dwSt), 1184 dwStates(dwSt),
1207 rect(rc), 1185 rect(rc),
1208 wsDay(wsday) {} 1186 wsDay(wsday) {}
1209 1187
1210 FWL_DATEINFO::~FWL_DATEINFO() {} 1188 FWL_DATEINFO::~FWL_DATEINFO() {}
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_monthcalendar.h ('k') | xfa/fwl/core/ifwl_picturebox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698