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

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

Issue 2467203003: Remove FX_BOOL from xfa. (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
« 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::December)); 116 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::December));
117 } 117 }
118 118
119 } // namespace 119 } // namespace
120 120
121 IFWL_MonthCalendar::IFWL_MonthCalendar( 121 IFWL_MonthCalendar::IFWL_MonthCalendar(
122 const IFWL_App* app, 122 const IFWL_App* app,
123 const CFWL_WidgetImpProperties& properties, 123 const CFWL_WidgetImpProperties& properties,
124 IFWL_Widget* pOuter) 124 IFWL_Widget* pOuter)
125 : IFWL_Widget(app, properties, pOuter), 125 : IFWL_Widget(app, properties, pOuter),
126 m_bInit(FALSE), 126 m_bInit(false),
127 m_pDateTime(new CFX_DateTime), 127 m_pDateTime(new CFX_DateTime),
128 m_iCurYear(2011), 128 m_iCurYear(2011),
129 m_iCurMonth(1), 129 m_iCurMonth(1),
130 m_iYear(2011), 130 m_iYear(2011),
131 m_iMonth(1), 131 m_iMonth(1),
132 m_iDay(1), 132 m_iDay(1),
133 m_iHovered(-1), 133 m_iHovered(-1),
134 m_iLBtnPartStates(CFWL_PartState_Normal), 134 m_iLBtnPartStates(CFWL_PartState_Normal),
135 m_iRBtnPartStates(CFWL_PartState_Normal), 135 m_iRBtnPartStates(CFWL_PartState_Normal),
136 m_iMaxSel(1) { 136 m_iMaxSel(1) {
(...skipping 13 matching lines...) Expand all
150 150
151 IFWL_MonthCalendar::~IFWL_MonthCalendar() { 151 IFWL_MonthCalendar::~IFWL_MonthCalendar() {
152 ClearDateItem(); 152 ClearDateItem();
153 m_arrSelDays.RemoveAll(); 153 m_arrSelDays.RemoveAll();
154 } 154 }
155 155
156 FWL_Type IFWL_MonthCalendar::GetClassID() const { 156 FWL_Type IFWL_MonthCalendar::GetClassID() const {
157 return FWL_Type::MonthCalendar; 157 return FWL_Type::MonthCalendar;
158 } 158 }
159 159
160 FWL_Error IFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect, 160 FWL_Error IFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
161 FX_BOOL bAutoSize) {
162 if (bAutoSize) { 161 if (bAutoSize) {
163 CFX_SizeF fs = CalcSize(TRUE); 162 CFX_SizeF fs = CalcSize(true);
164 rect.Set(0, 0, fs.x, fs.y); 163 rect.Set(0, 0, fs.x, fs.y);
165 IFWL_Widget::GetWidgetRect(rect, TRUE); 164 IFWL_Widget::GetWidgetRect(rect, true);
166 } else { 165 } else {
167 rect = m_pProperties->m_rtWidget; 166 rect = m_pProperties->m_rtWidget;
168 } 167 }
169 return FWL_Error::Succeeded; 168 return FWL_Error::Succeeded;
170 } 169 }
171 170
172 FWL_Error IFWL_MonthCalendar::Update() { 171 FWL_Error IFWL_MonthCalendar::Update() {
173 if (IsLocked()) { 172 if (IsLocked()) {
174 return FWL_Error::Indefinite; 173 return FWL_Error::Indefinite;
175 } 174 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 DrawWeekNumberSep(pGraphics, pTheme, pMatrix); 215 DrawWeekNumberSep(pGraphics, pTheme, pMatrix);
217 DrawWeekNumber(pGraphics, pTheme, pMatrix); 216 DrawWeekNumber(pGraphics, pTheme, pMatrix);
218 } 217 }
219 return FWL_Error::Succeeded; 218 return FWL_Error::Succeeded;
220 } 219 }
221 220
222 int32_t IFWL_MonthCalendar::CountSelect() { 221 int32_t IFWL_MonthCalendar::CountSelect() {
223 return m_arrSelDays.GetSize(); 222 return m_arrSelDays.GetSize();
224 } 223 }
225 224
226 FX_BOOL IFWL_MonthCalendar::GetSelect(int32_t& iYear, 225 bool IFWL_MonthCalendar::GetSelect(int32_t& iYear,
227 int32_t& iMonth, 226 int32_t& iMonth,
228 int32_t& iDay, 227 int32_t& iDay,
229 int32_t nIndex) { 228 int32_t nIndex) {
230 if (nIndex >= m_arrSelDays.GetSize()) { 229 if (nIndex >= m_arrSelDays.GetSize()) {
231 return FALSE; 230 return false;
232 } 231 }
233 iYear = m_iCurYear; 232 iYear = m_iCurYear;
234 iMonth = m_iCurMonth; 233 iMonth = m_iCurMonth;
235 iDay = m_arrSelDays[nIndex]; 234 iDay = m_arrSelDays[nIndex];
236 return TRUE; 235 return true;
237 } 236 }
238 237
239 FX_BOOL IFWL_MonthCalendar::SetSelect(int32_t iYear, 238 bool IFWL_MonthCalendar::SetSelect(int32_t iYear,
240 int32_t iMonth, 239 int32_t iMonth,
241 int32_t iDay) { 240 int32_t iDay) {
242 ChangeToMonth(iYear, iMonth); 241 ChangeToMonth(iYear, iMonth);
243 return AddSelDay(iDay); 242 return AddSelDay(iDay);
244 } 243 }
245 244
246 void IFWL_MonthCalendar::DrawBkground(CFX_Graphics* pGraphics, 245 void IFWL_MonthCalendar::DrawBkground(CFX_Graphics* pGraphics,
247 IFWL_ThemeProvider* pTheme, 246 IFWL_ThemeProvider* pTheme,
248 const CFX_Matrix* pMatrix) { 247 const CFX_Matrix* pMatrix) {
249 CFWL_ThemeBackground params; 248 CFWL_ThemeBackground params;
250 params.m_pWidget = this; 249 params.m_pWidget = this;
251 params.m_iPart = CFWL_Part::Background; 250 params.m_iPart = CFWL_Part::Background;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 params.m_iPart = CFWL_Part::TodayCircle; 558 params.m_iPart = CFWL_Part::TodayCircle;
560 params.m_pGraphics = pGraphics; 559 params.m_pGraphics = pGraphics;
561 params.m_dwStates = CFWL_PartState_Normal; 560 params.m_dwStates = CFWL_PartState_Normal;
562 params.m_rtPart = m_rtTodayFlag; 561 params.m_rtPart = m_rtTodayFlag;
563 if (pMatrix) { 562 if (pMatrix) {
564 params.m_matrix.Concat(*pMatrix); 563 params.m_matrix.Concat(*pMatrix);
565 } 564 }
566 pTheme->DrawBackground(&params); 565 pTheme->DrawBackground(&params);
567 } 566 }
568 567
569 CFX_SizeF IFWL_MonthCalendar::CalcSize(FX_BOOL bAutoSize) { 568 CFX_SizeF IFWL_MonthCalendar::CalcSize(bool bAutoSize) {
570 if (!m_pProperties->m_pThemeProvider) 569 if (!m_pProperties->m_pThemeProvider)
571 return CFX_SizeF(); 570 return CFX_SizeF();
572 571
573 if (!bAutoSize) { 572 if (!bAutoSize) {
574 GetClientRect(m_rtClient); 573 GetClientRect(m_rtClient);
575 return CFX_SizeF(m_rtClient.width, m_rtClient.height); 574 return CFX_SizeF(m_rtClient.width, m_rtClient.height);
576 } 575 }
577 576
578 CFX_SizeF fs; 577 CFX_SizeF fs;
579 CFWL_ThemePart params; 578 CFWL_ThemePart params;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, 678 m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
680 m_rtWeek.bottom(), 679 m_rtWeek.bottom(),
681 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, 680 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
682 m_szCell.y * (MONTHCAL_ROWS - 3) + 681 m_szCell.y * (MONTHCAL_ROWS - 3) +
683 MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2); 682 MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2);
684 } 683 }
685 CalDateItem(); 684 CalDateItem();
686 } 685 }
687 686
688 void IFWL_MonthCalendar::CalDateItem() { 687 void IFWL_MonthCalendar::CalDateItem() {
689 FX_BOOL bNewWeek = FALSE; 688 bool bNewWeek = false;
690 int32_t iWeekOfMonth = 0; 689 int32_t iWeekOfMonth = 0;
691 FX_FLOAT fLeft = m_rtDates.left; 690 FX_FLOAT fLeft = m_rtDates.left;
692 FX_FLOAT fTop = m_rtDates.top; 691 FX_FLOAT fTop = m_rtDates.top;
693 int32_t iCount = m_arrDates.GetSize(); 692 int32_t iCount = m_arrDates.GetSize();
694 for (int32_t i = 0; i < iCount; i++) { 693 for (int32_t i = 0; i < iCount; i++) {
695 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i); 694 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i);
696 if (bNewWeek) { 695 if (bNewWeek) {
697 iWeekOfMonth++; 696 iWeekOfMonth++;
698 bNewWeek = FALSE; 697 bNewWeek = false;
699 } 698 }
700 pDateInfo->rect.Set( 699 pDateInfo->rect.Set(
701 fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)), 700 fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)),
702 fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)), 701 fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)),
703 m_szCell.x + (MONTHCAL_HMARGIN * 2), 702 m_szCell.x + (MONTHCAL_HMARGIN * 2),
704 m_szCell.y + (MONTHCAL_VMARGIN * 2)); 703 m_szCell.y + (MONTHCAL_VMARGIN * 2));
705 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { 704 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
706 pDateInfo->rect.Offset(m_fWeekNumWid, 0); 705 pDateInfo->rect.Offset(m_fWeekNumWid, 0);
707 } 706 }
708 if (pDateInfo->iDayOfWeek >= 6) { 707 if (pDateInfo->iDayOfWeek >= 6) {
709 bNewWeek = TRUE; 708 bNewWeek = true;
710 } 709 }
711 } 710 }
712 } 711 }
713 712
714 void IFWL_MonthCalendar::GetCapValue() { 713 void IFWL_MonthCalendar::GetCapValue() {
715 if (!m_pProperties->m_pThemeProvider) { 714 if (!m_pProperties->m_pThemeProvider) {
716 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 715 m_pProperties->m_pThemeProvider = GetAvailableTheme();
717 } 716 }
718 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 717 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
719 CFWL_ThemePart part; 718 CFWL_ThemePart part;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 m_fMCHei = *static_cast<FX_FLOAT*>( 773 m_fMCHei = *static_cast<FX_FLOAT*>(
775 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height)); 774 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height));
776 } 775 }
777 776
778 int32_t IFWL_MonthCalendar::CalWeekNumber(int32_t iYear, 777 int32_t IFWL_MonthCalendar::CalWeekNumber(int32_t iYear,
779 int32_t iMonth, 778 int32_t iMonth,
780 int32_t iDay) { 779 int32_t iDay) {
781 return 0; 780 return 0;
782 } 781 }
783 782
784 FX_BOOL IFWL_MonthCalendar::GetMinDate(int32_t& iYear, 783 bool IFWL_MonthCalendar::GetMinDate(int32_t& iYear,
785 int32_t& iMonth, 784 int32_t& iMonth,
786 int32_t& iDay) { 785 int32_t& iDay) {
787 iYear = m_dtMin.iYear; 786 iYear = m_dtMin.iYear;
788 iMonth = m_dtMin.iMonth; 787 iMonth = m_dtMin.iMonth;
789 iDay = m_dtMin.iDay; 788 iDay = m_dtMin.iDay;
790 return TRUE; 789 return true;
791 } 790 }
792 791
793 FX_BOOL IFWL_MonthCalendar::SetMinDate(int32_t iYear, 792 bool IFWL_MonthCalendar::SetMinDate(int32_t iYear,
794 int32_t iMonth, 793 int32_t iMonth,
795 int32_t iDay) { 794 int32_t iDay) {
796 m_dtMin = DATE(iYear, iMonth, iDay); 795 m_dtMin = DATE(iYear, iMonth, iDay);
797 return TRUE; 796 return true;
798 } 797 }
799 798
800 FX_BOOL IFWL_MonthCalendar::GetMaxDate(int32_t& iYear, 799 bool IFWL_MonthCalendar::GetMaxDate(int32_t& iYear,
801 int32_t& iMonth, 800 int32_t& iMonth,
802 int32_t& iDay) { 801 int32_t& iDay) {
803 iYear = m_dtMax.iYear; 802 iYear = m_dtMax.iYear;
804 iMonth = m_dtMax.iMonth; 803 iMonth = m_dtMax.iMonth;
805 iDay = m_dtMax.iDay; 804 iDay = m_dtMax.iDay;
806 return TRUE; 805 return true;
807 } 806 }
808 807
809 FX_BOOL IFWL_MonthCalendar::SetMaxDate(int32_t iYear, 808 bool IFWL_MonthCalendar::SetMaxDate(int32_t iYear,
810 int32_t iMonth, 809 int32_t iMonth,
811 int32_t iDay) { 810 int32_t iDay) {
812 m_dtMax = DATE(iYear, iMonth, iDay); 811 m_dtMax = DATE(iYear, iMonth, iDay);
813 return TRUE; 812 return true;
814 } 813 }
815 814
816 FX_BOOL IFWL_MonthCalendar::InitDate() { 815 bool IFWL_MonthCalendar::InitDate() {
817 if (m_pProperties->m_pDataProvider) { 816 if (m_pProperties->m_pDataProvider) {
818 IFWL_MonthCalendarDP* pDateProv = 817 IFWL_MonthCalendarDP* pDateProv =
819 static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider); 818 static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider);
820 m_iYear = pDateProv->GetCurYear(this); 819 m_iYear = pDateProv->GetCurYear(this);
821 m_iMonth = pDateProv->GetCurMonth(this); 820 m_iMonth = pDateProv->GetCurMonth(this);
822 m_iDay = pDateProv->GetCurDay(this); 821 m_iDay = pDateProv->GetCurDay(this);
823 m_iCurYear = m_iYear; 822 m_iCurYear = m_iYear;
824 m_iCurMonth = m_iMonth; 823 m_iCurMonth = m_iMonth;
825 } else { 824 } else {
826 m_iDay = 1; 825 m_iDay = 1;
827 m_iMonth = 1; 826 m_iMonth = 1;
828 m_iYear = 1; 827 m_iYear = 1;
829 m_iCurYear = m_iYear; 828 m_iCurYear = m_iYear;
830 m_iCurMonth = m_iMonth; 829 m_iCurMonth = m_iMonth;
831 } 830 }
832 GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday); 831 GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday);
833 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); 832 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
834 m_dtMin = DATE(1500, 12, 1); 833 m_dtMin = DATE(1500, 12, 1);
835 m_dtMax = DATE(2200, 1, 1); 834 m_dtMax = DATE(2200, 1, 1);
836 return TRUE; 835 return true;
837 } 836 }
838 837
839 void IFWL_MonthCalendar::ClearDateItem() { 838 void IFWL_MonthCalendar::ClearDateItem() {
840 for (int32_t i = 0; i < m_arrDates.GetSize(); i++) 839 for (int32_t i = 0; i < m_arrDates.GetSize(); i++)
841 delete m_arrDates.GetAt(i); 840 delete m_arrDates.GetAt(i);
842 841
843 m_arrDates.RemoveAll(); 842 m_arrDates.RemoveAll();
844 } 843 }
845 844
846 void IFWL_MonthCalendar::ReSetDateItem() { 845 void IFWL_MonthCalendar::ReSetDateItem() {
(...skipping 14 matching lines...) Expand all
861 dwStates |= FWL_ITEMSTATE_MCD_Selected; 860 dwStates |= FWL_ITEMSTATE_MCD_Selected;
862 } 861 }
863 CFX_RectF rtDate; 862 CFX_RectF rtDate;
864 rtDate.Set(0, 0, 0, 0); 863 rtDate.Set(0, 0, 0, 0);
865 m_arrDates.Add( 864 m_arrDates.Add(
866 new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); 865 new FWL_DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay));
867 iDayOfWeek++; 866 iDayOfWeek++;
868 } 867 }
869 } 868 }
870 869
871 FX_BOOL IFWL_MonthCalendar::NextMonth() { 870 bool IFWL_MonthCalendar::NextMonth() {
872 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; 871 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
873 if (iMonth >= 12) { 872 if (iMonth >= 12) {
874 iMonth = 1; 873 iMonth = 1;
875 iYear++; 874 iYear++;
876 } else { 875 } else {
877 iMonth++; 876 iMonth++;
878 } 877 }
879 DATE dt(m_iCurYear, m_iCurMonth, 1); 878 DATE dt(m_iCurYear, m_iCurMonth, 1);
880 if (!(dt < m_dtMax)) { 879 if (!(dt < m_dtMax)) {
881 return FALSE; 880 return false;
882 } 881 }
883 m_iCurYear = iYear, m_iCurMonth = iMonth; 882 m_iCurYear = iYear, m_iCurMonth = iMonth;
884 ChangeToMonth(m_iCurYear, m_iCurMonth); 883 ChangeToMonth(m_iCurYear, m_iCurMonth);
885 return TRUE; 884 return true;
886 } 885 }
887 886
888 FX_BOOL IFWL_MonthCalendar::PrevMonth() { 887 bool IFWL_MonthCalendar::PrevMonth() {
889 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; 888 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
890 if (iMonth <= 1) { 889 if (iMonth <= 1) {
891 iMonth = 12; 890 iMonth = 12;
892 iYear--; 891 iYear--;
893 } else { 892 } else {
894 iMonth--; 893 iMonth--;
895 } 894 }
896 DATE dt(m_iCurYear, m_iCurMonth, 1); 895 DATE dt(m_iCurYear, m_iCurMonth, 1);
897 if (!(dt > m_dtMin)) { 896 if (!(dt > m_dtMin)) {
898 return FALSE; 897 return false;
899 } 898 }
900 m_iCurYear = iYear, m_iCurMonth = iMonth; 899 m_iCurYear = iYear, m_iCurMonth = iMonth;
901 ChangeToMonth(m_iCurYear, m_iCurMonth); 900 ChangeToMonth(m_iCurYear, m_iCurMonth);
902 return TRUE; 901 return true;
903 } 902 }
904 903
905 void IFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) { 904 void IFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) {
906 m_iCurYear = iYear; 905 m_iCurYear = iYear;
907 m_iCurMonth = iMonth; 906 m_iCurMonth = iMonth;
908 m_iHovered = -1; 907 m_iHovered = -1;
909 ClearDateItem(); 908 ClearDateItem();
910 ReSetDateItem(); 909 ReSetDateItem();
911 CalDateItem(); 910 CalDateItem();
912 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); 911 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
913 } 912 }
914 913
915 FX_BOOL IFWL_MonthCalendar::RemoveSelDay(int32_t iDay, FX_BOOL bAll) { 914 bool IFWL_MonthCalendar::RemoveSelDay(int32_t iDay, bool bAll) {
916 if (iDay == -1 && !bAll) { 915 if (iDay == -1 && !bAll) {
917 return FALSE; 916 return false;
918 } 917 }
919 if (bAll) { 918 if (bAll) {
920 int32_t iCount = m_arrSelDays.GetSize(); 919 int32_t iCount = m_arrSelDays.GetSize();
921 int32_t iDatesCount = m_arrDates.GetSize(); 920 int32_t iDatesCount = m_arrDates.GetSize();
922 for (int32_t i = 0; i < iCount; i++) { 921 for (int32_t i = 0; i < iCount; i++) {
923 int32_t iSelDay = m_arrSelDays.GetAt(i); 922 int32_t iSelDay = m_arrSelDays.GetAt(i);
924 if (iSelDay <= iDatesCount) { 923 if (iSelDay <= iDatesCount) {
925 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); 924 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
926 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; 925 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
927 } 926 }
928 } 927 }
929 m_arrSelDays.RemoveAll(); 928 m_arrSelDays.RemoveAll();
930 } else { 929 } else {
931 int32_t index = m_arrSelDays.Find(iDay); 930 int32_t index = m_arrSelDays.Find(iDay);
932 if (index == -1) { 931 if (index == -1) {
933 return FALSE; 932 return false;
934 } 933 }
935 int32_t iSelDay = m_arrSelDays.GetAt(iDay); 934 int32_t iSelDay = m_arrSelDays.GetAt(iDay);
936 int32_t iDatesCount = m_arrDates.GetSize(); 935 int32_t iDatesCount = m_arrDates.GetSize();
937 if (iSelDay <= iDatesCount) { 936 if (iSelDay <= iDatesCount) {
938 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); 937 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
939 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; 938 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
940 } 939 }
941 m_arrSelDays.RemoveAt(index); 940 m_arrSelDays.RemoveAt(index);
942 } 941 }
943 return TRUE; 942 return true;
944 } 943 }
945 944
946 FX_BOOL IFWL_MonthCalendar::AddSelDay(int32_t iDay) { 945 bool IFWL_MonthCalendar::AddSelDay(int32_t iDay) {
947 ASSERT(iDay > 0); 946 ASSERT(iDay > 0);
948 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) { 947 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
949 } else { 948 } else {
950 if (m_arrSelDays.Find(iDay) == -1) { 949 if (m_arrSelDays.Find(iDay) == -1) {
951 RemoveSelDay(-1, TRUE); 950 RemoveSelDay(-1, true);
952 if (iDay <= m_arrDates.GetSize()) { 951 if (iDay <= m_arrDates.GetSize()) {
953 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1); 952 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1);
954 pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected; 953 pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected;
955 } 954 }
956 m_arrSelDays.Add(iDay); 955 m_arrSelDays.Add(iDay);
957 } 956 }
958 } 957 }
959 return TRUE; 958 return true;
960 } 959 }
961 960
962 FX_BOOL IFWL_MonthCalendar::JumpToToday() { 961 bool IFWL_MonthCalendar::JumpToToday() {
963 if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) { 962 if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) {
964 m_iCurYear = m_iYear; 963 m_iCurYear = m_iYear;
965 m_iCurMonth = m_iMonth; 964 m_iCurMonth = m_iMonth;
966 ChangeToMonth(m_iYear, m_iMonth); 965 ChangeToMonth(m_iYear, m_iMonth);
967 AddSelDay(m_iDay); 966 AddSelDay(m_iDay);
968 } else { 967 } else {
969 if (m_arrSelDays.Find(m_iDay) == -1) { 968 if (m_arrSelDays.Find(m_iDay) == -1) {
970 AddSelDay(m_iDay); 969 AddSelDay(m_iDay);
971 } 970 }
972 } 971 }
973 return TRUE; 972 return true;
974 } 973 }
975 974
976 void IFWL_MonthCalendar::GetHeadText(int32_t iYear, 975 void IFWL_MonthCalendar::GetHeadText(int32_t iYear,
977 int32_t iMonth, 976 int32_t iMonth,
978 CFX_WideString& wsHead) { 977 CFX_WideString& wsHead) {
979 ASSERT(iMonth > 0 && iMonth < 13); 978 ASSERT(iMonth > 0 && iMonth < 13);
980 static const FX_WCHAR* const pMonth[] = { 979 static const FX_WCHAR* const pMonth[] = {
981 L"January", L"February", L"March", L"April", 980 L"January", L"February", L"March", L"April",
982 L"May", L"June", L"July", L"August", 981 L"May", L"June", L"July", L"August",
983 L"September", L"October", L"November", L"December"}; 982 L"September", L"October", L"November", L"December"};
(...skipping 11 matching lines...) Expand all
995 int32_t iCount = m_arrDates.GetSize(); 994 int32_t iCount = m_arrDates.GetSize();
996 for (int32_t i = 0; i < iCount; i++) { 995 for (int32_t i = 0; i < iCount; i++) {
997 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i); 996 FWL_DATEINFO* pDateInfo = m_arrDates.GetAt(i);
998 if (pDateInfo->rect.Contains(x, y)) { 997 if (pDateInfo->rect.Contains(x, y)) {
999 return ++i; 998 return ++i;
1000 } 999 }
1001 } 1000 }
1002 return -1; 1001 return -1;
1003 } 1002 }
1004 1003
1005 FX_BOOL IFWL_MonthCalendar::GetDayRect(int32_t iDay, CFX_RectF& rtDay) { 1004 bool IFWL_MonthCalendar::GetDayRect(int32_t iDay, CFX_RectF& rtDay) {
1006 if (iDay <= 0 || iDay > m_arrDates.GetSize()) { 1005 if (iDay <= 0 || iDay > m_arrDates.GetSize()) {
1007 return FALSE; 1006 return false;
1008 } 1007 }
1009 FWL_DATEINFO* pDateInfo = m_arrDates[iDay - 1]; 1008 FWL_DATEINFO* pDateInfo = m_arrDates[iDay - 1];
1010 if (!pDateInfo) 1009 if (!pDateInfo)
1011 return FALSE; 1010 return false;
1012 rtDay = pDateInfo->rect; 1011 rtDay = pDateInfo->rect;
1013 return TRUE; 1012 return true;
1014 } 1013 }
1015 1014
1016 void IFWL_MonthCalendar::OnProcessMessage(CFWL_Message* pMessage) { 1015 void IFWL_MonthCalendar::OnProcessMessage(CFWL_Message* pMessage) {
1017 if (!pMessage) 1016 if (!pMessage)
1018 return; 1017 return;
1019 1018
1020 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 1019 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
1021 switch (dwMsgCode) { 1020 switch (dwMsgCode) {
1022 case CFWL_MessageType::SetFocus: 1021 case CFWL_MessageType::SetFocus:
1023 OnFocusChanged(pMessage, TRUE); 1022 OnFocusChanged(pMessage, true);
1024 break; 1023 break;
1025 case CFWL_MessageType::KillFocus: 1024 case CFWL_MessageType::KillFocus:
1026 OnFocusChanged(pMessage, FALSE); 1025 OnFocusChanged(pMessage, false);
1027 break; 1026 break;
1028 case CFWL_MessageType::Key: 1027 case CFWL_MessageType::Key:
1029 break; 1028 break;
1030 case CFWL_MessageType::Mouse: { 1029 case CFWL_MessageType::Mouse: {
1031 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); 1030 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
1032 switch (pMouse->m_dwCmd) { 1031 switch (pMouse->m_dwCmd) {
1033 case FWL_MouseCommand::LeftButtonDown: 1032 case FWL_MouseCommand::LeftButtonDown:
1034 OnLButtonDown(pMouse); 1033 OnLButtonDown(pMouse);
1035 break; 1034 break;
1036 case FWL_MouseCommand::LeftButtonUp: 1035 case FWL_MouseCommand::LeftButtonUp:
(...skipping 14 matching lines...) Expand all
1051 break; 1050 break;
1052 } 1051 }
1053 IFWL_Widget::OnProcessMessage(pMessage); 1052 IFWL_Widget::OnProcessMessage(pMessage);
1054 } 1053 }
1055 1054
1056 void IFWL_MonthCalendar::OnDrawWidget(CFX_Graphics* pGraphics, 1055 void IFWL_MonthCalendar::OnDrawWidget(CFX_Graphics* pGraphics,
1057 const CFX_Matrix* pMatrix) { 1056 const CFX_Matrix* pMatrix) {
1058 DrawWidget(pGraphics, pMatrix); 1057 DrawWidget(pGraphics, pMatrix);
1059 } 1058 }
1060 1059
1061 void IFWL_MonthCalendar::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { 1060 void IFWL_MonthCalendar::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
1062 if (bSet) 1061 if (bSet)
1063 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 1062 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1064 else 1063 else
1065 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 1064 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
1066 1065
1067 Repaint(&m_rtClient); 1066 Repaint(&m_rtClient);
1068 } 1067 }
1069 1068
1070 void IFWL_MonthCalendar::OnLButtonDown(CFWL_MsgMouse* pMsg) { 1069 void IFWL_MonthCalendar::OnLButtonDown(CFWL_MsgMouse* pMsg) {
1071 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1070 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
(...skipping 10 matching lines...) Expand all
1082 Repaint(&m_rtClient); 1081 Repaint(&m_rtClient);
1083 } 1082 }
1084 } else { 1083 } else {
1085 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)) { 1084 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)) {
1086 int32_t iOldSel = 0; 1085 int32_t iOldSel = 0;
1087 if (m_arrSelDays.GetSize() <= 0) 1086 if (m_arrSelDays.GetSize() <= 0)
1088 return; 1087 return;
1089 iOldSel = m_arrSelDays[0]; 1088 iOldSel = m_arrSelDays[0];
1090 1089
1091 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); 1090 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
1092 FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel; 1091 bool bSelChanged = iCurSel > 0 && iCurSel != iOldSel;
1093 if (bSelChanged) { 1092 if (bSelChanged) {
1094 FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1); 1093 FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1);
1095 CFX_RectF rtInvalidate(lpDatesInfo->rect); 1094 CFX_RectF rtInvalidate(lpDatesInfo->rect);
1096 if (iOldSel > 0) { 1095 if (iOldSel > 0) {
1097 lpDatesInfo = m_arrDates.GetAt(iOldSel - 1); 1096 lpDatesInfo = m_arrDates.GetAt(iOldSel - 1);
1098 rtInvalidate.Union(lpDatesInfo->rect); 1097 rtInvalidate.Union(lpDatesInfo->rect);
1099 } 1098 }
1100 AddSelDay(iCurSel); 1099 AddSelDay(iCurSel);
1101 CFWL_EvtClick wmClick; 1100 CFWL_EvtClick wmClick;
1102 wmClick.m_pSrcTarget = this; 1101 wmClick.m_pSrcTarget = this;
(...skipping 22 matching lines...) Expand all
1125 int32_t iDay = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); 1124 int32_t iDay = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
1126 if (iDay != -1) 1125 if (iDay != -1)
1127 AddSelDay(iDay); 1126 AddSelDay(iDay);
1128 } 1127 }
1129 } 1128 }
1130 1129
1131 void IFWL_MonthCalendar::OnMouseMove(CFWL_MsgMouse* pMsg) { 1130 void IFWL_MonthCalendar::OnMouseMove(CFWL_MsgMouse* pMsg) {
1132 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) 1131 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)
1133 return; 1132 return;
1134 1133
1135 FX_BOOL bRepaint = FALSE; 1134 bool bRepaint = false;
1136 CFX_RectF rtInvalidate; 1135 CFX_RectF rtInvalidate;
1137 rtInvalidate.Set(0, 0, 0, 0); 1136 rtInvalidate.Set(0, 0, 0, 0);
1138 if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { 1137 if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
1139 int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); 1138 int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
1140 bRepaint = m_iHovered != iHover; 1139 bRepaint = m_iHovered != iHover;
1141 if (bRepaint) { 1140 if (bRepaint) {
1142 if (m_iHovered > 0) 1141 if (m_iHovered > 0)
1143 GetDayRect(m_iHovered, rtInvalidate); 1142 GetDayRect(m_iHovered, rtInvalidate);
1144 if (iHover > 0) { 1143 if (iHover > 0) {
1145 CFX_RectF rtDay; 1144 CFX_RectF rtDay;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 uint32_t dwSt, 1178 uint32_t dwSt,
1180 CFX_RectF rc, 1179 CFX_RectF rc,
1181 CFX_WideString& wsday) 1180 CFX_WideString& wsday)
1182 : iDay(day), 1181 : iDay(day),
1183 iDayOfWeek(dayofweek), 1182 iDayOfWeek(dayofweek),
1184 dwStates(dwSt), 1183 dwStates(dwSt),
1185 rect(rc), 1184 rect(rc),
1186 wsDay(wsday) {} 1185 wsDay(wsday) {}
1187 1186
1188 FWL_DATEINFO::~FWL_DATEINFO() {} 1187 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