Home | History | Annotate | Download | only in fxfa
      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 #ifndef XFA_FXFA_FXFA_WIDGET_H_
      8 #define XFA_FXFA_FXFA_WIDGET_H_
      9 
     10 #include <memory>
     11 
     12 #include "core/fxcrt/cfx_retain_ptr.h"
     13 #include "core/fxcrt/fx_coordinates.h"
     14 #include "core/fxge/fx_dib.h"
     15 #include "xfa/fxfa/parser/cxfa_box.h"
     16 #include "xfa/fxfa/parser/cxfa_event.h"
     17 #include "xfa/fxfa/parser/cxfa_image.h"
     18 #include "xfa/fxfa/parser/cxfa_margin.h"
     19 #include "xfa/fxfa/parser/cxfa_script.h"
     20 #include "xfa/fxfa/parser/cxfa_value.h"
     21 #include "xfa/fxfa/parser/cxfa_widgetdata.h"
     22 
     23 class CFGAS_GEFont;
     24 class CXFA_EventParam;
     25 class CXFA_FFApp;
     26 class CXFA_FFDoc;
     27 class CXFA_FFDocView;
     28 class CXFA_FFWidget;
     29 class CXFA_Node;
     30 class CXFA_TextLayout;
     31 class CXFA_WidgetLayoutData;
     32 class IXFA_AppProvider;
     33 
     34 class CXFA_WidgetAcc : public CXFA_WidgetData {
     35  public:
     36   CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode);
     37   ~CXFA_WidgetAcc();
     38 
     39   bool GetName(CFX_WideString& wsName, int32_t iNameType = 0);
     40   bool ProcessValueChanged();
     41   void ResetData();
     42 
     43   void SetImageEdit(const CFX_WideString& wsContentType,
     44                     const CFX_WideString& wsHref,
     45                     const CFX_WideString& wsData);
     46 
     47   CXFA_WidgetAcc* GetExclGroup();
     48   CXFA_FFDocView* GetDocView();
     49   CXFA_FFDoc* GetDoc();
     50   CXFA_FFApp* GetApp();
     51   IXFA_AppProvider* GetAppProvider();
     52 
     53   int32_t ProcessEvent(int32_t iActivity, CXFA_EventParam* pEventParam);
     54   int32_t ProcessEvent(CXFA_Event& event, CXFA_EventParam* pEventParam);
     55   int32_t ProcessCalculate();
     56   int32_t ProcessValidate(int32_t iFlags = 0);
     57   int32_t ExecuteScript(CXFA_Script script,
     58                         CXFA_EventParam* pEventParam,
     59                         CFXJSE_Value** pRetValue = nullptr);
     60 
     61   CXFA_FFWidget* GetNextWidget(CXFA_FFWidget* pWidget);
     62   void StartWidgetLayout(FX_FLOAT& fCalcWidth, FX_FLOAT& fCalcHeight);
     63   bool FindSplitPos(int32_t iBlockIndex, FX_FLOAT& fCalcHeight);
     64   bool LoadCaption();
     65   void LoadText();
     66   bool LoadImageImage();
     67   bool LoadImageEditImage();
     68   void GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi);
     69   void GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi);
     70   CXFA_TextLayout* GetCaptionTextLayout();
     71   CXFA_TextLayout* GetTextLayout();
     72   CFX_DIBitmap* GetImageImage();
     73   CFX_DIBitmap* GetImageEditImage();
     74   void SetImageImage(CFX_DIBitmap* newImage);
     75   void SetImageEditImage(CFX_DIBitmap* newImage);
     76   void UpdateUIDisplay(CXFA_FFWidget* pExcept = nullptr);
     77 
     78   CXFA_Node* GetDatasets();
     79   CFX_RetainPtr<CFGAS_GEFont> GetFDEFont();
     80   FX_FLOAT GetFontSize();
     81   FX_ARGB GetTextColor();
     82   FX_FLOAT GetLineHeight();
     83   CXFA_WidgetLayoutData* GetWidgetLayoutData();
     84 
     85  protected:
     86   void ProcessScriptTestValidate(CXFA_Validate validate,
     87                                  int32_t iRet,
     88                                  CFXJSE_Value* pRetValue,
     89                                  bool bVersionFlag);
     90   int32_t ProcessFormatTestValidate(CXFA_Validate validate, bool bVersionFlag);
     91   int32_t ProcessNullTestValidate(CXFA_Validate validate,
     92                                   int32_t iFlags,
     93                                   bool bVersionFlag);
     94   CFX_WideString GetValidateCaptionName(bool bVersionFlag);
     95   CFX_WideString GetValidateMessage(bool bError, bool bVersionFlag);
     96   void CalcCaptionSize(CFX_SizeF& szCap);
     97   bool CalculateFieldAutoSize(CFX_SizeF& size);
     98   bool CalculateWidgetAutoSize(CFX_SizeF& size);
     99   bool CalculateTextEditAutoSize(CFX_SizeF& size);
    100   bool CalculateCheckButtonAutoSize(CFX_SizeF& size);
    101   bool CalculatePushButtonAutoSize(CFX_SizeF& size);
    102   bool CalculateImageEditAutoSize(CFX_SizeF& size);
    103   bool CalculateImageAutoSize(CFX_SizeF& size);
    104   bool CalculateTextAutoSize(CFX_SizeF& size);
    105   FX_FLOAT CalculateWidgetAutoHeight(FX_FLOAT fHeightCalc);
    106   FX_FLOAT CalculateWidgetAutoWidth(FX_FLOAT fWidthCalc);
    107   FX_FLOAT GetWidthWithoutMargin(FX_FLOAT fWidthCalc);
    108   FX_FLOAT GetHeightWithoutMargin(FX_FLOAT fHeightCalc);
    109   void CalculateTextContentSize(CFX_SizeF& size);
    110   void CalculateAccWidthAndHeight(XFA_Element eUIType,
    111                                   FX_FLOAT& fWidth,
    112                                   FX_FLOAT& fCalcHeight);
    113   void InitLayoutData();
    114   void StartTextLayout(FX_FLOAT& fCalcWidth, FX_FLOAT& fCalcHeight);
    115 
    116   CXFA_FFDocView* m_pDocView;
    117   std::unique_ptr<CXFA_WidgetLayoutData> m_pLayoutData;
    118   uint32_t m_nRecursionDepth;
    119 };
    120 
    121 #endif  // XFA_FXFA_FXFA_WIDGET_H_
    122