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/fwl_widgetimp.h" | 7 #include "xfa/fwl/core/fwl_widgetimp.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return static_cast<CFWL_WidgetImp*>(GetImpl()) | 130 return static_cast<CFWL_WidgetImp*>(GetImpl()) |
131 ->SetThemeProvider(pThemeProvider); | 131 ->SetThemeProvider(pThemeProvider); |
132 } | 132 } |
133 FWL_ERR IFWL_Widget::SetDataProvider(IFWL_DataProvider* pDataProvider) { | 133 FWL_ERR IFWL_Widget::SetDataProvider(IFWL_DataProvider* pDataProvider) { |
134 return static_cast<CFWL_WidgetImp*>(GetImpl()) | 134 return static_cast<CFWL_WidgetImp*>(GetImpl()) |
135 ->SetDataProvider(pDataProvider); | 135 ->SetDataProvider(pDataProvider); |
136 } | 136 } |
137 IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { | 137 IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { |
138 return static_cast<CFWL_WidgetImp*>(GetImpl())->SetDelegate(pDelegate); | 138 return static_cast<CFWL_WidgetImp*>(GetImpl())->SetDelegate(pDelegate); |
139 } | 139 } |
140 IFWL_NoteThread* IFWL_Widget::GetOwnerThread() const { | 140 IFWL_Thread* IFWL_Widget::GetOwnerThread() const { |
141 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerThread(); | 141 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerThread(); |
142 } | 142 } |
143 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { | 143 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { |
144 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent); | 144 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent); |
145 } | 145 } |
146 FWL_ERR CFWL_WidgetImp::Initialize() { | 146 FWL_ERR CFWL_WidgetImp::Initialize() { |
147 IFWL_App* pApp = FWL_GetApp(); | 147 IFWL_App* pApp = FWL_GetApp(); |
148 if (!pApp) | 148 if (!pApp) |
149 return FWL_ERR_Indefinite; | 149 return FWL_ERR_Indefinite; |
150 IFWL_AdapterNative* pAdapter = pApp->GetAdapterNative(); | 150 IFWL_AdapterNative* pAdapter = pApp->GetAdapterNative(); |
151 if (!pAdapter) | 151 if (!pAdapter) |
152 return FWL_ERR_Indefinite; | 152 return FWL_ERR_Indefinite; |
153 IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr(); | 153 IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr(); |
154 if (!pAdapterThread) | 154 if (!pAdapterThread) |
155 return FWL_ERR_Indefinite; | 155 return FWL_ERR_Indefinite; |
156 SetOwnerThread(static_cast<CFWL_NoteThreadImp*>( | 156 SetOwnerThread(static_cast<CFWL_ThreadImp*>( |
157 pAdapterThread->GetCurrentThread()->GetImpl())); | 157 pAdapterThread->GetCurrentThread()->GetImpl())); |
158 IFWL_Widget* pParent = m_pProperties->m_pParent; | 158 IFWL_Widget* pParent = m_pProperties->m_pParent; |
159 m_pWidgetMgr->InsertWidget(pParent, m_pInterface); | 159 m_pWidgetMgr->InsertWidget(pParent, m_pInterface); |
160 if (!IsChild()) { | 160 if (!IsChild()) { |
161 { | 161 { |
162 IFWL_Widget* pOwner = m_pProperties->m_pOwner; | 162 IFWL_Widget* pOwner = m_pProperties->m_pOwner; |
163 if (pOwner) { | 163 if (pOwner) { |
164 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); | 164 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); |
165 } | 165 } |
166 } | 166 } |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 if (!m_pCurDelegate) { | 501 if (!m_pCurDelegate) { |
502 m_pCurDelegate = m_pDelegate; | 502 m_pCurDelegate = m_pDelegate; |
503 } | 503 } |
504 if (!pDelegate) { | 504 if (!pDelegate) { |
505 return m_pCurDelegate; | 505 return m_pCurDelegate; |
506 } | 506 } |
507 IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate; | 507 IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate; |
508 m_pCurDelegate = pDelegate; | 508 m_pCurDelegate = pDelegate; |
509 return pOldDelegate; | 509 return pOldDelegate; |
510 } | 510 } |
511 IFWL_NoteThread* CFWL_WidgetImp::GetOwnerThread() const { | 511 IFWL_Thread* CFWL_WidgetImp::GetOwnerThread() const { |
512 return static_cast<IFWL_NoteThread*>(m_pOwnerThread->GetInterface()); | 512 return static_cast<IFWL_Thread*>(m_pOwnerThread->GetInterface()); |
513 } | 513 } |
514 FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread) { | 514 FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_ThreadImp* pOwnerThread) { |
515 m_pOwnerThread = pOwnerThread; | 515 m_pOwnerThread = pOwnerThread; |
516 return FWL_ERR_Succeeded; | 516 return FWL_ERR_Succeeded; |
517 } | 517 } |
518 IFWL_Widget* CFWL_WidgetImp::GetInterface() const { | 518 IFWL_Widget* CFWL_WidgetImp::GetInterface() const { |
519 return m_pInterface; | 519 return m_pInterface; |
520 } | 520 } |
521 void CFWL_WidgetImp::SetInterface(IFWL_Widget* pInterface) { | 521 void CFWL_WidgetImp::SetInterface(IFWL_Widget* pInterface) { |
522 m_pInterface = pInterface; | 522 m_pInterface = pInterface; |
523 } | 523 } |
524 CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, | 524 CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 CFWL_ThemeText calPart; | 686 CFWL_ThemeText calPart; |
687 calPart.m_pWidget = m_pInterface; | 687 calPart.m_pWidget = m_pInterface; |
688 calPart.m_wsText = wsText; | 688 calPart.m_wsText = wsText; |
689 calPart.m_dwTTOStyles = dwTTOStyles; | 689 calPart.m_dwTTOStyles = dwTTOStyles; |
690 calPart.m_iTTOAlign = iTTOAlign; | 690 calPart.m_iTTOAlign = iTTOAlign; |
691 pTheme->CalcTextRect(&calPart, rect); | 691 pTheme->CalcTextRect(&calPart, rect); |
692 } | 692 } |
693 void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) { | 693 void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) { |
694 if (m_pWidgetMgr->IsFormDisabled()) | 694 if (m_pWidgetMgr->IsFormDisabled()) |
695 return; | 695 return; |
696 IFWL_NoteThread* pThread = GetOwnerThread(); | 696 IFWL_Thread* pThread = GetOwnerThread(); |
697 if (!pThread) | 697 if (!pThread) |
698 return; | 698 return; |
699 CFWL_NoteDriver* pDriver = | 699 CFWL_NoteDriver* pDriver = |
700 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); | 700 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); |
701 if (!pDriver) | 701 if (!pDriver) |
702 return; | 702 return; |
703 IFWL_Widget* curFocus = pDriver->GetFocus(); | 703 IFWL_Widget* curFocus = pDriver->GetFocus(); |
704 if (bFocus && curFocus != m_pInterface) { | 704 if (bFocus && curFocus != m_pInterface) { |
705 pDriver->SetFocus(m_pInterface); | 705 pDriver->SetFocus(m_pInterface); |
706 } else if (!bFocus && curFocus == m_pInterface) { | 706 } else if (!bFocus && curFocus == m_pInterface) { |
707 pDriver->SetFocus(NULL); | 707 pDriver->SetFocus(NULL); |
708 } | 708 } |
709 } | 709 } |
710 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { | 710 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { |
711 IFWL_NoteThread* pThread = GetOwnerThread(); | 711 IFWL_Thread* pThread = GetOwnerThread(); |
712 if (!pThread) | 712 if (!pThread) |
713 return; | 713 return; |
714 CFWL_NoteDriver* pDriver = | 714 CFWL_NoteDriver* pDriver = |
715 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); | 715 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); |
716 pDriver->SetGrab(m_pInterface, bSet); | 716 pDriver->SetGrab(m_pInterface, bSet); |
717 } | 717 } |
718 FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight, | 718 FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight, |
719 FX_FLOAT fMaxHeight, | 719 FX_FLOAT fMaxHeight, |
720 const CFX_RectF& rtAnchor, | 720 const CFX_RectF& rtAnchor, |
721 CFX_RectF& rtPopup) { | 721 CFX_RectF& rtPopup) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 rtPopup.height); | 817 rtPopup.height); |
818 } | 818 } |
819 rtPopup.Offset(fx, fy); | 819 rtPopup.Offset(fx, fy); |
820 return TRUE; | 820 return TRUE; |
821 } | 821 } |
822 FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) { | 822 FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) { |
823 return FALSE; | 823 return FALSE; |
824 } | 824 } |
825 void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource, | 825 void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource, |
826 uint32_t dwFilter) { | 826 uint32_t dwFilter) { |
827 IFWL_NoteThread* pThread = GetOwnerThread(); | 827 IFWL_Thread* pThread = GetOwnerThread(); |
828 if (!pThread) | 828 if (!pThread) |
829 return; | 829 return; |
830 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); | 830 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); |
831 if (!pNoteDriver) | 831 if (!pNoteDriver) |
832 return; | 832 return; |
833 pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter); | 833 pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter); |
834 } | 834 } |
835 void CFWL_WidgetImp::UnregisterEventTarget() { | 835 void CFWL_WidgetImp::UnregisterEventTarget() { |
836 IFWL_NoteThread* pThread = GetOwnerThread(); | 836 IFWL_Thread* pThread = GetOwnerThread(); |
837 if (!pThread) | 837 if (!pThread) |
838 return; | 838 return; |
839 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); | 839 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); |
840 if (!pNoteDriver) | 840 if (!pNoteDriver) |
841 return; | 841 return; |
842 pNoteDriver->UnregisterEventTarget(m_pInterface); | 842 pNoteDriver->UnregisterEventTarget(m_pInterface); |
843 } | 843 } |
844 void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) { | 844 void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) { |
845 if (!pNote) | 845 if (!pNote) |
846 return; | 846 return; |
847 CFWL_EvtKey* pEvent = new CFWL_EvtKey; | 847 CFWL_EvtKey* pEvent = new CFWL_EvtKey; |
848 pEvent->m_pSrcTarget = m_pInterface; | 848 pEvent->m_pSrcTarget = m_pInterface; |
849 pEvent->m_dwCmd = pNote->m_dwCmd; | 849 pEvent->m_dwCmd = pNote->m_dwCmd; |
850 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; | 850 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; |
851 pEvent->m_dwFlags = pNote->m_dwFlags; | 851 pEvent->m_dwFlags = pNote->m_dwFlags; |
852 DispatchEvent(pEvent); | 852 DispatchEvent(pEvent); |
853 pEvent->Release(); | 853 pEvent->Release(); |
854 } | 854 } |
855 void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { | 855 void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { |
856 if (m_pOuter) { | 856 if (m_pOuter) { |
857 IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(NULL); | 857 IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(NULL); |
858 pDelegate->OnProcessEvent(pEvent); | 858 pDelegate->OnProcessEvent(pEvent); |
859 return; | 859 return; |
860 } | 860 } |
861 IFWL_NoteThread* pThread = GetOwnerThread(); | 861 IFWL_Thread* pThread = GetOwnerThread(); |
862 if (!pThread) | 862 if (!pThread) |
863 return; | 863 return; |
864 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); | 864 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); |
865 if (!pNoteDriver) | 865 if (!pNoteDriver) |
866 return; | 866 return; |
867 pNoteDriver->SendNote(pEvent); | 867 pNoteDriver->SendNote(pEvent); |
868 } | 868 } |
869 void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) { | 869 void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) { |
870 if (pRect) { | 870 if (pRect) { |
871 m_pWidgetMgr->RepaintWidget(m_pInterface, pRect); | 871 m_pWidgetMgr->RepaintWidget(m_pInterface, pRect); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 param.m_pWidget = m_pInterface; | 918 param.m_pWidget = m_pInterface; |
919 param.m_iPart = iPartEdge; | 919 param.m_iPart = iPartEdge; |
920 param.m_pGraphics = pGraphics; | 920 param.m_pGraphics = pGraphics; |
921 if (pMatrix) { | 921 if (pMatrix) { |
922 param.m_matrix.Concat(*pMatrix, TRUE); | 922 param.m_matrix.Concat(*pMatrix, TRUE); |
923 } | 923 } |
924 param.m_rtPart = rtEdge; | 924 param.m_rtPart = rtEdge; |
925 pTheme->DrawBackground(¶m); | 925 pTheme->DrawBackground(¶m); |
926 } | 926 } |
927 void CFWL_WidgetImp::NotifyDriver() { | 927 void CFWL_WidgetImp::NotifyDriver() { |
928 IFWL_NoteThread* pThread = GetOwnerThread(); | 928 IFWL_Thread* pThread = GetOwnerThread(); |
929 if (!pThread) | 929 if (!pThread) |
930 return; | 930 return; |
931 CFWL_NoteDriver* pDriver = | 931 CFWL_NoteDriver* pDriver = |
932 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); | 932 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); |
933 if (!pDriver) | 933 if (!pDriver) |
934 return; | 934 return; |
935 pDriver->NotifyTargetDestroy(m_pInterface); | 935 pDriver->NotifyTargetDestroy(m_pInterface); |
936 } | 936 } |
937 CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) { | 937 CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) { |
938 if (pParent == GetInterface()) | 938 if (pParent == GetInterface()) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 IFWL_Custom* pCustom = new IFWL_Custom; | 1078 IFWL_Custom* pCustom = new IFWL_Custom; |
1079 CFWL_CustomImp* pCustomImpl = new CFWL_CustomImp(properties, pOuter); | 1079 CFWL_CustomImp* pCustomImpl = new CFWL_CustomImp(properties, pOuter); |
1080 pCustom->SetImpl(pCustomImpl); | 1080 pCustom->SetImpl(pCustomImpl); |
1081 pCustomImpl->SetInterface(pCustom); | 1081 pCustomImpl->SetInterface(pCustom); |
1082 return pCustom; | 1082 return pCustom; |
1083 } | 1083 } |
1084 IFWL_Custom::IFWL_Custom() {} | 1084 IFWL_Custom::IFWL_Custom() {} |
1085 FWL_ERR IFWL_Custom::SetProxy(IFWL_Proxy* pProxy) { | 1085 FWL_ERR IFWL_Custom::SetProxy(IFWL_Proxy* pProxy) { |
1086 return static_cast<CFWL_CustomImp*>(GetImpl())->SetProxy(pProxy); | 1086 return static_cast<CFWL_CustomImp*>(GetImpl())->SetProxy(pProxy); |
1087 } | 1087 } |
OLD | NEW |