OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fwl/core/cfwl_datetimepicker.h" | 7 #include "xfa/fwl/core/cfwl_datetimepicker.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return; | 122 return; |
123 } | 123 } |
124 | 124 |
125 FWL_WidgetHit CFWL_DateTimePicker::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 125 FWL_WidgetHit CFWL_DateTimePicker::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
126 if (m_pWidgetMgr->IsFormDisabled()) | 126 if (m_pWidgetMgr->IsFormDisabled()) |
127 return DisForm_HitTest(fx, fy); | 127 return DisForm_HitTest(fx, fy); |
128 if (m_rtClient.Contains(fx, fy)) | 128 if (m_rtClient.Contains(fx, fy)) |
129 return FWL_WidgetHit::Client; | 129 return FWL_WidgetHit::Client; |
130 if (IsMonthCalendarVisible()) { | 130 if (IsMonthCalendarVisible()) { |
131 CFX_RectF rect; | 131 CFX_RectF rect; |
132 m_pMonthCal->GetWidgetRect(rect); | 132 m_pMonthCal->GetWidgetRect(rect, false); |
133 if (rect.Contains(fx, fy)) | 133 if (rect.Contains(fx, fy)) |
134 return FWL_WidgetHit::Client; | 134 return FWL_WidgetHit::Client; |
135 } | 135 } |
136 return FWL_WidgetHit::Unknown; | 136 return FWL_WidgetHit::Unknown; |
137 } | 137 } |
138 | 138 |
139 void CFWL_DateTimePicker::DrawWidget(CFX_Graphics* pGraphics, | 139 void CFWL_DateTimePicker::DrawWidget(CFX_Graphics* pGraphics, |
140 const CFX_Matrix* pMatrix) { | 140 const CFX_Matrix* pMatrix) { |
141 if (!pGraphics) | 141 if (!pGraphics) |
142 return; | 142 return; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 void CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) const { | 204 void CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) const { |
205 if (m_pWidgetMgr->IsFormDisabled()) { | 205 if (m_pWidgetMgr->IsFormDisabled()) { |
206 DisForm_GetBBox(rect); | 206 DisForm_GetBBox(rect); |
207 return; | 207 return; |
208 } | 208 } |
209 | 209 |
210 rect = m_pProperties->m_rtWidget; | 210 rect = m_pProperties->m_rtWidget; |
211 if (IsMonthCalendarVisible()) { | 211 if (IsMonthCalendarVisible()) { |
212 CFX_RectF rtMonth; | 212 CFX_RectF rtMonth; |
213 m_pMonthCal->GetWidgetRect(rtMonth); | 213 m_pMonthCal->GetWidgetRect(rtMonth, false); |
214 rtMonth.Offset(m_pProperties->m_rtWidget.left, | 214 rtMonth.Offset(m_pProperties->m_rtWidget.left, |
215 m_pProperties->m_rtWidget.top); | 215 m_pProperties->m_rtWidget.top); |
216 rect.Union(rtMonth); | 216 rect.Union(rtMonth); |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 void CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, | 220 void CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, |
221 uint32_t dwStylesExRemoved) { | 221 uint32_t dwStylesExRemoved) { |
222 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 222 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
223 } | 223 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 return; | 261 return; |
262 if (!m_pForm) | 262 if (!m_pForm) |
263 InitProxyForm(); | 263 InitProxyForm(); |
264 | 264 |
265 if (!bActivate) { | 265 if (!bActivate) { |
266 m_pForm->EndDoModal(); | 266 m_pForm->EndDoModal(); |
267 return; | 267 return; |
268 } | 268 } |
269 | 269 |
270 CFX_RectF rtMonth; | 270 CFX_RectF rtMonth; |
271 m_pMonthCal->GetWidgetRect(rtMonth); | 271 m_pMonthCal->GetWidgetRect(rtMonth, false); |
272 | 272 |
273 CFX_RectF rtAnchor; | 273 CFX_RectF rtAnchor; |
274 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, | 274 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, |
275 m_pProperties->m_rtWidget.height); | 275 m_pProperties->m_rtWidget.height); |
276 GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth); | 276 GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth); |
277 m_pForm->SetWidgetRect(rtMonth); | 277 m_pForm->SetWidgetRect(rtMonth); |
278 | 278 |
279 rtMonth.left = rtMonth.top = 0; | 279 rtMonth.left = rtMonth.top = 0; |
280 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); | 280 if (bActivate) |
| 281 m_pMonthCal->RemoveStates(FWL_WGTSTATE_Invisible); |
| 282 else |
| 283 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible); |
281 m_pMonthCal->SetWidgetRect(rtMonth); | 284 m_pMonthCal->SetWidgetRect(rtMonth); |
282 m_pMonthCal->Update(); | 285 m_pMonthCal->Update(); |
283 m_pForm->DoModal(); | 286 m_pForm->DoModal(); |
284 } | 287 } |
285 | 288 |
286 bool CFWL_DateTimePicker::IsMonthCalendarVisible() const { | 289 bool CFWL_DateTimePicker::IsMonthCalendarVisible() const { |
287 if (m_pWidgetMgr->IsFormDisabled()) | 290 if (m_pWidgetMgr->IsFormDisabled()) |
288 return DisForm_IsMonthCalendarVisible(); | 291 return DisForm_IsMonthCalendarVisible(); |
289 if (!m_pForm) | 292 if (!m_pForm) |
290 return false; | 293 return false; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 CFX_RectF rtAnchor(m_pProperties->m_rtWidget); | 391 CFX_RectF rtAnchor(m_pProperties->m_rtWidget); |
389 rtAnchor.width = rtMonthCal.width; | 392 rtAnchor.width = rtMonthCal.width; |
390 rtMonthCal.left = m_rtClient.left; | 393 rtMonthCal.left = m_rtClient.left; |
391 rtMonthCal.top = rtAnchor.Height(); | 394 rtMonthCal.top = rtAnchor.Height(); |
392 GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal); | 395 GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal); |
393 m_pMonthCal->SetWidgetRect(rtMonthCal); | 396 m_pMonthCal->SetWidgetRect(rtMonthCal); |
394 if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) | 397 if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) |
395 m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay); | 398 m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay); |
396 m_pMonthCal->Update(); | 399 m_pMonthCal->Update(); |
397 } | 400 } |
398 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); | 401 if (bActivate) |
| 402 m_pMonthCal->RemoveStates(FWL_WGTSTATE_Invisible); |
| 403 else |
| 404 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible); |
399 | 405 |
400 if (bActivate) { | 406 if (bActivate) { |
401 CFWL_MsgSetFocus msg(m_pEdit.get(), m_pMonthCal.get()); | 407 CFWL_MsgSetFocus msg(m_pEdit.get(), m_pMonthCal.get()); |
402 m_pEdit->GetDelegate()->OnProcessMessage(&msg); | 408 m_pEdit->GetDelegate()->OnProcessMessage(&msg); |
403 } | 409 } |
404 | 410 |
405 CFX_RectF rtInvalidate, rtCal; | 411 CFX_RectF rtInvalidate, rtCal; |
406 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, | 412 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, |
407 m_pProperties->m_rtWidget.height); | 413 m_pProperties->m_rtWidget.height); |
408 m_pMonthCal->GetWidgetRect(rtCal); | 414 m_pMonthCal->GetWidgetRect(rtCal, false); |
409 rtInvalidate.Union(rtCal); | 415 rtInvalidate.Union(rtCal); |
410 rtInvalidate.Inflate(2, 2); | 416 rtInvalidate.Inflate(2, 2); |
411 Repaint(&rtInvalidate); | 417 Repaint(&rtInvalidate); |
412 } | 418 } |
413 | 419 |
414 FWL_WidgetHit CFWL_DateTimePicker::DisForm_HitTest(FX_FLOAT fx, | 420 FWL_WidgetHit CFWL_DateTimePicker::DisForm_HitTest(FX_FLOAT fx, |
415 FX_FLOAT fy) const { | 421 FX_FLOAT fy) const { |
416 CFX_RectF rect; | 422 CFX_RectF rect; |
417 rect.Set(0, 0, m_pProperties->m_rtWidget.width, | 423 rect.Set(0, 0, m_pProperties->m_rtWidget.width, |
418 m_pProperties->m_rtWidget.height); | 424 m_pProperties->m_rtWidget.height); |
419 if (rect.Contains(fx, fy)) | 425 if (rect.Contains(fx, fy)) |
420 return FWL_WidgetHit::Edit; | 426 return FWL_WidgetHit::Edit; |
421 if (DisForm_IsNeedShowButton()) | 427 if (DisForm_IsNeedShowButton()) |
422 rect.width += m_fBtn; | 428 rect.width += m_fBtn; |
423 if (rect.Contains(fx, fy)) | 429 if (rect.Contains(fx, fy)) |
424 return FWL_WidgetHit::Client; | 430 return FWL_WidgetHit::Client; |
425 if (IsMonthCalendarVisible()) { | 431 if (IsMonthCalendarVisible()) { |
426 m_pMonthCal->GetWidgetRect(rect); | 432 m_pMonthCal->GetWidgetRect(rect, false); |
427 if (rect.Contains(fx, fy)) | 433 if (rect.Contains(fx, fy)) |
428 return FWL_WidgetHit::Client; | 434 return FWL_WidgetHit::Client; |
429 } | 435 } |
430 return FWL_WidgetHit::Unknown; | 436 return FWL_WidgetHit::Unknown; |
431 } | 437 } |
432 | 438 |
433 bool CFWL_DateTimePicker::DisForm_IsNeedShowButton() const { | 439 bool CFWL_DateTimePicker::DisForm_IsNeedShowButton() const { |
434 return m_pProperties->m_dwStates & FWL_WGTSTATE_Focused || | 440 return m_pProperties->m_dwStates & FWL_WGTSTATE_Focused || |
435 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || | 441 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || |
436 m_pEdit->GetStates() & FWL_WGTSTATE_Focused; | 442 m_pEdit->GetStates() & FWL_WGTSTATE_Focused; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 } | 481 } |
476 | 482 |
477 void CFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) const { | 483 void CFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) const { |
478 rect = m_pProperties->m_rtWidget; | 484 rect = m_pProperties->m_rtWidget; |
479 if (DisForm_IsNeedShowButton()) | 485 if (DisForm_IsNeedShowButton()) |
480 rect.width += m_fBtn; | 486 rect.width += m_fBtn; |
481 if (!IsMonthCalendarVisible()) | 487 if (!IsMonthCalendarVisible()) |
482 return; | 488 return; |
483 | 489 |
484 CFX_RectF rtMonth; | 490 CFX_RectF rtMonth; |
485 m_pMonthCal->GetWidgetRect(rtMonth); | 491 m_pMonthCal->GetWidgetRect(rtMonth, false); |
486 rtMonth.Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top); | 492 rtMonth.Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top); |
487 rect.Union(rtMonth); | 493 rect.Union(rtMonth); |
488 } | 494 } |
489 | 495 |
490 void CFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics, | 496 void CFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics, |
491 const CFX_Matrix* pMatrix) { | 497 const CFX_Matrix* pMatrix) { |
492 if (!pGraphics) | 498 if (!pGraphics) |
493 return; | 499 return; |
494 if (m_pEdit) { | 500 if (m_pEdit) { |
495 CFX_RectF rtEdit; | 501 CFX_RectF rtEdit; |
496 m_pEdit->GetWidgetRect(rtEdit); | 502 m_pEdit->GetWidgetRect(rtEdit, false); |
497 | 503 |
498 CFX_Matrix mt; | 504 CFX_Matrix mt; |
499 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); | 505 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); |
500 if (pMatrix) | 506 if (pMatrix) |
501 mt.Concat(*pMatrix); | 507 mt.Concat(*pMatrix); |
502 m_pEdit->DrawWidget(pGraphics, &mt); | 508 m_pEdit->DrawWidget(pGraphics, &mt); |
503 } | 509 } |
504 if (!IsMonthCalendarVisible()) | 510 if (!IsMonthCalendarVisible()) |
505 return; | 511 return; |
506 | 512 |
507 CFX_RectF rtMonth; | 513 CFX_RectF rtMonth; |
508 m_pMonthCal->GetWidgetRect(rtMonth); | 514 m_pMonthCal->GetWidgetRect(rtMonth, false); |
509 CFX_Matrix mt; | 515 CFX_Matrix mt; |
510 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); | 516 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); |
511 if (pMatrix) | 517 if (pMatrix) |
512 mt.Concat(*pMatrix); | 518 mt.Concat(*pMatrix); |
513 m_pMonthCal->DrawWidget(pGraphics, &mt); | 519 m_pMonthCal->DrawWidget(pGraphics, &mt); |
514 } | 520 } |
515 | 521 |
516 void CFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) { | 522 void CFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) { |
517 if (!pMessage) | 523 if (!pMessage) |
518 return; | 524 return; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 if (DisForm_IsMonthCalendarVisible()) | 650 if (DisForm_IsMonthCalendarVisible()) |
645 ShowMonthCalendar(false); | 651 ShowMonthCalendar(false); |
646 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { | 652 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { |
647 pMsg->m_pSrcTarget = m_pEdit.get(); | 653 pMsg->m_pSrcTarget = m_pEdit.get(); |
648 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 654 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
649 } | 655 } |
650 } | 656 } |
651 rtInvalidate.Inflate(2, 2); | 657 rtInvalidate.Inflate(2, 2); |
652 Repaint(&rtInvalidate); | 658 Repaint(&rtInvalidate); |
653 } | 659 } |
OLD | NEW |