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> |
11 | 11 |
12 #include "third_party/base/ptr_util.h" | 12 #include "third_party/base/ptr_util.h" |
13 #include "xfa/fwl/core/cfwl_evteditchanged.h" | 13 #include "xfa/fwl/core/cfwl_event.h" |
14 #include "xfa/fwl/core/cfwl_evtselectchanged.h" | 14 #include "xfa/fwl/core/cfwl_evtselectchanged.h" |
15 #include "xfa/fwl/core/cfwl_formproxy.h" | 15 #include "xfa/fwl/core/cfwl_formproxy.h" |
16 #include "xfa/fwl/core/cfwl_msgmouse.h" | 16 #include "xfa/fwl/core/cfwl_msgmouse.h" |
17 #include "xfa/fwl/core/cfwl_msgsetfocus.h" | 17 #include "xfa/fwl/core/cfwl_msgsetfocus.h" |
18 #include "xfa/fwl/core/cfwl_notedriver.h" | 18 #include "xfa/fwl/core/cfwl_notedriver.h" |
19 #include "xfa/fwl/core/cfwl_spinbutton.h" | 19 #include "xfa/fwl/core/cfwl_spinbutton.h" |
20 #include "xfa/fwl/core/cfwl_themebackground.h" | 20 #include "xfa/fwl/core/cfwl_themebackground.h" |
21 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 21 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
22 #include "xfa/fwl/core/ifwl_themeprovider.h" | 22 #include "xfa/fwl/core/ifwl_themeprovider.h" |
23 | 23 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 m_pMonthCal->SetSelect(iYear, iMonth, iDay); | 185 m_pMonthCal->SetSelect(iYear, iMonth, iDay); |
186 } | 186 } |
187 | 187 |
188 void CFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) { | 188 void CFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) { |
189 if (!m_pEdit) | 189 if (!m_pEdit) |
190 return; | 190 return; |
191 | 191 |
192 m_pEdit->SetText(wsText); | 192 m_pEdit->SetText(wsText); |
193 Repaint(&m_rtClient); | 193 Repaint(&m_rtClient); |
194 | 194 |
195 CFWL_EvtEditChanged ev; | 195 CFWL_Event ev(CFWL_Event::Type::EditChanged); |
196 DispatchEvent(&ev); | 196 DispatchEvent(&ev); |
197 } | 197 } |
198 | 198 |
199 CFX_WideString CFWL_DateTimePicker::GetEditText(int32_t nStart, | 199 CFX_WideString CFWL_DateTimePicker::GetEditText(int32_t nStart, |
200 int32_t nCount) const { | 200 int32_t nCount) const { |
201 return m_pEdit ? m_pEdit->GetText(nStart, nCount) : L""; | 201 return m_pEdit ? m_pEdit->GetText(nStart, nCount) : L""; |
202 } | 202 } |
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()) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 m_iYear = iYear; | 340 m_iYear = iYear; |
341 m_iMonth = iMonth; | 341 m_iMonth = iMonth; |
342 m_iDay = iDay; | 342 m_iDay = iDay; |
343 | 343 |
344 CFX_WideString wsText; | 344 CFX_WideString wsText; |
345 FormatDateString(m_iYear, m_iMonth, m_iDay, wsText); | 345 FormatDateString(m_iYear, m_iMonth, m_iDay, wsText); |
346 m_pEdit->SetText(wsText); | 346 m_pEdit->SetText(wsText); |
347 m_pEdit->Update(); | 347 m_pEdit->Update(); |
348 Repaint(&m_rtClient); | 348 Repaint(&m_rtClient); |
349 | 349 |
350 CFWL_EvtSelectChanged ev; | 350 CFWL_EvtSelectChanged ev(this); |
351 ev.m_pSrcTarget = this; | |
352 ev.iYear = m_iYear; | 351 ev.iYear = m_iYear; |
353 ev.iMonth = m_iMonth; | 352 ev.iMonth = m_iMonth; |
354 ev.iDay = m_iDay; | 353 ev.iDay = m_iDay; |
355 DispatchEvent(&ev); | 354 DispatchEvent(&ev); |
356 } | 355 } |
357 | 356 |
358 void CFWL_DateTimePicker::InitProxyForm() { | 357 void CFWL_DateTimePicker::InitProxyForm() { |
359 if (m_pForm) | 358 if (m_pForm) |
360 return; | 359 return; |
361 if (!m_pMonthCal) | 360 if (!m_pMonthCal) |
(...skipping 30 matching lines...) Expand all Loading... |
392 rtMonthCal.top = rtAnchor.Height(); | 391 rtMonthCal.top = rtAnchor.Height(); |
393 GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal); | 392 GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal); |
394 m_pMonthCal->SetWidgetRect(rtMonthCal); | 393 m_pMonthCal->SetWidgetRect(rtMonthCal); |
395 if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) | 394 if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) |
396 m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay); | 395 m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay); |
397 m_pMonthCal->Update(); | 396 m_pMonthCal->Update(); |
398 } | 397 } |
399 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); | 398 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); |
400 | 399 |
401 if (bActivate) { | 400 if (bActivate) { |
402 CFWL_MsgSetFocus msg; | 401 CFWL_MsgSetFocus msg(m_pEdit.get(), m_pMonthCal.get()); |
403 msg.m_pDstTarget = m_pMonthCal.get(); | |
404 msg.m_pSrcTarget = m_pEdit.get(); | |
405 m_pEdit->GetDelegate()->OnProcessMessage(&msg); | 402 m_pEdit->GetDelegate()->OnProcessMessage(&msg); |
406 } | 403 } |
407 | 404 |
408 CFX_RectF rtInvalidate, rtCal; | 405 CFX_RectF rtInvalidate, rtCal; |
409 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, | 406 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, |
410 m_pProperties->m_rtWidget.height); | 407 m_pProperties->m_rtWidget.height); |
411 m_pMonthCal->GetWidgetRect(rtCal); | 408 m_pMonthCal->GetWidgetRect(rtCal); |
412 rtInvalidate.Union(rtCal); | 409 rtInvalidate.Union(rtCal); |
413 rtInvalidate.Inflate(2, 2); | 410 rtInvalidate.Inflate(2, 2); |
414 Repaint(&rtInvalidate); | 411 Repaint(&rtInvalidate); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); | 510 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); |
514 if (pMatrix) | 511 if (pMatrix) |
515 mt.Concat(*pMatrix); | 512 mt.Concat(*pMatrix); |
516 m_pMonthCal->DrawWidget(pGraphics, &mt); | 513 m_pMonthCal->DrawWidget(pGraphics, &mt); |
517 } | 514 } |
518 | 515 |
519 void CFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) { | 516 void CFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) { |
520 if (!pMessage) | 517 if (!pMessage) |
521 return; | 518 return; |
522 | 519 |
523 switch (pMessage->GetClassID()) { | 520 switch (pMessage->GetType()) { |
524 case CFWL_MessageType::SetFocus: | 521 case CFWL_Message::Type::SetFocus: |
525 OnFocusChanged(pMessage, true); | 522 OnFocusChanged(pMessage, true); |
526 break; | 523 break; |
527 case CFWL_MessageType::KillFocus: | 524 case CFWL_Message::Type::KillFocus: |
528 OnFocusChanged(pMessage, false); | 525 OnFocusChanged(pMessage, false); |
529 break; | 526 break; |
530 case CFWL_MessageType::Mouse: { | 527 case CFWL_Message::Type::Mouse: { |
531 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); | 528 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); |
532 switch (pMouse->m_dwCmd) { | 529 switch (pMouse->m_dwCmd) { |
533 case FWL_MouseCommand::LeftButtonDown: | 530 case FWL_MouseCommand::LeftButtonDown: |
534 OnLButtonDown(pMouse); | 531 OnLButtonDown(pMouse); |
535 break; | 532 break; |
536 case FWL_MouseCommand::LeftButtonUp: | 533 case FWL_MouseCommand::LeftButtonUp: |
537 OnLButtonUp(pMouse); | 534 OnLButtonUp(pMouse); |
538 break; | 535 break; |
539 case FWL_MouseCommand::Move: | 536 case FWL_MouseCommand::Move: |
540 OnMouseMove(pMouse); | 537 OnMouseMove(pMouse); |
541 break; | 538 break; |
542 case FWL_MouseCommand::Leave: | 539 case FWL_MouseCommand::Leave: |
543 OnMouseLeave(pMouse); | 540 OnMouseLeave(pMouse); |
544 break; | 541 break; |
545 default: | 542 default: |
546 break; | 543 break; |
547 } | 544 } |
548 break; | 545 break; |
549 } | 546 } |
550 case CFWL_MessageType::Key: { | 547 case CFWL_Message::Type::Key: { |
551 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { | 548 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { |
552 m_pEdit->GetDelegate()->OnProcessMessage(pMessage); | 549 m_pEdit->GetDelegate()->OnProcessMessage(pMessage); |
553 return; | 550 return; |
554 } | 551 } |
555 break; | 552 break; |
556 } | 553 } |
557 default: | 554 default: |
558 break; | 555 break; |
559 } | 556 } |
560 | 557 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 if (DisForm_IsMonthCalendarVisible()) | 644 if (DisForm_IsMonthCalendarVisible()) |
648 ShowMonthCalendar(false); | 645 ShowMonthCalendar(false); |
649 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { | 646 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { |
650 pMsg->m_pSrcTarget = m_pEdit.get(); | 647 pMsg->m_pSrcTarget = m_pEdit.get(); |
651 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 648 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
652 } | 649 } |
653 } | 650 } |
654 rtInvalidate.Inflate(2, 2); | 651 rtInvalidate.Inflate(2, 2); |
655 Repaint(&rtInvalidate); | 652 Repaint(&rtInvalidate); |
656 } | 653 } |
OLD | NEW |