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_CXFA_FFFIELD_H_ 8 #define XFA_FXFA_CXFA_FFFIELD_H_ 9 10 #include <memory> 11 12 #include "xfa/fwl/cfwl_widget.h" 13 #include "xfa/fwl/ifwl_widgetdelegate.h" 14 #include "xfa/fxfa/cxfa_ffpageview.h" 15 #include "xfa/fxfa/cxfa_ffwidget.h" 16 17 #define XFA_MINUI_HEIGHT 4.32f 18 #define XFA_DEFAULTUI_HEIGHT 2.0f 19 20 class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate { 21 public: 22 explicit CXFA_FFField(CXFA_Node* pNode); 23 ~CXFA_FFField() override; 24 25 // CXFA_FFWidget 26 CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; 27 void RenderWidget(CXFA_Graphics* pGS, 28 const CFX_Matrix& matrix, 29 uint32_t dwStatus) override; 30 bool IsLoaded() override; 31 bool LoadWidget() override; 32 void UnloadWidget() override; 33 bool PerformLayout() override; 34 bool OnMouseEnter() override; 35 bool OnMouseExit() override; 36 bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; 37 bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; 38 bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; 39 bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; 40 bool OnMouseWheel(uint32_t dwFlags, 41 int16_t zDelta, 42 const CFX_PointF& point) override; 43 bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; 44 bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; 45 bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; 46 47 bool OnSetFocus(CXFA_FFWidget* pOldWidget) override; 48 bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; 49 bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) override; 50 bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) override; 51 bool OnChar(uint32_t dwChar, uint32_t dwFlags) override; 52 FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; 53 bool OnSetCursor(const CFX_PointF& point) override; 54 55 // IFWL_WidgetDelegate 56 void OnProcessMessage(CFWL_Message* pMessage) override; 57 void OnProcessEvent(CFWL_Event* pEvent) override; 58 void OnDrawWidget(CXFA_Graphics* pGraphics, 59 const CFX_Matrix& matrix) override; 60 61 void UpdateFWL(); 62 uint32_t UpdateUIProperty(); 63 64 protected: 65 bool PtInActiveRect(const CFX_PointF& point) override; 66 67 virtual void SetFWLRect(); 68 void SetFWLThemeProvider(); GetNormalWidget()69 CFWL_Widget* GetNormalWidget() { return m_pNormalWidget.get(); } 70 CFX_PointF FWLToClient(const CFX_PointF& point); 71 void LayoutCaption(); 72 void RenderCaption(CXFA_Graphics* pGS, CFX_Matrix* pMatrix); 73 74 int32_t CalculateOverride(); 75 int32_t CalculateWidgetAcc(CXFA_WidgetAcc* pAcc); 76 bool ProcessCommittedData(); 77 virtual bool CommitData(); 78 virtual bool IsDataChanged(); 79 void DrawHighlight(CXFA_Graphics* pGS, 80 CFX_Matrix* pMatrix, 81 uint32_t dwStatus, 82 bool bEllipse); 83 void DrawFocus(CXFA_Graphics* pGS, CFX_Matrix* pMatrix); 84 void TranslateFWLMessage(CFWL_Message* pMessage); 85 void CapPlacement(); 86 void CapTopBottomPlacement(const CXFA_Margin* margin, 87 const CFX_RectF& rtWidget, 88 XFA_AttributeEnum iCapPlacement); 89 void CapLeftRightPlacement(const CXFA_Margin* margin, 90 const CFX_RectF& rtWidget, 91 XFA_AttributeEnum iCapPlacement); 92 void SetEditScrollOffset(); 93 94 std::unique_ptr<CFWL_Widget> m_pNormalWidget; 95 CFX_RectF m_rtUI; 96 CFX_RectF m_rtCaption; 97 }; 98 99 #endif // XFA_FXFA_CXFA_FFFIELD_H_ 100