| 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 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "xfa/fxfa/xfa_ffapp.h" | 23 #include "xfa/fxfa/xfa_ffapp.h" |
| 24 | 24 |
| 25 #define FWL_STYLEEXT_MNU_Vert (1L << 0) | 25 #define FWL_STYLEEXT_MNU_Vert (1L << 0) |
| 26 | 26 |
| 27 IFWL_Widget::IFWL_Widget(const IFWL_App* app, | 27 IFWL_Widget::IFWL_Widget(const IFWL_App* app, |
| 28 const CFWL_WidgetImpProperties& properties, | 28 const CFWL_WidgetImpProperties& properties, |
| 29 IFWL_Widget* pOuter) | 29 IFWL_Widget* pOuter) |
| 30 : m_pOwnerApp(app), | 30 : m_pOwnerApp(app), |
| 31 m_pWidgetMgr(app->GetWidgetMgr()), | 31 m_pWidgetMgr(app->GetWidgetMgr()), |
| 32 m_pProperties(new CFWL_WidgetImpProperties(properties)), | 32 m_pProperties(new CFWL_WidgetImpProperties(properties)), |
| 33 m_pCurDelegate(nullptr), | |
| 34 m_pOuter(pOuter), | 33 m_pOuter(pOuter), |
| 35 m_pLayoutItem(nullptr), | 34 m_pLayoutItem(nullptr), |
| 36 m_pAssociate(nullptr), | 35 m_pAssociate(nullptr), |
| 37 m_iLock(0), | 36 m_iLock(0), |
| 38 m_nEventKey(0) { | 37 m_nEventKey(0), |
| 38 m_pDelegate(nullptr) { |
| 39 ASSERT(m_pWidgetMgr); | 39 ASSERT(m_pWidgetMgr); |
| 40 | 40 |
| 41 IFWL_Widget* pParent = m_pProperties->m_pParent; | 41 IFWL_Widget* pParent = m_pProperties->m_pParent; |
| 42 m_pWidgetMgr->InsertWidget(pParent, this); | 42 m_pWidgetMgr->InsertWidget(pParent, this); |
| 43 if (IsChild()) | 43 if (IsChild()) |
| 44 return; | 44 return; |
| 45 | 45 |
| 46 IFWL_Widget* pOwner = m_pProperties->m_pOwner; | 46 IFWL_Widget* pOwner = m_pProperties->m_pOwner; |
| 47 if (pOwner) | 47 if (pOwner) |
| 48 m_pWidgetMgr->SetOwner(pOwner, this); | 48 m_pWidgetMgr->SetOwner(pOwner, this); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 CFX_RectF rtOld = m_pProperties->m_rtWidget; | 90 CFX_RectF rtOld = m_pProperties->m_rtWidget; |
| 91 m_pProperties->m_rtWidget = rect; | 91 m_pProperties->m_rtWidget = rect; |
| 92 if (IsChild()) { | 92 if (IsChild()) { |
| 93 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || | 93 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || |
| 94 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { | 94 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { |
| 95 CFWL_EvtSizeChanged ev; | 95 CFWL_EvtSizeChanged ev; |
| 96 ev.m_pSrcTarget = this; | 96 ev.m_pSrcTarget = this; |
| 97 ev.m_rtOld = rtOld; | 97 ev.m_rtOld = rtOld; |
| 98 ev.m_rtNew = rect; | 98 ev.m_rtNew = rect; |
| 99 | 99 |
| 100 if (IFWL_WidgetDelegate* pDelegate = GetCurrentDelegate()) | 100 if (IFWL_WidgetDelegate* pDelegate = GetDelegate()) |
| 101 pDelegate->OnProcessEvent(&ev); | 101 pDelegate->OnProcessEvent(&ev); |
| 102 } | 102 } |
| 103 return FWL_Error::Succeeded; | 103 return FWL_Error::Succeeded; |
| 104 } | 104 } |
| 105 m_pWidgetMgr->SetWidgetRect_Native(this, rect); | 105 m_pWidgetMgr->SetWidgetRect_Native(this, rect); |
| 106 return FWL_Error::Succeeded; | 106 return FWL_Error::Succeeded; |
| 107 } | 107 } |
| 108 | 108 |
| 109 FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) { | 109 FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) { |
| 110 GetEdgeRect(rect); | 110 GetEdgeRect(rect); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 341 } |
| 342 | 342 |
| 343 IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() { | 343 IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() { |
| 344 return m_pProperties->m_pThemeProvider; | 344 return m_pProperties->m_pThemeProvider; |
| 345 } | 345 } |
| 346 FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 346 FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
| 347 m_pProperties->m_pThemeProvider = pThemeProvider; | 347 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 348 return FWL_Error::Succeeded; | 348 return FWL_Error::Succeeded; |
| 349 } | 349 } |
| 350 | 350 |
| 351 IFWL_WidgetDelegate* IFWL_Widget::GetCurrentDelegate() { | |
| 352 if (!m_pCurDelegate) | |
| 353 m_pCurDelegate = m_pDelegate.get(); | |
| 354 return m_pCurDelegate; | |
| 355 } | |
| 356 | |
| 357 void IFWL_Widget::SetCurrentDelegate(IFWL_WidgetDelegate* pDelegate) { | |
| 358 m_pCurDelegate = pDelegate; | |
| 359 } | |
| 360 | |
| 361 const IFWL_App* IFWL_Widget::GetOwnerApp() const { | 351 const IFWL_App* IFWL_Widget::GetOwnerApp() const { |
| 362 return m_pOwnerApp; | 352 return m_pOwnerApp; |
| 363 } | 353 } |
| 364 | 354 |
| 365 uint32_t IFWL_Widget::GetEventKey() const { | 355 uint32_t IFWL_Widget::GetEventKey() const { |
| 366 return m_nEventKey; | 356 return m_nEventKey; |
| 367 } | 357 } |
| 368 | 358 |
| 369 void IFWL_Widget::SetEventKey(uint32_t key) { | 359 void IFWL_Widget::SetEventKey(uint32_t key) { |
| 370 m_nEventKey = key; | 360 m_nEventKey = key; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 pEvent->m_pSrcTarget = this; | 703 pEvent->m_pSrcTarget = this; |
| 714 pEvent->m_dwCmd = pNote->m_dwCmd; | 704 pEvent->m_dwCmd = pNote->m_dwCmd; |
| 715 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; | 705 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; |
| 716 pEvent->m_dwFlags = pNote->m_dwFlags; | 706 pEvent->m_dwFlags = pNote->m_dwFlags; |
| 717 DispatchEvent(pEvent); | 707 DispatchEvent(pEvent); |
| 718 pEvent->Release(); | 708 pEvent->Release(); |
| 719 } | 709 } |
| 720 | 710 |
| 721 void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { | 711 void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { |
| 722 if (m_pOuter) { | 712 if (m_pOuter) { |
| 723 m_pOuter->GetCurrentDelegate()->OnProcessEvent(pEvent); | 713 m_pOuter->GetDelegate()->OnProcessEvent(pEvent); |
| 724 return; | 714 return; |
| 725 } | 715 } |
| 726 const IFWL_App* pApp = GetOwnerApp(); | 716 const IFWL_App* pApp = GetOwnerApp(); |
| 727 if (!pApp) | 717 if (!pApp) |
| 728 return; | 718 return; |
| 729 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 719 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
| 730 if (!pNoteDriver) | 720 if (!pNoteDriver) |
| 731 return; | 721 return; |
| 732 pNoteDriver->SendEvent(pEvent); | 722 pNoteDriver->SendEvent(pEvent); |
| 733 } | 723 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 FX_BOOL IFWL_Widget::IsParent(IFWL_Widget* pParent) { | 821 FX_BOOL IFWL_Widget::IsParent(IFWL_Widget* pParent) { |
| 832 IFWL_Widget* pUpWidget = GetParent(); | 822 IFWL_Widget* pUpWidget = GetParent(); |
| 833 while (pUpWidget) { | 823 while (pUpWidget) { |
| 834 if (pUpWidget == pParent) | 824 if (pUpWidget == pParent) |
| 835 return TRUE; | 825 return TRUE; |
| 836 pUpWidget = pUpWidget->GetParent(); | 826 pUpWidget = pUpWidget->GetParent(); |
| 837 } | 827 } |
| 838 return FALSE; | 828 return FALSE; |
| 839 } | 829 } |
| 840 | 830 |
| 841 CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {} | 831 void IFWL_Widget::OnProcessMessage(CFWL_Message* pMessage) { |
| 842 | |
| 843 void CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | |
| 844 if (!pMessage->m_pDstTarget) | 832 if (!pMessage->m_pDstTarget) |
| 845 return; | 833 return; |
| 846 | 834 |
| 847 IFWL_Widget* pWidget = pMessage->m_pDstTarget; | 835 IFWL_Widget* pWidget = pMessage->m_pDstTarget; |
| 848 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 836 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
| 849 switch (dwMsgCode) { | 837 switch (dwMsgCode) { |
| 850 case CFWL_MessageType::Mouse: { | 838 case CFWL_MessageType::Mouse: { |
| 851 CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage); | 839 CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage); |
| 852 CFWL_EvtMouse evt; | 840 CFWL_EvtMouse evt; |
| 853 evt.m_pSrcTarget = pWidget; | 841 evt.m_pSrcTarget = pWidget; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 evt.m_pDstTarget = pMsgKillFocus->m_pDstTarget; | 889 evt.m_pDstTarget = pMsgKillFocus->m_pDstTarget; |
| 902 evt.m_pKillFocus = pWidget; | 890 evt.m_pKillFocus = pWidget; |
| 903 pWidget->DispatchEvent(&evt); | 891 pWidget->DispatchEvent(&evt); |
| 904 break; | 892 break; |
| 905 } | 893 } |
| 906 default: | 894 default: |
| 907 break; | 895 break; |
| 908 } | 896 } |
| 909 } | 897 } |
| 910 | 898 |
| 911 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} | 899 void IFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} |
| 912 | 900 |
| 913 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 901 void IFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, |
| 914 const CFX_Matrix* pMatrix) { | 902 const CFX_Matrix* pMatrix) {} |
| 915 CFWL_EvtDraw evt; | |
| 916 evt.m_pGraphics = pGraphics; | |
| 917 } | |
| OLD | NEW |