Home | History | Annotate | Download | only in core
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #include "xfa/src/foxitlib.h"
      8 #include "xfa/src/fwl/src/core/include/fwl_targetimp.h"
      9 #include "xfa/src/fwl/src/core/include/fwl_threadimp.h"
     10 #include "xfa/src/fwl/src/core/include/fwl_noteimp.h"
     11 #include "xfa/src/fwl/src/core/include/fwl_widgetimp.h"
     12 #include "xfa/src/fwl/src/core/include/fwl_contentimp.h"
     13 #include "xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h"
     14 FWL_ERR IFWL_Content::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
     15   return static_cast<CFWL_ContentImp*>(GetImpl())->InsertWidget(pChild, nIndex);
     16 }
     17 FWL_ERR IFWL_Content::RemoveWidget(IFWL_Widget* pWidget) {
     18   return static_cast<CFWL_ContentImp*>(GetImpl())->RemoveWidget(pWidget);
     19 }
     20 FWL_ERR IFWL_Content::RemoveAllWidgets() {
     21   return static_cast<CFWL_ContentImp*>(GetImpl())->RemoveAllWidgets();
     22 }
     23 FWL_ERR IFWL_Content::GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
     24   return static_cast<CFWL_ContentImp*>(GetImpl())->GetMinSize(fWidth, fHeight);
     25 }
     26 FWL_ERR IFWL_Content::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
     27   return static_cast<CFWL_ContentImp*>(GetImpl())->SetMinSize(fWidth, fHeight);
     28 }
     29 FWL_ERR IFWL_Content::GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
     30   return static_cast<CFWL_ContentImp*>(GetImpl())->GetMaxSize(fWidth, fHeight);
     31 }
     32 FWL_ERR IFWL_Content::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
     33   return static_cast<CFWL_ContentImp*>(GetImpl())->SetMaxSize(fWidth, fHeight);
     34 }
     35 IFWL_Content::IFWL_Content() {
     36 }
     37 CFWL_ContentImp::CFWL_ContentImp(const CFWL_WidgetImpProperties& properties,
     38                                  IFWL_Widget* pOuter)
     39     : CFWL_WidgetImp(properties, pOuter),
     40       m_fWidthMin(0),
     41       m_fWidthMax(10000),
     42       m_fHeightMin(0),
     43       m_fHeightMax(10000) {}
     44 CFWL_ContentImp::~CFWL_ContentImp() {}
     45 FWL_ERR CFWL_ContentImp::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
     46   if (!pChild)
     47     return FWL_ERR_Indefinite;
     48   pChild->SetParent(m_pInterface);
     49   if (nIndex == -1) {
     50     return FWL_ERR_Succeeded;
     51   }
     52   CFWL_WidgetMgr* pMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
     53   if (!pMgr)
     54     return FWL_ERR_Indefinite;
     55   pMgr->SetWidgetIndex(pChild, nIndex);
     56   return FWL_ERR_Succeeded;
     57 }
     58 FWL_ERR CFWL_ContentImp::RemoveWidget(IFWL_Widget* pWidget) {
     59   if (!pWidget)
     60     return FWL_ERR_Indefinite;
     61   pWidget->SetParent(NULL);
     62   return FWL_ERR_Succeeded;
     63 }
     64 FWL_ERR CFWL_ContentImp::RemoveAllWidgets() {
     65   CFWL_WidgetMgr* pMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
     66   if (!pMgr)
     67     return FWL_ERR_Indefinite;
     68   while (IFWL_Widget* widget =
     69              pMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild)) {
     70     pMgr->SetParent(NULL, widget);
     71   }
     72   return FWL_ERR_Succeeded;
     73 }
     74 FWL_ERR CFWL_ContentImp::GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
     75   fWidth = m_fWidthMin;
     76   fHeight = m_fHeightMin;
     77   return FWL_ERR_Succeeded;
     78 }
     79 FWL_ERR CFWL_ContentImp::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
     80   m_fWidthMin = fWidth;
     81   m_fHeightMin = fHeight;
     82   return FWL_ERR_Succeeded;
     83 }
     84 FWL_ERR CFWL_ContentImp::GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
     85   fWidth = m_fWidthMax;
     86   fHeight = m_fHeightMax;
     87   return FWL_ERR_Succeeded;
     88 }
     89 FWL_ERR CFWL_ContentImp::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
     90   m_fWidthMax = fWidth;
     91   m_fHeightMax = fHeight;
     92   return FWL_ERR_Succeeded;
     93 }
     94