Index: xfa/fwl/core/ifwl_datetimecalendar.cpp |
diff --git a/xfa/fwl/core/ifwl_datetimecalendar.cpp b/xfa/fwl/core/ifwl_datetimecalendar.cpp |
index a44b55819076e708910b18a2acfd6e48d289aad6..f521c56fb70bb7312fafe3a7c7a2b9362fbc232f 100644 |
--- a/xfa/fwl/core/ifwl_datetimecalendar.cpp |
+++ b/xfa/fwl/core/ifwl_datetimecalendar.cpp |
@@ -15,23 +15,14 @@ IFWL_DateTimeCalendar::IFWL_DateTimeCalendar( |
const IFWL_App* app, |
const CFWL_WidgetImpProperties& properties, |
IFWL_Widget* pOuter) |
- : IFWL_MonthCalendar(app, properties, pOuter) { |
- SetDelegate(pdfium::MakeUnique<CFWL_DateTimeCalendarImpDelegate>(this)); |
-} |
- |
-CFWL_DateTimeCalendarImpDelegate::CFWL_DateTimeCalendarImpDelegate( |
- IFWL_DateTimeCalendar* pOwner) |
- : CFWL_MonthCalendarImpDelegate(pOwner), m_pOwner(pOwner) { |
- m_bFlag = FALSE; |
-} |
+ : IFWL_MonthCalendar(app, properties, pOuter), m_bFlag(FALSE) {} |
-void CFWL_DateTimeCalendarImpDelegate::OnProcessMessage( |
- CFWL_Message* pMessage) { |
+void IFWL_DateTimeCalendar::OnProcessMessage(CFWL_Message* pMessage) { |
CFWL_MessageType dwCode = pMessage->GetClassID(); |
if (dwCode == CFWL_MessageType::SetFocus || |
dwCode == CFWL_MessageType::KillFocus) { |
- IFWL_Widget* pOuter = m_pOwner->GetOuter(); |
- pOuter->GetCurrentDelegate()->OnProcessMessage(pMessage); |
+ IFWL_Widget* pOuter = GetOuter(); |
+ pOuter->GetDelegate()->OnProcessMessage(pMessage); |
return; |
} |
if (dwCode == CFWL_MessageType::Mouse) { |
@@ -42,72 +33,67 @@ void CFWL_DateTimeCalendarImpDelegate::OnProcessMessage( |
OnLButtonUpEx(pMsg); |
return; |
} |
- CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); |
+ IFWL_MonthCalendar::OnProcessMessage(pMessage); |
} |
-void CFWL_DateTimeCalendarImpDelegate::OnLButtonDownEx(CFWL_MsgMouse* pMsg) { |
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
- m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed; |
- m_pOwner->PrevMonth(); |
- m_pOwner->Repaint(&m_pOwner->m_rtClient); |
- } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
- m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed; |
- m_pOwner->NextMonth(); |
- m_pOwner->Repaint(&m_pOwner->m_rtClient); |
- } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { |
- if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == |
- 0) { |
- m_pOwner->JumpToToday(); |
- m_pOwner->Repaint(&m_pOwner->m_rtClient); |
+void IFWL_DateTimeCalendar::OnLButtonDownEx(CFWL_MsgMouse* pMsg) { |
+ if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ m_iLBtnPartStates = CFWL_PartState_Pressed; |
+ PrevMonth(); |
+ Repaint(&m_rtClient); |
+ } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ m_iRBtnPartStates |= CFWL_PartState_Pressed; |
+ NextMonth(); |
+ Repaint(&m_rtClient); |
+ } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 0) { |
+ JumpToToday(); |
+ Repaint(&m_rtClient); |
} |
} else { |
- IFWL_DateTimePicker* pIPicker = |
- static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); |
- if (pIPicker->IsMonthCalendarShowed()) { |
+ IFWL_DateTimePicker* pIPicker = static_cast<IFWL_DateTimePicker*>(m_pOuter); |
+ if (pIPicker->IsMonthCalendarShowed()) |
m_bFlag = 1; |
- } |
} |
} |
-void CFWL_DateTimeCalendarImpDelegate::OnLButtonUpEx(CFWL_MsgMouse* pMsg) { |
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { |
+void IFWL_DateTimeCalendar::OnLButtonUpEx(CFWL_MsgMouse* pMsg) { |
+ if (m_pWidgetMgr->IsFormDisabled()) |
return DisForm_OnLButtonUpEx(pMsg); |
- } |
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
- m_pOwner->m_iLBtnPartStates = 0; |
- m_pOwner->Repaint(&m_pOwner->m_rtLBtn); |
+ if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ m_iLBtnPartStates = 0; |
+ Repaint(&m_rtLBtn); |
return; |
} |
- if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
- m_pOwner->m_iRBtnPartStates = 0; |
- m_pOwner->Repaint(&m_pOwner->m_rtRBtn); |
+ if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ m_iRBtnPartStates = 0; |
+ Repaint(&m_rtRBtn); |
return; |
} |
- if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) |
return; |
- } |
+ |
int32_t iOldSel = 0; |
- if (m_pOwner->m_arrSelDays.GetSize() > 0) { |
- iOldSel = m_pOwner->m_arrSelDays[0]; |
- } |
- int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
+ if (m_arrSelDays.GetSize() > 0) |
+ iOldSel = m_arrSelDays[0]; |
+ |
+ int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
CFX_RectF rt; |
- IFWL_DateTimePicker* pIPicker = |
- static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); |
- pIPicker->m_pForm->GetWidgetRect(rt); |
+ IFWL_DateTimePicker* pIPicker = static_cast<IFWL_DateTimePicker*>(m_pOuter); |
+ pIPicker->GetFormProxy()->GetWidgetRect(rt); |
rt.Set(0, 0, rt.width, rt.height); |
if (iCurSel > 0) { |
- FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1); |
+ FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1); |
CFX_RectF rtInvalidate(lpDatesInfo->rect); |
- if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) { |
- lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1); |
+ if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) { |
+ lpDatesInfo = m_arrDates.GetAt(iOldSel - 1); |
rtInvalidate.Union(lpDatesInfo->rect); |
} |
- m_pOwner->AddSelDay(iCurSel); |
- if (!m_pOwner->m_pOuter) |
+ AddSelDay(iCurSel); |
+ if (!m_pOuter) |
return; |
- pIPicker->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth, |
- iCurSel); |
+ |
+ pIPicker->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel); |
pIPicker->ShowMonthCalendar(FALSE); |
} else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) { |
pIPicker->ShowMonthCalendar(FALSE); |
@@ -115,48 +101,44 @@ void CFWL_DateTimeCalendarImpDelegate::OnLButtonUpEx(CFWL_MsgMouse* pMsg) { |
m_bFlag = 0; |
} |
-void CFWL_DateTimeCalendarImpDelegate::OnMouseMoveEx(CFWL_MsgMouse* pMsg) { |
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { |
+void IFWL_DateTimeCalendar::OnMouseMoveEx(CFWL_MsgMouse* pMsg) { |
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) |
return; |
- } |
+ |
FX_BOOL bRepaint = FALSE; |
CFX_RectF rtInvalidate; |
rtInvalidate.Set(0, 0, 0, 0); |
- if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { |
- int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
- bRepaint = m_pOwner->m_iHovered != iHover; |
+ if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
+ bRepaint = m_iHovered != iHover; |
if (bRepaint) { |
- if (m_pOwner->m_iHovered > 0) { |
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); |
- } |
+ if (m_iHovered > 0) |
+ GetDayRect(m_iHovered, rtInvalidate); |
if (iHover > 0) { |
CFX_RectF rtDay; |
- m_pOwner->GetDayRect(iHover, rtDay); |
- if (rtInvalidate.IsEmpty()) { |
+ GetDayRect(iHover, rtDay); |
+ if (rtInvalidate.IsEmpty()) |
rtInvalidate = rtDay; |
- } else { |
+ else |
rtInvalidate.Union(rtDay); |
- } |
} |
} |
- m_pOwner->m_iHovered = iHover; |
+ m_iHovered = iHover; |
CFWL_Event_DtpHoverChanged ev; |
ev.hoverday = iHover; |
- m_pOwner->DispatchEvent(&ev); |
+ DispatchEvent(&ev); |
} else { |
- bRepaint = m_pOwner->m_iHovered > 0; |
- if (bRepaint) { |
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); |
- } |
- m_pOwner->m_iHovered = -1; |
- } |
- if (bRepaint && !rtInvalidate.IsEmpty()) { |
- m_pOwner->Repaint(&rtInvalidate); |
+ bRepaint = m_iHovered > 0; |
+ if (bRepaint) |
+ GetDayRect(m_iHovered, rtInvalidate); |
+ |
+ m_iHovered = -1; |
} |
+ if (bRepaint && !rtInvalidate.IsEmpty()) |
+ Repaint(&rtInvalidate); |
} |
-void CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( |
- CFWL_Message* pMessage) { |
+void IFWL_DateTimeCalendar::DisForm_OnProcessMessage(CFWL_Message* pMessage) { |
if (pMessage->GetClassID() == CFWL_MessageType::Mouse) { |
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { |
@@ -164,41 +146,39 @@ void CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( |
return; |
} |
} |
- CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); |
+ IFWL_MonthCalendar::OnProcessMessage(pMessage); |
} |
-void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx( |
- CFWL_MsgMouse* pMsg) { |
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
- m_pOwner->m_iLBtnPartStates = 0; |
- m_pOwner->Repaint(&(m_pOwner->m_rtLBtn)); |
+void IFWL_DateTimeCalendar::DisForm_OnLButtonUpEx(CFWL_MsgMouse* pMsg) { |
+ if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ m_iLBtnPartStates = 0; |
+ Repaint(&(m_rtLBtn)); |
return; |
} |
- if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
- m_pOwner->m_iRBtnPartStates = 0; |
- m_pOwner->Repaint(&(m_pOwner->m_rtRBtn)); |
+ if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ m_iRBtnPartStates = 0; |
+ Repaint(&(m_rtRBtn)); |
return; |
} |
- if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { |
+ if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) |
return; |
- } |
+ |
int32_t iOldSel = 0; |
- if (m_pOwner->m_arrSelDays.GetSize() > 0) { |
- iOldSel = m_pOwner->m_arrSelDays[0]; |
- } |
- int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
+ if (m_arrSelDays.GetSize() > 0) |
+ iOldSel = m_arrSelDays[0]; |
+ |
+ int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); |
if (iCurSel > 0) { |
- FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1); |
+ FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1); |
CFX_RectF rtInvalidate(lpDatesInfo->rect); |
- if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) { |
- lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1); |
+ if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) { |
+ lpDatesInfo = m_arrDates.GetAt(iOldSel - 1); |
rtInvalidate.Union(lpDatesInfo->rect); |
} |
- m_pOwner->AddSelDay(iCurSel); |
+ AddSelDay(iCurSel); |
IFWL_DateTimePicker* pDateTime = |
- static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter); |
- pDateTime->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth, |
- iCurSel); |
+ static_cast<IFWL_DateTimePicker*>(m_pOuter); |
+ pDateTime->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel); |
pDateTime->ShowMonthCalendar(FALSE); |
} |
} |