summaryrefslogtreecommitdiff
path: root/xfa/fwl/cfwl_monthcalendar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fwl/cfwl_monthcalendar.cpp')
-rw-r--r--xfa/fwl/cfwl_monthcalendar.cpp69
1 files changed, 28 insertions, 41 deletions
diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp
index 6487262991..c779665820 100644
--- a/xfa/fwl/cfwl_monthcalendar.cpp
+++ b/xfa/fwl/cfwl_monthcalendar.cpp
@@ -243,13 +243,7 @@ void CFWL_MonthCalendar::DrawCaption(CFX_Graphics* pGraphics,
textParam.m_iPart = CFWL_Part::Caption;
textParam.m_dwStates = CFWL_PartState_Normal;
textParam.m_pGraphics = pGraphics;
- int32_t iYear;
- int32_t iMonth;
- iYear = m_iCurYear;
- iMonth = m_iCurMonth;
- CFX_WideString wsCation;
- GetHeadText(iYear, iMonth, wsCation);
- textParam.m_wsText = wsCation;
+ textParam.m_wsText = GetHeadText(m_iCurYear, m_iCurMonth);
m_szHead =
CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider, false);
CalcHeadSize();
@@ -337,10 +331,7 @@ void CFWL_MonthCalendar::DrawToday(CFX_Graphics* pGraphics,
params.m_pGraphics = pGraphics;
params.m_dwStates = CFWL_PartState_Normal;
params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
-
- CFX_WideString wsText;
- GetTodayText(m_iYear, m_iMonth, m_iDay, wsText);
- params.m_wsText = L"Today" + wsText;
+ params.m_wsText = L"Today" + GetTodayText(m_iYear, m_iMonth, m_iDay);
m_szToday =
CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider, false);
@@ -457,18 +448,14 @@ CFX_SizeF CFWL_MonthCalendar::CalcSize() {
fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y;
}
- CFX_WideString wsYear;
- GetHeadText(m_iYear, m_iMonth, wsYear);
-
- CFX_SizeF szYear =
- CalcTextSize(wsYear, m_pProperties->m_pThemeProvider, false);
+ CFX_SizeF szYear = CalcTextSize(GetHeadText(m_iYear, m_iMonth),
+ m_pProperties->m_pThemeProvider, false);
fMonthMaxH = std::max(fMonthMaxH, szYear.y);
m_szHead = CFX_SizeF(fMonthMaxW + szYear.x, fMonthMaxH);
fMonthMaxW = m_szHead.x + MONTHCAL_HEADER_BTN_HMARGIN * 2 + m_szCell.x * 2;
fs.x = std::max(fs.x, fMonthMaxW);
- CFX_WideString wsToday;
- GetTodayText(m_iYear, m_iMonth, m_iDay, wsToday);
+ CFX_WideString wsToday = GetTodayText(m_iYear, m_iMonth, m_iDay);
m_wsToday = L"Today" + wsToday;
m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider, false);
m_szToday.y = (m_szToday.y >= m_szCell.y) ? m_szToday.y : m_szCell.y;
@@ -622,8 +609,8 @@ void CFWL_MonthCalendar::InitDate() {
m_iCurYear = m_iYear;
m_iCurMonth = m_iMonth;
- GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday);
- GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
+ m_wsToday = GetTodayText(m_iYear, m_iMonth, m_iDay);
+ m_wsHead = GetHeadText(m_iCurYear, m_iCurMonth);
m_dtMin = DATE(1500, 12, 1);
m_dtMax = DATE(2200, 1, 1);
}
@@ -658,7 +645,8 @@ void CFWL_MonthCalendar::ResetDateItem() {
}
void CFWL_MonthCalendar::NextMonth() {
- int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
+ int32_t iYear = m_iCurYear;
+ int32_t iMonth = m_iCurMonth;
if (iMonth >= 12) {
iMonth = 1;
iYear++;
@@ -674,7 +662,8 @@ void CFWL_MonthCalendar::NextMonth() {
}
void CFWL_MonthCalendar::PrevMonth() {
- int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
+ int32_t iYear = m_iCurYear;
+ int32_t iMonth = m_iCurMonth;
if (iMonth <= 1) {
iMonth = 12;
iYear--;
@@ -698,7 +687,7 @@ void CFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) {
ClearDateItem();
ResetDateItem();
CalDateItem();
- GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
+ m_wsHead = GetHeadText(m_iCurYear, m_iCurMonth);
}
void CFWL_MonthCalendar::RemoveSelDay() {
@@ -741,22 +730,23 @@ void CFWL_MonthCalendar::JumpToToday() {
AddSelDay(m_iDay);
}
-void CFWL_MonthCalendar::GetHeadText(int32_t iYear,
- int32_t iMonth,
- CFX_WideString& wsHead) {
+CFX_WideString CFWL_MonthCalendar::GetHeadText(int32_t iYear, int32_t iMonth) {
ASSERT(iMonth > 0 && iMonth < 13);
static const FX_WCHAR* const pMonth[] = {
L"January", L"February", L"March", L"April",
L"May", L"June", L"July", L"August",
L"September", L"October", L"November", L"December"};
+ CFX_WideString wsHead;
wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear);
+ return wsHead;
}
-void CFWL_MonthCalendar::GetTodayText(int32_t iYear,
- int32_t iMonth,
- int32_t iDay,
- CFX_WideString& wsToday) {
+CFX_WideString CFWL_MonthCalendar::GetTodayText(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ CFX_WideString wsToday;
wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear);
+ return wsToday;
}
int32_t CFWL_MonthCalendar::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) {
@@ -769,14 +759,14 @@ int32_t CFWL_MonthCalendar::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) {
return -1;
}
-void CFWL_MonthCalendar::GetDayRect(int32_t iDay, CFX_RectF& rtDay) {
+CFX_RectF CFWL_MonthCalendar::GetDayRect(int32_t iDay) {
if (iDay <= 0 || iDay > m_arrDates.GetSize())
- return;
+ return CFX_RectF();
DATEINFO* pDateInfo = m_arrDates[iDay - 1];
if (!pDateInfo)
- return;
- rtDay = pDateInfo->rect;
+ return CFX_RectF();
+ return pDateInfo->rect;
}
void CFWL_MonthCalendar::OnProcessMessage(CFWL_Message* pMessage) {
@@ -927,10 +917,9 @@ void CFWL_MonthCalendar::OnMouseMove(CFWL_MessageMouse* pMsg) {
bRepaint = m_iHovered != iHover;
if (bRepaint) {
if (m_iHovered > 0)
- GetDayRect(m_iHovered, rtInvalidate);
+ rtInvalidate = GetDayRect(m_iHovered);
if (iHover > 0) {
- CFX_RectF rtDay;
- GetDayRect(iHover, rtDay);
+ CFX_RectF rtDay = GetDayRect(iHover);
if (rtInvalidate.IsEmpty())
rtInvalidate = rtDay;
else
@@ -941,7 +930,7 @@ void CFWL_MonthCalendar::OnMouseMove(CFWL_MessageMouse* pMsg) {
} else {
bRepaint = m_iHovered > 0;
if (bRepaint)
- GetDayRect(m_iHovered, rtInvalidate);
+ rtInvalidate = GetDayRect(m_iHovered);
m_iHovered = -1;
}
@@ -953,9 +942,7 @@ void CFWL_MonthCalendar::OnMouseLeave(CFWL_MessageMouse* pMsg) {
if (m_iHovered <= 0)
return;
- CFX_RectF rtInvalidate;
- rtInvalidate.Set(0, 0, 0, 0);
- GetDayRect(m_iHovered, rtInvalidate);
+ CFX_RectF rtInvalidate = GetDayRect(m_iHovered);
m_iHovered = -1;
if (!rtInvalidate.IsEmpty())
RepaintRect(rtInvalidate);