Index: xfa/fwl/core/cfwl_widget.h |
diff --git a/xfa/fwl/core/cfwl_widget.h b/xfa/fwl/core/cfwl_widget.h |
index abb8d549bdb9e54c578a50d730bdfa7d555cf76c..7a993e5e228bfc966c28978597f4cdb5cd9fe8b5 100644 |
--- a/xfa/fwl/core/cfwl_widget.h |
+++ b/xfa/fwl/core/cfwl_widget.h |
@@ -6,52 +6,190 @@ |
#ifndef XFA_FWL_CORE_CFWL_WIDGET_H_ |
#define XFA_FWL_CORE_CFWL_WIDGET_H_ |
- |
#include <memory> |
+#include "core/fxcrt/fx_coordinates.h" |
+#include "core/fxcrt/fx_system.h" |
#include "xfa/fwl/core/cfwl_event.h" |
-#include "xfa/fwl/core/ifwl_widget.h" |
+#include "xfa/fwl/core/cfwl_themepart.h" |
+#include "xfa/fwl/core/cfwl_widgetmgr.h" |
+#include "xfa/fwl/core/fwl_widgethit.h" |
+#include "xfa/fwl/core/ifwl_widgetdelegate.h" |
+#include "xfa/fwl/theme/cfwl_widgettp.h" |
+ |
+enum class FWL_Type { |
+ Unknown = 0, |
+ |
+ Barcode, |
+ Caret, |
+ CheckBox, |
+ ComboBox, |
+ DateTimePicker, |
+ Edit, |
+ Form, |
+ FormProxy, |
+ ListBox, |
+ MonthCalendar, |
+ PictureBox, |
+ PushButton, |
+ ScrollBar, |
+ SpinButton, |
+ ToolTip |
+}; |
-class CFWL_Event; |
-class CFWL_Message; |
+class CFWL_App; |
+class CFWL_AppImp; |
+class CFWL_MsgKey; |
class CFWL_Widget; |
-class CFWL_WidgetDelegate; |
class CFWL_WidgetMgr; |
+class CFWL_WidgetProperties; |
+class IFWL_ThemeProvider; |
-class CFWL_Widget { |
+class CFWL_Widget : public IFWL_WidgetDelegate { |
public: |
- explicit CFWL_Widget(const CFWL_App*); |
- virtual ~CFWL_Widget(); |
+ ~CFWL_Widget() override; |
+ |
+ virtual FWL_Type GetClassID() const = 0; |
+ virtual bool IsInstance(const CFX_WideStringC& wsClass) const; |
+ virtual void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false); |
+ virtual void GetClientRect(CFX_RectF& rect); |
+ virtual void ModifyStylesEx(uint32_t dwStylesExAdded, |
+ uint32_t dwStylesExRemoved); |
+ virtual void SetStates(uint32_t dwStates, bool bSet = true); |
+ virtual void Update() = 0; |
+ virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy); |
+ virtual void DrawWidget(CFX_Graphics* pGraphics, |
+ const CFX_Matrix* pMatrix = nullptr) = 0; |
+ virtual void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider); |
+ |
+ // IFWL_WidgetDelegate. |
+ void OnProcessMessage(CFWL_Message* pMessage) override; |
+ void OnProcessEvent(CFWL_Event* pEvent) override; |
+ void OnDrawWidget(CFX_Graphics* pGraphics, |
+ const CFX_Matrix* pMatrix = nullptr) override; |
- IFWL_Widget* GetWidget() { return m_pIface.get(); } |
- IFWL_Widget* GetWidget() const { return m_pIface.get(); } |
- |
- void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false); |
void SetWidgetRect(const CFX_RectF& rect); |
+ void SetParent(CFWL_Widget* pParent); |
+ |
+ CFWL_Widget* GetOwner() { return m_pWidgetMgr->GetOwnerWidget(this); } |
+ CFWL_Widget* GetOuter() const { return m_pOuter; } |
+ |
+ uint32_t GetStyles() const; |
void ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved); |
- uint32_t GetStylesEx(); |
- void ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); |
+ uint32_t GetStylesEx() const; |
+ uint32_t GetStates() const; |
- uint32_t GetStates(); |
- void SetStates(uint32_t dwStates, bool bSet = true); |
- void SetLayoutItem(void* pItem); |
+ void LockUpdate() { m_iLock++; } |
+ void UnlockUpdate() { |
+ if (IsLocked()) |
+ m_iLock--; |
+ } |
- void Update(); |
- void LockUpdate(); |
- void UnlockUpdate(); |
+ void TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy); |
+ void GetMatrix(CFX_Matrix& matrix, bool bGlobal = false); |
+ IFWL_ThemeProvider* GetThemeProvider() const; |
- FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy); |
- void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = nullptr); |
+ void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; } |
+ IFWL_WidgetDelegate* GetDelegate() { |
+ return m_pDelegate ? m_pDelegate : this; |
+ } |
+ const IFWL_WidgetDelegate* GetDelegate() const { |
+ return m_pDelegate ? m_pDelegate : this; |
+ } |
- IFWL_WidgetDelegate* GetDelegate() const; |
- void SetDelegate(IFWL_WidgetDelegate*); |
+ const CFWL_App* GetOwnerApp() const { return m_pOwnerApp; } |
+ uint32_t GetEventKey() const { return m_nEventKey; } |
+ void SetEventKey(uint32_t key) { m_nEventKey = key; } |
- protected: |
- void Initialize(); |
+ void* GetLayoutItem() const { return m_pLayoutItem; } |
+ void SetLayoutItem(void* pItem) { m_pLayoutItem = pItem; } |
- const CFWL_App* m_pApp; |
- std::unique_ptr<IFWL_Widget> m_pIface; |
+ void SetFocus(bool bFocus); |
+ void Repaint(const CFX_RectF* pRect = nullptr); |
+ |
+ protected: |
+ CFWL_Widget(const CFWL_App* app, |
+ std::unique_ptr<CFWL_WidgetProperties> properties, |
+ CFWL_Widget* pOuter); |
+ |
+ bool IsEnabled() const; |
+ bool IsActive() const; |
+ bool IsLocked() const { return m_iLock > 0; } |
+ bool HasBorder() const; |
+ bool HasEdge() const; |
+ void GetEdgeRect(CFX_RectF& rtEdge); |
+ FX_FLOAT GetBorderSize(bool bCX = true); |
+ FX_FLOAT GetEdgeWidth(); |
+ void GetRelativeRect(CFX_RectF& rect); |
+ void* GetThemeCapacity(CFWL_WidgetCapacity dwCapacity); |
+ IFWL_ThemeProvider* GetAvailableTheme(); |
+ CFX_SizeF CalcTextSize(const CFX_WideString& wsText, |
+ IFWL_ThemeProvider* pTheme, |
+ bool bMultiLine = false, |
+ int32_t iLineWidth = -1); |
+ void CalcTextRect(const CFX_WideString& wsText, |
+ IFWL_ThemeProvider* pTheme, |
+ uint32_t dwTTOStyles, |
+ int32_t iTTOAlign, |
+ CFX_RectF& rect); |
+ void SetGrab(bool bSet); |
+ void GetPopupPos(FX_FLOAT fMinHeight, |
+ FX_FLOAT fMaxHeight, |
+ const CFX_RectF& rtAnchor, |
+ CFX_RectF& rtPopup); |
+ void RegisterEventTarget(CFWL_Widget* pEventSource); |
+ void UnregisterEventTarget(); |
+ void DispatchKeyEvent(CFWL_MsgKey* pNote); |
+ void DispatchEvent(CFWL_Event* pEvent); |
+ void DrawBorder(CFX_Graphics* pGraphics, |
+ CFWL_Part iPartBorder, |
+ IFWL_ThemeProvider* pTheme, |
+ const CFX_Matrix* pMatrix = nullptr); |
+ void DrawEdge(CFX_Graphics* pGraphics, |
+ CFWL_Part iPartEdge, |
+ IFWL_ThemeProvider* pTheme, |
+ const CFX_Matrix* pMatrix = nullptr); |
+ |
+ const CFWL_App* const m_pOwnerApp; |
+ CFWL_WidgetMgr* const m_pWidgetMgr; |
+ std::unique_ptr<CFWL_WidgetProperties> m_pProperties; |
+ CFWL_Widget* m_pOuter; |
+ int32_t m_iLock; |
+ |
+ private: |
+ CFWL_Widget* GetParent() { return m_pWidgetMgr->GetParentWidget(this); } |
+ CFX_SizeF GetOffsetFromParent(CFWL_Widget* pParent); |
+ |
+ bool IsVisible() const; |
+ bool IsOverLapper() const; |
+ bool IsPopup() const; |
+ bool IsChild() const; |
+ bool IsOffscreen() const; |
+ CFWL_Widget* GetRootOuter(); |
+ bool GetPopupPosMenu(FX_FLOAT fMinHeight, |
+ FX_FLOAT fMaxHeight, |
+ const CFX_RectF& rtAnchor, |
+ CFX_RectF& rtPopup); |
+ bool GetPopupPosComboBox(FX_FLOAT fMinHeight, |
+ FX_FLOAT fMaxHeight, |
+ const CFX_RectF& rtAnchor, |
+ CFX_RectF& rtPopup); |
+ bool GetPopupPosGeneral(FX_FLOAT fMinHeight, |
+ FX_FLOAT fMaxHeight, |
+ const CFX_RectF& rtAnchor, |
+ CFX_RectF& rtPopup); |
+ bool GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); |
+ void DrawBackground(CFX_Graphics* pGraphics, |
+ CFWL_Part iPartBk, |
+ IFWL_ThemeProvider* pTheme, |
+ const CFX_Matrix* pMatrix = nullptr); |
+ void NotifyDriver(); |
+ bool IsParent(CFWL_Widget* pParent); |
+ |
+ void* m_pLayoutItem; |
+ uint32_t m_nEventKey; |
+ IFWL_WidgetDelegate* m_pDelegate; // Not owned. |
}; |
#endif // XFA_FWL_CORE_CFWL_WIDGET_H_ |