blob: ccb2f3d630d4789ab66f555b764fd02bc0faa5ea [file] [log] [blame]
dsinclairdf4bc592016-03-31 20:34:43 -07001// 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
dsinclair5b493092016-09-29 20:20:24 -07007#ifndef XFA_FXFA_XFA_FFWIDGETHANDLER_H_
8#define XFA_FXFA_XFA_FFWIDGETHANDLER_H_
dsinclairdf4bc592016-03-31 20:34:43 -07009
10#include <vector>
11
dsinclair5b493092016-09-29 20:20:24 -070012#include "xfa/fxfa/cxfa_eventparam.h"
13#include "xfa/fxfa/fxfa.h"
dsinclair16280242016-07-21 12:03:47 -070014#include "xfa/fxfa/parser/cxfa_document.h"
dsinclairdf4bc592016-03-31 20:34:43 -070015
16class CXFA_FFDocView;
dsinclair89fcde82016-05-03 13:00:25 -070017enum class FWL_WidgetHit;
dsinclairdf4bc592016-03-31 20:34:43 -070018
19class CXFA_FFWidgetHandler {
20 public:
21 CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView);
22 ~CXFA_FFWidgetHandler();
dsinclair221caf62016-04-04 12:08:40 -070023
dsinclairdf4bc592016-03-31 20:34:43 -070024 CXFA_FFWidget* CreateWidget(CXFA_FFWidget* hParent,
25 XFA_WIDGETTYPE eType,
dsinclair85d1f2c2016-06-23 12:40:16 -070026 CXFA_FFWidget* hBefore = nullptr);
dsinclair221caf62016-04-04 12:08:40 -070027
tsepezd19e9122016-11-02 15:43:18 -070028 bool OnMouseEnter(CXFA_FFWidget* hWidget);
29 bool OnMouseExit(CXFA_FFWidget* hWidget);
30 bool OnLButtonDown(CXFA_FFWidget* hWidget,
31 uint32_t dwFlags,
32 FX_FLOAT fx,
33 FX_FLOAT fy);
34 bool OnLButtonUp(CXFA_FFWidget* hWidget,
35 uint32_t dwFlags,
36 FX_FLOAT fx,
37 FX_FLOAT fy);
38 bool OnLButtonDblClk(CXFA_FFWidget* hWidget,
dsinclairdf4bc592016-03-31 20:34:43 -070039 uint32_t dwFlags,
dsinclairdf4bc592016-03-31 20:34:43 -070040 FX_FLOAT fx,
41 FX_FLOAT fy);
tsepezd19e9122016-11-02 15:43:18 -070042 bool OnMouseMove(CXFA_FFWidget* hWidget,
43 uint32_t dwFlags,
44 FX_FLOAT fx,
45 FX_FLOAT fy);
46 bool OnMouseWheel(CXFA_FFWidget* hWidget,
47 uint32_t dwFlags,
48 int16_t zDelta,
49 FX_FLOAT fx,
50 FX_FLOAT fy);
51 bool OnRButtonDown(CXFA_FFWidget* hWidget,
52 uint32_t dwFlags,
53 FX_FLOAT fx,
54 FX_FLOAT fy);
55 bool OnRButtonUp(CXFA_FFWidget* hWidget,
56 uint32_t dwFlags,
57 FX_FLOAT fx,
58 FX_FLOAT fy);
59 bool OnRButtonDblClk(CXFA_FFWidget* hWidget,
60 uint32_t dwFlags,
61 FX_FLOAT fx,
62 FX_FLOAT fy);
dsinclairdf4bc592016-03-31 20:34:43 -070063
tsepezd19e9122016-11-02 15:43:18 -070064 bool OnKeyDown(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags);
65 bool OnKeyUp(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags);
66 bool OnChar(CXFA_FFWidget* hWidget, uint32_t dwChar, uint32_t dwFlags);
dsinclair89fcde82016-05-03 13:00:25 -070067 FWL_WidgetHit OnHitTest(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy);
tsepezd19e9122016-11-02 15:43:18 -070068 bool OnSetCursor(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy);
dsinclairdf4bc592016-03-31 20:34:43 -070069 void RenderWidget(CXFA_FFWidget* hWidget,
70 CFX_Graphics* pGS,
dsinclair9d6ca992016-06-16 10:51:56 -070071 CFX_Matrix* pMatrix,
tsepezd19e9122016-11-02 15:43:18 -070072 bool bHighlight);
73 bool HasEvent(CXFA_WidgetAcc* pWidgetAcc, XFA_EVENTTYPE eEventType);
dsinclairdf4bc592016-03-31 20:34:43 -070074 int32_t ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, CXFA_EventParam* pParam);
75
76 protected:
77 CXFA_Node* CreateWidgetFormItem(XFA_WIDGETTYPE eType,
78 CXFA_Node* pParent,
79 CXFA_Node* pBefore) const;
80
81 CXFA_Node* CreatePushButton(CXFA_Node* pParent, CXFA_Node* pBefore) const;
82 CXFA_Node* CreateCheckButton(CXFA_Node* pParent, CXFA_Node* pBefore) const;
83 CXFA_Node* CreateExclGroup(CXFA_Node* pParent, CXFA_Node* pBefore) const;
84 CXFA_Node* CreateRadioButton(CXFA_Node* pParent, CXFA_Node* pBefore) const;
85 CXFA_Node* CreateDatetimeEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const;
86 CXFA_Node* CreateDecimalField(CXFA_Node* pParent, CXFA_Node* pBefore) const;
87 CXFA_Node* CreateNumericField(CXFA_Node* pParent, CXFA_Node* pBefore) const;
88 CXFA_Node* CreateSignature(CXFA_Node* pParent, CXFA_Node* pBefore) const;
89 CXFA_Node* CreateTextEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const;
90 CXFA_Node* CreateDropdownList(CXFA_Node* pParent, CXFA_Node* pBefore) const;
91 CXFA_Node* CreateListBox(CXFA_Node* pParent, CXFA_Node* pBefore) const;
92 CXFA_Node* CreateImageField(CXFA_Node* pParent, CXFA_Node* pBefore) const;
93 CXFA_Node* CreatePasswordEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const;
dsinclair56a8b192016-06-21 14:15:25 -070094 CXFA_Node* CreateField(XFA_Element eElement,
dsinclairdf4bc592016-03-31 20:34:43 -070095 CXFA_Node* pParent,
96 CXFA_Node* pBefore) const;
97 CXFA_Node* CreateArc(CXFA_Node* pParent, CXFA_Node* pBefore) const;
98 CXFA_Node* CreateRectangle(CXFA_Node* pParent, CXFA_Node* pBefore) const;
99 CXFA_Node* CreateImage(CXFA_Node* pParent, CXFA_Node* pBefore) const;
100 CXFA_Node* CreateLine(CXFA_Node* pParent, CXFA_Node* pBefore) const;
101 CXFA_Node* CreateText(CXFA_Node* pParent, CXFA_Node* pBefore) const;
dsinclair56a8b192016-06-21 14:15:25 -0700102 CXFA_Node* CreateDraw(XFA_Element eElement,
dsinclairdf4bc592016-03-31 20:34:43 -0700103 CXFA_Node* pParent,
104 CXFA_Node* pBefore) const;
105
106 CXFA_Node* CreateSubform(CXFA_Node* pParent, CXFA_Node* pBefore) const;
dsinclair56a8b192016-06-21 14:15:25 -0700107 CXFA_Node* CreateFormItem(XFA_Element eElement,
dsinclairdf4bc592016-03-31 20:34:43 -0700108 CXFA_Node* pParent,
109 CXFA_Node* pBefore) const;
dsinclair56a8b192016-06-21 14:15:25 -0700110 CXFA_Node* CreateCopyNode(XFA_Element eElement,
dsinclairdf4bc592016-03-31 20:34:43 -0700111 CXFA_Node* pParent,
dsinclair85d1f2c2016-06-23 12:40:16 -0700112 CXFA_Node* pBefore = nullptr) const;
dsinclair56a8b192016-06-21 14:15:25 -0700113 CXFA_Node* CreateTemplateNode(XFA_Element eElement,
dsinclairdf4bc592016-03-31 20:34:43 -0700114 CXFA_Node* pParent,
115 CXFA_Node* pBefore) const;
116 CXFA_Node* CreateFontNode(CXFA_Node* pParent) const;
117 CXFA_Node* CreateMarginNode(CXFA_Node* pParent,
118 uint32_t dwFlags,
119 FX_FLOAT fInsets[4]) const;
dsinclair56a8b192016-06-21 14:15:25 -0700120 CXFA_Node* CreateValueNode(XFA_Element eValue, CXFA_Node* pParent) const;
dsinclairdf4bc592016-03-31 20:34:43 -0700121 CXFA_Document* GetObjFactory() const;
122 CXFA_Document* GetXFADoc() const;
123
124 CXFA_FFDocView* m_pDocView;
125};
126
dsinclair5b493092016-09-29 20:20:24 -0700127#endif // XFA_FXFA_XFA_FFWIDGETHANDLER_H_