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_WIDGETIMP_H_ 8 #define FWL_WIDGETIMP_H_ 9 10 #include "xfa/include/fwl/core/fwl_widget.h" 11 #include "xfa/src/fwl/src/core/include/fwl_targetimp.h" 12 13 class CFWL_NoteTarget; 14 class CFWL_NoteThreadImp; 15 class CFWL_WidgetImpProperties; 16 class CFWL_WidgetMgr; 17 class IFWL_DataProvider; 18 class IFWL_ThemeProvider; 19 class IFWL_Widget; 20 class IFWL_WidgetDelegate; 21 22 class CFWL_WidgetImp : public CFWL_TargetImp { 23 public: 24 virtual FWL_ERR Initialize(); 25 virtual FWL_ERR Finalize(); 26 27 virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); 28 virtual FWL_ERR GetGlobalRect(CFX_RectF& rect); 29 virtual FWL_ERR SetWidgetRect(const CFX_RectF& rect); 30 virtual FWL_ERR GetClientRect(CFX_RectF& rect); 31 virtual IFWL_Widget* GetParent(); 32 virtual FWL_ERR SetParent(IFWL_Widget* pParent); 33 virtual IFWL_Widget* GetOwner(); 34 virtual FWL_ERR SetOwner(IFWL_Widget* pOwner); 35 virtual IFWL_Widget* GetOuter(); 36 virtual FX_DWORD GetStyles(); 37 virtual FWL_ERR ModifyStyles(FX_DWORD dwStylesAdded, 38 FX_DWORD dwStylesRemoved); 39 virtual FX_DWORD GetStylesEx(); 40 virtual FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded, 41 FX_DWORD dwStylesExRemoved); 42 virtual FX_DWORD GetStates(); 43 virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE); 44 virtual FWL_ERR SetPrivateData(void* module_id, 45 void* pData, 46 PD_CALLBACK_FREEDATA callback); 47 virtual void* GetPrivateData(void* module_id); 48 virtual FWL_ERR Update(); 49 virtual FWL_ERR LockUpdate(); 50 virtual FWL_ERR UnlockUpdate(); 51 virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy); 52 virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy); 53 virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt); 54 virtual FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE); 55 virtual FWL_ERR SetMatrix(const CFX_Matrix& matrix); 56 virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics, 57 const CFX_Matrix* pMatrix = NULL); 58 virtual IFWL_ThemeProvider* GetThemeProvider(); 59 virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider); 60 virtual FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider); 61 virtual IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate); 62 virtual IFWL_NoteThread* GetOwnerThread() const; 63 FWL_ERR SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread); 64 IFWL_Widget* GetInterface() const; 65 void SetInterface(IFWL_Widget* pInterface); 66 CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent); 67 68 protected: 69 CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, 70 IFWL_Widget* pOuter); 71 virtual ~CFWL_WidgetImp(); 72 FX_BOOL IsEnabled() const; 73 FX_BOOL IsVisible() const; 74 FX_BOOL IsActive() const; 75 FX_BOOL IsOverLapper() const; 76 FX_BOOL IsPopup() const; 77 FX_BOOL IsChild() const; 78 FX_BOOL IsLocked() const; 79 FX_BOOL IsOffscreen() const; 80 FX_BOOL HasBorder() const; 81 FX_BOOL HasEdge() const; 82 void GetEdgeRect(CFX_RectF& rtEdge); 83 FX_FLOAT GetBorderSize(FX_BOOL bCX = TRUE); 84 FX_FLOAT GetEdgeWidth(); 85 void GetRelativeRect(CFX_RectF& rect); 86 void* GetThemeCapacity(FX_DWORD dwCapacity); 87 IFWL_ThemeProvider* GetAvailableTheme(); 88 CFWL_WidgetImp* GetRootOuter(); 89 CFX_SizeF CalcTextSize(const CFX_WideString& wsText, 90 IFWL_ThemeProvider* pTheme, 91 FX_BOOL bMultiLine = FALSE, 92 int32_t iLineWidth = -1); 93 void CalcTextRect(const CFX_WideString& wsText, 94 IFWL_ThemeProvider* pTheme, 95 FX_DWORD dwTTOStyles, 96 int32_t iTTOAlign, 97 CFX_RectF& rect); 98 void SetFocus(FX_BOOL bFocus); 99 void SetGrab(FX_BOOL bSet); 100 FX_BOOL GetPopupPos(FX_FLOAT fMinHeight, 101 FX_FLOAT fMaxHeight, 102 const CFX_RectF& rtAnchor, 103 CFX_RectF& rtPopup); 104 FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight, 105 FX_FLOAT fMaxHeight, 106 const CFX_RectF& rtAnchor, 107 CFX_RectF& rtPopup); 108 FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight, 109 FX_FLOAT fMaxHeight, 110 const CFX_RectF& rtAnchor, 111 CFX_RectF& rtPopup); 112 FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight, 113 FX_FLOAT fMaxHeight, 114 const CFX_RectF& rtAnchor, 115 CFX_RectF& rtPopup); 116 FX_BOOL GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); 117 void RegisterEventTarget(IFWL_Widget* pEventSource = NULL, 118 FX_DWORD dwFilter = FWL_EVENT_ALL_MASK); 119 void UnregisterEventTarget(); 120 void DispatchKeyEvent(CFWL_MsgKey* pNote); 121 void DispatchEvent(CFWL_Event* pEvent); 122 void Repaint(const CFX_RectF* pRect = NULL); 123 void DrawBackground(CFX_Graphics* pGraphics, 124 int32_t iPartBk, 125 IFWL_ThemeProvider* pTheme, 126 const CFX_Matrix* pMatrix = NULL); 127 void DrawBorder(CFX_Graphics* pGraphics, 128 int32_t iPartBorder, 129 IFWL_ThemeProvider* pTheme, 130 const CFX_Matrix* pMatrix = NULL); 131 void DrawEdge(CFX_Graphics* pGraphics, 132 int32_t iPartEdge, 133 IFWL_ThemeProvider* pTheme, 134 const CFX_Matrix* pMatrix = NULL); 135 void NotifyDriver(); 136 137 FX_BOOL IsParent(IFWL_Widget* pParent); 138 CFWL_WidgetMgr* m_pWidgetMgr; 139 CFWL_NoteThreadImp* m_pOwnerThread; 140 CFWL_WidgetImpProperties* m_pProperties; 141 CFX_PrivateData* m_pPrivateData; 142 IFWL_WidgetDelegate* m_pDelegate; 143 IFWL_WidgetDelegate* m_pCurDelegate; 144 IFWL_Widget* m_pOuter; 145 IFWL_Widget* m_pInterface; 146 int32_t m_iLock; 147 friend class CFWL_WidgetImpDelegate; 148 friend void FWL_SetWidgetRect(IFWL_Widget* widget, const CFX_RectF& rect); 149 friend void FWL_SetWidgetStates(IFWL_Widget* widget, FX_DWORD dwStates); 150 friend void FWL_SetWidgetStyles(IFWL_Widget* widget, FX_DWORD dwStyles); 151 }; 152 153 class CFWL_WidgetImpDelegate : public IFWL_WidgetDelegate { 154 public: 155 CFWL_WidgetImpDelegate(); ~CFWL_WidgetImpDelegate()156 ~CFWL_WidgetImpDelegate() override {} 157 int32_t OnProcessMessage(CFWL_Message* pMessage) override; 158 FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override; 159 FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics, 160 const CFX_Matrix* pMatrix = NULL) override; 161 }; 162 163 #endif // FWL_WIDGETIMP_H_ 164