1 // Copyright 2014 PDFium Authors. All rights reserved.
\r
2 // Use of this source code is governed by a BSD-style license that can be
\r
3 // found in the LICENSE file.
\r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
\r
7 #include "../../../foxitlib.h"
\r
8 #include "include/fwl_targetimp.h"
\r
9 #include "include/fwl_noteimp.h"
\r
10 #include "include/fwl_widgetimp.h"
\r
11 #include "include/fwl_panelimp.h"
\r
12 IFWL_Panel* IFWL_Panel::Create()
\r
14 return new IFWL_Panel;
\r
16 FWL_ERR IFWL_Panel::Initialize(IFWL_Widget *pOuter )
\r
18 m_pData = FX_NEW CFWL_PanelImp(pOuter);
\r
19 ((CFWL_PanelImp*)m_pData)->SetInterface(this);
\r
20 return ((CFWL_PanelImp*)m_pData)->Initialize();
\r
22 FWL_ERR IFWL_Panel::Initialize(CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
\r
24 m_pData = FX_NEW CFWL_PanelImp(properties, pOuter);
\r
25 ((CFWL_PanelImp*)m_pData)->SetInterface(this);
\r
26 return ((CFWL_PanelImp*)m_pData)->Initialize();
\r
28 IFWL_Content* IFWL_Panel::GetContent()
\r
30 return ((CFWL_PanelImp*)m_pData)->GetContent();
\r
32 FWL_ERR IFWL_Panel::SetContent(IFWL_Content *pContent)
\r
34 return ((CFWL_PanelImp*)m_pData)->SetContent(pContent);
\r
36 IFWL_Panel::IFWL_Panel()
\r
40 IFWL_Panel::~IFWL_Panel()
\r
43 delete (CFWL_PanelImp*)m_pData;
\r
47 CFWL_PanelImp::CFWL_PanelImp(IFWL_Widget* pOuter )
\r
48 : CFWL_WidgetImp(pOuter)
\r
52 CFWL_PanelImp::CFWL_PanelImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
\r
53 : CFWL_WidgetImp(properties, pOuter)
\r
57 CFWL_PanelImp::~CFWL_PanelImp()
\r
60 FWL_ERR CFWL_PanelImp::GetClassName(CFX_WideString &wsClass) const
\r
62 wsClass = FWL_CLASS_Panel;
\r
63 return FWL_ERR_Succeeded;
\r
65 FX_DWORD CFWL_PanelImp::GetClassID() const
\r
67 return FWL_CLASSHASH_Panel;
\r
69 FWL_ERR CFWL_PanelImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
\r
73 m_pContent->GetWidgetRect(rect, TRUE);
\r
76 rect = m_pProperties->m_rtWidget;
\r
78 return FWL_ERR_Succeeded;
\r
80 FWL_ERR CFWL_PanelImp::Update()
\r
84 GetClientRect(rtClient);
\r
85 FWL_GRIDUNIT eWidth = FWL_GRIDUNIT_Fixed, eHeight = FWL_GRIDUNIT_Fixed;
\r
86 IFWL_WidgetMgr *pWidgetMgr = FWL_GetWidgetMgr();
\r
87 _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FWL_ERR_Indefinite);
\r
88 IFWL_Widget *pParent = pWidgetMgr->GetWidget((IFWL_Widget*)this, FWL_WGTRELATION_Parent);
\r
89 if (pParent && pParent->GetClassID() == FWL_CLASSHASH_Grid) {
\r
90 IFWL_Grid* pGrid = (IFWL_Grid*)pParent;
\r
91 pGrid->GetWidgetSize((IFWL_Widget*)this, FWL_GRIDSIZE_Width, eWidth);
\r
92 pGrid->GetWidgetSize((IFWL_Widget*)this, FWL_GRIDSIZE_Height, eHeight);
\r
94 if (eWidth != FWL_GRIDUNIT_Auto || eHeight != FWL_GRIDUNIT_Auto) {
\r
96 m_pContent->SetWidgetRect(rtClient);
\r
97 m_pContent->Update();
\r
99 return FWL_ERR_Succeeded;
\r
101 IFWL_Content* CFWL_PanelImp::GetContent()
\r
105 FWL_ERR CFWL_PanelImp::SetContent(IFWL_Content *pContent)
\r
107 _FWL_RETURN_VALUE_IF_FAIL(pContent, FWL_ERR_Indefinite);
\r
108 m_pContent = pContent;
\r
109 return pContent->SetParent(m_pInterface);
\r
111 class CFWL_CustomPanelImp : public CFWL_WidgetImp
\r
114 CFWL_CustomPanelImp(IFWL_Widget *pOuter = NULL);
\r
115 CFWL_CustomPanelImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
\r
116 virtual ~CFWL_CustomPanelImp();
\r
117 virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
\r
118 virtual FWL_ERR Update();
\r
119 virtual IFWL_Content* GetContent();
\r
120 virtual FWL_ERR SetContent(IFWL_Content *pContent);
\r
121 FWL_ERR SetProxy(IFWL_Proxy *pProxy);
\r
123 IFWL_Content *m_pContent;
\r
124 IFWL_Proxy *m_pProxy;
\r
126 CFWL_CustomPanelImp::CFWL_CustomPanelImp(IFWL_Widget* pOuter )
\r
127 : CFWL_WidgetImp(pOuter)
\r
132 CFWL_CustomPanelImp::CFWL_CustomPanelImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
\r
133 : CFWL_WidgetImp(properties, pOuter)
\r
138 CFWL_CustomPanelImp::~CFWL_CustomPanelImp()
\r
141 FWL_ERR CFWL_CustomPanelImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
\r
143 if (bAutoSize && m_pProxy && (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) {
\r
144 return FWL_ERR_Succeeded;
\r
146 return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize);
\r
148 FWL_ERR CFWL_CustomPanelImp::Update()
\r
151 return m_pProxy->Update();
\r
153 return CFWL_WidgetImp::Update();
\r
155 IFWL_Content* CFWL_CustomPanelImp::GetContent()
\r
159 FWL_ERR CFWL_CustomPanelImp::SetContent(IFWL_Content *pContent)
\r
161 _FWL_RETURN_VALUE_IF_FAIL(pContent, FWL_ERR_Indefinite);
\r
162 m_pContent = pContent;
\r
163 return pContent->SetParent(m_pInterface);
\r
165 FWL_ERR CFWL_CustomPanelImp::SetProxy(IFWL_Proxy *pProxy)
\r
168 return FWL_ERR_Succeeded;
\r
170 IFWL_CustomPanel* IFWL_CustomPanel::Create()
\r
172 return new IFWL_CustomPanel;
\r
174 FWL_ERR IFWL_CustomPanel::Initialize(IFWL_Widget *pOuter )
\r
176 m_pData = FX_NEW CFWL_CustomPanelImp(pOuter);
\r
177 ((CFWL_CustomPanelImp*)m_pData)->SetInterface(this);
\r
178 return ((CFWL_CustomPanelImp*)m_pData)->Initialize();
\r
180 FWL_ERR IFWL_CustomPanel::Initialize(CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
\r
182 m_pData = FX_NEW CFWL_CustomPanelImp(properties, pOuter);
\r
183 ((CFWL_CustomPanelImp*)m_pData)->SetInterface(this);
\r
184 return ((CFWL_CustomPanelImp*)m_pData)->Initialize();
\r
186 IFWL_Content* IFWL_CustomPanel::GetContent()
\r
188 return ((CFWL_CustomPanelImp*)m_pData)->GetContent();
\r
190 FWL_ERR IFWL_CustomPanel::SetContent(IFWL_Content *pContent)
\r
192 return ((CFWL_CustomPanelImp*)m_pData)->SetContent(pContent);
\r
194 FWL_ERR IFWL_CustomPanel::SetProxy(IFWL_Proxy *pProxy)
\r
196 return ((CFWL_CustomPanelImp*)m_pData)->SetProxy(pProxy);
\r
198 IFWL_CustomPanel::IFWL_CustomPanel()
\r
202 IFWL_CustomPanel::~IFWL_CustomPanel()
\r
205 delete (CFWL_CustomPanelImp*)m_pData;
\r