| 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/basewidget/fwl_monthcalendarimp.h" | 7 #include "xfa/fwl/basewidget/fwl_monthcalendarimp.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 CFWL_MonthCalendarImp::~CFWL_MonthCalendarImp() { | 87 CFWL_MonthCalendarImp::~CFWL_MonthCalendarImp() { |
| 88 ClearDateItem(); | 88 ClearDateItem(); |
| 89 delete m_pDateTime; | 89 delete m_pDateTime; |
| 90 m_arrSelDays.RemoveAll(); | 90 m_arrSelDays.RemoveAll(); |
| 91 } | 91 } |
| 92 FWL_ERR CFWL_MonthCalendarImp::GetClassName(CFX_WideString& wsClass) const { | 92 FWL_ERR CFWL_MonthCalendarImp::GetClassName(CFX_WideString& wsClass) const { |
| 93 wsClass = FWL_CLASS_MonthCalendar; | 93 wsClass = FWL_CLASS_MonthCalendar; |
| 94 return FWL_ERR_Succeeded; | 94 return FWL_ERR_Succeeded; |
| 95 } | 95 } |
| 96 FX_DWORD CFWL_MonthCalendarImp::GetClassID() const { | 96 uint32_t CFWL_MonthCalendarImp::GetClassID() const { |
| 97 return FWL_CLASSHASH_MonthCalendar; | 97 return FWL_CLASSHASH_MonthCalendar; |
| 98 } | 98 } |
| 99 FWL_ERR CFWL_MonthCalendarImp::Initialize() { | 99 FWL_ERR CFWL_MonthCalendarImp::Initialize() { |
| 100 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 100 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) |
| 101 return FWL_ERR_Indefinite; | 101 return FWL_ERR_Indefinite; |
| 102 m_pDelegate = new CFWL_MonthCalendarImpDelegate(this); | 102 m_pDelegate = new CFWL_MonthCalendarImpDelegate(this); |
| 103 return FWL_ERR_Succeeded; | 103 return FWL_ERR_Succeeded; |
| 104 } | 104 } |
| 105 FWL_ERR CFWL_MonthCalendarImp::Finalize() { | 105 FWL_ERR CFWL_MonthCalendarImp::Finalize() { |
| 106 delete m_pDelegate; | 106 delete m_pDelegate; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 return CFX_SizeF(m_rtClient.width, m_rtClient.height); | 506 return CFX_SizeF(m_rtClient.width, m_rtClient.height); |
| 507 } | 507 } |
| 508 | 508 |
| 509 CFX_SizeF fs; | 509 CFX_SizeF fs; |
| 510 CFWL_ThemePart params; | 510 CFWL_ThemePart params; |
| 511 params.m_pWidget = m_pInterface; | 511 params.m_pWidget = m_pInterface; |
| 512 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 512 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 513 CFX_WideString* wsText = NULL; | 513 CFX_WideString* wsText = NULL; |
| 514 FX_FLOAT fMaxWeekW = 0.0f; | 514 FX_FLOAT fMaxWeekW = 0.0f; |
| 515 FX_FLOAT fMaxWeekH = 0.0f; | 515 FX_FLOAT fMaxWeekH = 0.0f; |
| 516 for (FX_DWORD week = FWL_MCCAPACITY_Sun; week <= FWL_MCCAPACITY_Sat; week++) { | 516 for (uint32_t week = FWL_MCCAPACITY_Sun; week <= FWL_MCCAPACITY_Sat; week++) { |
| 517 wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(¶ms, week)); | 517 wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(¶ms, week)); |
| 518 CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider); | 518 CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider); |
| 519 fMaxWeekW = (fMaxWeekW >= sz.x) ? fMaxWeekW : sz.x; | 519 fMaxWeekW = (fMaxWeekW >= sz.x) ? fMaxWeekW : sz.x; |
| 520 fMaxWeekH = (fMaxWeekH >= sz.y) ? fMaxWeekH : sz.y; | 520 fMaxWeekH = (fMaxWeekH >= sz.y) ? fMaxWeekH : sz.y; |
| 521 } | 521 } |
| 522 FX_FLOAT fDayMaxW = 0.0f; | 522 FX_FLOAT fDayMaxW = 0.0f; |
| 523 FX_FLOAT fDayMaxH = 0.0f; | 523 FX_FLOAT fDayMaxH = 0.0f; |
| 524 for (int day = 10; day <= 31; day++) { | 524 for (int day = 10; day <= 31; day++) { |
| 525 CFX_WideString wsDay; | 525 CFX_WideString wsDay; |
| 526 wsDay.Format(L"%d", day); | 526 wsDay.Format(L"%d", day); |
| 527 CFX_SizeF sz = CalcTextSize(wsDay, m_pProperties->m_pThemeProvider); | 527 CFX_SizeF sz = CalcTextSize(wsDay, m_pProperties->m_pThemeProvider); |
| 528 fDayMaxW = (fDayMaxW >= sz.x) ? fDayMaxW : sz.x; | 528 fDayMaxW = (fDayMaxW >= sz.x) ? fDayMaxW : sz.x; |
| 529 fDayMaxH = (fDayMaxH >= sz.y) ? fDayMaxH : sz.y; | 529 fDayMaxH = (fDayMaxH >= sz.y) ? fDayMaxH : sz.y; |
| 530 } | 530 } |
| 531 m_szCell.x = FX_FLOAT((fMaxWeekW >= fDayMaxW) ? (int)(fMaxWeekW + 0.5) | 531 m_szCell.x = FX_FLOAT((fMaxWeekW >= fDayMaxW) ? (int)(fMaxWeekW + 0.5) |
| 532 : (int)(fDayMaxW + 0.5)); | 532 : (int)(fDayMaxW + 0.5)); |
| 533 m_szCell.y = (fMaxWeekH >= fDayMaxH) ? fMaxWeekH : fDayMaxH; | 533 m_szCell.y = (fMaxWeekH >= fDayMaxH) ? fMaxWeekH : fDayMaxH; |
| 534 fs.x = m_szCell.x * MONTHCAL_COLUMNS + | 534 fs.x = m_szCell.x * MONTHCAL_COLUMNS + |
| 535 MONTHCAL_HMARGIN * MONTHCAL_COLUMNS * 2 + | 535 MONTHCAL_HMARGIN * MONTHCAL_COLUMNS * 2 + |
| 536 MONTHCAL_HEADER_BTN_HMARGIN * 2; | 536 MONTHCAL_HEADER_BTN_HMARGIN * 2; |
| 537 FX_FLOAT fMonthMaxW = 0.0f; | 537 FX_FLOAT fMonthMaxW = 0.0f; |
| 538 FX_FLOAT fMonthMaxH = 0.0f; | 538 FX_FLOAT fMonthMaxH = 0.0f; |
| 539 for (FX_DWORD month = FWL_MCCAPACITY_January; | 539 for (uint32_t month = FWL_MCCAPACITY_January; |
| 540 month <= FWL_MCCAPACITY_December; month++) { | 540 month <= FWL_MCCAPACITY_December; month++) { |
| 541 wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(¶ms, month)); | 541 wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(¶ms, month)); |
| 542 CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider); | 542 CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider); |
| 543 fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x; | 543 fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x; |
| 544 fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y; | 544 fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y; |
| 545 } | 545 } |
| 546 CFX_WideString wsYear; | 546 CFX_WideString wsYear; |
| 547 GetHeadText(m_iYear, m_iMonth, wsYear); | 547 GetHeadText(m_iYear, m_iMonth, wsYear); |
| 548 CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider); | 548 CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider); |
| 549 fMonthMaxH = std::max(fMonthMaxH, szYear.y); | 549 fMonthMaxH = std::max(fMonthMaxH, szYear.y); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 void CFWL_MonthCalendarImp::ReSetDateItem() { | 766 void CFWL_MonthCalendarImp::ReSetDateItem() { |
| 767 m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1); | 767 m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1); |
| 768 int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth); | 768 int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth); |
| 769 int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek(); | 769 int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek(); |
| 770 for (int32_t i = 0; i < iDays; i++) { | 770 for (int32_t i = 0; i < iDays; i++) { |
| 771 if (iDayOfWeek >= 7) { | 771 if (iDayOfWeek >= 7) { |
| 772 iDayOfWeek = 0; | 772 iDayOfWeek = 0; |
| 773 } | 773 } |
| 774 CFX_WideString wsDay; | 774 CFX_WideString wsDay; |
| 775 wsDay.Format(L"%d", i + 1); | 775 wsDay.Format(L"%d", i + 1); |
| 776 FX_DWORD dwStates = 0; | 776 uint32_t dwStates = 0; |
| 777 if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) { | 777 if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) { |
| 778 dwStates |= FWL_ITEMSTATE_MCD_Flag; | 778 dwStates |= FWL_ITEMSTATE_MCD_Flag; |
| 779 } | 779 } |
| 780 if (m_arrSelDays.Find(i + 1) != -1) { | 780 if (m_arrSelDays.Find(i + 1) != -1) { |
| 781 dwStates |= FWL_ITEMSTATE_MCD_Selected; | 781 dwStates |= FWL_ITEMSTATE_MCD_Selected; |
| 782 } | 782 } |
| 783 CFX_RectF rtDate; | 783 CFX_RectF rtDate; |
| 784 rtDate.Set(0, 0, 0, 0); | 784 rtDate.Set(0, 0, 0, 0); |
| 785 m_arrDates.Add( | 785 m_arrDates.Add( |
| 786 new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); | 786 new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 rtDay = pDateInfo->rect; | 922 rtDay = pDateInfo->rect; |
| 923 return TRUE; | 923 return TRUE; |
| 924 } | 924 } |
| 925 CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate( | 925 CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate( |
| 926 CFWL_MonthCalendarImp* pOwner) | 926 CFWL_MonthCalendarImp* pOwner) |
| 927 : m_pOwner(pOwner) {} | 927 : m_pOwner(pOwner) {} |
| 928 int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage( | 928 int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage( |
| 929 CFWL_Message* pMessage) { | 929 CFWL_Message* pMessage) { |
| 930 if (!pMessage) | 930 if (!pMessage) |
| 931 return 0; | 931 return 0; |
| 932 FX_DWORD dwMsgCode = pMessage->GetClassID(); | 932 uint32_t dwMsgCode = pMessage->GetClassID(); |
| 933 int32_t iRet = 1; | 933 int32_t iRet = 1; |
| 934 switch (dwMsgCode) { | 934 switch (dwMsgCode) { |
| 935 case FWL_MSGHASH_SetFocus: | 935 case FWL_MSGHASH_SetFocus: |
| 936 case FWL_MSGHASH_KillFocus: { | 936 case FWL_MSGHASH_KillFocus: { |
| 937 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); | 937 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); |
| 938 break; | 938 break; |
| 939 } | 939 } |
| 940 case FWL_MSGHASH_Key: { | 940 case FWL_MSGHASH_Key: { |
| 941 break; | 941 break; |
| 942 } | 942 } |
| 943 case FWL_MSGHASH_Mouse: { | 943 case FWL_MSGHASH_Mouse: { |
| 944 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); | 944 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); |
| 945 FX_DWORD dwCmd = pMouse->m_dwCmd; | 945 uint32_t dwCmd = pMouse->m_dwCmd; |
| 946 switch (dwCmd) { | 946 switch (dwCmd) { |
| 947 case FWL_MSGMOUSECMD_LButtonDown: { | 947 case FWL_MSGMOUSECMD_LButtonDown: { |
| 948 OnLButtonDown(pMouse); | 948 OnLButtonDown(pMouse); |
| 949 break; | 949 break; |
| 950 } | 950 } |
| 951 case FWL_MSGMOUSECMD_LButtonUp: { | 951 case FWL_MSGMOUSECMD_LButtonUp: { |
| 952 OnLButtonUp(pMouse); | 952 OnLButtonUp(pMouse); |
| 953 break; | 953 break; |
| 954 } | 954 } |
| 955 case FWL_MSGMOUSECMD_MouseMove: { | 955 case FWL_MSGMOUSECMD_MouseMove: { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 if (m_pOwner->m_iHovered > 0) { | 1092 if (m_pOwner->m_iHovered > 0) { |
| 1093 CFX_RectF rtInvalidate; | 1093 CFX_RectF rtInvalidate; |
| 1094 rtInvalidate.Set(0, 0, 0, 0); | 1094 rtInvalidate.Set(0, 0, 0, 0); |
| 1095 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); | 1095 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); |
| 1096 m_pOwner->m_iHovered = -1; | 1096 m_pOwner->m_iHovered = -1; |
| 1097 if (!rtInvalidate.IsEmpty()) { | 1097 if (!rtInvalidate.IsEmpty()) { |
| 1098 m_pOwner->Repaint(&rtInvalidate); | 1098 m_pOwner->Repaint(&rtInvalidate); |
| 1099 } | 1099 } |
| 1100 } | 1100 } |
| 1101 } | 1101 } |
| OLD | NEW |