summaryrefslogtreecommitdiff
path: root/xfa/src/fxfa/src/app/xfa_ffwidget.h
blob: 8f19e71a0ed183f5422b0eef0b899a64a6a4f1d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef _FXFA_FORMFILLER_WIDGET_IMP_H
#define _FXFA_FORMFILLER_WIDGET_IMP_H

#include "../../../../include/fxfa/fxfa.h"

class CXFA_FFPageView;
class CXFA_FFDocView;
class CXFA_FFDoc;
class CXFA_FFApp;
class CXFA_LayoutItem;

#define XFA_GOTO_POSITION_IF_FAIL(arg, pos) { if (!(arg)) goto pos; }
inline FX_FLOAT XFA_UnitPx2Pt(FX_FLOAT fPx, FX_FLOAT fDpi)
{
    return fPx * 72.0f / fDpi;
}
#define XFA_FLOAT_PERCISION 0.001f
enum XFA_WIDGETITEM {
    XFA_WIDGETITEM_Parent,
    XFA_WIDGETITEM_FirstChild,
    XFA_WIDGETITEM_NextSibling,
    XFA_WIDGETITEM_PrevSibling,
};
class CXFA_CalcData
{
public:
    CXFA_CalcData() : m_iRefCount(0) {}
    ~CXFA_CalcData()
    {
        m_Globals.RemoveAll();
    }
    CFX_PtrArray				m_Globals;
    FX_INT32					m_iRefCount;
};
class CXFA_FFWidget : public IXFA_Widget, public CFX_PrivateData, public CXFA_ContentLayoutItemImpl
{
public:
    CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc);
    virtual ~CXFA_FFWidget();
    IXFA_PageView*	GetPageView();
    void			SetPageView(IXFA_PageView* pPageView);
    void			GetWidgetRect(CFX_RectF &rtWidget);
    CFX_RectF		ReCacheWidgetRect();
    FX_DWORD		GetStatus();
    void			ModifyStatus(FX_DWORD dwAdded, FX_DWORD dwRemoved);
    virtual FX_BOOL			GetBBox(CFX_RectF &rtBox, FX_DWORD dwStatus, FX_BOOL bDrawFocus = FALSE);
    CXFA_WidgetAcc*	GetDataAcc();
    FX_BOOL			GetToolTip(CFX_WideString &wsToolTip);
    virtual void			RenderWidget(CFX_Graphics* pGS, CFX_Matrix* pMatrix = NULL, FX_DWORD dwStatus = 0, FX_INT32 iRotate = 0);

    virtual	FX_BOOL			IsLoaded();
    virtual FX_BOOL			LoadWidget();
    virtual void			UnloadWidget();
    virtual FX_BOOL			LayoutWidget();
    virtual FX_BOOL			UpdateFWLData();
    virtual void			UpdateWidgetProperty();
    virtual FX_BOOL		OnMouseEnter();
    virtual FX_BOOL		OnMouseExit();
    virtual FX_BOOL		OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
    virtual FX_BOOL		OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
    virtual FX_BOOL		OnLButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
    virtual FX_BOOL		OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
    virtual FX_BOOL		OnMouseWheel(FX_DWORD dwFlags, FX_SHORT zDelta, FX_FLOAT fx, FX_FLOAT fy);
    virtual FX_BOOL		OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
    virtual FX_BOOL		OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
    virtual FX_BOOL		OnRButtonDblClk(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);

    virtual FX_BOOL		OnSetFocus(CXFA_FFWidget* pOldWidget);
    virtual FX_BOOL		OnKillFocus(CXFA_FFWidget* pNewWidget);
    virtual FX_BOOL		OnKeyDown(FX_DWORD dwKeyCode, FX_DWORD dwFlags);
    virtual FX_BOOL		OnKeyUp(FX_DWORD dwKeyCode, FX_DWORD dwFlags);
    virtual FX_BOOL		OnChar(FX_DWORD dwChar, FX_DWORD dwFlags);
    virtual	FX_DWORD	OnHitTest(FX_FLOAT fx, FX_FLOAT fy);
    virtual FX_BOOL		OnSetCursor(FX_FLOAT fx, FX_FLOAT fy);
    virtual FX_BOOL		CanUndo()
    {
        return FALSE;
    }
    virtual FX_BOOL		CanRedo()
    {
        return FALSE;
    }
    virtual FX_BOOL		Undo()
    {
        return FALSE;
    }
    virtual FX_BOOL		Redo()
    {
        return FALSE;
    }
    virtual FX_BOOL		CanCopy()
    {
        return FALSE;
    }
    virtual FX_BOOL		CanCut()
    {
        return FALSE;
    }
    virtual FX_BOOL		CanPaste()
    {
        return FALSE;
    }
    virtual FX_BOOL		CanSelectAll()
    {
        return FALSE;
    }
    virtual FX_BOOL		CanDelete()
    {
        return CanCut();
    }
    virtual FX_BOOL		CanDeSelect()
    {
        return CanCopy();
    }
    virtual FX_BOOL		Copy(CFX_WideString &wsCopy)
    {
        return FALSE;
    }
    virtual FX_BOOL		Cut(CFX_WideString &wsCut)
    {
        return FALSE;
    }
    virtual FX_BOOL		Paste(const CFX_WideString &wsPaste)
    {
        return FALSE;
    }
    virtual FX_BOOL		SelectAll()
    {
        return FALSE;
    }
    virtual FX_BOOL		Delete()
    {
        return FALSE;
    }
    virtual FX_BOOL		DeSelect()
    {
        return FALSE;
    }
    virtual FX_BOOL		GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray &sSuggest)
    {
        return FALSE;
    }
    virtual FX_BOOL		ReplaceSpellCheckWord(CFX_PointF pointf, FX_BSTR bsReplace)
    {
        return FALSE;
    }
    CXFA_FFDocView*		GetDocView();
    void				SetDocView(CXFA_FFDocView* pDocView)
    {
        m_pDocView = pDocView;
    }
    CXFA_FFDoc*			GetDoc();
    CXFA_FFApp*			GetApp();
    IXFA_AppProvider*	GetAppProvider();
    void				InvalidateWidget(const CFX_RectF* pRect = NULL);
    void				AddInvalidateRect(const CFX_RectF* pRect = NULL);
    FX_BOOL				GetCaptionText(CFX_WideString &wsCap);
    FX_BOOL				IsFocused();
    CXFA_LayoutItem*	GetLayoutItem()
    {
        return (CXFA_LayoutItem*)(CXFA_ContentLayoutItemImpl*)this;
    }
    void				Rotate2Normal(FX_FLOAT &fx, FX_FLOAT &fy);
    void				GetRotateMatrix(CFX_Matrix &mt);
    FX_BOOL				IsLayoutRectEmpty();
    CXFA_FFWidget*		GetParent();
    FX_BOOL				IsAncestorOf(CXFA_FFWidget* pWidget);

