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 |
11 #include "xfa/fde/tto/fde_textout.h" | 11 #include "xfa/fde/tto/fde_textout.h" |
12 #include "xfa/fwl/basewidget/ifwl_combobox.h" | 12 #include "xfa/fwl/basewidget/ifwl_combobox.h" |
13 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" | 13 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" |
14 #include "xfa/fwl/core/cfwl_message.h" | 14 #include "xfa/fwl/core/cfwl_message.h" |
15 #include "xfa/fwl/core/cfwl_themebackground.h" | 15 #include "xfa/fwl/core/cfwl_themebackground.h" |
16 #include "xfa/fwl/core/cfwl_themepart.h" | 16 #include "xfa/fwl/core/cfwl_themepart.h" |
17 #include "xfa/fwl/core/cfwl_themetext.h" | 17 #include "xfa/fwl/core/cfwl_themetext.h" |
18 #include "xfa/fwl/core/fwl_appimp.h" | 18 #include "xfa/fwl/core/fwl_appimp.h" |
19 #include "xfa/fwl/core/fwl_noteimp.h" | 19 #include "xfa/fwl/core/fwl_noteimp.h" |
20 #include "xfa/fwl/core/fwl_targetimp.h" | 20 #include "xfa/fwl/core/fwl_targetimp.h" |
21 #include "xfa/fwl/core/fwl_threadimp.h" | 21 #include "xfa/fwl/core/fwl_threadimp.h" |
22 #include "xfa/fwl/core/fwl_widgetmgrimp.h" | 22 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
23 #include "xfa/fwl/core/ifwl_adapternative.h" | 23 #include "xfa/fwl/core/ifwl_adapternative.h" |
24 #include "xfa/fwl/core/ifwl_adapterthreadmgr.h" | 24 #include "xfa/fwl/core/ifwl_adapterthreadmgr.h" |
25 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" | 25 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" |
26 #include "xfa/fwl/core/ifwl_app.h" | 26 #include "xfa/fwl/core/ifwl_app.h" |
27 #include "xfa/fwl/core/ifwl_content.h" | |
28 #include "xfa/fwl/core/ifwl_custom.h" | |
29 #include "xfa/fwl/core/ifwl_form.h" | 27 #include "xfa/fwl/core/ifwl_form.h" |
30 #include "xfa/fwl/core/ifwl_proxy.h" | |
31 #include "xfa/fwl/core/ifwl_themeprovider.h" | 28 #include "xfa/fwl/core/ifwl_themeprovider.h" |
32 | 29 |
33 #define FWL_CLASSHASH_Menu 3957949655 | 30 #define FWL_CLASSHASH_Menu 3957949655 |
34 #define FWL_STYLEEXT_MNU_Vert (1L << 0) | 31 #define FWL_STYLEEXT_MNU_Vert (1L << 0) |
35 | 32 |
36 FWL_ERR IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 33 FWL_ERR IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
37 return static_cast<CFWL_WidgetImp*>(GetImpl()) | 34 return static_cast<CFWL_WidgetImp*>(GetImpl()) |
38 ->GetWidgetRect(rect, bAutoSize); | 35 ->GetWidgetRect(rect, bAutoSize); |
39 } | 36 } |
40 FWL_ERR IFWL_Widget::GetGlobalRect(CFX_RectF& rect) { | 37 FWL_ERR IFWL_Widget::GetGlobalRect(CFX_RectF& rect) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 if (pOwner) { | 160 if (pOwner) { |
164 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); | 161 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); |
165 } | 162 } |
166 } | 163 } |
167 m_pWidgetMgr->CreateWidget_Native(m_pInterface); | 164 m_pWidgetMgr->CreateWidget_Native(m_pInterface); |
168 } | 165 } |
169 return FWL_ERR_Succeeded; | 166 return FWL_ERR_Succeeded; |
170 } | 167 } |
171 FWL_ERR CFWL_WidgetImp::Finalize() { | 168 FWL_ERR CFWL_WidgetImp::Finalize() { |
172 NotifyDriver(); | 169 NotifyDriver(); |
173 IFWL_Form* pForm = static_cast<IFWL_Form*>( | 170 if (!IsChild()) |
174 FWL_GetWidgetMgr()->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm)); | |
175 if (pForm && pForm != m_pInterface) { | |
176 IFWL_Content* pContent = pForm->GetContent(); | |
177 if (pContent) { | |
178 pContent->RemoveWidget(m_pInterface); | |
179 } | |
180 } | |
181 if (!IsChild()) { | |
182 m_pWidgetMgr->DestroyWidget_Native(m_pInterface); | 171 m_pWidgetMgr->DestroyWidget_Native(m_pInterface); |
183 } | 172 |
184 m_pWidgetMgr->RemoveWidget(m_pInterface); | 173 m_pWidgetMgr->RemoveWidget(m_pInterface); |
185 return FWL_ERR_Succeeded; | 174 return FWL_ERR_Succeeded; |
186 } | 175 } |
187 FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 176 FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
188 if (bAutoSize) { | 177 if (bAutoSize) { |
189 if (HasEdge()) { | 178 if (HasEdge()) { |
190 FX_FLOAT fEdge = GetEdgeWidth(); | 179 FX_FLOAT fEdge = GetEdgeWidth(); |
191 rect.Inflate(fEdge, fEdge); | 180 rect.Inflate(fEdge, fEdge); |
192 } | 181 } |
193 if (HasBorder()) { | 182 if (HasBorder()) { |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 } | 1022 } |
1034 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1023 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
1035 return FWL_ERR_Succeeded; | 1024 return FWL_ERR_Succeeded; |
1036 } | 1025 } |
1037 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1026 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
1038 const CFX_Matrix* pMatrix) { | 1027 const CFX_Matrix* pMatrix) { |
1039 CFWL_EvtDraw evt; | 1028 CFWL_EvtDraw evt; |
1040 evt.m_pGraphics = pGraphics; | 1029 evt.m_pGraphics = pGraphics; |
1041 return FWL_ERR_Succeeded; | 1030 return FWL_ERR_Succeeded; |
1042 } | 1031 } |
1043 class CFWL_CustomImp : public CFWL_WidgetImp { | |
1044 public: | |
1045 CFWL_CustomImp(const CFWL_WidgetImpProperties& properties, | |
1046 IFWL_Widget* pOuter); | |
1047 virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); | |
1048 virtual FWL_ERR Update(); | |
1049 virtual FWL_ERR SetProxy(IFWL_Proxy* pProxy); | |
1050 | |
1051 protected: | |
1052 IFWL_Proxy* m_pProxy; | |
1053 }; | |
1054 CFWL_CustomImp::CFWL_CustomImp(const CFWL_WidgetImpProperties& properties, | |
1055 IFWL_Widget* pOuter) | |
1056 : CFWL_WidgetImp(properties, pOuter), m_pProxy(NULL) {} | |
1057 FWL_ERR CFWL_CustomImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | |
1058 if (m_pProxy && | |
1059 (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) { | |
1060 return FWL_ERR_Succeeded; | |
1061 } | |
1062 return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize); | |
1063 } | |
1064 FWL_ERR CFWL_CustomImp::Update() { | |
1065 if (m_pProxy) { | |
1066 return m_pProxy->Update(); | |
1067 } | |
1068 return CFWL_WidgetImp::Update(); | |
1069 } | |
1070 FWL_ERR CFWL_CustomImp::SetProxy(IFWL_Proxy* pProxy) { | |
1071 m_pProxy = pProxy; | |
1072 return FWL_ERR_Succeeded; | |
1073 } | |
1074 | |
1075 // static | |
1076 IFWL_Custom* IFWL_Custom::Create(const CFWL_WidgetImpProperties& properties, | |
1077 IFWL_Widget* pOuter) { | |
1078 IFWL_Custom* pCustom = new IFWL_Custom; | |
1079 CFWL_CustomImp* pCustomImpl = new CFWL_CustomImp(properties, pOuter); | |
1080 pCustom->SetImpl(pCustomImpl); | |
1081 pCustomImpl->SetInterface(pCustom); | |
1082 return pCustom; | |
1083 } | |
1084 IFWL_Custom::IFWL_Custom() {} | |
1085 FWL_ERR IFWL_Custom::SetProxy(IFWL_Proxy* pProxy) { | |
1086 return static_cast<CFWL_CustomImp*>(GetImpl())->SetProxy(pProxy); | |
1087 } | |
OLD | NEW |