| 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_panelimp.h" | 7 #include "xfa/fwl/core/fwl_panelimp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/core/cfwl_widgetimpproperties.h" | 9 #include "xfa/fwl/core/cfwl_widgetimpproperties.h" |
| 10 #include "xfa/fwl/core/fwl_noteimp.h" | 10 #include "xfa/fwl/core/fwl_noteimp.h" |
| 11 #include "xfa/fwl/core/fwl_targetimp.h" | 11 #include "xfa/fwl/core/fwl_targetimp.h" |
| 12 #include "xfa/fwl/core/fwl_widgetimp.h" | 12 #include "xfa/fwl/core/fwl_widgetimp.h" |
| 13 #include "xfa/fwl/core/fwl_widgetmgrimp.h" | 13 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
| 14 #include "xfa/fwl/core/ifwl_content.h" | |
| 15 #include "xfa/fwl/core/ifwl_custompanel.h" | |
| 16 #include "xfa/fwl/core/ifwl_panel.h" | 14 #include "xfa/fwl/core/ifwl_panel.h" |
| 17 #include "xfa/fwl/core/ifwl_proxy.h" | |
| 18 | 15 |
| 19 // static | |
| 20 IFWL_Panel* IFWL_Panel::Create(CFWL_WidgetImpProperties& properties, | |
| 21 IFWL_Widget* pOuter) { | |
| 22 IFWL_Panel* pPanel = new IFWL_Panel; | |
| 23 CFWL_PanelImp* pPanelImpl = new CFWL_PanelImp(properties, pOuter); | |
| 24 pPanel->SetImpl(pPanelImpl); | |
| 25 pPanelImpl->SetInterface(pPanel); | |
| 26 return pPanel; | |
| 27 } | |
| 28 IFWL_Panel::IFWL_Panel() {} | 16 IFWL_Panel::IFWL_Panel() {} |
| 29 IFWL_Content* IFWL_Panel::GetContent() { | |
| 30 return static_cast<CFWL_PanelImp*>(GetImpl())->GetContent(); | |
| 31 } | |
| 32 FWL_ERR IFWL_Panel::SetContent(IFWL_Content* pContent) { | |
| 33 return static_cast<CFWL_PanelImp*>(GetImpl())->SetContent(pContent); | |
| 34 } | |
| 35 | 17 |
| 36 CFWL_PanelImp::CFWL_PanelImp(const CFWL_WidgetImpProperties& properties, | 18 CFWL_PanelImp::CFWL_PanelImp(const CFWL_WidgetImpProperties& properties, |
| 37 IFWL_Widget* pOuter) | 19 IFWL_Widget* pOuter) |
| 38 : CFWL_WidgetImp(properties, pOuter), m_pContent(nullptr) {} | 20 : CFWL_WidgetImp(properties, pOuter) {} |
| 39 CFWL_PanelImp::~CFWL_PanelImp() {} | 21 CFWL_PanelImp::~CFWL_PanelImp() {} |
| 40 FWL_ERR CFWL_PanelImp::GetClassName(CFX_WideString& wsClass) const { | 22 FWL_ERR CFWL_PanelImp::GetClassName(CFX_WideString& wsClass) const { |
| 41 wsClass = FWL_CLASS_Panel; | 23 wsClass = FWL_CLASS_Panel; |
| 42 return FWL_ERR_Succeeded; | 24 return FWL_ERR_Succeeded; |
| 43 } | 25 } |
| 44 uint32_t CFWL_PanelImp::GetClassID() const { | 26 uint32_t CFWL_PanelImp::GetClassID() const { |
| 45 return FWL_CLASSHASH_Panel; | 27 return FWL_CLASSHASH_Panel; |
| 46 } | 28 } |
| 47 FWL_ERR CFWL_PanelImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 29 FWL_ERR CFWL_PanelImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 48 if (bAutoSize) { | 30 if (!bAutoSize) |
| 49 if (m_pContent) { | |
| 50 m_pContent->GetWidgetRect(rect, TRUE); | |
| 51 } | |
| 52 } else { | |
| 53 rect = m_pProperties->m_rtWidget; | 31 rect = m_pProperties->m_rtWidget; |
| 54 } | 32 |
| 55 return FWL_ERR_Succeeded; | 33 return FWL_ERR_Succeeded; |
| 56 } | 34 } |
| 57 FWL_ERR CFWL_PanelImp::Update() { | |
| 58 if (m_pContent) { | |
| 59 CFX_RectF rtClient; | |
| 60 GetClientRect(rtClient); | |
| 61 IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); | |
| 62 if (!pWidgetMgr) | |
| 63 return FWL_ERR_Indefinite; | |
| 64 | |
| 65 m_pContent->SetWidgetRect(rtClient); | |
| 66 m_pContent->Update(); | |
| 67 } | |
| 68 return FWL_ERR_Succeeded; | |
| 69 } | |
| 70 IFWL_Content* CFWL_PanelImp::GetContent() { | |
| 71 return m_pContent; | |
| 72 } | |
| 73 FWL_ERR CFWL_PanelImp::SetContent(IFWL_Content* pContent) { | |
| 74 if (!pContent) | |
| 75 return FWL_ERR_Indefinite; | |
| 76 m_pContent = pContent; | |
| 77 return pContent->SetParent(m_pInterface); | |
| 78 } | |
| 79 class CFWL_CustomPanelImp : public CFWL_WidgetImp { | |
| 80 public: | |
| 81 CFWL_CustomPanelImp(const CFWL_WidgetImpProperties& properties, | |
| 82 IFWL_Widget* pOuter); | |
| 83 virtual ~CFWL_CustomPanelImp(); | |
| 84 virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); | |
| 85 virtual FWL_ERR Update(); | |
| 86 virtual IFWL_Content* GetContent(); | |
| 87 virtual FWL_ERR SetContent(IFWL_Content* pContent); | |
| 88 FWL_ERR SetProxy(IFWL_Proxy* pProxy); | |
| 89 | |
| 90 protected: | |
| 91 IFWL_Content* m_pContent; | |
| 92 IFWL_Proxy* m_pProxy; | |
| 93 }; | |
| 94 CFWL_CustomPanelImp::CFWL_CustomPanelImp( | |
| 95 const CFWL_WidgetImpProperties& properties, | |
| 96 IFWL_Widget* pOuter) | |
| 97 : CFWL_WidgetImp(properties, pOuter), | |
| 98 m_pContent(nullptr), | |
| 99 m_pProxy(nullptr) {} | |
| 100 CFWL_CustomPanelImp::~CFWL_CustomPanelImp() {} | |
| 101 FWL_ERR CFWL_CustomPanelImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | |
| 102 if (bAutoSize && m_pProxy && | |
| 103 (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) { | |
| 104 return FWL_ERR_Succeeded; | |
| 105 } | |
| 106 return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize); | |
| 107 } | |
| 108 FWL_ERR CFWL_CustomPanelImp::Update() { | |
| 109 if (m_pProxy) { | |
| 110 return m_pProxy->Update(); | |
| 111 } | |
| 112 return CFWL_WidgetImp::Update(); | |
| 113 } | |
| 114 IFWL_Content* CFWL_CustomPanelImp::GetContent() { | |
| 115 return m_pContent; | |
| 116 } | |
| 117 FWL_ERR CFWL_CustomPanelImp::SetContent(IFWL_Content* pContent) { | |
| 118 if (!pContent) | |
| 119 return FWL_ERR_Indefinite; | |
| 120 m_pContent = pContent; | |
| 121 return pContent->SetParent(m_pInterface); | |
| 122 } | |
| 123 FWL_ERR CFWL_CustomPanelImp::SetProxy(IFWL_Proxy* pProxy) { | |
| 124 m_pProxy = pProxy; | |
| 125 return FWL_ERR_Succeeded; | |
| 126 } | |
| 127 | |
| 128 // statuc | |
| 129 IFWL_CustomPanel* IFWL_CustomPanel::Create(CFWL_WidgetImpProperties& properties, | |
| 130 IFWL_Widget* pOuter) { | |
| 131 IFWL_CustomPanel* pCustomPanel = new IFWL_CustomPanel; | |
| 132 CFWL_CustomPanelImp* pCustomPanelImpl = | |
| 133 new CFWL_CustomPanelImp(properties, pOuter); | |
| 134 pCustomPanel->SetImpl(pCustomPanelImpl); | |
| 135 pCustomPanelImpl->SetInterface(pCustomPanel); | |
| 136 return pCustomPanel; | |
| 137 } | |
| 138 IFWL_CustomPanel::IFWL_CustomPanel() {} | |
| 139 IFWL_Content* IFWL_CustomPanel::GetContent() { | |
| 140 return static_cast<CFWL_CustomPanelImp*>(GetImpl())->GetContent(); | |
| 141 } | |
| 142 FWL_ERR IFWL_CustomPanel::SetContent(IFWL_Content* pContent) { | |
| 143 return static_cast<CFWL_CustomPanelImp*>(GetImpl())->SetContent(pContent); | |
| 144 } | |
| 145 FWL_ERR IFWL_CustomPanel::SetProxy(IFWL_Proxy* pProxy) { | |
| 146 return static_cast<CFWL_CustomPanelImp*>(GetImpl())->SetProxy(pProxy); | |
| 147 } | |
| OLD | NEW |