protected:
    virtual	FX_BOOL	PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy);
    void	DrawBorder(CFX_Graphics* pGS, CXFA_Box box, const CFX_RectF& rtBorder, CFX_Matrix* pMatrix, FX_DWORD dwFlags = 0);
    void	GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth);
    void	GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight);
    void	GetRectWithoutRotate(CFX_RectF &rtWidget);
    FX_BOOL IsMatchVisibleStatus(FX_DWORD dwStatus);

    void		EventKillFocus();
    FX_BOOL		IsButtonDown();
    void		SetButtonDown(FX_BOOL bSet);
    CXFA_FFDocView*		m_pDocView;
    CXFA_FFPageView*	m_pPageView;
    CXFA_WidgetAcc*		m_pDataAcc;
    CFX_RectF			m_rtWidget;
};
FX_INT32		XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, FX_INT32 iStrokeType, FX_INT32 iCapType);
CFX_GraphStateData::LineCap XFA_LineCapToFXGE(FX_INT32 iLineCap);
void			XFA_DrawImage(CFX_Graphics* pGS, const CFX_RectF &rtImage, CFX_Matrix* pMatrix, CFX_DIBitmap* pDIBitmap, FX_INT32 iAspect, FX_INT32 iImageXDpi, FX_INT32 iImageYDpi, FX_INT32 iHorzAlign = XFA_ATTRIBUTEENUM_Left, FX_INT32 iVertAlign = XFA_ATTRIBUTEENUM_Top);
CFX_DIBitmap*	XFA_LoadImageData(CXFA_FFDoc *pDoc, CXFA_Image *pImage, FX_BOOL &bNameImage, FX_INT32 &iImageXDpi, FX_INT32 &iImageYDpi);
CFX_DIBitmap*	XFA_LoadImageFromBuffer(IFX_FileRead* pImageFileRead, FXCODEC_IMAGE_TYPE type, FX_INT32 &iImageXDpi, FX_INT32 &iImageYDpi);
FXCODEC_IMAGE_TYPE XFA_GetImageType(FX_WSTR wsType);
FX_LPSTR		XFA_Base64Encode(FX_LPCBYTE buf, FX_INT32 buf_len);
void			XFA_RectWidthoutMargin(CFX_RectF &rt, const CXFA_Margin &mg, FX_BOOL bUI = FALSE);
FX_FLOAT		XFA_GetEdgeThickness(const CXFA_StrokeArray &strokes, FX_BOOL b3DStyle, FX_INT32 nIndex);
CXFA_FFWidget*	XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem);
FX_BOOL			XFA_IsCreateWidget(XFA_ELEMENT iType);
#define XFA_DRAWBOX_ForceRound	1
#define XFA_DRAWBOX_Lowered3D	2
void XFA_DrawBox(CXFA_Box box, CFX_Graphics* pGS, const CFX_RectF &rtWidget, CFX_Matrix* pMatrix, FX_DWORD dwFlags = 0);
#endif