| 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) { |
| 39 ASSERT(m_pWidgetMgr); | 38 ASSERT(m_pWidgetMgr); |
| 40 | 39 |
| 41 IFWL_Widget* pParent = m_pProperties->m_pParent; | 40 IFWL_Widget* pParent = m_pProperties->m_pParent; |
| 42 m_pWidgetMgr->InsertWidget(pParent, this); | 41 m_pWidgetMgr->InsertWidget(pParent, this); |
| 43 if (IsChild()) | 42 if (IsChild()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 CFX_RectF rtOld = m_pProperties->m_rtWidget; | 89 CFX_RectF rtOld = m_pProperties->m_rtWidget; |
| 91 m_pProperties->m_rtWidget = rect; | 90 m_pProperties->m_rtWidget = rect; |
| 92 if (IsChild()) { | 91 if (IsChild()) { |
| 93 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || | 92 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || |
| 94 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { | 93 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { |
| 95 CFWL_EvtSizeChanged ev; | 94 CFWL_EvtSizeChanged ev; |
| 96 ev.m_pSrcTarget = this; | 95 ev.m_pSrcTarget = this; |
| 97 ev.m_rtOld = rtOld; | 96 ev.m_rtOld = rtOld; |
| 98 ev.m_rtNew = rect; | 97 ev.m_rtNew = rect; |
| 99 | 98 |
| 100 if (IFWL_WidgetDelegate* pDelegate = GetCurrentDelegate()) | 99 if (IFWL_WidgetDelegate* pDelegate = GetDelegate()) |
| 101 pDelegate->OnProcessEvent(&ev); | 100 pDelegate->OnProcessEvent(&ev); |
| 102 } | 101 } |
| 103 return FWL_Error::Succeeded; | 102 return FWL_Error::Succeeded; |
| 104 } | 103 } |
| 105 m_pWidgetMgr->SetWidgetRect_Native(this, rect); | 104 m_pWidgetMgr->SetWidgetRect_Native(this, rect); |
| 106 return FWL_Error::Succeeded; | 105 return FWL_Error::Succeeded; |
| 107 } | 106 } |
| 108 | 107 |
| 109 FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) { | 108 FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) { |
| 110 GetEdgeRect(rect); | 109 GetEdgeRect(rect); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 340 } |
| 342 | 341 |
| 343 IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() { | 342 IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() { |
| 344 return m_pProperties->m_pThemeProvider; | 343 return m_pProperties->m_pThemeProvider; |
| 345 } | 344 } |
| 346 FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 345 FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
| 347 m_pProperties->m_pThemeProvider = pThemeProvider; | 346 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 348 return FWL_Error::Succeeded; | 347 return FWL_Error::Succeeded; |
| 349 } | 348 } |
| 350 | 349 |
| 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 { | 350 const IFWL_App* IFWL_Widget::GetOwnerApp() const { |
| 362 return m_pOwnerApp; | 351 return m_pOwnerApp; |
| 363 } | 352 } |
| 364 | 353 |
| 365 uint32_t IFWL_Widget::GetEventKey() const { | 354 uint32_t IFWL_Widget::GetEventKey() const { |
| 366 return m_nEventKey; | 355 return m_nEventKey; |
| 367 } | 356 } |
| 368 | 357 |
| 369 void IFWL_Widget::SetEventKey(uint32_t key) { | 358 void IFWL_Widget::SetEventKey(uint32_t key) { |
| 370 m_nEventKey = key; | 359 m_nEventKey = key; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 pEvent->m_pSrcTarget = this; | 702 pEvent->m_pSrcTarget = this; |
| 714 pEvent->m_dwCmd = pNote->m_dwCmd; | 703 pEvent->m_dwCmd = pNote->m_dwCmd; |
| 715 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; | 704 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; |
| 716 pEvent->m_dwFlags = pNote->m_dwFlags; | 705 pEvent->m_dwFlags = pNote->m_dwFlags; |
| 717 DispatchEvent(pEvent); | 706 DispatchEvent(pEvent); |
| 718 pEvent->Release(); | 707 pEvent->Release(); |
| 719 } | 708 } |
| 720 | 709 |
| 721 void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { | 710 void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { |
| 722 if (m_pOuter) { | 711 if (m_pOuter) { |
| 723 m_pOuter->GetCurrentDelegate()->OnProcessEvent(pEvent); | 712 m_pOuter->GetDelegate()->OnProcessEvent(pEvent); |
| 724 return; | 713 return; |
| 725 } | 714 } |
| 726 const IFWL_App* pApp = GetOwnerApp(); | 715 const IFWL_App* pApp = GetOwnerApp(); |
| 727 if (!pApp) | 716 if (!pApp) |
| 728 return; | 717 return; |
| 729 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 718 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
| 730 if (!pNoteDriver) | 719 if (!pNoteDriver) |
| 731 return; | 720 return; |
| 732 pNoteDriver->SendEvent(pEvent); | 721 pNoteDriver->SendEvent(pEvent); |
| 733 } | 722 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 } | 897 } |
| 909 } | 898 } |
| 910 | 899 |
| 911 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} | 900 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} |
| 912 | 901 |
| 913 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 902 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 914 const CFX_Matrix* pMatrix) { | 903 const CFX_Matrix* pMatrix) { |
| 915 CFWL_EvtDraw evt; | 904 CFWL_EvtDraw evt; |
| 916 evt.m_pGraphics = pGraphics; | 905 evt.m_pGraphics = pGraphics; |
| 917 } | 906 } |
| OLD | NEW |