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

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

Issue 2510793003: Continue formatting fwl/core (Closed)
Patch Set: format 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 IFWL_MonthCalendar::~IFWL_MonthCalendar() { 153 IFWL_MonthCalendar::~IFWL_MonthCalendar() {
154 ClearDateItem(); 154 ClearDateItem();
155 m_arrSelDays.RemoveAll(); 155 m_arrSelDays.RemoveAll();
156 } 156 }
157 157
158 FWL_Type IFWL_MonthCalendar::GetClassID() const { 158 FWL_Type IFWL_MonthCalendar::GetClassID() const {
159 return FWL_Type::MonthCalendar; 159 return FWL_Type::MonthCalendar;
160 } 160 }
161 161
162 void IFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 162 void IFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
163 if (bAutoSize) { 163 if (!bAutoSize) {
164 CFX_SizeF fs = CalcSize(true);
165 rect.Set(0, 0, fs.x, fs.y);
166 IFWL_Widget::GetWidgetRect(rect, true);
167 } else {
168 rect = m_pProperties->m_rtWidget; 164 rect = m_pProperties->m_rtWidget;
165 return;
169 } 166 }
167
168 CFX_SizeF fs = CalcSize(true);
169 rect.Set(0, 0, fs.x, fs.y);
170 IFWL_Widget::GetWidgetRect(rect, true);
170 } 171 }
171 172
172 void IFWL_MonthCalendar::Update() { 173 void IFWL_MonthCalendar::Update() {
173 if (IsLocked()) { 174 if (IsLocked())
174 return; 175 return;
175 } 176 if (!m_pProperties->m_pThemeProvider)
176 if (!m_pProperties->m_pThemeProvider) {
177 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 177 m_pProperties->m_pThemeProvider = GetAvailableTheme();
178 } 178
179 GetCapValue(); 179 GetCapValue();
180 if (!m_bInitialized) { 180 if (!m_bInitialized) {
181 InitDate(); 181 InitDate();
182 m_bInitialized = true; 182 m_bInitialized = true;
183 } 183 }
184
184 ClearDateItem(); 185 ClearDateItem();
185 ResetDateItem(); 186 ResetDateItem();
186 Layout(); 187 Layout();
187 } 188 }
188 189
189 void IFWL_MonthCalendar::DrawWidget(CFX_Graphics* pGraphics, 190 void IFWL_MonthCalendar::DrawWidget(CFX_Graphics* pGraphics,
190 const CFX_Matrix* pMatrix) { 191 const CFX_Matrix* pMatrix) {
191 if (!pGraphics) 192 if (!pGraphics)
192 return; 193 return;
193 if (!m_pProperties->m_pThemeProvider) { 194 if (!m_pProperties->m_pThemeProvider)
194 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 195 m_pProperties->m_pThemeProvider = GetAvailableTheme();
195 } 196
196 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 197 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
197 if (HasBorder()) { 198 if (HasBorder())
198 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 199 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
199 } 200 if (HasEdge())
200 if (HasEdge()) {
201 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); 201 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
202 } 202
203 DrawBkground(pGraphics, pTheme, pMatrix); 203 DrawBackground(pGraphics, pTheme, pMatrix);
204 DrawHeadBK(pGraphics, pTheme, pMatrix); 204 DrawHeadBK(pGraphics, pTheme, pMatrix);
205 DrawLButton(pGraphics, pTheme, pMatrix); 205 DrawLButton(pGraphics, pTheme, pMatrix);
206 DrawRButton(pGraphics, pTheme, pMatrix); 206 DrawRButton(pGraphics, pTheme, pMatrix);
207 DrawSeperator(pGraphics, pTheme, pMatrix); 207 DrawSeperator(pGraphics, pTheme, pMatrix);
208 DrawDatesInBK(pGraphics, pTheme, pMatrix); 208 DrawDatesInBK(pGraphics, pTheme, pMatrix);
209 DrawDatesInCircle(pGraphics, pTheme, pMatrix); 209 DrawDatesInCircle(pGraphics, pTheme, pMatrix);
210 DrawCaption(pGraphics, pTheme, pMatrix); 210 DrawCaption(pGraphics, pTheme, pMatrix);
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 void IFWL_MonthCalendar::SetSelect(int32_t iYear, 221 void IFWL_MonthCalendar::SetSelect(int32_t iYear,
222 int32_t iMonth, 222 int32_t iMonth,
223 int32_t iDay) { 223 int32_t iDay) {
224 ChangeToMonth(iYear, iMonth); 224 ChangeToMonth(iYear, iMonth);
225 AddSelDay(iDay); 225 AddSelDay(iDay);
226 } 226 }
227 227
228 void IFWL_MonthCalendar::DrawBkground(CFX_Graphics* pGraphics, 228 void IFWL_MonthCalendar::DrawBackground(CFX_Graphics* pGraphics,
229 IFWL_ThemeProvider* pTheme, 229 IFWL_ThemeProvider* pTheme,
230 const CFX_Matrix* pMatrix) { 230 const CFX_Matrix* pMatrix) {
231 CFWL_ThemeBackground params; 231 CFWL_ThemeBackground params;
232 params.m_pWidget = this; 232 params.m_pWidget = this;
233 params.m_iPart = CFWL_Part::Background; 233 params.m_iPart = CFWL_Part::Background;
234 params.m_pGraphics = pGraphics; 234 params.m_pGraphics = pGraphics;
235 params.m_dwStates = CFWL_PartState_Normal; 235 params.m_dwStates = CFWL_PartState_Normal;
236 params.m_rtPart = m_rtClient; 236 params.m_rtPart = m_rtClient;
237 if (pMatrix) { 237 if (pMatrix)
238 params.m_matrix.Concat(*pMatrix); 238 params.m_matrix.Concat(*pMatrix);
239 }
240 pTheme->DrawBackground(&params); 239 pTheme->DrawBackground(&params);
241 } 240 }
242 241
243 void IFWL_MonthCalendar::DrawHeadBK(CFX_Graphics* pGraphics, 242 void IFWL_MonthCalendar::DrawHeadBK(CFX_Graphics* pGraphics,
244 IFWL_ThemeProvider* pTheme, 243 IFWL_ThemeProvider* pTheme,
245 const CFX_Matrix* pMatrix) { 244 const CFX_Matrix* pMatrix) {
246 CFWL_ThemeBackground params; 245 CFWL_ThemeBackground params;
247 params.m_pWidget = this; 246 params.m_pWidget = this;
248 params.m_iPart = CFWL_Part::Header; 247 params.m_iPart = CFWL_Part::Header;
249 params.m_pGraphics = pGraphics; 248 params.m_pGraphics = pGraphics;
250 params.m_dwStates = CFWL_PartState_Normal; 249 params.m_dwStates = CFWL_PartState_Normal;
251 params.m_rtPart = m_rtHead; 250 params.m_rtPart = m_rtHead;
252 if (pMatrix) { 251 if (pMatrix)
253 params.m_matrix.Concat(*pMatrix); 252 params.m_matrix.Concat(*pMatrix);
254 }
255 pTheme->DrawBackground(&params); 253 pTheme->DrawBackground(&params);
256 } 254 }
257 255
258 void IFWL_MonthCalendar::DrawLButton(CFX_Graphics* pGraphics, 256 void IFWL_MonthCalendar::DrawLButton(CFX_Graphics* pGraphics,
259 IFWL_ThemeProvider* pTheme, 257 IFWL_ThemeProvider* pTheme,
260 const CFX_Matrix* pMatrix) { 258 const CFX_Matrix* pMatrix) {
261 CFWL_ThemeBackground params; 259 CFWL_ThemeBackground params;
262 params.m_pWidget = this; 260 params.m_pWidget = this;
263 params.m_iPart = CFWL_Part::LBtn; 261 params.m_iPart = CFWL_Part::LBtn;
264 params.m_pGraphics = pGraphics; 262 params.m_pGraphics = pGraphics;
265 params.m_dwStates = m_iLBtnPartStates; 263 params.m_dwStates = m_iLBtnPartStates;
266 params.m_rtPart = m_rtLBtn; 264 params.m_rtPart = m_rtLBtn;
267 if (pMatrix) { 265 if (pMatrix)
268 params.m_matrix.Concat(*pMatrix); 266 params.m_matrix.Concat(*pMatrix);
269 }
270 pTheme->DrawBackground(&params); 267 pTheme->DrawBackground(&params);
271 } 268 }
272 269
273 void IFWL_MonthCalendar::DrawRButton(CFX_Graphics* pGraphics, 270 void IFWL_MonthCalendar::DrawRButton(CFX_Graphics* pGraphics,
274 IFWL_ThemeProvider* pTheme, 271 IFWL_ThemeProvider* pTheme,
275 const CFX_Matrix* pMatrix) { 272 const CFX_Matrix* pMatrix) {
276 CFWL_ThemeBackground params; 273 CFWL_ThemeBackground params;
277 params.m_pWidget = this; 274 params.m_pWidget = this;
278 params.m_iPart = CFWL_Part::RBtn; 275 params.m_iPart = CFWL_Part::RBtn;
279 params.m_pGraphics = pGraphics; 276 params.m_pGraphics = pGraphics;
280 params.m_dwStates = m_iRBtnPartStates; 277 params.m_dwStates = m_iRBtnPartStates;
281 params.m_rtPart = m_rtRBtn; 278 params.m_rtPart = m_rtRBtn;
282 if (pMatrix) { 279 if (pMatrix)
283 params.m_matrix.Concat(*pMatrix); 280 params.m_matrix.Concat(*pMatrix);
284 }
285 pTheme->DrawBackground(&params); 281 pTheme->DrawBackground(&params);
286 } 282 }
287 283
288 void IFWL_MonthCalendar::DrawCaption(CFX_Graphics* pGraphics, 284 void IFWL_MonthCalendar::DrawCaption(CFX_Graphics* pGraphics,
289 IFWL_ThemeProvider* pTheme, 285 IFWL_ThemeProvider* pTheme,
290 const CFX_Matrix* pMatrix) { 286 const CFX_Matrix* pMatrix) {
291 CFWL_ThemeText textParam; 287 CFWL_ThemeText textParam;
292 textParam.m_pWidget = this; 288 textParam.m_pWidget = this;
293 textParam.m_iPart = CFWL_Part::Caption; 289 textParam.m_iPart = CFWL_Part::Caption;
294 textParam.m_dwStates = CFWL_PartState_Normal; 290 textParam.m_dwStates = CFWL_PartState_Normal;
295 textParam.m_pGraphics = pGraphics; 291 textParam.m_pGraphics = pGraphics;
296 int32_t iYear; 292 int32_t iYear;
297 int32_t iMonth; 293 int32_t iMonth;
298 iYear = m_iCurYear; 294 iYear = m_iCurYear;
299 iMonth = m_iCurMonth; 295 iMonth = m_iCurMonth;
300 CFX_WideString wsCation; 296 CFX_WideString wsCation;
301 GetHeadText(iYear, iMonth, wsCation); 297 GetHeadText(iYear, iMonth, wsCation);
302 textParam.m_wsText = wsCation; 298 textParam.m_wsText = wsCation;
303 m_szHead = CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider); 299 m_szHead = CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider);
304 CalcHeadSize(); 300 CalcHeadSize();
305 textParam.m_rtPart = m_rtHeadText; 301 textParam.m_rtPart = m_rtHeadText;
306 textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 302 textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
307 textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 303 textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
308 if (pMatrix) { 304 if (pMatrix)
309 textParam.m_matrix.Concat(*pMatrix); 305 textParam.m_matrix.Concat(*pMatrix);
310 }
311 pTheme->DrawText(&textParam); 306 pTheme->DrawText(&textParam);
312 } 307 }
313 308
314 void IFWL_MonthCalendar::DrawSeperator(CFX_Graphics* pGraphics, 309 void IFWL_MonthCalendar::DrawSeperator(CFX_Graphics* pGraphics,
315 IFWL_ThemeProvider* pTheme, 310 IFWL_ThemeProvider* pTheme,
316 const CFX_Matrix* pMatrix) { 311 const CFX_Matrix* pMatrix) {
317 CFWL_ThemeBackground params; 312 CFWL_ThemeBackground params;
318 params.m_pWidget = this; 313 params.m_pWidget = this;
319 params.m_iPart = CFWL_Part::HSeparator; 314 params.m_iPart = CFWL_Part::HSeparator;
320 params.m_pGraphics = pGraphics; 315 params.m_pGraphics = pGraphics;
321 params.m_dwStates = CFWL_PartState_Normal; 316 params.m_dwStates = CFWL_PartState_Normal;
322 params.m_rtPart = m_rtHSep; 317 params.m_rtPart = m_rtHSep;
323 if (pMatrix) { 318 if (pMatrix)
324 params.m_matrix.Concat(*pMatrix); 319 params.m_matrix.Concat(*pMatrix);
325 }
326 pTheme->DrawBackground(&params); 320 pTheme->DrawBackground(&params);
327 } 321 }
328 322
329 void IFWL_MonthCalendar::DrawDatesInBK(CFX_Graphics* pGraphics, 323 void IFWL_MonthCalendar::DrawDatesInBK(CFX_Graphics* pGraphics,
330 IFWL_ThemeProvider* pTheme, 324 IFWL_ThemeProvider* pTheme,
331 const CFX_Matrix* pMatrix) { 325 const CFX_Matrix* pMatrix) {
332 CFWL_ThemeBackground params; 326 CFWL_ThemeBackground params;
333 params.m_pWidget = this; 327 params.m_pWidget = this;
334 params.m_iPart = CFWL_Part::DateInBK; 328 params.m_iPart = CFWL_Part::DateInBK;
335 params.m_pGraphics = pGraphics; 329 params.m_pGraphics = pGraphics;
336 if (pMatrix) { 330 if (pMatrix)
337 params.m_matrix.Concat(*pMatrix); 331 params.m_matrix.Concat(*pMatrix);
338 } 332
339 int32_t iCount = m_arrDates.GetSize(); 333 int32_t iCount = m_arrDates.GetSize();
340 for (int32_t j = 0; j < iCount; j++) { 334 for (int32_t j = 0; j < iCount; j++) {
341 DATEINFO* pDataInfo = m_arrDates.GetAt(j); 335 DATEINFO* pDataInfo = m_arrDates.GetAt(j);
342 if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Selected) { 336 if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Selected) {
343 params.m_dwStates |= CFWL_PartState_Selected; 337 params.m_dwStates |= CFWL_PartState_Selected;
344 if (((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) == 338 if (((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) ==
345 0) && 339 0) &&
346 pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { 340 pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
347 params.m_dwStates |= CFWL_PartState_Flagged; 341 params.m_dwStates |= CFWL_PartState_Flagged;
348 } 342 }
349 if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) { 343 if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused)
350 params.m_dwStates |= CFWL_PartState_Focused; 344 params.m_dwStates |= CFWL_PartState_Focused;
351 }
352 } else if (j == m_iHovered - 1) { 345 } else if (j == m_iHovered - 1) {
353 params.m_dwStates |= CFWL_PartState_Hovered; 346 params.m_dwStates |= CFWL_PartState_Hovered;
354 } else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { 347 } else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
355 params.m_dwStates = CFWL_PartState_Flagged; 348 params.m_dwStates = CFWL_PartState_Flagged;
356 pTheme->DrawBackground(&params); 349 pTheme->DrawBackground(&params);
357 } 350 }
358 params.m_rtPart = pDataInfo->rect; 351 params.m_rtPart = pDataInfo->rect;
359 pTheme->DrawBackground(&params); 352 pTheme->DrawBackground(&params);
360 params.m_dwStates = 0; 353 params.m_dwStates = 0;
361 } 354 }
362 } 355 }
363 356
364 void IFWL_MonthCalendar::DrawWeek(CFX_Graphics* pGraphics, 357 void IFWL_MonthCalendar::DrawWeek(CFX_Graphics* pGraphics,
365 IFWL_ThemeProvider* pTheme, 358 IFWL_ThemeProvider* pTheme,
366 const CFX_Matrix* pMatrix) { 359 const CFX_Matrix* pMatrix) {
367 CFWL_ThemeText params; 360 CFWL_ThemeText params;
368 params.m_pWidget = this; 361 params.m_pWidget = this;
369 params.m_iPart = CFWL_Part::Week; 362 params.m_iPart = CFWL_Part::Week;
370 params.m_pGraphics = pGraphics; 363 params.m_pGraphics = pGraphics;
371 params.m_dwStates = CFWL_PartState_Normal; 364 params.m_dwStates = CFWL_PartState_Normal;
372 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 365 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
373 CFX_RectF rtDayOfWeek; 366 CFX_RectF rtDayOfWeek;
374 if (pMatrix) { 367 if (pMatrix)
375 params.m_matrix.Concat(*pMatrix); 368 params.m_matrix.Concat(*pMatrix);
376 } 369
377 for (int32_t i = 0; i < 7; i++) { 370 for (int32_t i = 0; i < 7; i++) {
378 rtDayOfWeek.Set(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2), 371 rtDayOfWeek.Set(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2),
379 m_rtWeek.top, m_szCell.x, m_szCell.y); 372 m_rtWeek.top, m_szCell.x, m_szCell.y);
380 params.m_rtPart = rtDayOfWeek; 373 params.m_rtPart = rtDayOfWeek;
381 params.m_wsText = *GetCapacityForDay(pTheme, params, i); 374 params.m_wsText = *GetCapacityForDay(pTheme, params, i);
382 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 375 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
383 pTheme->DrawText(&params); 376 pTheme->DrawText(&params);
384 } 377 }
385 } 378 }
386 379
387 void IFWL_MonthCalendar::DrawWeekNumber(CFX_Graphics* pGraphics, 380 void IFWL_MonthCalendar::DrawWeekNumber(CFX_Graphics* pGraphics,
388 IFWL_ThemeProvider* pTheme, 381 IFWL_ThemeProvider* pTheme,
389 const CFX_Matrix* pMatrix) { 382 const CFX_Matrix* pMatrix) {
390 CFWL_ThemeText params; 383 CFWL_ThemeText params;
391 params.m_pWidget = this; 384 params.m_pWidget = this;
392 params.m_iPart = CFWL_Part::WeekNum; 385 params.m_iPart = CFWL_Part::WeekNum;
393 params.m_pGraphics = pGraphics; 386 params.m_pGraphics = pGraphics;
394 params.m_dwStates = CFWL_PartState_Normal; 387 params.m_dwStates = CFWL_PartState_Normal;
395 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; 388 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
396 CFX_WideString wsWeekNum; 389 CFX_WideString wsWeekNum;
397 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 390 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
398 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 391 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
399 if (pMatrix) { 392 if (pMatrix)
400 params.m_matrix.Concat(*pMatrix); 393 params.m_matrix.Concat(*pMatrix);
401 } 394
402 int32_t iMonthNum = m_pDateTime->GetMonth(); 395 int32_t iMonthNum = m_pDateTime->GetMonth();
403 int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum); 396 int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum);
404 int32_t iTemp = 0; 397 int32_t iTemp = 0;
405 FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei; 398 FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei;
406 FX_FLOAT fHStartPos = m_rtClient.left; 399 FX_FLOAT fHStartPos = m_rtClient.left;
407 for (int32_t i = 1; i <= iDayNum; i += 7) { 400 for (int32_t i = 1; i <= iDayNum; i += 7) {
408 iTemp++; 401 iTemp++;
409 m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp, 402 m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp,
410 m_fWeekNumWid, m_fDateCellHei); 403 m_fWeekNumWid, m_fDateCellHei);
411 wsWeekNum.Format(L"0"); 404 wsWeekNum.Format(L"0");
412 params.m_wsText = wsWeekNum; 405 params.m_wsText = wsWeekNum;
413 params.m_rtPart = m_rtWeekNum; 406 params.m_rtPart = m_rtWeekNum;
414 pTheme->DrawText(&params); 407 pTheme->DrawText(&params);
415 } 408 }
416 } 409 }
417 410
418 void IFWL_MonthCalendar::DrawWeekNumberSep(CFX_Graphics* pGraphics, 411 void IFWL_MonthCalendar::DrawWeekNumberSep(CFX_Graphics* pGraphics,
419 IFWL_ThemeProvider* pTheme, 412 IFWL_ThemeProvider* pTheme,
420 const CFX_Matrix* pMatrix) { 413 const CFX_Matrix* pMatrix) {
421 CFWL_ThemeBackground params; 414 CFWL_ThemeBackground params;
422 params.m_pWidget = this; 415 params.m_pWidget = this;
423 params.m_iPart = CFWL_Part::WeekNumSep; 416 params.m_iPart = CFWL_Part::WeekNumSep;
424 params.m_pGraphics = pGraphics; 417 params.m_pGraphics = pGraphics;
425 params.m_dwStates = CFWL_PartState_Normal; 418 params.m_dwStates = CFWL_PartState_Normal;
426 params.m_rtPart = m_rtWeekNumSep; 419 params.m_rtPart = m_rtWeekNumSep;
427 if (pMatrix) { 420 if (pMatrix)
428 params.m_matrix.Concat(*pMatrix); 421 params.m_matrix.Concat(*pMatrix);
429 }
430 pTheme->DrawBackground(&params); 422 pTheme->DrawBackground(&params);
431 } 423 }
432 424
433 void IFWL_MonthCalendar::DrawToday(CFX_Graphics* pGraphics, 425 void IFWL_MonthCalendar::DrawToday(CFX_Graphics* pGraphics,
434 IFWL_ThemeProvider* pTheme, 426 IFWL_ThemeProvider* pTheme,
435 const CFX_Matrix* pMatrix) { 427 const CFX_Matrix* pMatrix) {
436 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) { 428 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday)
437 return; 429 return;
438 } 430
439 CFWL_ThemeText params; 431 CFWL_ThemeText params;
440 params.m_pWidget = this; 432 params.m_pWidget = this;
441 params.m_iPart = CFWL_Part::Today; 433 params.m_iPart = CFWL_Part::Today;
442 params.m_pGraphics = pGraphics; 434 params.m_pGraphics = pGraphics;
443 params.m_dwStates = CFWL_PartState_Normal; 435 params.m_dwStates = CFWL_PartState_Normal;
444 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; 436 params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
437
445 CFX_WideString* wsDay = static_cast<CFX_WideString*>( 438 CFX_WideString* wsDay = static_cast<CFX_WideString*>(
446 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today)); 439 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today));
447 CFX_WideString wsText; 440 CFX_WideString wsText;
448 GetTodayText(m_iYear, m_iMonth, m_iDay, wsText); 441 GetTodayText(m_iYear, m_iMonth, m_iDay, wsText);
449 params.m_wsText = *wsDay + wsText; 442 params.m_wsText = *wsDay + wsText;
443
450 m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider); 444 m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider);
451 CalcTodaySize(); 445 CalcTodaySize();
452 params.m_rtPart = m_rtToday; 446 params.m_rtPart = m_rtToday;
453 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 447 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
454 if (pMatrix) { 448 if (pMatrix)
455 params.m_matrix.Concat(*pMatrix); 449 params.m_matrix.Concat(*pMatrix);
456 }
457 pTheme->DrawText(&params); 450 pTheme->DrawText(&params);
458 } 451 }
459 452
460 void IFWL_MonthCalendar::DrawDatesIn(CFX_Graphics* pGraphics, 453 void IFWL_MonthCalendar::DrawDatesIn(CFX_Graphics* pGraphics,
461 IFWL_ThemeProvider* pTheme, 454 IFWL_ThemeProvider* pTheme,
462 const CFX_Matrix* pMatrix) { 455 const CFX_Matrix* pMatrix) {
463 CFWL_ThemeText params; 456 CFWL_ThemeText params;
464 params.m_pWidget = this; 457 params.m_pWidget = this;
465 params.m_iPart = CFWL_Part::DatesIn; 458 params.m_iPart = CFWL_Part::DatesIn;
466 params.m_pGraphics = pGraphics; 459 params.m_pGraphics = pGraphics;
467 params.m_dwStates = CFWL_PartState_Normal; 460 params.m_dwStates = CFWL_PartState_Normal;
468 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 461 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
469 if (pMatrix) { 462 if (pMatrix)
470 params.m_matrix.Concat(*pMatrix); 463 params.m_matrix.Concat(*pMatrix);
471 } 464
472 int32_t iCount = m_arrDates.GetSize(); 465 int32_t iCount = m_arrDates.GetSize();
473 for (int32_t j = 0; j < iCount; j++) { 466 for (int32_t j = 0; j < iCount; j++) {
474 DATEINFO* pDataInfo = m_arrDates.GetAt(j); 467 DATEINFO* pDataInfo = m_arrDates.GetAt(j);
475 params.m_wsText = pDataInfo->wsDay; 468 params.m_wsText = pDataInfo->wsDay;
476 params.m_rtPart = pDataInfo->rect; 469 params.m_rtPart = pDataInfo->rect;
477 params.m_dwStates = pDataInfo->dwStates; 470 params.m_dwStates = pDataInfo->dwStates;
478 if (j + 1 == m_iHovered) { 471 if (j + 1 == m_iHovered)
479 params.m_dwStates |= CFWL_PartState_Hovered; 472 params.m_dwStates |= CFWL_PartState_Hovered;
480 }
481 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 473 params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
482 pTheme->DrawText(&params); 474 pTheme->DrawText(&params);
483 } 475 }
484 } 476 }
485 477
486 void IFWL_MonthCalendar::DrawDatesOut(CFX_Graphics* pGraphics, 478 void IFWL_MonthCalendar::DrawDatesOut(CFX_Graphics* pGraphics,
487 IFWL_ThemeProvider* pTheme, 479 IFWL_ThemeProvider* pTheme,
488 const CFX_Matrix* pMatrix) { 480 const CFX_Matrix* pMatrix) {
489 CFWL_ThemeText params; 481 CFWL_ThemeText params;
490 params.m_pWidget = this; 482 params.m_pWidget = this;
491 params.m_iPart = CFWL_Part::DatesOut; 483 params.m_iPart = CFWL_Part::DatesOut;
492 params.m_pGraphics = pGraphics; 484 params.m_pGraphics = pGraphics;
493 params.m_dwStates = CFWL_PartState_Normal; 485 params.m_dwStates = CFWL_PartState_Normal;
494 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; 486 params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
495 if (pMatrix) { 487 if (pMatrix)
496 params.m_matrix.Concat(*pMatrix); 488 params.m_matrix.Concat(*pMatrix);
497 }
498 pTheme->DrawText(&params); 489 pTheme->DrawText(&params);
499 } 490 }
500 491
501 void IFWL_MonthCalendar::DrawDatesInCircle(CFX_Graphics* pGraphics, 492 void IFWL_MonthCalendar::DrawDatesInCircle(CFX_Graphics* pGraphics,
502 IFWL_ThemeProvider* pTheme, 493 IFWL_ThemeProvider* pTheme,
503 const CFX_Matrix* pMatrix) { 494 const CFX_Matrix* pMatrix) {
504 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) { 495 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle)
505 return; 496 return;
506 } 497 if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear)
507 if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear) {
508 return; 498 return;
509 } 499 if (m_iDay < 1 || m_iDay > m_arrDates.GetSize())
510 if (m_iDay < 1 || m_iDay > m_arrDates.GetSize()) {
511 return; 500 return;
512 } 501
513 DATEINFO* pDate = m_arrDates[m_iDay - 1]; 502 DATEINFO* pDate = m_arrDates[m_iDay - 1];
514 if (!pDate) 503 if (!pDate)
515 return; 504 return;
505
516 CFWL_ThemeBackground params; 506 CFWL_ThemeBackground params;
517 params.m_pWidget = this; 507 params.m_pWidget = this;
518 params.m_iPart = CFWL_Part::DateInCircle; 508 params.m_iPart = CFWL_Part::DateInCircle;
519 params.m_pGraphics = pGraphics; 509 params.m_pGraphics = pGraphics;
520 params.m_rtPart = pDate->rect; 510 params.m_rtPart = pDate->rect;
521 params.m_dwStates = CFWL_PartState_Normal; 511 params.m_dwStates = CFWL_PartState_Normal;
522 if (pMatrix) { 512 if (pMatrix)
523 params.m_matrix.Concat(*pMatrix); 513 params.m_matrix.Concat(*pMatrix);
524 }
525 pTheme->DrawBackground(&params); 514 pTheme->DrawBackground(&params);
526 } 515 }
527 516
528 CFX_SizeF IFWL_MonthCalendar::CalcSize(bool bAutoSize) { 517 CFX_SizeF IFWL_MonthCalendar::CalcSize(bool bAutoSize) {
529 if (!m_pProperties->m_pThemeProvider) 518 if (!m_pProperties->m_pThemeProvider)
530 return CFX_SizeF(); 519 return CFX_SizeF();
531
532 if (!bAutoSize) { 520 if (!bAutoSize) {
533 GetClientRect(m_rtClient); 521 GetClientRect(m_rtClient);
534 return CFX_SizeF(m_rtClient.width, m_rtClient.height); 522 return CFX_SizeF(m_rtClient.width, m_rtClient.height);
535 } 523 }
536 524
537 CFX_SizeF fs; 525 CFX_SizeF fs;
538 CFWL_ThemePart params; 526 CFWL_ThemePart params;
539 params.m_pWidget = this; 527 params.m_pWidget = this;
540 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 528 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
541 FX_FLOAT fMaxWeekW = 0.0f; 529 FX_FLOAT fMaxWeekW = 0.0f;
(...skipping 23 matching lines...) Expand all
565 MONTHCAL_HEADER_BTN_HMARGIN * 2; 553 MONTHCAL_HEADER_BTN_HMARGIN * 2;
566 FX_FLOAT fMonthMaxW = 0.0f; 554 FX_FLOAT fMonthMaxW = 0.0f;
567 FX_FLOAT fMonthMaxH = 0.0f; 555 FX_FLOAT fMonthMaxH = 0.0f;
568 556
569 for (uint32_t i = 0; i < 12; ++i) { 557 for (uint32_t i = 0; i < 12; ++i) {
570 CFX_SizeF sz = CalcTextSize(*GetCapacityForMonth(pTheme, params, i), 558 CFX_SizeF sz = CalcTextSize(*GetCapacityForMonth(pTheme, params, i),
571 m_pProperties->m_pThemeProvider); 559 m_pProperties->m_pThemeProvider);
572 fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x; 560 fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x;
573 fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y; 561 fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y;
574 } 562 }
563
575 CFX_WideString wsYear; 564 CFX_WideString wsYear;
576 GetHeadText(m_iYear, m_iMonth, wsYear); 565 GetHeadText(m_iYear, m_iMonth, wsYear);
566
577 CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider); 567 CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider);
578 fMonthMaxH = std::max(fMonthMaxH, szYear.y); 568 fMonthMaxH = std::max(fMonthMaxH, szYear.y);
579 m_szHead = CFX_SizeF(fMonthMaxW + szYear.x, fMonthMaxH); 569 m_szHead = CFX_SizeF(fMonthMaxW + szYear.x, fMonthMaxH);
580 fMonthMaxW = m_szHead.x + MONTHCAL_HEADER_BTN_HMARGIN * 2 + m_szCell.x * 2; 570 fMonthMaxW = m_szHead.x + MONTHCAL_HEADER_BTN_HMARGIN * 2 + m_szCell.x * 2;
581 fs.x = std::max(fs.x, fMonthMaxW); 571 fs.x = std::max(fs.x, fMonthMaxW);
572
582 CFX_WideString wsToday; 573 CFX_WideString wsToday;
583 GetTodayText(m_iYear, m_iMonth, m_iDay, wsToday); 574 GetTodayText(m_iYear, m_iMonth, m_iDay, wsToday);
584 CFX_WideString* wsText = static_cast<CFX_WideString*>( 575 CFX_WideString* wsText = static_cast<CFX_WideString*>(
585 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today)); 576 pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today));
586 m_wsToday = *wsText + wsToday; 577 m_wsToday = *wsText + wsToday;
587 m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider); 578 m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider);
588 m_szToday.y = (m_szToday.y >= m_szCell.y) ? m_szToday.y : m_szCell.y; 579 m_szToday.y = (m_szToday.y >= m_szCell.y) ? m_szToday.y : m_szCell.y;
589 fs.y = m_szCell.x + m_szCell.y * (MONTHCAL_ROWS - 2) + m_szToday.y + 580 fs.y = m_szCell.x + m_szCell.y * (MONTHCAL_ROWS - 2) + m_szToday.y +
590 MONTHCAL_VMARGIN * MONTHCAL_ROWS * 2 + MONTHCAL_HEADER_BTN_VMARGIN * 4; 581 MONTHCAL_VMARGIN * MONTHCAL_ROWS * 2 + MONTHCAL_HEADER_BTN_VMARGIN * 4;
591 return fs; 582 return fs;
(...skipping 15 matching lines...) Expand all
607 m_szCell.x, m_szToday.y); 598 m_szCell.x, m_szToday.y);
608 m_rtToday.Set( 599 m_rtToday.Set(
609 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x + 600 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x +
610 MONTHCAL_HMARGIN * 2, 601 MONTHCAL_HMARGIN * 2,
611 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, 602 m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN,
612 m_szToday.x, m_szToday.y); 603 m_szToday.x, m_szToday.y);
613 } 604 }
614 605
615 void IFWL_MonthCalendar::Layout() { 606 void IFWL_MonthCalendar::Layout() {
616 GetClientRect(m_rtClient); 607 GetClientRect(m_rtClient);
617 { 608
618 m_rtHead.Set( 609 m_rtHead.Set(
619 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, 610 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top,
620 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, 611 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
621 m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); 612 m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2);
622 m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, 613 m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtHead.bottom(),
623 m_rtHead.bottom(), 614 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
624 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, 615 m_szCell.y + MONTHCAL_VMARGIN * 2);
625 m_szCell.y + MONTHCAL_VMARGIN * 2); 616 m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
626 m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, 617 m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x,
627 m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, 618 m_szCell.x);
628 m_szCell.x); 619 m_rtRBtn.Set(m_rtClient.left + m_rtClient.width -
629 m_rtRBtn.Set(m_rtClient.left + m_rtClient.width - 620 MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x,
630 MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x, 621 m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x,
631 m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, 622 m_szCell.x);
632 m_szCell.x); 623 m_rtHSep.Set(
633 m_rtHSep.Set( 624 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN,
634 m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, 625 m_rtWeek.bottom() - MONTHCAL_VMARGIN,
635 m_rtWeek.bottom() - MONTHCAL_VMARGIN, 626 m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2,
636 m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2, 627 MONTHCAL_HSEP_HEIGHT);
637 MONTHCAL_HSEP_HEIGHT); 628 m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
638 m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, 629 m_rtWeek.bottom(),
639 m_rtWeek.bottom(), 630 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
640 m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, 631 m_szCell.y * (MONTHCAL_ROWS - 3) +
641 m_szCell.y * (MONTHCAL_ROWS - 3) + 632 MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2);
642 MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2); 633
643 }
644 CalDateItem(); 634 CalDateItem();
645 } 635 }
646 636
647 void IFWL_MonthCalendar::CalDateItem() { 637 void IFWL_MonthCalendar::CalDateItem() {
648 bool bNewWeek = false; 638 bool bNewWeek = false;
649 int32_t iWeekOfMonth = 0; 639 int32_t iWeekOfMonth = 0;
650 FX_FLOAT fLeft = m_rtDates.left; 640 FX_FLOAT fLeft = m_rtDates.left;
651 FX_FLOAT fTop = m_rtDates.top; 641 FX_FLOAT fTop = m_rtDates.top;
652 int32_t iCount = m_arrDates.GetSize(); 642 int32_t iCount = m_arrDates.GetSize();
653 for (int32_t i = 0; i < iCount; i++) { 643 for (int32_t i = 0; i < iCount; i++) {
654 DATEINFO* pDateInfo = m_arrDates.GetAt(i); 644 DATEINFO* pDateInfo = m_arrDates.GetAt(i);
655 if (bNewWeek) { 645 if (bNewWeek) {
656 iWeekOfMonth++; 646 iWeekOfMonth++;
657 bNewWeek = false; 647 bNewWeek = false;
658 } 648 }
659 pDateInfo->rect.Set( 649 pDateInfo->rect.Set(
660 fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)), 650 fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)),
661 fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)), 651 fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)),
662 m_szCell.x + (MONTHCAL_HMARGIN * 2), 652 m_szCell.x + (MONTHCAL_HMARGIN * 2),
663 m_szCell.y + (MONTHCAL_VMARGIN * 2)); 653 m_szCell.y + (MONTHCAL_VMARGIN * 2));
664 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { 654 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers)
665 pDateInfo->rect.Offset(m_fWeekNumWid, 0); 655 pDateInfo->rect.Offset(m_fWeekNumWid, 0);
666 } 656 if (pDateInfo->iDayOfWeek >= 6)
667 if (pDateInfo->iDayOfWeek >= 6) {
668 bNewWeek = true; 657 bNewWeek = true;
669 }
670 } 658 }
671 } 659 }
672 660
673 void IFWL_MonthCalendar::GetCapValue() { 661 void IFWL_MonthCalendar::GetCapValue() {
674 if (!m_pProperties->m_pThemeProvider) { 662 if (!m_pProperties->m_pThemeProvider)
675 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 663 m_pProperties->m_pThemeProvider = GetAvailableTheme();
676 } 664
677 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 665 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
678 CFWL_ThemePart part; 666 CFWL_ThemePart part;
679 part.m_pWidget = this; 667 part.m_pWidget = this;
680 m_fHeadWid = *static_cast<FX_FLOAT*>( 668 m_fHeadWid = *static_cast<FX_FLOAT*>(
681 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderWidth)); 669 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderWidth));
682 m_fHeadHei = *static_cast<FX_FLOAT*>( 670 m_fHeadHei = *static_cast<FX_FLOAT*>(
683 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderHeight)); 671 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderHeight));
684 m_fHeadBtnWid = *static_cast<FX_FLOAT*>( 672 m_fHeadBtnWid = *static_cast<FX_FLOAT*>(
685 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnWidth)); 673 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnWidth));
686 m_fHeadBtnHei = *static_cast<FX_FLOAT*>( 674 m_fHeadBtnHei = *static_cast<FX_FLOAT*>(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 m_fDateCellHei = *static_cast<FX_FLOAT*>( 708 m_fDateCellHei = *static_cast<FX_FLOAT*>(
721 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::DatesCellHeight)); 709 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::DatesCellHeight));
722 m_fTodayWid = *static_cast<FX_FLOAT*>( 710 m_fTodayWid = *static_cast<FX_FLOAT*>(
723 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayWidth)); 711 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayWidth));
724 m_fTodayHei = *static_cast<FX_FLOAT*>( 712 m_fTodayHei = *static_cast<FX_FLOAT*>(
725 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayHeight)); 713 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayHeight));
726 m_fTodayFlagWid = *static_cast<FX_FLOAT*>( 714 m_fTodayFlagWid = *static_cast<FX_FLOAT*>(
727 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayFlagWidth)); 715 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayFlagWidth));
728 m_fMCWid = *static_cast<FX_FLOAT*>( 716 m_fMCWid = *static_cast<FX_FLOAT*>(
729 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Width)); 717 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Width));
730 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { 718 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers)
731 m_fMCWid += m_fWeekNumWid; 719 m_fMCWid += m_fWeekNumWid;
732 } 720
733 m_fMCHei = *static_cast<FX_FLOAT*>( 721 m_fMCHei = *static_cast<FX_FLOAT*>(
734 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height)); 722 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height));
735 } 723 }
736 724
737 void IFWL_MonthCalendar::InitDate() { 725 void IFWL_MonthCalendar::InitDate() {
738 if (m_pProperties->m_pDataProvider) { 726 if (m_pProperties->m_pDataProvider) {
739 IFWL_MonthCalendarDP* pDateProv = 727 IFWL_MonthCalendarDP* pDateProv =
740 static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider); 728 static_cast<IFWL_MonthCalendarDP*>(m_pProperties->m_pDataProvider);
741 m_iYear = pDateProv->GetCurYear(this); 729 m_iYear = pDateProv->GetCurYear(this);
742 m_iMonth = pDateProv->GetCurMonth(this); 730 m_iMonth = pDateProv->GetCurMonth(this);
743 m_iDay = pDateProv->GetCurDay(this); 731 m_iDay = pDateProv->GetCurDay(this);
744 m_iCurYear = m_iYear; 732 m_iCurYear = m_iYear;
745 m_iCurMonth = m_iMonth; 733 m_iCurMonth = m_iMonth;
746 } else { 734 } else {
747 m_iDay = 1; 735 m_iDay = 1;
748 m_iMonth = 1; 736 m_iMonth = 1;
749 m_iYear = 1; 737 m_iYear = 1;
750 m_iCurYear = m_iYear; 738 m_iCurYear = m_iYear;
751 m_iCurMonth = m_iMonth; 739 m_iCurMonth = m_iMonth;
752 } 740 }
753 GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday); 741 GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday);
754 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); 742 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
755 m_dtMin = DATE(1500, 12, 1); 743 m_dtMin = DATE(1500, 12, 1);
756 m_dtMax = DATE(2200, 1, 1); 744 m_dtMax = DATE(2200, 1, 1);
757 } 745 }
758 746
759 void IFWL_MonthCalendar::ClearDateItem() { 747 void IFWL_MonthCalendar::ClearDateItem() {
760 for (int32_t i = 0; i < m_arrDates.GetSize(); i++) 748 for (int32_t i = 0; i < m_arrDates.GetSize(); i++)
761 delete m_arrDates.GetAt(i); 749 delete m_arrDates.GetAt(i);
762
763 m_arrDates.RemoveAll(); 750 m_arrDates.RemoveAll();
764 } 751 }
765 752
766 void IFWL_MonthCalendar::ResetDateItem() { 753 void IFWL_MonthCalendar::ResetDateItem() {
767 m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1); 754 m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1);
768 int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth); 755 int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth);
769 int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek(); 756 int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek();
770 for (int32_t i = 0; i < iDays; i++) { 757 for (int32_t i = 0; i < iDays; i++) {
771 if (iDayOfWeek >= 7) { 758 if (iDayOfWeek >= 7)
772 iDayOfWeek = 0; 759 iDayOfWeek = 0;
773 } 760
774 CFX_WideString wsDay; 761 CFX_WideString wsDay;
775 wsDay.Format(L"%d", i + 1); 762 wsDay.Format(L"%d", i + 1);
776 uint32_t dwStates = 0; 763 uint32_t dwStates = 0;
777 if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) { 764 if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1))
778 dwStates |= FWL_ITEMSTATE_MCD_Flag; 765 dwStates |= FWL_ITEMSTATE_MCD_Flag;
779 } 766 if (m_arrSelDays.Find(i + 1) != -1)
780 if (m_arrSelDays.Find(i + 1) != -1) {
781 dwStates |= FWL_ITEMSTATE_MCD_Selected; 767 dwStates |= FWL_ITEMSTATE_MCD_Selected;
782 } 768
783 CFX_RectF rtDate; 769 CFX_RectF rtDate;
784 rtDate.Set(0, 0, 0, 0); 770 rtDate.Set(0, 0, 0, 0);
785 m_arrDates.Add(new DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); 771 m_arrDates.Add(new DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay));
786 iDayOfWeek++; 772 iDayOfWeek++;
787 } 773 }
788 } 774 }
789 775
790 void IFWL_MonthCalendar::NextMonth() { 776 void IFWL_MonthCalendar::NextMonth() {
791 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; 777 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
792 if (iMonth >= 12) { 778 if (iMonth >= 12) {
793 iMonth = 1; 779 iMonth = 1;
794 iYear++; 780 iYear++;
795 } else { 781 } else {
796 iMonth++; 782 iMonth++;
797 } 783 }
798 DATE dt(m_iCurYear, m_iCurMonth, 1); 784 DATE dt(m_iCurYear, m_iCurMonth, 1);
799 if (!(dt < m_dtMax)) { 785 if (!(dt < m_dtMax))
800 return; 786 return;
801 } 787
802 m_iCurYear = iYear, m_iCurMonth = iMonth; 788 m_iCurYear = iYear, m_iCurMonth = iMonth;
803 ChangeToMonth(m_iCurYear, m_iCurMonth); 789 ChangeToMonth(m_iCurYear, m_iCurMonth);
804 } 790 }
805 791
806 void IFWL_MonthCalendar::PrevMonth() { 792 void IFWL_MonthCalendar::PrevMonth() {
807 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth; 793 int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
808 if (iMonth <= 1) { 794 if (iMonth <= 1) {
809 iMonth = 12; 795 iMonth = 12;
810 iYear--; 796 iYear--;
811 } else { 797 } else {
812 iMonth--; 798 iMonth--;
813 } 799 }
800
814 DATE dt(m_iCurYear, m_iCurMonth, 1); 801 DATE dt(m_iCurYear, m_iCurMonth, 1);
815 if (!(dt > m_dtMin)) { 802 if (!(dt > m_dtMin))
816 return; 803 return;
817 } 804
818 m_iCurYear = iYear, m_iCurMonth = iMonth; 805 m_iCurYear = iYear, m_iCurMonth = iMonth;
819 ChangeToMonth(m_iCurYear, m_iCurMonth); 806 ChangeToMonth(m_iCurYear, m_iCurMonth);
820 } 807 }
821 808
822 void IFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) { 809 void IFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) {
823 m_iCurYear = iYear; 810 m_iCurYear = iYear;
824 m_iCurMonth = iMonth; 811 m_iCurMonth = iMonth;
825 m_iHovered = -1; 812 m_iHovered = -1;
813
826 ClearDateItem(); 814 ClearDateItem();
827 ResetDateItem(); 815 ResetDateItem();
828 CalDateItem(); 816 CalDateItem();
829 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); 817 GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
830 } 818 }
831 819
832 void IFWL_MonthCalendar::RemoveSelDay(int32_t iDay, bool bAll) { 820 void IFWL_MonthCalendar::RemoveSelDay(int32_t iDay, bool bAll) {
833 if (iDay == -1 && !bAll) { 821 if (iDay == -1 && !bAll)
834 return; 822 return;
835 }
836 if (bAll) { 823 if (bAll) {
837 int32_t iCount = m_arrSelDays.GetSize(); 824 int32_t iCount = m_arrSelDays.GetSize();
838 int32_t iDatesCount = m_arrDates.GetSize(); 825 int32_t iDatesCount = m_arrDates.GetSize();
839 for (int32_t i = 0; i < iCount; i++) { 826 for (int32_t i = 0; i < iCount; i++) {
840 int32_t iSelDay = m_arrSelDays.GetAt(i); 827 int32_t iSelDay = m_arrSelDays.GetAt(i);
841 if (iSelDay <= iDatesCount) { 828 if (iSelDay <= iDatesCount) {
842 DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); 829 DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
843 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; 830 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
844 } 831 }
845 } 832 }
846 m_arrSelDays.RemoveAll(); 833 m_arrSelDays.RemoveAll();
847 } else { 834 return;
848 int32_t index = m_arrSelDays.Find(iDay);
849 if (index == -1) {
850 return;
851 }
852 int32_t iSelDay = m_arrSelDays.GetAt(iDay);
853 int32_t iDatesCount = m_arrDates.GetSize();
854 if (iSelDay <= iDatesCount) {
855 DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
856 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
857 }
858 m_arrSelDays.RemoveAt(index);
859 } 835 }
836
837 int32_t index = m_arrSelDays.Find(iDay);
838 if (index == -1)
839 return;
840
841 int32_t iSelDay = m_arrSelDays.GetAt(iDay);
842 int32_t iDatesCount = m_arrDates.GetSize();
843 if (iSelDay <= iDatesCount) {
844 DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1);
845 pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
846 }
847 m_arrSelDays.RemoveAt(index);
860 } 848 }
861 849
862 void IFWL_MonthCalendar::AddSelDay(int32_t iDay) { 850 void IFWL_MonthCalendar::AddSelDay(int32_t iDay) {
863 ASSERT(iDay > 0); 851 ASSERT(iDay > 0);
864 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) 852 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)
865 return; 853 return;
866 854
867 if (m_arrSelDays.Find(iDay) == -1) { 855 if (m_arrSelDays.Find(iDay) != -1)
868 RemoveSelDay(-1, true); 856 return;
869 if (iDay <= m_arrDates.GetSize()) { 857
870 DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1); 858 RemoveSelDay(-1, true);
871 pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected; 859 if (iDay <= m_arrDates.GetSize()) {
872 } 860 DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1);
873 m_arrSelDays.Add(iDay); 861 pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected;
874 } 862 }
863 m_arrSelDays.Add(iDay);
875 } 864 }
876 865
877 void IFWL_MonthCalendar::JumpToToday() { 866 void IFWL_MonthCalendar::JumpToToday() {
878 if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) { 867 if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) {
879 m_iCurYear = m_iYear; 868 m_iCurYear = m_iYear;
880 m_iCurMonth = m_iMonth; 869 m_iCurMonth = m_iMonth;
881 ChangeToMonth(m_iYear, m_iMonth); 870 ChangeToMonth(m_iYear, m_iMonth);
882 AddSelDay(m_iDay); 871 AddSelDay(m_iDay);
883 } else { 872 return;
884 if (m_arrSelDays.Find(m_iDay) == -1) {
885 AddSelDay(m_iDay);
886 }
887 } 873 }
874
875 if (m_arrSelDays.Find(m_iDay) == -1)
876 AddSelDay(m_iDay);
888 } 877 }
889 878
890 void IFWL_MonthCalendar::GetHeadText(int32_t iYear, 879 void IFWL_MonthCalendar::GetHeadText(int32_t iYear,
891 int32_t iMonth, 880 int32_t iMonth,
892 CFX_WideString& wsHead) { 881 CFX_WideString& wsHead) {
893 ASSERT(iMonth > 0 && iMonth < 13); 882 ASSERT(iMonth > 0 && iMonth < 13);
894 static const FX_WCHAR* const pMonth[] = { 883 static const FX_WCHAR* const pMonth[] = {
895 L"January", L"February", L"March", L"April", 884 L"January", L"February", L"March", L"April",
896 L"May", L"June", L"July", L"August", 885 L"May", L"June", L"July", L"August",
897 L"September", L"October", L"November", L"December"}; 886 L"September", L"October", L"November", L"December"};
898 wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear); 887 wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear);
899 } 888 }
900 889
901 void IFWL_MonthCalendar::GetTodayText(int32_t iYear, 890 void IFWL_MonthCalendar::GetTodayText(int32_t iYear,
902 int32_t iMonth, 891 int32_t iMonth,
903 int32_t iDay, 892 int32_t iDay,
904 CFX_WideString& wsToday) { 893 CFX_WideString& wsToday) {
905 wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear); 894 wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear);
906 } 895 }
907 896
908 int32_t IFWL_MonthCalendar::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) { 897 int32_t IFWL_MonthCalendar::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) {
909 int32_t iCount = m_arrDates.GetSize(); 898 int32_t iCount = m_arrDates.GetSize();
910 for (int32_t i = 0; i < iCount; i++) { 899 for (int32_t i = 0; i < iCount; i++) {
911 DATEINFO* pDateInfo = m_arrDates.GetAt(i); 900 DATEINFO* pDateInfo = m_arrDates.GetAt(i);
912 if (pDateInfo->rect.Contains(x, y)) { 901 if (pDateInfo->rect.Contains(x, y))
913 return ++i; 902 return ++i;
914 }
915 } 903 }
916 return -1; 904 return -1;
917 } 905 }
918 906
919 void IFWL_MonthCalendar::GetDayRect(int32_t iDay, CFX_RectF& rtDay) { 907 void IFWL_MonthCalendar::GetDayRect(int32_t iDay, CFX_RectF& rtDay) {
920 if (iDay <= 0 || iDay > m_arrDates.GetSize()) 908 if (iDay <= 0 || iDay > m_arrDates.GetSize())
921 return; 909 return;
922 910
923 DATEINFO* pDateInfo = m_arrDates[iDay - 1]; 911 DATEINFO* pDateInfo = m_arrDates[iDay - 1];
924 if (!pDateInfo) 912 if (!pDateInfo)
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 uint32_t dwSt, 1108 uint32_t dwSt,
1121 CFX_RectF rc, 1109 CFX_RectF rc,
1122 CFX_WideString& wsday) 1110 CFX_WideString& wsday)
1123 : iDay(day), 1111 : iDay(day),
1124 iDayOfWeek(dayofweek), 1112 iDayOfWeek(dayofweek),
1125 dwStates(dwSt), 1113 dwStates(dwSt),
1126 rect(rc), 1114 rect(rc),
1127 wsDay(wsday) {} 1115 wsDay(wsday) {}
1128 1116
1129 IFWL_MonthCalendar::DATEINFO::~DATEINFO() {} 1117 IFWL_MonthCalendar::DATEINFO::~DATEINFO() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698