| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef XFA_SRC_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_ | |
| 8 #define XFA_SRC_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_ | |
| 9 | |
| 10 #include "xfa/src/fgas/localization/fgas_datetime.h" | |
| 11 #include "xfa/src/fwl/core/fwl_widgetimp.h" | |
| 12 | |
| 13 class CFWL_WidgetImpProperties; | |
| 14 class IFWL_Widget; | |
| 15 class CFWL_MonthCalendarImpDelegate; | |
| 16 | |
| 17 extern uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth); | |
| 18 | |
| 19 class CFWL_MonthCalendarImp : public CFWL_WidgetImp { | |
| 20 public: | |
| 21 CFWL_MonthCalendarImp(const CFWL_WidgetImpProperties& properties, | |
| 22 IFWL_Widget* pOuter); | |
| 23 ~CFWL_MonthCalendarImp(); | |
| 24 virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const; | |
| 25 virtual FX_DWORD GetClassID() const; | |
| 26 virtual FWL_ERR Initialize(); | |
| 27 virtual FWL_ERR Finalize(); | |
| 28 virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); | |
| 29 virtual FWL_ERR Update(); | |
| 30 virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics, | |
| 31 const CFX_Matrix* pMatrix = NULL); | |
| 32 virtual int32_t CountSelect(); | |
| 33 virtual FX_BOOL GetSelect(int32_t& iYear, | |
| 34 int32_t& iMonth, | |
| 35 int32_t& iDay, | |
| 36 int32_t nIndex = 0); | |
| 37 virtual FX_BOOL SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay); | |
| 38 | |
| 39 protected: | |
| 40 struct DATE { | |
| 41 DATE() : iYear(0), iMonth(0), iDay(0) {} | |
| 42 DATE(int32_t year, int32_t month, int32_t day) | |
| 43 : iYear(year), iMonth(month), iDay(day) {} | |
| 44 FX_BOOL operator<(const DATE& right) { | |
| 45 if (iYear < right.iYear) { | |
| 46 return TRUE; | |
| 47 } else if (iYear == right.iYear) { | |
| 48 if (iMonth < right.iMonth) { | |
| 49 return TRUE; | |
| 50 } else if (iMonth == right.iMonth) { | |
| 51 return iDay < right.iDay; | |
| 52 } | |
| 53 } | |
| 54 return FALSE; | |
| 55 } | |
| 56 FX_BOOL operator>(const DATE& right) { | |
| 57 if (iYear > right.iYear) { | |
| 58 return TRUE; | |
| 59 } else if (iYear == right.iYear) { | |
| 60 if (iMonth > right.iMonth) { | |
| 61 return TRUE; | |
| 62 } else if (iMonth == right.iMonth) { | |
| 63 return iDay > right.iDay; | |
| 64 } | |
| 65 } | |
| 66 return FALSE; | |
| 67 } | |
| 68 int32_t iYear; | |
| 69 int32_t iMonth; | |
| 70 int32_t iDay; | |
| 71 }; | |
| 72 | |
| 73 void DrawBkground(CFX_Graphics* pGraphics, | |
| 74 IFWL_ThemeProvider* pTheme, | |
| 75 const CFX_Matrix* pMatrix); | |
| 76 void DrawHeadBK(CFX_Graphics* pGraphics, | |
| 77 IFWL_ThemeProvider* pTheme, | |
| 78 const CFX_Matrix* pMatrix); | |
| 79 void DrawLButton(CFX_Graphics* pGraphics, | |
| 80 IFWL_ThemeProvider* pTheme, | |
| 81 const CFX_Matrix* pMatrix); | |
| 82 void DrawRButton(CFX_Graphics* pGraphics, | |
| 83 IFWL_ThemeProvider* pTheme, | |
| 84 const CFX_Matrix* pMatrix); | |
| 85 void DrawCaption(CFX_Graphics* pGraphics, | |
| 86 IFWL_ThemeProvider* pTheme, | |
| 87 const CFX_Matrix* pMatrix); | |
| 88 void DrawSeperator(CFX_Graphics* pGraphics, | |
| 89 IFWL_ThemeProvider* pTheme, | |
| 90 const CFX_Matrix* pMatrix); | |
| 91 void DrawDatesInBK(CFX_Graphics* pGraphics, | |
| 92 IFWL_ThemeProvider* pTheme, | |
| 93 const CFX_Matrix* pMatrix); | |
| 94 void DrawWeek(CFX_Graphics* pGraphics, | |
| 95 IFWL_ThemeProvider* pTheme, | |
| 96 const CFX_Matrix* pMatrix); | |
| 97 void DrawWeekNumber(CFX_Graphics* pGraphics, | |
| 98 IFWL_ThemeProvider* pTheme, | |
| 99 const CFX_Matrix* pMatrix); | |
| 100 void DrawWeekNumberSep(CFX_Graphics* pGraphics, | |
| 101 IFWL_ThemeProvider* pTheme, | |
| 102 const CFX_Matrix* pMatrix); | |
| 103 void DrawToday(CFX_Graphics* pGraphics, | |
| 104 IFWL_ThemeProvider* pTheme, | |
| 105 const CFX_Matrix* pMatrix); | |
| 106 void DrawDatesIn(CFX_Graphics* pGraphics, | |
| 107 IFWL_ThemeProvider* pTheme, | |
| 108 const CFX_Matrix* pMatrix); | |
| 109 void DrawDatesOut(CFX_Graphics* pGraphics, | |
| 110 IFWL_ThemeProvider* pTheme, | |
| 111 const CFX_Matrix* pMatrix); | |
| 112 void DrawDatesInCircle(CFX_Graphics* pGraphics, | |
| 113 IFWL_ThemeProvider* pTheme, | |
| 114 const CFX_Matrix* pMatrix); | |
| 115 void DrawTodayCircle(CFX_Graphics* pGraphics, | |
| 116 IFWL_ThemeProvider* pTheme, | |
| 117 const CFX_Matrix* pMatrix); | |
| 118 CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE); | |
| 119 void LayOut(); | |
| 120 void CalcHeadSize(); | |
| 121 void CalcTodaySize(); | |
| 122 void CalDateItem(); | |
| 123 void GetCapValue(); | |
| 124 int32_t CalWeekNumber(int32_t iYear, int32_t iMonth, int32_t iDay); | |
| 125 FX_BOOL GetMinDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay); | |
| 126 FX_BOOL SetMinDate(int32_t iYear, int32_t iMonth, int32_t iDay); | |
| 127 FX_BOOL GetMaxDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay); | |
| 128 FX_BOOL SetMaxDate(int32_t iYear, int32_t iMonth, int32_t iDay); | |
| 129 FX_BOOL InitDate(); | |
| 130 void ClearDateItem(); | |
| 131 void ReSetDateItem(); | |
| 132 FX_BOOL NextMonth(); | |
| 133 FX_BOOL PrevMonth(); | |
| 134 void ChangeToMonth(int32_t iYear, int32_t iMonth); | |
| 135 FX_BOOL RemoveSelDay(int32_t iDay, FX_BOOL bAll = FALSE); | |
| 136 FX_BOOL AddSelDay(int32_t iDay); | |
| 137 FX_BOOL JumpToToday(); | |
| 138 void GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString& wsHead); | |
| 139 void GetTodayText(int32_t iYear, | |
| 140 int32_t iMonth, | |
| 141 int32_t iDay, | |
| 142 CFX_WideString& wsToday); | |
| 143 int32_t GetDayAtPoint(FX_FLOAT x, FX_FLOAT y); | |
| 144 FX_BOOL GetDayRect(int32_t iDay, CFX_RectF& rtDay); | |
| 145 | |
| 146 FX_BOOL m_bInit; | |
| 147 CFX_RectF m_rtHead; | |
| 148 CFX_RectF m_rtWeek; | |
| 149 CFX_RectF m_rtLBtn; | |
| 150 CFX_RectF m_rtRBtn; | |
| 151 CFX_RectF m_rtDates; | |
| 152 CFX_RectF m_rtHSep; | |
| 153 CFX_RectF m_rtHeadText; | |
| 154 CFX_RectF m_rtToday; | |
| 155 CFX_RectF m_rtTodayFlag; | |
| 156 CFX_RectF m_rtWeekNum; | |
| 157 CFX_RectF m_rtWeekNumSep; | |
| 158 CFX_RectF m_rtTemp; | |
| 159 CFX_WideString m_wsHead; | |
| 160 CFX_WideString m_wsToday; | |
| 161 CFX_DateTime* m_pDateTime; | |
| 162 CFX_PtrArray m_arrDates; | |
| 163 int32_t m_iCurYear; | |
| 164 int32_t m_iCurMonth; | |
| 165 int32_t m_iYear; | |
| 166 int32_t m_iMonth; | |
| 167 int32_t m_iDay; | |
| 168 int32_t m_iHovered; | |
| 169 int32_t m_iLBtnPartStates; | |
| 170 int32_t m_iRBtnPartStates; | |
| 171 DATE m_dtMin; | |
| 172 DATE m_dtMax; | |
| 173 CFX_SizeF m_szHead; | |
| 174 CFX_SizeF m_szCell; | |
| 175 CFX_SizeF m_szToday; | |
| 176 CFX_ArrayTemplate<int32_t> m_arrSelDays; | |
| 177 int32_t m_iMaxSel; | |
| 178 CFX_RectF m_rtClient; | |
| 179 FX_FLOAT m_fHeadWid; | |
| 180 FX_FLOAT m_fHeadHei; | |
| 181 FX_FLOAT m_fHeadBtnWid; | |
| 182 FX_FLOAT m_fHeadBtnHei; | |
| 183 FX_FLOAT m_fHeadBtnHMargin; | |
| 184 FX_FLOAT m_fHeadBtnVMargin; | |
| 185 FX_FLOAT m_fHeadTextWid; | |
| 186 FX_FLOAT m_fHeadTextHei; | |
| 187 FX_FLOAT m_fHeadTextHMargin; | |
| 188 FX_FLOAT m_fHeadTextVMargin; | |
| 189 FX_FLOAT m_fHSepWid; | |
| 190 FX_FLOAT m_fHSepHei; | |
| 191 FX_FLOAT m_fWeekNumWid; | |
| 192 FX_FLOAT m_fSepDOffset; | |
| 193 FX_FLOAT m_fSepX; | |
| 194 FX_FLOAT m_fSepY; | |
| 195 FX_FLOAT m_fWeekNumHeigh; | |
| 196 FX_FLOAT m_fWeekWid; | |
| 197 FX_FLOAT m_fWeekHei; | |
| 198 FX_FLOAT m_fDateCellWid; | |
| 199 FX_FLOAT m_fDateCellHei; | |
| 200 FX_FLOAT m_fTodayWid; | |
| 201 FX_FLOAT m_fTodayHei; | |
| 202 FX_FLOAT m_fTodayFlagWid; | |
| 203 FX_FLOAT m_fMCWid; | |
| 204 FX_FLOAT m_fMCHei; | |
| 205 friend class CFWL_MonthCalendarImpDelegate; | |
| 206 }; | |
| 207 | |
| 208 struct FWL_DATEINFO { | |
| 209 FWL_DATEINFO(int32_t day, | |
| 210 int32_t dayofweek, | |
| 211 FX_DWORD dwSt, | |
| 212 CFX_RectF rc, | |
| 213 CFX_WideString& wsday) | |
| 214 : iDay(day), | |
| 215 iDayOfWeek(dayofweek), | |
| 216 dwStates(dwSt), | |
| 217 rect(rc), | |
| 218 wsDay(wsday) {} | |
| 219 int32_t iDay; | |
| 220 int32_t iDayOfWeek; | |
| 221 FX_DWORD dwStates; | |
| 222 CFX_RectF rect; | |
| 223 CFX_WideString wsDay; | |
| 224 }; | |
| 225 | |
| 226 class CFWL_MonthCalendarImpDelegate : public CFWL_WidgetImpDelegate { | |
| 227 public: | |
| 228 CFWL_MonthCalendarImpDelegate(CFWL_MonthCalendarImp* pOwner); | |
| 229 int32_t OnProcessMessage(CFWL_Message* pMessage) override; | |
| 230 FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics, | |
| 231 const CFX_Matrix* pMatrix = NULL) override; | |
| 232 | |
| 233 protected: | |
| 234 void OnActivate(CFWL_Message* pMsg); | |
| 235 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | |
| 236 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 237 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
| 238 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
| 239 void OnMouseLeave(CFWL_MsgMouse* pMsg); | |
| 240 CFWL_MonthCalendarImp* m_pOwner; | |
| 241 }; | |
| 242 | |
| 243 #endif // XFA_SRC_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_ | |
| OLD | NEW |