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 _FWL_WIDGET_LIGHT_H 8 #define _FWL_WIDGET_LIGHT_H 9 10 #include "xfa/include/fwl/core/fwl_widget.h" 11 12 class CFWL_Event; 13 class CFWL_Message; 14 class CFWL_Widget; 15 class CFWL_WidgetDelegate; 16 class CFWL_WidgetMgr; 17 18 class CFWL_WidgetProperties { 19 public: CFWL_WidgetProperties()20 CFWL_WidgetProperties() { 21 m_ctmOnParent.SetIdentity(); 22 m_rtWidget.Set(0, 0, 0, 0); 23 m_dwStyles = FWL_WGTSTYLE_Child; 24 m_dwStyleExes = 0; 25 m_dwStates = 0; 26 m_pParent = NULL; 27 m_pOwner = NULL; 28 } 29 CFWL_WidgetImpProperties MakeWidgetImpProperties( 30 IFWL_DataProvider* pDataProvider) const; 31 32 CFX_WideString m_wsWindowclass; 33 CFX_Matrix m_ctmOnParent; 34 CFX_RectF m_rtWidget; 35 FX_DWORD m_dwStyles; 36 FX_DWORD m_dwStyleExes; 37 FX_DWORD m_dwStates; 38 CFWL_Widget* m_pParent; 39 CFWL_Widget* m_pOwner; 40 }; 41 42 class CFWL_Widget { 43 public: 44 virtual ~CFWL_Widget(); 45 IFWL_Widget* GetWidget(); 46 FWL_ERR GetClassName(CFX_WideString& wsClass) const; 47 FX_DWORD GetClassID() const; 48 virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; 49 50 protected: 51 FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); 52 53 public: 54 FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); 55 FWL_ERR GetGlobalRect(CFX_RectF& rect); 56 FWL_ERR SetWidgetRect(const CFX_RectF& rect); 57 FWL_ERR GetClientRect(CFX_RectF& rtClient); 58 CFWL_Widget* GetParent(); 59 FWL_ERR SetParent(CFWL_Widget* pParent); 60 CFWL_Widget* GetOwner(); 61 FWL_ERR SetOwner(CFWL_Widget* pOwner); 62 FX_DWORD GetStyles(); 63 FWL_ERR ModifyStyles(FX_DWORD dwStylesAdded, FX_DWORD dwStylesRemoved); 64 FX_DWORD GetStylesEx(); 65 FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved); 66 FX_DWORD GetStates(); 67 FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE); 68 FWL_ERR SetPrivateData(void* module_id, 69 void* pData, 70 PD_CALLBACK_FREEDATA callback); 71 void* GetPrivateData(void* module_id); 72 FWL_ERR Update(); 73 FWL_ERR LockUpdate(); 74 FWL_ERR UnlockUpdate(); 75 FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy); 76 FWL_ERR TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy); 77 FWL_ERR TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt); 78 FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE); 79 FWL_ERR SetMatrix(const CFX_Matrix& matrix); 80 FWL_ERR DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = NULL); 81 IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate); 82 FWL_ERR Repaint(const CFX_RectF* pRect = NULL); 83 FWL_ERR SetFocus(FX_BOOL bFocus); 84 FWL_ERR SetGrab(FX_BOOL bSet); 85 CFWL_Widget(); 86 87 void RegisterEventTarget(CFWL_Widget* pEventSource = NULL, 88 FX_DWORD dwFilter = FWL_EVENT_ALL_MASK); 89 void DispatchEvent(CFWL_Event* pEvent); 90 CFX_SizeF CalcTextSize(const CFX_WideString& wsText, 91 FX_BOOL bMultiLine = FALSE, 92 int32_t iLineWidth = -1); 93 IFWL_Widget* m_pIface; 94 IFWL_WidgetDelegate* m_pDelegate; 95 CFWL_WidgetMgr* m_pWidgetMgr; 96 CFWL_WidgetProperties* m_pProperties; 97 }; 98 class CFWL_WidgetDelegate { 99 public: 100 CFWL_WidgetDelegate(); 101 virtual ~CFWL_WidgetDelegate(); 102 virtual int32_t OnProcessMessage(CFWL_Message* pMessage); 103 virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent); 104 virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics, 105 const CFX_Matrix* pMatrix = NULL); 106 }; 107 #endif 108