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

Side by Side Diff: xfa/fwl/cfwl_datetimepicker.cpp

Issue 2559173002: Move xfa/fwl/core to xfa/fwl. (Closed)
Patch Set: Created 4 years 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/cfwl_datetimepicker.h ('k') | xfa/fwl/cfwl_edit.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/cfwl_datetimepicker.h" 7 #include "xfa/fwl/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_event.h" 13 #include "xfa/fwl/cfwl_event.h"
14 #include "xfa/fwl/core/cfwl_evtselectchanged.h" 14 #include "xfa/fwl/cfwl_eventselectchanged.h"
15 #include "xfa/fwl/core/cfwl_formproxy.h" 15 #include "xfa/fwl/cfwl_formproxy.h"
16 #include "xfa/fwl/core/cfwl_msgmouse.h" 16 #include "xfa/fwl/cfwl_messagemouse.h"
17 #include "xfa/fwl/core/cfwl_msgsetfocus.h" 17 #include "xfa/fwl/cfwl_messagesetfocus.h"
18 #include "xfa/fwl/core/cfwl_notedriver.h" 18 #include "xfa/fwl/cfwl_notedriver.h"
19 #include "xfa/fwl/core/cfwl_spinbutton.h" 19 #include "xfa/fwl/cfwl_spinbutton.h"
20 #include "xfa/fwl/core/cfwl_themebackground.h" 20 #include "xfa/fwl/cfwl_themebackground.h"
21 #include "xfa/fwl/core/cfwl_widgetmgr.h" 21 #include "xfa/fwl/cfwl_widgetmgr.h"
22 #include "xfa/fwl/core/ifwl_themeprovider.h" 22 #include "xfa/fwl/ifwl_themeprovider.h"
23 23
24 namespace { 24 namespace {
25 25
26 const int kDateTimePickerHeight = 20; 26 const int kDateTimePickerHeight = 20;
27 27
28 } // namespace 28 } // namespace
29 CFWL_DateTimePicker::CFWL_DateTimePicker(const CFWL_App* app) 29 CFWL_DateTimePicker::CFWL_DateTimePicker(const CFWL_App* app)
30 : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr), 30 : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr),
31 m_iBtnState(1), 31 m_iBtnState(1),
32 m_iYear(-1), 32 m_iYear(-1),
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 m_iYear = iYear; 322 m_iYear = iYear;
323 m_iMonth = iMonth; 323 m_iMonth = iMonth;
324 m_iDay = iDay; 324 m_iDay = iDay;
325 325
326 CFX_WideString wsText; 326 CFX_WideString wsText;
327 FormatDateString(m_iYear, m_iMonth, m_iDay, wsText); 327 FormatDateString(m_iYear, m_iMonth, m_iDay, wsText);
328 m_pEdit->SetText(wsText); 328 m_pEdit->SetText(wsText);
329 m_pEdit->Update(); 329 m_pEdit->Update();
330 Repaint(&m_rtClient); 330 Repaint(&m_rtClient);
331 331
332 CFWL_EvtSelectChanged ev(this); 332 CFWL_EventSelectChanged ev(this);
333 ev.iYear = m_iYear; 333 ev.iYear = m_iYear;
334 ev.iMonth = m_iMonth; 334 ev.iMonth = m_iMonth;
335 ev.iDay = m_iDay; 335 ev.iDay = m_iDay;
336 DispatchEvent(&ev); 336 DispatchEvent(&ev);
337 } 337 }
338 338
339 void CFWL_DateTimePicker::InitProxyForm() { 339 void CFWL_DateTimePicker::InitProxyForm() {
340 if (m_pForm) 340 if (m_pForm)
341 return; 341 return;
342 if (!m_pMonthCal) 342 if (!m_pMonthCal)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) 375 if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0)
376 m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay); 376 m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay);
377 m_pMonthCal->Update(); 377 m_pMonthCal->Update();
378 } 378 }
379 if (bActivate) 379 if (bActivate)
380 m_pMonthCal->RemoveStates(FWL_WGTSTATE_Invisible); 380 m_pMonthCal->RemoveStates(FWL_WGTSTATE_Invisible);
381 else 381 else
382 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible); 382 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible);
383 383
384 if (bActivate) { 384 if (bActivate) {
385 CFWL_MsgSetFocus msg(m_pEdit.get(), m_pMonthCal.get()); 385 CFWL_MessageSetFocus msg(m_pEdit.get(), m_pMonthCal.get());
386 m_pEdit->GetDelegate()->OnProcessMessage(&msg); 386 m_pEdit->GetDelegate()->OnProcessMessage(&msg);
387 } 387 }
388 388
389 CFX_RectF rtInvalidate; 389 CFX_RectF rtInvalidate;
390 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, 390 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
391 m_pProperties->m_rtWidget.height); 391 m_pProperties->m_rtWidget.height);
392 392
393 CFX_RectF rtCal = m_pMonthCal->GetWidgetRect(); 393 CFX_RectF rtCal = m_pMonthCal->GetWidgetRect();
394 rtInvalidate.Union(rtCal); 394 rtInvalidate.Union(rtCal);
395 rtInvalidate.Inflate(2, 2); 395 rtInvalidate.Inflate(2, 2);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return; 490 return;
491 491
492 switch (pMessage->GetType()) { 492 switch (pMessage->GetType()) {
493 case CFWL_Message::Type::SetFocus: 493 case CFWL_Message::Type::SetFocus:
494 OnFocusChanged(pMessage, true); 494 OnFocusChanged(pMessage, true);
495 break; 495 break;
496 case CFWL_Message::Type::KillFocus: 496 case CFWL_Message::Type::KillFocus:
497 OnFocusChanged(pMessage, false); 497 OnFocusChanged(pMessage, false);
498 break; 498 break;
499 case CFWL_Message::Type::Mouse: { 499 case CFWL_Message::Type::Mouse: {
500 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); 500 CFWL_MessageMouse* pMouse = static_cast<CFWL_MessageMouse*>(pMessage);
501 switch (pMouse->m_dwCmd) { 501 switch (pMouse->m_dwCmd) {
502 case FWL_MouseCommand::LeftButtonDown: 502 case FWL_MouseCommand::LeftButtonDown:
503 OnLButtonDown(pMouse); 503 OnLButtonDown(pMouse);
504 break; 504 break;
505 case FWL_MouseCommand::LeftButtonUp: 505 case FWL_MouseCommand::LeftButtonUp:
506 OnLButtonUp(pMouse); 506 OnLButtonUp(pMouse);
507 break; 507 break;
508 case FWL_MouseCommand::Move: 508 case FWL_MouseCommand::Move:
509 OnMouseMove(pMouse); 509 OnMouseMove(pMouse);
510 break; 510 break;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } else { 547 } else {
548 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); 548 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
549 Repaint(&m_rtClient); 549 Repaint(&m_rtClient);
550 } 550 }
551 if (pMsg->m_pSrcTarget == m_pMonthCal.get() && IsMonthCalendarVisible()) { 551 if (pMsg->m_pSrcTarget == m_pMonthCal.get() && IsMonthCalendarVisible()) {
552 ShowMonthCalendar(false); 552 ShowMonthCalendar(false);
553 } 553 }
554 Repaint(&m_rtClient); 554 Repaint(&m_rtClient);
555 } 555 }
556 556
557 void CFWL_DateTimePicker::OnLButtonDown(CFWL_MsgMouse* pMsg) { 557 void CFWL_DateTimePicker::OnLButtonDown(CFWL_MessageMouse* pMsg) {
558 if (!pMsg) 558 if (!pMsg)
559 return; 559 return;
560 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) 560 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
561 SetFocus(true); 561 SetFocus(true);
562 if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) 562 if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
563 return; 563 return;
564 564
565 if (IsMonthCalendarVisible()) { 565 if (IsMonthCalendarVisible()) {
566 ShowMonthCalendar(false); 566 ShowMonthCalendar(false);
567 return; 567 return;
568 } 568 }
569 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat)) 569 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat))
570 ShowMonthCalendar(true); 570 ShowMonthCalendar(true);
571 571
572 m_bLBtnDown = true; 572 m_bLBtnDown = true;
573 Repaint(&m_rtClient); 573 Repaint(&m_rtClient);
574 } 574 }
575 575
576 void CFWL_DateTimePicker::OnLButtonUp(CFWL_MsgMouse* pMsg) { 576 void CFWL_DateTimePicker::OnLButtonUp(CFWL_MessageMouse* pMsg) {
577 if (!pMsg) 577 if (!pMsg)
578 return; 578 return;
579 579
580 m_bLBtnDown = false; 580 m_bLBtnDown = false;
581 if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) 581 if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
582 m_iBtnState = CFWL_PartState_Hovered; 582 m_iBtnState = CFWL_PartState_Hovered;
583 else 583 else
584 m_iBtnState = CFWL_PartState_Normal; 584 m_iBtnState = CFWL_PartState_Normal;
585 Repaint(&m_rtBtn); 585 Repaint(&m_rtBtn);
586 } 586 }
587 587
588 void CFWL_DateTimePicker::OnMouseMove(CFWL_MsgMouse* pMsg) { 588 void CFWL_DateTimePicker::OnMouseMove(CFWL_MessageMouse* pMsg) {
589 if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) 589 if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
590 m_iBtnState = CFWL_PartState_Normal; 590 m_iBtnState = CFWL_PartState_Normal;
591 Repaint(&m_rtBtn); 591 Repaint(&m_rtBtn);
592 } 592 }
593 593
594 void CFWL_DateTimePicker::OnMouseLeave(CFWL_MsgMouse* pMsg) { 594 void CFWL_DateTimePicker::OnMouseLeave(CFWL_MessageMouse* pMsg) {
595 if (!pMsg) 595 if (!pMsg)
596 return; 596 return;
597 m_iBtnState = CFWL_PartState_Normal; 597 m_iBtnState = CFWL_PartState_Normal;
598 Repaint(&m_rtBtn); 598 Repaint(&m_rtBtn);
599 } 599 }
600 600
601 void CFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg, 601 void CFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg,
602 bool bSet) { 602 bool bSet) {
603 CFX_RectF rtInvalidate(m_rtBtn); 603 CFX_RectF rtInvalidate(m_rtBtn);
604 if (bSet) { 604 if (bSet) {
(...skipping 11 matching lines...) Expand all
616 if (DisForm_IsMonthCalendarVisible()) 616 if (DisForm_IsMonthCalendarVisible())
617 ShowMonthCalendar(false); 617 ShowMonthCalendar(false);
618 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { 618 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
619 pMsg->m_pSrcTarget = m_pEdit.get(); 619 pMsg->m_pSrcTarget = m_pEdit.get();
620 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); 620 m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
621 } 621 }
622 } 622 }
623 rtInvalidate.Inflate(2, 2); 623 rtInvalidate.Inflate(2, 2);
624 Repaint(&rtInvalidate); 624 Repaint(&rtInvalidate);
625 } 625 }
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_datetimepicker.h ('k') | xfa/fwl/cfwl_edit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698