| 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/ifwl_widget.h" | 7 #include "xfa/fwl/core/ifwl_widget.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "xfa/fde/tto/fde_textout.h" | 12 #include "xfa/fde/tto/fde_textout.h" |
| 13 #include "xfa/fwl/core/cfwl_app.h" |
| 13 #include "xfa/fwl/core/cfwl_evtkey.h" | 14 #include "xfa/fwl/core/cfwl_evtkey.h" |
| 14 #include "xfa/fwl/core/cfwl_evtkillfocus.h" | 15 #include "xfa/fwl/core/cfwl_evtkillfocus.h" |
| 15 #include "xfa/fwl/core/cfwl_evtmouse.h" | 16 #include "xfa/fwl/core/cfwl_evtmouse.h" |
| 16 #include "xfa/fwl/core/cfwl_evtmousewheel.h" | 17 #include "xfa/fwl/core/cfwl_evtmousewheel.h" |
| 17 #include "xfa/fwl/core/cfwl_evtsetfocus.h" | 18 #include "xfa/fwl/core/cfwl_evtsetfocus.h" |
| 18 #include "xfa/fwl/core/cfwl_evtsizechanged.h" | 19 #include "xfa/fwl/core/cfwl_evtsizechanged.h" |
| 19 #include "xfa/fwl/core/cfwl_msgkey.h" | 20 #include "xfa/fwl/core/cfwl_msgkey.h" |
| 20 #include "xfa/fwl/core/cfwl_msgkillfocus.h" | 21 #include "xfa/fwl/core/cfwl_msgkillfocus.h" |
| 21 #include "xfa/fwl/core/cfwl_msgmouse.h" | 22 #include "xfa/fwl/core/cfwl_msgmouse.h" |
| 22 #include "xfa/fwl/core/cfwl_msgmousewheel.h" | 23 #include "xfa/fwl/core/cfwl_msgmousewheel.h" |
| 23 #include "xfa/fwl/core/cfwl_msgsetfocus.h" | 24 #include "xfa/fwl/core/cfwl_msgsetfocus.h" |
| 24 #include "xfa/fwl/core/cfwl_notedriver.h" | 25 #include "xfa/fwl/core/cfwl_notedriver.h" |
| 25 #include "xfa/fwl/core/cfwl_themebackground.h" | 26 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 26 #include "xfa/fwl/core/cfwl_themepart.h" | 27 #include "xfa/fwl/core/cfwl_themepart.h" |
| 27 #include "xfa/fwl/core/cfwl_themetext.h" | 28 #include "xfa/fwl/core/cfwl_themetext.h" |
| 28 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 29 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
| 29 #include "xfa/fwl/core/ifwl_app.h" | |
| 30 #include "xfa/fwl/core/ifwl_combobox.h" | 30 #include "xfa/fwl/core/ifwl_combobox.h" |
| 31 #include "xfa/fwl/core/ifwl_form.h" | 31 #include "xfa/fwl/core/ifwl_form.h" |
| 32 #include "xfa/fwl/core/ifwl_themeprovider.h" | 32 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 33 #include "xfa/fxfa/xfa_ffapp.h" | 33 #include "xfa/fxfa/xfa_ffapp.h" |
| 34 | 34 |
| 35 #define FWL_STYLEEXT_MNU_Vert (1L << 0) | 35 #define FWL_STYLEEXT_MNU_Vert (1L << 0) |
| 36 #define FWL_WGT_CalcHeight 2048 | 36 #define FWL_WGT_CalcHeight 2048 |
| 37 #define FWL_WGT_CalcWidth 2048 | 37 #define FWL_WGT_CalcWidth 2048 |
| 38 #define FWL_WGT_CalcMultiLineDefWidth 120.0f | 38 #define FWL_WGT_CalcMultiLineDefWidth 120.0f |
| 39 | 39 |
| 40 IFWL_Widget::IFWL_Widget(const IFWL_App* app, | 40 IFWL_Widget::IFWL_Widget(const CFWL_App* app, |
| 41 std::unique_ptr<CFWL_WidgetProperties> properties, | 41 std::unique_ptr<CFWL_WidgetProperties> properties, |
| 42 IFWL_Widget* pOuter) | 42 IFWL_Widget* pOuter) |
| 43 : m_pOwnerApp(app), | 43 : m_pOwnerApp(app), |
| 44 m_pWidgetMgr(app->GetWidgetMgr()), | 44 m_pWidgetMgr(app->GetWidgetMgr()), |
| 45 m_pProperties(std::move(properties)), | 45 m_pProperties(std::move(properties)), |
| 46 m_pOuter(pOuter), | 46 m_pOuter(pOuter), |
| 47 m_iLock(0), | 47 m_iLock(0), |
| 48 m_pLayoutItem(nullptr), | 48 m_pLayoutItem(nullptr), |
| 49 m_pAssociate(nullptr), | 49 m_pAssociate(nullptr), |
| 50 m_nEventKey(0), | 50 m_nEventKey(0), |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 calPart.m_wsText = wsText; | 452 calPart.m_wsText = wsText; |
| 453 calPart.m_dwTTOStyles = dwTTOStyles; | 453 calPart.m_dwTTOStyles = dwTTOStyles; |
| 454 calPart.m_iTTOAlign = iTTOAlign; | 454 calPart.m_iTTOAlign = iTTOAlign; |
| 455 pTheme->CalcTextRect(&calPart, rect); | 455 pTheme->CalcTextRect(&calPart, rect); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void IFWL_Widget::SetFocus(bool bFocus) { | 458 void IFWL_Widget::SetFocus(bool bFocus) { |
| 459 if (m_pWidgetMgr->IsFormDisabled()) | 459 if (m_pWidgetMgr->IsFormDisabled()) |
| 460 return; | 460 return; |
| 461 | 461 |
| 462 const IFWL_App* pApp = GetOwnerApp(); | 462 const CFWL_App* pApp = GetOwnerApp(); |
| 463 if (!pApp) | 463 if (!pApp) |
| 464 return; | 464 return; |
| 465 | 465 |
| 466 CFWL_NoteDriver* pDriver = | 466 CFWL_NoteDriver* pDriver = |
| 467 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 467 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 468 if (!pDriver) | 468 if (!pDriver) |
| 469 return; | 469 return; |
| 470 | 470 |
| 471 IFWL_Widget* curFocus = pDriver->GetFocus(); | 471 IFWL_Widget* curFocus = pDriver->GetFocus(); |
| 472 if (bFocus && curFocus != this) | 472 if (bFocus && curFocus != this) |
| 473 pDriver->SetFocus(this); | 473 pDriver->SetFocus(this); |
| 474 else if (!bFocus && curFocus == this) | 474 else if (!bFocus && curFocus == this) |
| 475 pDriver->SetFocus(nullptr); | 475 pDriver->SetFocus(nullptr); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void IFWL_Widget::SetGrab(bool bSet) { | 478 void IFWL_Widget::SetGrab(bool bSet) { |
| 479 const IFWL_App* pApp = GetOwnerApp(); | 479 const CFWL_App* pApp = GetOwnerApp(); |
| 480 if (!pApp) | 480 if (!pApp) |
| 481 return; | 481 return; |
| 482 | 482 |
| 483 CFWL_NoteDriver* pDriver = | 483 CFWL_NoteDriver* pDriver = |
| 484 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 484 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 485 pDriver->SetGrab(this, bSet); | 485 pDriver->SetGrab(this, bSet); |
| 486 } | 486 } |
| 487 | 487 |
| 488 void IFWL_Widget::GetPopupPos(FX_FLOAT fMinHeight, | 488 void IFWL_Widget::GetPopupPos(FX_FLOAT fMinHeight, |
| 489 FX_FLOAT fMaxHeight, | 489 FX_FLOAT fMaxHeight, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 rtPopup.height); | 578 rtPopup.height); |
| 579 } else { | 579 } else { |
| 580 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, | 580 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, |
| 581 rtPopup.height); | 581 rtPopup.height); |
| 582 } | 582 } |
| 583 rtPopup.Offset(fx, fy); | 583 rtPopup.Offset(fx, fy); |
| 584 return true; | 584 return true; |
| 585 } | 585 } |
| 586 | 586 |
| 587 void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource) { | 587 void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource) { |
| 588 const IFWL_App* pApp = GetOwnerApp(); | 588 const CFWL_App* pApp = GetOwnerApp(); |
| 589 if (!pApp) | 589 if (!pApp) |
| 590 return; | 590 return; |
| 591 | 591 |
| 592 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 592 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
| 593 if (!pNoteDriver) | 593 if (!pNoteDriver) |
| 594 return; | 594 return; |
| 595 | 595 |
| 596 pNoteDriver->RegisterEventTarget(this, pEventSource); | 596 pNoteDriver->RegisterEventTarget(this, pEventSource); |
| 597 } | 597 } |
| 598 | 598 |
| 599 void IFWL_Widget::UnregisterEventTarget() { | 599 void IFWL_Widget::UnregisterEventTarget() { |
| 600 const IFWL_App* pApp = GetOwnerApp(); | 600 const CFWL_App* pApp = GetOwnerApp(); |
| 601 if (!pApp) | 601 if (!pApp) |
| 602 return; | 602 return; |
| 603 | 603 |
| 604 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 604 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
| 605 if (!pNoteDriver) | 605 if (!pNoteDriver) |
| 606 return; | 606 return; |
| 607 | 607 |
| 608 pNoteDriver->UnregisterEventTarget(this); | 608 pNoteDriver->UnregisterEventTarget(this); |
| 609 } | 609 } |
| 610 | 610 |
| 611 void IFWL_Widget::DispatchKeyEvent(CFWL_MsgKey* pNote) { | 611 void IFWL_Widget::DispatchKeyEvent(CFWL_MsgKey* pNote) { |
| 612 if (!pNote) | 612 if (!pNote) |
| 613 return; | 613 return; |
| 614 | 614 |
| 615 auto pEvent = pdfium::MakeUnique<CFWL_EvtKey>(); | 615 auto pEvent = pdfium::MakeUnique<CFWL_EvtKey>(); |
| 616 pEvent->m_pSrcTarget = this; | 616 pEvent->m_pSrcTarget = this; |
| 617 pEvent->m_dwCmd = pNote->m_dwCmd; | 617 pEvent->m_dwCmd = pNote->m_dwCmd; |
| 618 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; | 618 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; |
| 619 pEvent->m_dwFlags = pNote->m_dwFlags; | 619 pEvent->m_dwFlags = pNote->m_dwFlags; |
| 620 DispatchEvent(pEvent.get()); | 620 DispatchEvent(pEvent.get()); |
| 621 } | 621 } |
| 622 | 622 |
| 623 void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { | 623 void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { |
| 624 if (m_pOuter) { | 624 if (m_pOuter) { |
| 625 m_pOuter->GetDelegate()->OnProcessEvent(pEvent); | 625 m_pOuter->GetDelegate()->OnProcessEvent(pEvent); |
| 626 return; | 626 return; |
| 627 } | 627 } |
| 628 const IFWL_App* pApp = GetOwnerApp(); | 628 const CFWL_App* pApp = GetOwnerApp(); |
| 629 if (!pApp) | 629 if (!pApp) |
| 630 return; | 630 return; |
| 631 | 631 |
| 632 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 632 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
| 633 if (!pNoteDriver) | 633 if (!pNoteDriver) |
| 634 return; | 634 return; |
| 635 pNoteDriver->SendEvent(pEvent); | 635 pNoteDriver->SendEvent(pEvent); |
| 636 } | 636 } |
| 637 | 637 |
| 638 void IFWL_Widget::Repaint(const CFX_RectF* pRect) { | 638 void IFWL_Widget::Repaint(const CFX_RectF* pRect) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 param.m_pWidget = this; | 688 param.m_pWidget = this; |
| 689 param.m_iPart = iPartEdge; | 689 param.m_iPart = iPartEdge; |
| 690 param.m_pGraphics = pGraphics; | 690 param.m_pGraphics = pGraphics; |
| 691 if (pMatrix) | 691 if (pMatrix) |
| 692 param.m_matrix.Concat(*pMatrix, true); | 692 param.m_matrix.Concat(*pMatrix, true); |
| 693 param.m_rtPart = rtEdge; | 693 param.m_rtPart = rtEdge; |
| 694 pTheme->DrawBackground(¶m); | 694 pTheme->DrawBackground(¶m); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void IFWL_Widget::NotifyDriver() { | 697 void IFWL_Widget::NotifyDriver() { |
| 698 const IFWL_App* pApp = GetOwnerApp(); | 698 const CFWL_App* pApp = GetOwnerApp(); |
| 699 if (!pApp) | 699 if (!pApp) |
| 700 return; | 700 return; |
| 701 | 701 |
| 702 CFWL_NoteDriver* pDriver = | 702 CFWL_NoteDriver* pDriver = |
| 703 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 703 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 704 if (!pDriver) | 704 if (!pDriver) |
| 705 return; | 705 return; |
| 706 | 706 |
| 707 pDriver->NotifyTargetDestroy(this); | 707 pDriver->NotifyTargetDestroy(this); |
| 708 } | 708 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 } | 803 } |
| 804 default: | 804 default: |
| 805 break; | 805 break; |
| 806 } | 806 } |
| 807 } | 807 } |
| 808 | 808 |
| 809 void IFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} | 809 void IFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} |
| 810 | 810 |
| 811 void IFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, | 811 void IFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, |
| 812 const CFX_Matrix* pMatrix) {} | 812 const CFX_Matrix* pMatrix) {} |
| OLD | NEW |