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_FFWIDGETHANDLER_H_
8 #define XFA_FXFA_CXFA_FFWIDGETHANDLER_H_
9 
10 #include "core/fxcrt/unowned_ptr.h"
11 #include "xfa/fxfa/cxfa_eventparam.h"
12 #include "xfa/fxfa/fxfa.h"
13 #include "xfa/fxfa/parser/cxfa_document.h"
14 
15 class CXFA_FFDocView;
16 class CXFA_Graphics;
17 enum class FWL_WidgetHit;
18 
19 class CXFA_FFWidgetHandler {
20  public:
21   explicit CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView);
22   ~CXFA_FFWidgetHandler();
23 
24   bool OnMouseEnter(CXFA_FFWidget* hWidget);
25   bool OnMouseExit(CXFA_FFWidget* hWidget);
26   bool OnLButtonDown(CXFA_FFWidget* hWidget,
27                      uint32_t dwFlags,
28                      const CFX_PointF& point);
29   bool OnLButtonUp(CXFA_FFWidget* hWidget,
30                    uint32_t dwFlags,
31                    const CFX_PointF& point);
32   bool OnLButtonDblClk(CXFA_FFWidget* hWidget,
33                        uint32_t dwFlags,
34                        const CFX_PointF& point);
35   bool OnMouseMove(CXFA_FFWidget* hWidget,
36                    uint32_t dwFlags,
37                    const CFX_PointF& point);
38   bool OnMouseWheel(CXFA_FFWidget* hWidget,
39                     uint32_t dwFlags,
40                     int16_t zDelta,
41                     const CFX_PointF& point);
42   bool OnRButtonDown(CXFA_FFWidget* hWidget,
43                      uint32_t dwFlags,
44                      const CFX_PointF& point);
45   bool OnRButtonUp(CXFA_FFWidget* hWidget,
46                    uint32_t dwFlags,
47                    const CFX_PointF& point);
48   bool OnRButtonDblClk(CXFA_FFWidget* hWidget,
49                        uint32_t dwFlags,
50                        const CFX_PointF& point);
51 
52   WideString GetText(CXFA_FFWidget* widget);
53   WideString GetSelectedText(CXFA_FFWidget* widget);
54   void PasteText(CXFA_FFWidget* widget, const WideString& text);
55 
56   bool CanUndo(CXFA_FFWidget* widget);
57   bool CanRedo(CXFA_FFWidget* widget);
58   bool Undo(CXFA_FFWidget* widget);
59   bool Redo(CXFA_FFWidget* widget);
60 
61   bool OnKeyDown(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags);
62   bool OnKeyUp(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags);
63   bool OnChar(CXFA_FFWidget* hWidget, uint32_t dwChar, uint32_t dwFlags);
64   bool OnSetCursor(CXFA_FFWidget* hWidget, const CFX_PointF& point);
65   FWL_WidgetHit HitTest(CXFA_FFWidget* pWidget, const CFX_PointF& point);
66   void RenderWidget(CXFA_FFWidget* hWidget,
67                     CXFA_Graphics* pGS,
68                     const CFX_Matrix& matrix,
69                     bool bHighlight);
70   bool HasEvent(CXFA_Node* pNode, XFA_EVENTTYPE eEventType);
71   XFA_EventError ProcessEvent(CXFA_Node* pNode, CXFA_EventParam* pParam);
72 
73  private:
74   UnownedPtr<CXFA_FFDocView> m_pDocView;
75 };
76 
77 #endif  //  XFA_FXFA_CXFA_FFWIDGETHANDLER_H_
78