| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 FWL_Error IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { | 93 FWL_Error IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { |
| 94 CFX_RectF rtOld = m_pProperties->m_rtWidget; | 94 CFX_RectF rtOld = m_pProperties->m_rtWidget; |
| 95 m_pProperties->m_rtWidget = rect; | 95 m_pProperties->m_rtWidget = rect; |
| 96 if (IsChild()) { | 96 if (IsChild()) { |
| 97 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || | 97 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || |
| 98 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { | 98 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { |
| 99 CFWL_EvtSizeChanged ev; | 99 CFWL_EvtSizeChanged ev; |
| 100 ev.m_pSrcTarget = this; | 100 ev.m_pSrcTarget = this; |
| 101 ev.m_rtOld = rtOld; | 101 ev.m_rtOld = rtOld; |
| 102 ev.m_rtNew = rect; | 102 ev.m_rtNew = rect; |
| 103 IFWL_WidgetDelegate* pDelegate = SetDelegate(nullptr); | 103 |
| 104 if (pDelegate) { | 104 if (IFWL_WidgetDelegate* pDelegate = GetCurrentDelegate()) |
| 105 pDelegate->OnProcessEvent(&ev); | 105 pDelegate->OnProcessEvent(&ev); |
| 106 } | |
| 107 } | 106 } |
| 108 return FWL_Error::Succeeded; | 107 return FWL_Error::Succeeded; |
| 109 } | 108 } |
| 110 m_pWidgetMgr->SetWidgetRect_Native(this, rect); | 109 m_pWidgetMgr->SetWidgetRect_Native(this, rect); |
| 111 return FWL_Error::Succeeded; | 110 return FWL_Error::Succeeded; |
| 112 } | 111 } |
| 113 | 112 |
| 114 FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) { | 113 FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) { |
| 115 GetEdgeRect(rect); | 114 GetEdgeRect(rect); |
| 116 if (HasEdge()) { | 115 if (HasEdge()) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 345 } |
| 347 | 346 |
| 348 IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() { | 347 IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() { |
| 349 return m_pProperties->m_pThemeProvider; | 348 return m_pProperties->m_pThemeProvider; |
| 350 } | 349 } |
| 351 FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 350 FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
| 352 m_pProperties->m_pThemeProvider = pThemeProvider; | 351 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 353 return FWL_Error::Succeeded; | 352 return FWL_Error::Succeeded; |
| 354 } | 353 } |
| 355 | 354 |
| 356 IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { | 355 IFWL_WidgetDelegate* IFWL_Widget::GetCurrentDelegate() { |
| 357 if (!m_pCurDelegate) { | 356 if (!m_pCurDelegate) |
| 358 m_pCurDelegate = m_pDelegate; | 357 m_pCurDelegate = m_pDelegate; |
| 359 } | 358 return m_pCurDelegate; |
| 360 if (!pDelegate) { | 359 } |
| 361 return m_pCurDelegate; | 360 |
| 362 } | 361 void IFWL_Widget::SetCurrentDelegate(IFWL_WidgetDelegate* pDelegate) { |
| 363 IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate; | |
| 364 m_pCurDelegate = pDelegate; | 362 m_pCurDelegate = pDelegate; |
| 365 return pOldDelegate; | |
| 366 } | 363 } |
| 367 | 364 |
| 368 const IFWL_App* IFWL_Widget::GetOwnerApp() const { | 365 const IFWL_App* IFWL_Widget::GetOwnerApp() const { |
| 369 return m_pOwnerApp; | 366 return m_pOwnerApp; |
| 370 } | 367 } |
| 371 | 368 |
| 372 uint32_t IFWL_Widget::GetEventKey() const { | 369 uint32_t IFWL_Widget::GetEventKey() const { |
| 373 return m_nEventKey; | 370 return m_nEventKey; |
| 374 } | 371 } |
| 375 | 372 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 pEvent->m_pSrcTarget = this; | 717 pEvent->m_pSrcTarget = this; |
| 721 pEvent->m_dwCmd = pNote->m_dwCmd; | 718 pEvent->m_dwCmd = pNote->m_dwCmd; |
| 722 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; | 719 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; |
| 723 pEvent->m_dwFlags = pNote->m_dwFlags; | 720 pEvent->m_dwFlags = pNote->m_dwFlags; |
| 724 DispatchEvent(pEvent); | 721 DispatchEvent(pEvent); |
| 725 pEvent->Release(); | 722 pEvent->Release(); |
| 726 } | 723 } |
| 727 | 724 |
| 728 void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { | 725 void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { |
| 729 if (m_pOuter) { | 726 if (m_pOuter) { |
| 730 IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(nullptr); | 727 m_pOuter->GetCurrentDelegate()->OnProcessEvent(pEvent); |
| 731 pDelegate->OnProcessEvent(pEvent); | |
| 732 return; | 728 return; |
| 733 } | 729 } |
| 734 const IFWL_App* pApp = GetOwnerApp(); | 730 const IFWL_App* pApp = GetOwnerApp(); |
| 735 if (!pApp) | 731 if (!pApp) |
| 736 return; | 732 return; |
| 737 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 733 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
| 738 if (!pNoteDriver) | 734 if (!pNoteDriver) |
| 739 return; | 735 return; |
| 740 pNoteDriver->SendEvent(pEvent); | 736 pNoteDriver->SendEvent(pEvent); |
| 741 } | 737 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 } | 912 } |
| 917 } | 913 } |
| 918 | 914 |
| 919 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} | 915 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} |
| 920 | 916 |
| 921 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 917 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 922 const CFX_Matrix* pMatrix) { | 918 const CFX_Matrix* pMatrix) { |
| 923 CFWL_EvtDraw evt; | 919 CFWL_EvtDraw evt; |
| 924 evt.m_pGraphics = pGraphics; | 920 evt.m_pGraphics = pGraphics; |
| 925 } | 921 } |
| OLD | NEW |