• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FWL_CFWL_WIDGETMGR_H_
8 #define XFA_FWL_CFWL_WIDGETMGR_H_
9 
10 #include <map>
11 #include <memory>
12 #include <vector>
13 
14 #include "core/fxcrt/fx_system.h"
15 #include "xfa/fwl/ifwl_widgetmgrdelegate.h"
16 #include "xfa/fxgraphics/cfx_graphics.h"
17 
18 #define FWL_WGTMGR_DisableForm 0x00000002
19 
20 class CFWL_Message;
21 class CXFA_FFApp;
22 class CXFA_FWLAdapterWidgetMgr;
23 class CFX_Graphics;
24 class CFX_Matrix;
25 class CFWL_Widget;
26 
27 class CFWL_WidgetMgr : public CFWL_WidgetMgrDelegate {
28  public:
29   explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative);
30   ~CFWL_WidgetMgr();
31 
32   // CFWL_WidgetMgrDelegate
33   void OnSetCapability(uint32_t dwCapability) override;
34   void OnProcessMessageToForm(CFWL_Message* pMessage) override;
35   void OnDrawWidget(CFWL_Widget* pWidget,
36                     CFX_Graphics* pGraphics,
37                     const CFX_Matrix* pMatrix) override;
38 
39   CFWL_Widget* GetParentWidget(CFWL_Widget* pWidget) const;
40   CFWL_Widget* GetOwnerWidget(CFWL_Widget* pWidget) const;
41   CFWL_Widget* GetNextSiblingWidget(CFWL_Widget* pWidget) const;
42   CFWL_Widget* GetFirstChildWidget(CFWL_Widget* pWidget) const;
43   CFWL_Widget* GetSystemFormWidget(CFWL_Widget* pWidget) const;
44 
45   void RepaintWidget(CFWL_Widget* pWidget, const CFX_RectF& pRect);
46 
47   void InsertWidget(CFWL_Widget* pParent, CFWL_Widget* pChild);
48   void RemoveWidget(CFWL_Widget* pWidget);
49   void SetOwner(CFWL_Widget* pOwner, CFWL_Widget* pOwned);
50   void SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild);
51 
52   CFWL_Widget* GetWidgetAtPoint(CFWL_Widget* pParent,
53                                 const CFX_PointF& point) const;
54   CFWL_Widget* NextTab(CFWL_Widget* parent, CFWL_Widget* focus, bool& bFind);
55 
56   std::vector<CFWL_Widget*> GetSameGroupRadioButton(
57       CFWL_Widget* pRadioButton) const;
58 
59   CFWL_Widget* GetDefaultButton(CFWL_Widget* pParent) const;
60   void AddRedrawCounts(CFWL_Widget* pWidget);
61 
IsFormDisabled()62   bool IsFormDisabled() const {
63     return !!(m_dwCapability & FWL_WGTMGR_DisableForm);
64   }
65 
66   void GetAdapterPopupPos(CFWL_Widget* pWidget,
67                           FX_FLOAT fMinHeight,
68                           FX_FLOAT fMaxHeight,
69                           const CFX_RectF& rtAnchor,
70                           CFX_RectF& rtPopup) const;
71 
72  private:
73   class Item {
74    public:
75     Item();
76     explicit Item(CFWL_Widget* widget);
77     ~Item();
78 
79     Item* pParent;
80     Item* pOwner;
81     Item* pChild;
82     Item* pPrevious;
83     Item* pNext;
84     CFWL_Widget* const pWidget;
85     std::unique_ptr<CFX_Graphics> pOffscreen;
86     int32_t iRedrawCounter;
87 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
88     bool bOutsideChanged;
89 #endif
90   };
91 
92   CFWL_Widget* GetFirstSiblingWidget(CFWL_Widget* pWidget) const;
93   CFWL_Widget* GetPriorSiblingWidget(CFWL_Widget* pWidget) const;
94   CFWL_Widget* GetLastChildWidget(CFWL_Widget* pWidget) const;
95   Item* GetWidgetMgrItem(CFWL_Widget* pWidget) const;
96 
97   void AppendWidget(CFWL_Widget* pWidget);
98 
99   int32_t CountRadioButtonGroup(CFWL_Widget* pFirst) const;
100   CFWL_Widget* GetRadioButtonGroupHeader(CFWL_Widget* pRadioButton) const;
101 
102   void ResetRedrawCounts(CFWL_Widget* pWidget);
103 
104   void DrawChild(CFWL_Widget* pParent,
105                  const CFX_RectF& rtClip,
106                  CFX_Graphics* pGraphics,
107                  const CFX_Matrix* pMatrix);
108   CFX_Graphics* DrawWidgetBefore(CFWL_Widget* pWidget,
109                                  CFX_Graphics* pGraphics,
110                                  const CFX_Matrix* pMatrix);
111   bool IsNeedRepaint(CFWL_Widget* pWidget,
112                      CFX_Matrix* pMatrix,
113                      const CFX_RectF& rtDirty);
114 
115   bool IsAbleNative(CFWL_Widget* pWidget) const;
116 
117   uint32_t m_dwCapability;
118   std::map<CFWL_Widget*, std::unique_ptr<Item>> m_mapWidgetItem;
119   CXFA_FWLAdapterWidgetMgr* const m_pAdapter;
120 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
121   CFX_RectF m_rtScreen;
122 #endif
123 };
124 
125 #endif  // XFA_FWL_CFWL_WIDGETMGR_H_
126