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

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

Issue 2493583002: Cleanup methds in IFWL_MonthCalendar (Closed)
Patch Set: 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
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::December)); 118 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::December));
119 } 119 }
120 120
121 } // namespace 121 } // namespace
122 122
123 IFWL_MonthCalendar::IFWL_MonthCalendar( 123 IFWL_MonthCalendar::IFWL_MonthCalendar(
124 const IFWL_App* app, 124 const IFWL_App* app,
125 std::unique_ptr<CFWL_WidgetProperties> properties, 125 std::unique_ptr<CFWL_WidgetProperties> properties,
126 IFWL_Widget* pOuter) 126 IFWL_Widget* pOuter)
127 : IFWL_Widget(app, std::move(properties), pOuter), 127 : IFWL_Widget(app, std::move(properties), pOuter),
128 m_bInit(false), 128 m_bInitialized(false),
129 m_pDateTime(new CFX_DateTime), 129 m_pDateTime(new CFX_DateTime),
130 m_iCurYear(2011), 130 m_iCurYear(2011),
131 m_iCurMonth(1), 131 m_iCurMonth(1),
132 m_iYear(2011), 132 m_iYear(2011),
133 m_iMonth(1), 133 m_iMonth(1),
134 m_iDay(1), 134 m_iDay(1),
135 m_iHovered(-1), 135 m_iHovered(-1),
136 m_iLBtnPartStates(CFWL_PartState_Normal), 136 m_iLBtnPartStates(CFWL_PartState_Normal),
137 m_iRBtnPartStates(CFWL_PartState_Normal), 137 m_iRBtnPartStates(CFWL_PartState_Normal),
138 m_iMaxSel(1),
139 m_bFlag(false) { 138 m_bFlag(false) {
140 m_rtHead.Reset(); 139 m_rtHead.Reset();
141 m_rtWeek.Reset(); 140 m_rtWeek.Reset();
142 m_rtLBtn.Reset(); 141 m_rtLBtn.Reset();
143 m_rtRBtn.Reset(); 142 m_rtRBtn.Reset();
144 m_rtDates.Reset(); 143 m_rtDates.Reset();
145 m_rtHSep.Reset(); 144 m_rtHSep.Reset();
146 m_rtHeadText.Reset(); 145 m_rtHeadText.Reset();
147 m_rtToday.Reset(); 146 m_rtToday.Reset();
148 m_rtTodayFlag.Reset(); 147 m_rtTodayFlag.Reset();
(...skipping 22 matching lines...) Expand all
171 } 170 }
172 171
173 void IFWL_MonthCalendar::Update() { 172 void IFWL_MonthCalendar::Update() {
174 if (IsLocked()) { 173 if (IsLocked()) {
175 return; 174 return;
176 } 175 }
177 if (!m_pProperties->m_pThemeProvider) { 176 if (!m_pProperties->m_pThemeProvider) {
178 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 177 m_pProperties->m_pThemeProvider = GetAvailableTheme();
179 } 178 }
180 GetCapValue(); 179 GetCapValue();
181 if (!m_bInit) { 180 if (!m_bInitialized) {
182 m_bInit = InitDate(); 181 InitDate();
182 m_bInitialized = true;
183 } 183 }
184 ClearDateItem(); 184 ClearDateItem();
185 ReSetDateItem(); 185 ResetDateItem();
186 LayOut(); 186 Layout();
187 } 187 }
188 188
189 void IFWL_MonthCalendar::DrawWidget(CFX_Graphics* pGraphics, 189 void IFWL_MonthCalendar::DrawWidget(CFX_Graphics* pGraphics,
190 const CFX_Matrix* pMatrix) { 190 const CFX_Matrix* pMatrix) {
191 if (!pGraphics) 191 if (!pGraphics)
192 return; 192 return;
193 if (!m_pProperties->m_pThemeProvider) { 193 if (!m_pProperties->m_pThemeProvider) {
194 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 194 m_pProperties->m_pThemeProvider = GetAvailableTheme();
195 } 195 }
196 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 196 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
(...skipping 14 matching lines...) Expand all
211 DrawWeek(pGraphics, pTheme, pMatrix); 211 DrawWeek(pGraphics, pTheme, pMatrix);
212 DrawDatesIn(pGraphics, pTheme, pMatrix); 212 DrawDatesIn(pGraphics, pTheme, pMatrix);
213 DrawDatesOut(pGraphics, pTheme, pMatrix); 213 DrawDatesOut(pGraphics, pTheme, pMatrix);
214 DrawToday(pGraphics, pTheme, pMatrix); 214 DrawToday(pGraphics, pTheme, pMatrix);
215 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { 215 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
216 DrawWeekNumberSep(pGraphics, pTheme, pMatrix); 216 DrawWeekNumberSep(pGraphics, pTheme, pMatrix);
217 DrawWeekNumber(pGraphics, pTheme, pMatrix); 217 DrawWeekNumber(pGraphics, pTheme, pMatrix);
218 } 218 }
219 } 219 }
220 220
221 int32_t IFWL_MonthCalendar::CountSelect() { 221 void IFWL_MonthCalendar::SetSelect(int32_t iYear,
222 return m_arrSelDays.GetSize();
223 }
224
225 bool IFWL_MonthCalendar::GetSelect(int32_t& iYear,
226 int32_t& iMonth,
227 int32_t& iDay,
228 int32_t nIndex) {
229 if (nIndex >= m_arrSelDays.GetSize()) {
230 return false;
231 }
232 iYear = m_iCurYear;
233 iMonth = m_iCurMonth;
234 iDay = m_arrSelDays[nIndex];
235 return true;
236 }
237
238 bool IFWL_MonthCalendar::SetSelect(int32_t iYear,
239 int32_t iMonth, 222 int32_t iMonth,
240 int32_t iDay) { 223 int32_t iDay) {
241 ChangeToMonth(iYear, iMonth); 224 ChangeToMonth(iYear, iMonth);
242 return AddSelDay(iDay); 225 AddSelDay(iDay);
243 } 226 }
244 227
245 void IFWL_MonthCalendar::DrawBkground(CFX_Graphics* pGraphics, 228 void IFWL_MonthCalendar::DrawBkground(CFX_Graphics* pGraphics,
246 IFWL_ThemeProvider* pTheme, 229 IFWL_ThemeProvider* pTheme,
247 const CFX_Matrix* pMatrix) { 230 const CFX_Matrix* pMatrix) {
248 CFWL_ThemeBackground params; 231 CFWL_ThemeBackground params;
249 params.m_pWidget = this; 232 params.m_pWidget = this;
250 params.m_iPart = CFWL_Part::Background; 233 params.m_iPart = CFWL_Part::Background;
251 params.m_pGraphics = pGraphics; 234 params.m_pGraphics = pGraphics;
252 params.m_dwStates = CFWL_PartState_Normal; 235 params.m_dwStates = CFWL_PartState_Normal;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 params.m_iPart = CFWL_Part::WeekNum; 392 params.m_iPart = CFWL_Part::WeekNum;
410 params.m_pGraphics = pGraphics; 393 params.m_pGraphics = pGraphics;
411 params.m_dwStates = CFWL_PartState_Normal; 394 params.m_dwStates = CFWL_PartState_Normal;
412 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; 395 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
413 CFX_WideString wsWeekNum; 396 CFX_WideString wsWeekNum;
414 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 397 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
415 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 398 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
416 if (pMatrix) { 399 if (pMatrix) {
417 params.m_matrix.Concat(*pMatrix); 400 params.m_matrix.Concat(*pMatrix);
418 } 401 }
419 int32_t iWeekNum = 0;
420 int32_t iMonthNum = m_pDateTime->GetMonth(); 402 int32_t iMonthNum = m_pDateTime->GetMonth();
421 int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum); 403 int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum);
422 int32_t iTemp = 0; 404 int32_t iTemp = 0;
423 FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei; 405 FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei;
424 FX_FLOAT fHStartPos = m_rtClient.left; 406 FX_FLOAT fHStartPos = m_rtClient.left;
425 for (int32_t i = 1; i <= iDayNum; i += 7) { 407 for (int32_t i = 1; i <= iDayNum; i += 7) {
426 iTemp++; 408 iTemp++;
427 iWeekNum = CalWeekNumber(m_iCurYear, iMonthNum, i);
428 m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp, 409 m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp,
429 m_fWeekNumWid, m_fDateCellHei); 410 m_fWeekNumWid, m_fDateCellHei);
430 wsWeekNum.Format(L"%d", iWeekNum); 411 wsWeekNum.Format(L"0");
431 params.m_wsText = wsWeekNum; 412 params.m_wsText = wsWeekNum;
432 params.m_rtPart = m_rtWeekNum; 413 params.m_rtPart = m_rtWeekNum;
433 pTheme->DrawText(&params); 414 pTheme->DrawText(&params);
434 } 415 }
435 } 416 }
436 417
437 void IFWL_MonthCalendar::DrawWeekNumberSep(CFX_Graphics* pGraphics, 418 void IFWL_MonthCalendar::DrawWeekNumberSep(CFX_Graphics* pGraphics,
438 IFWL_ThemeProvider* pTheme, 419 IFWL_ThemeProvider* pTheme,
439 const CFX_Matrix* pMatrix) { 420 const CFX_Matrix* pMatrix) {
440 CFWL_ThemeBackground params; 421 CFWL_ThemeBackground params;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 params.m_iPart = CFWL_Part::DateInCircle; 518 params.m_iPart = CFWL_Part::DateInCircle;
538 params.m_pGraphics = pGraphics; 519 params.m_pGraphics = pGraphics;
539 params.m_rtPart = pDate->rect; 520 params.m_rtPart = pDate->rect;
540 params.m_dwStates = CFWL_PartState_Normal; 521 params.m_dwStates = CFWL_PartState_Normal;
541 if (pMatrix) { 522 if (pMatrix) {
542 params.m_matrix.Concat(*pMatrix); 523 params.m_matrix.Concat(*pMatrix);
543 } 524 }
544 pTheme->DrawBackground(&params); 525 pTheme->DrawBackground(&params);
545 } 526 }
546 527
547 void IFWL_MonthCalendar::DrawTodayCircle(CFX_Graphics* pGraphics,
548 IFWL_ThemeProvider* pTheme,
549 const CFX_Matrix* pMatrix) {
550 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) {
551 return;
552 }
553 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) {
554 return;
555 }
556 CFWL_ThemeBackground params;
557 params.m_pWidget = this;
558 params.m_iPart = CFWL_Part::TodayCircle;
559 params.m_pGraphics = pGraphics;
560 params.m_dwStates = CFWL_PartState_Normal;
561 params.m_rtPart = m_rtTodayFlag;
562 if (pMatrix) {
563 params.m_matrix.Concat(*pMatrix);
564 }
565 pTheme->DrawBackground(&params);
566 }
567
568 CFX_SizeF IFWL_MonthCalendar::CalcSize(bool bAutoSize) { 528 CFX_SizeF IFWL_MonthCalendar::CalcSize(bool bAutoSize) {
569 if (!m_pProperties->m_pThemeProvider) 529 if (!m_pProperties->m_pThemeProvider)
570 return CFX_SizeF(); 530 return CFX_SizeF();
571 531
572 if (!bAutoSize) { 532 if (!bAutoSize) {
573 GetClientRect(m_rtClient); 533 GetClientRect(m_rtClient);
574 return CFX_SizeF(m_rtClient.width, m_rtClient.height); 534 return CFX_SizeF(m_rtClient.width, m_rtClient.height);
575 } 535 }
576 536
577 CFX_SizeF fs; 537 CFX_SizeF fs;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, 605 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN,
646 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, 606 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN,
647 m_szCell.x, m_szToday.y); 607 m_szCell.x, m_szToday.y);
648 m_rtToday.Set( 608 m_rtToday.Set(
649 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x + 609 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x +
650 MONTHCAL_HMARGIN * 2, 610 MONTHCAL_HMARGIN * 2,
651 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, 611 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN,
652 m_szToday.x, m_szToday.y); 612 m_szToday.x, m_szToday.y);
653 } 613 }
654 614
655 void IFWL_MonthCalendar::LayOut() { 615 void IFWL_MonthCalendar::Layout() {
656 GetClientRect(m_rtClient); 616 GetClientRect(m_rtClient);
657 { 617 {
658 m_rtHead.Set( 618 m_rtHead.Set(
659 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, 619 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top,
660 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, 620 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
661 m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); 621 m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2);
662 m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, 622 m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
663 m_rtHead.bottom(), 623 m_rtHead.bottom(),
664 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, 624 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
665 m_szCell.y + MONTHCAL_VMARGIN * 2); 625 m_szCell.y + MONTHCAL_VMARGIN * 2);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayFlagWidth)); 727 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayFlagWidth));
768 m_fMCWid = *static_cast<FX_FLOAT*>( 728 m_fMCWid = *static_cast<FX_FLOAT*>(
769 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Width)); 729 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Width));
770 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { 730 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
771 m_fMCWid += m_fWeekNumWid; 731 m_fMCWid += m_fWeekNumWid;
772 } 732 }
773 m_fMCHei = *static_cast<FX_FLOAT*>( 733 m_fMCHei = *static_cast<FX_FLOAT*>(
774 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height)); 734 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height));
775 } 735 }
776 736
777 int32_t IFWL_MonthCalendar::CalWeekNumber(int32_t iYear, 737 void IFWL_MonthCalendar::InitDate() {
778 int32_t iMonth,
779 int32_t iDay) {
780 return 0;
781 }
782
783 bool IFWL_MonthCalendar::GetMinDate(int32_t& iYear,
784 int32_t& iMonth,
785 int32_t& iDay) {
786 iYear = m_dtMin.iYear;
787 iMonth = m_dtMin.iMonth;
788 iDay = m_dtMin.iDay;
789 return true;
790 }
791
792 bool IFWL_MonthCalendar::SetMinDate(int32_t iYear,
793 int32_t iMonth,
794 int32_t iDay) {
795 m_dtMin = DATE(iYear, iMonth, iDay);
796 return true;
797 }
798
799 bool IFWL_MonthCalendar::GetMaxDate(int32_t& iYear,
800 int32_t& iMonth,
801 int32_t& iDay) {
802 iYear = m_dtMax.iYear;
803 iMonth = m_dtMax.iMonth;
804 iDay = m_dtMax.iDay;
805 return true;
806 }
807
808 bool IFWL_MonthCalendar::SetMaxDate(int32_t iYear,
809 int32_t iMonth,
810 int32_t iDay) {
811 m_dtMax = DATE(iYear, iMonth, iDay);
812 return true;
813 }
814
815 bool IFWL_MonthCalendar::InitDate() {
816 if (m_pProperties->m_pDataProvider) { 738 if (m_pProperties->m_pDataProvider) {
817 IFWL_MonthCalendarDP* pDateProv = 739 IFWL_MonthCalendarDP* pDateProv =
818 static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider); 740 static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider);
819 m_iYear = pDateProv->GetCurYear(this); 741 m_iYear = pDateProv->GetCurYear(this);
820 m_iMonth = pDateProv->GetCurMonth(this); 742 m_iMonth = pDateProv->GetCurMonth(this);
821 m_iDay = pDateProv->GetCurDay(this); 743 m_iDay = pDateProv->GetCurDay(this);
822 m_iCurYear = m_iYear; 744 m_iCurYear = m_iYear;
823 m_iCurMonth = m_iMonth; 745 m_iCurMonth = m_iMonth;
824 } else { 746 } else {
825 m_iDay = 1; 747 m_iDay = 1;
826 m_iMonth = 1; 748 m_iMonth = 1;
827 m_iYear = 1; 749 m_iYear = 1;
828 m_iCurYear = m_iYear; 750 m_iCurYear = m_iYear;
829 m_iCurMonth = m_iMonth; 751 m_iCurMonth = m_iMonth;
830 } 752 }
831 GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday); 753 GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday);
832 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); 754 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
833 m_dtMin = DATE(1500, 12, 1); 755 m_dtMin = DATE(1500, 12, 1);
834 m_dtMax = DATE(2200, 1, 1); 756 m_dtMax = DATE(2200, 1, 1);
835 return true;
836 } 757 }
837 758
838 void IFWL_MonthCalendar::ClearDateItem() { 759 void IFWL_MonthCalendar::ClearDateItem() {
839 for (int32_t i = 0; i < m_arrDates.GetSize(); i++) 760 for (int32_t i = 0; i < m_arrDates.GetSize(); i++)
840 delete m_arrDates.GetAt(i); 761 delete m_arrDates.GetAt(i);
841 762
842 m_arrDates.RemoveAll(); 763 m_arrDates.RemoveAll();
843 } 764 }
844 765
845 void IFWL_MonthCalendar::ReSetDateItem() { 766 void IFWL_MonthCalendar::ResetDateItem() {
846 m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1); 767 m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1);
847 int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth); 768 int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth);
848 int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek(); 769 int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek();
849 for (int32_t i = 0; i < iDays; i++) { 770 for (int32_t i = 0; i < iDays; i++) {
850 if (iDayOfWeek >= 7) { 771 if (iDayOfWeek >= 7) {
851 iDayOfWeek = 0; 772 iDayOfWeek = 0;
852 } 773 }
853 CFX_WideString wsDay; 774 CFX_WideString wsDay;
854 wsDay.Format(L"%d", i + 1); 775 wsDay.Format(L"%d", i + 1);
855 uint32_t dwStates = 0; 776 uint32_t dwStates = 0;
856 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)) {
857 dwStates |= FWL_ITEMSTATE_MCD_Flag; 778 dwStates |= FWL_ITEMSTATE_MCD_Flag;
858 } 779 }
859 if (m_arrSelDays.Find(i + 1) != -1) { 780 if (m_arrSelDays.Find(i + 1) != -1) {
860 dwStates |= FWL_ITEMSTATE_MCD_Selected; 781 dwStates |= FWL_ITEMSTATE_MCD_Selected;
861 } 782 }
862 CFX_RectF rtDate; 783 CFX_RectF rtDate;
863 rtDate.Set(0, 0, 0, 0); 784 rtDate.Set(0, 0, 0, 0);
864 m_arrDates.Add( 785 m_arrDates.Add(
865 new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); 786 new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay));
866 iDayOfWeek++; 787 iDayOfWeek++;
867 } 788 }
868 } 789 }
869 790
870 bool IFWL_MonthCalendar::NextMonth() { 791 void IFWL_MonthCalendar::NextMonth() {
871 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; 792 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
872 if (iMonth >= 12) { 793 if (iMonth >= 12) {
873 iMonth = 1; 794 iMonth = 1;
874 iYear++; 795 iYear++;
875 } else { 796 } else {
876 iMonth++; 797 iMonth++;
877 } 798 }
878 DATE dt(m_iCurYear, m_iCurMonth, 1); 799 DATE dt(m_iCurYear, m_iCurMonth, 1);
879 if (!(dt < m_dtMax)) { 800 if (!(dt < m_dtMax)) {
880 return false; 801 return;
881 } 802 }
882 m_iCurYear = iYear, m_iCurMonth = iMonth; 803 m_iCurYear = iYear, m_iCurMonth = iMonth;
883 ChangeToMonth(m_iCurYear, m_iCurMonth); 804 ChangeToMonth(m_iCurYear, m_iCurMonth);
884 return true;
885 } 805 }
886 806
887 bool IFWL_MonthCalendar::PrevMonth() { 807 void IFWL_MonthCalendar::PrevMonth() {
888 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; 808 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
889 if (iMonth <= 1) { 809 if (iMonth <= 1) {
890 iMonth = 12; 810 iMonth = 12;
891 iYear--; 811 iYear--;
892 } else { 812 } else {
893 iMonth--; 813 iMonth--;
894 } 814 }
895 DATE dt(m_iCurYear, m_iCurMonth, 1); 815 DATE dt(m_iCurYear, m_iCurMonth, 1);
896 if (!(dt > m_dtMin)) { 816 if (!(dt > m_dtMin)) {
897 return false; 817 return;
898 } 818 }
899 m_iCurYear = iYear, m_iCurMonth = iMonth; 819 m_iCurYear = iYear, m_iCurMonth = iMonth;
900 ChangeToMonth(m_iCurYear, m_iCurMonth); 820 ChangeToMonth(m_iCurYear, m_iCurMonth);
901 return true;
902 } 821 }
903 822
904 void IFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) { 823 void IFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) {
905 m_iCurYear = iYear; 824 m_iCurYear = iYear;
906 m_iCurMonth = iMonth; 825 m_iCurMonth = iMonth;
907 m_iHovered = -1; 826 m_iHovered = -1;
908 ClearDateItem(); 827 ClearDateItem();
909 ReSetDateItem(); 828 ResetDateItem();
910 CalDateItem(); 829 CalDateItem();
911 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); 830 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
912 } 831 }
913 832
914 bool IFWL_MonthCalendar::RemoveSelDay(int32_t iDay, bool bAll) { 833 void IFWL_MonthCalendar::RemoveSelDay(int32_t iDay, bool bAll) {
915 if (iDay == -1 && !bAll) { 834 if (iDay == -1 && !bAll) {
916 return false; 835 return;
917 } 836 }
918 if (bAll) { 837 if (bAll) {
919 int32_t iCount = m_arrSelDays.GetSize(); 838 int32_t iCount = m_arrSelDays.GetSize();
920 int32_t iDatesCount = m_arrDates.GetSize(); 839 int32_t iDatesCount = m_arrDates.GetSize();
921 for (int32_t i = 0; i < iCount; i++) { 840 for (int32_t i = 0; i < iCount; i++) {
922 int32_t iSelDay = m_arrSelDays.GetAt(i); 841 int32_t iSelDay = m_arrSelDays.GetAt(i);
923 if (iSelDay <= iDatesCount) { 842 if (iSelDay <= iDatesCount) {
924 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); 843 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
925 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; 844 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
926 } 845 }
927 } 846 }
928 m_arrSelDays.RemoveAll(); 847 m_arrSelDays.RemoveAll();
929 } else { 848 } else {
930 int32_t index = m_arrSelDays.Find(iDay); 849 int32_t index = m_arrSelDays.Find(iDay);
931 if (index == -1) { 850 if (index == -1) {
932 return false; 851 return;
933 } 852 }
934 int32_t iSelDay = m_arrSelDays.GetAt(iDay); 853 int32_t iSelDay = m_arrSelDays.GetAt(iDay);
935 int32_t iDatesCount = m_arrDates.GetSize(); 854 int32_t iDatesCount = m_arrDates.GetSize();
936 if (iSelDay <= iDatesCount) { 855 if (iSelDay <= iDatesCount) {
937 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); 856 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
938 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; 857 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
939 } 858 }
940 m_arrSelDays.RemoveAt(index); 859 m_arrSelDays.RemoveAt(index);
941 } 860 }
942 return true;
943 } 861 }
944 862
945 bool IFWL_MonthCalendar::AddSelDay(int32_t iDay) { 863 void IFWL_MonthCalendar::AddSelDay(int32_t iDay) {
946 ASSERT(iDay > 0); 864 ASSERT(iDay > 0);
947 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { 865 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)
948 } else { 866 return;
949 if (m_arrSelDays.Find(iDay) == -1) { 867
950 RemoveSelDay(-1, true); 868 if (m_arrSelDays.Find(iDay) == -1) {
951 if (iDay <= m_arrDates.GetSize()) { 869 RemoveSelDay(-1, true);
952 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1); 870 if (iDay <= m_arrDates.GetSize()) {
953 pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected; 871 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1);
954 } 872 pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected;
955 m_arrSelDays.Add(iDay);
956 } 873 }
874 m_arrSelDays.Add(iDay);
957 } 875 }
958 return true;
959 } 876 }
960 877
961 bool IFWL_MonthCalendar::JumpToToday() { 878 void IFWL_MonthCalendar::JumpToToday() {
962 if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) { 879 if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) {
963 m_iCurYear = m_iYear; 880 m_iCurYear = m_iYear;
964 m_iCurMonth = m_iMonth; 881 m_iCurMonth = m_iMonth;
965 ChangeToMonth(m_iYear, m_iMonth); 882 ChangeToMonth(m_iYear, m_iMonth);
966 AddSelDay(m_iDay); 883 AddSelDay(m_iDay);
967 } else { 884 } else {
968 if (m_arrSelDays.Find(m_iDay) == -1) { 885 if (m_arrSelDays.Find(m_iDay) == -1) {
969 AddSelDay(m_iDay); 886 AddSelDay(m_iDay);
970 } 887 }
971 } 888 }
972 return true;
973 } 889 }
974 890
975 void IFWL_MonthCalendar::GetHeadText(int32_t iYear, 891 void IFWL_MonthCalendar::GetHeadText(int32_t iYear,
976 int32_t iMonth, 892 int32_t iMonth,
977 CFX_WideString& wsHead) { 893 CFX_WideString& wsHead) {
978 ASSERT(iMonth > 0 && iMonth < 13); 894 ASSERT(iMonth > 0 && iMonth < 13);
979 static const FX_WCHAR* const pMonth[] = { 895 static const FX_WCHAR* const pMonth[] = {
980 L"January", L"February", L"March", L"April", 896 L"January", L"February", L"March", L"April",
981 L"May", L"June", L"July", L"August", 897 L"May", L"June", L"July", L"August",
982 L"September", L"October", L"November", L"December"}; 898 L"September", L"October", L"November", L"December"};
(...skipping 11 matching lines...) Expand all
994 int32_t iCount = m_arrDates.GetSize(); 910 int32_t iCount = m_arrDates.GetSize();
995 for (int32_t i = 0; i < iCount; i++) { 911 for (int32_t i = 0; i < iCount; i++) {
996 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i); 912 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i);
997 if (pDateInfo->rect.Contains(x, y)) { 913 if (pDateInfo->rect.Contains(x, y)) {
998 return ++i; 914 return ++i;
999 } 915 }
1000 } 916 }
1001 return -1; 917 return -1;
1002 } 918 }
1003 919
1004 bool IFWL_MonthCalendar::GetDayRect(int32_t iDay, CFX_RectF& rtDay) { 920 void IFWL_MonthCalendar::GetDayRect(int32_t iDay, CFX_RectF& rtDay) {
1005 if (iDay <= 0 || iDay > m_arrDates.GetSize()) { 921 if (iDay <= 0 || iDay > m_arrDates.GetSize()) {
Tom Sepez 2016/11/09 21:13:11 nit: no {}
dsinclair 2016/11/10 18:04:16 Done.
1006 return false; 922 return;
1007 } 923 }
1008 FWL_DATEINFO* pDateInfo = m_arrDates[iDay - 1]; 924 FWL_DATEINFO* pDateInfo = m_arrDates[iDay - 1];
1009 if (!pDateInfo) 925 if (!pDateInfo)
1010 return false; 926 return;
1011 rtDay = pDateInfo->rect; 927 rtDay = pDateInfo->rect;
1012 return true;
1013 } 928 }
1014 929
1015 void IFWL_MonthCalendar::OnProcessMessage(CFWL_Message* pMessage) { 930 void IFWL_MonthCalendar::OnProcessMessage(CFWL_Message* pMessage) {
1016 if (!pMessage) 931 if (!pMessage)
1017 return; 932 return;
1018 933
1019 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 934 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
1020 switch (dwMsgCode) { 935 switch (dwMsgCode) {
1021 case CFWL_MessageType::SetFocus: 936 case CFWL_MessageType::SetFocus:
1022 case CFWL_MessageType::KillFocus: 937 case CFWL_MessageType::KillFocus:
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 uint32_t dwSt, 1121 uint32_t dwSt,
1207 CFX_RectF rc, 1122 CFX_RectF rc,
1208 CFX_WideString& wsday) 1123 CFX_WideString& wsday)
1209 : iDay(day), 1124 : iDay(day),
1210 iDayOfWeek(dayofweek), 1125 iDayOfWeek(dayofweek),
1211 dwStates(dwSt), 1126 dwStates(dwSt),
1212 rect(rc), 1127 rect(rc),
1213 wsDay(wsday) {} 1128 wsDay(wsday) {}
1214 1129
1215 FWL_DATEINFO::~FWL_DATEINFO() {} 1130 FWL_DATEINFO::~FWL_DATEINFO() {}
OLDNEW
« xfa/fwl/core/ifwl_monthcalendar.h ('K') | « xfa/fwl/core/ifwl_monthcalendar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698