OLD | NEW |
| (Empty) |
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_APP_XFA_FFWIDGET_H_ | |
8 #define XFA_FXFA_APP_XFA_FFWIDGET_H_ | |
9 | |
10 #include <vector> | |
11 | |
12 #include "core/include/fxcodec/fx_codec_def.h" | |
13 #include "core/include/fxge/fx_ge.h" | |
14 #include "xfa/fxfa/parser/xfa_doclayout.h" | |
15 #include "xfa/include/fxfa/fxfa.h" | |
16 | |
17 class CXFA_FFPageView; | |
18 class CXFA_FFDocView; | |
19 class CXFA_FFDoc; | |
20 class CXFA_FFApp; | |
21 | |
22 inline FX_FLOAT XFA_UnitPx2Pt(FX_FLOAT fPx, FX_FLOAT fDpi) { | |
23 return fPx * 72.0f / fDpi; | |
24 } | |
25 #define XFA_FLOAT_PERCISION 0.001f | |
26 enum XFA_WIDGETITEM { | |
27 XFA_WIDGETITEM_Parent, | |
28 XFA_WIDGETITEM_FirstChild, | |
29 XFA_WIDGETITEM_NextSibling, | |
30 XFA_WIDGETITEM_PrevSibling, | |
31 }; | |
32 class CXFA_CalcData { | |
33 public: | |
34 CXFA_CalcData() : m_iRefCount(0) {} | |
35 ~CXFA_CalcData() { m_Globals.RemoveAll(); } | |
36 CFX_PtrArray m_Globals; | |
37 int32_t m_iRefCount; | |
38 }; | |
39 class CXFA_FFWidget : public CFX_PrivateData, public CXFA_ContentLayoutItem { | |
40 public: | |
41 CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); | |
42 virtual ~CXFA_FFWidget(); | |
43 CXFA_FFPageView* GetPageView(); | |
44 void SetPageView(CXFA_FFPageView* pPageView); | |
45 void GetWidgetRect(CFX_RectF& rtWidget); | |
46 CFX_RectF ReCacheWidgetRect(); | |
47 uint32_t GetStatus(); | |
48 void ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved); | |
49 virtual FX_BOOL GetBBox(CFX_RectF& rtBox, | |
50 uint32_t dwStatus, | |
51 FX_BOOL bDrawFocus = FALSE); | |
52 CXFA_WidgetAcc* GetDataAcc(); | |
53 FX_BOOL GetToolTip(CFX_WideString& wsToolTip); | |
54 virtual void RenderWidget(CFX_Graphics* pGS, | |
55 CFX_Matrix* pMatrix = NULL, | |
56 uint32_t dwStatus = 0, | |
57 int32_t iRotate = 0); | |
58 | |
59 virtual FX_BOOL IsLoaded(); | |
60 virtual FX_BOOL LoadWidget(); | |
61 virtual void UnloadWidget(); | |
62 virtual FX_BOOL PerformLayout(); | |
63 virtual FX_BOOL UpdateFWLData(); | |
64 virtual void UpdateWidgetProperty(); | |
65 virtual FX_BOOL OnMouseEnter(); | |
66 virtual FX_BOOL OnMouseExit(); | |
67 virtual FX_BOOL OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
68 virtual FX_BOOL OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
69 virtual FX_BOOL OnLButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
70 virtual FX_BOOL OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
71 virtual FX_BOOL OnMouseWheel(uint32_t dwFlags, | |
72 int16_t zDelta, | |
73 FX_FLOAT fx, | |
74 FX_FLOAT fy); | |
75 virtual FX_BOOL OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
76 virtual FX_BOOL OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
77 virtual FX_BOOL OnRButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
78 | |
79 virtual FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget); | |
80 virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); | |
81 virtual FX_BOOL OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags); | |
82 virtual FX_BOOL OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags); | |
83 virtual FX_BOOL OnChar(uint32_t dwChar, uint32_t dwFlags); | |
84 virtual uint32_t OnHitTest(FX_FLOAT fx, FX_FLOAT fy); | |
85 virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy); | |
86 virtual FX_BOOL CanUndo() { return FALSE; } | |
87 virtual FX_BOOL CanRedo() { return FALSE; } | |
88 virtual FX_BOOL Undo() { return FALSE; } | |
89 virtual FX_BOOL Redo() { return FALSE; } | |
90 virtual FX_BOOL CanCopy() { return FALSE; } | |
91 virtual FX_BOOL CanCut() { return FALSE; } | |
92 virtual FX_BOOL CanPaste() { return FALSE; } | |
93 virtual FX_BOOL CanSelectAll() { return FALSE; } | |
94 virtual FX_BOOL CanDelete() { return CanCut(); } | |
95 virtual FX_BOOL CanDeSelect() { return CanCopy(); } | |
96 virtual FX_BOOL Copy(CFX_WideString& wsCopy) { return FALSE; } | |
97 virtual FX_BOOL Cut(CFX_WideString& wsCut) { return FALSE; } | |
98 virtual FX_BOOL Paste(const CFX_WideString& wsPaste) { return FALSE; } | |
99 virtual FX_BOOL SelectAll() { return FALSE; } | |
100 virtual FX_BOOL Delete() { return FALSE; } | |
101 virtual FX_BOOL DeSelect() { return FALSE; } | |
102 virtual FX_BOOL GetSuggestWords(CFX_PointF pointf, | |
103 std::vector<CFX_ByteString>& sSuggest) { | |
104 return FALSE; | |
105 } | |
106 virtual FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, | |
107 const CFX_ByteStringC& bsReplace) { | |
108 return FALSE; | |
109 } | |
110 CXFA_FFDocView* GetDocView(); | |
111 void SetDocView(CXFA_FFDocView* pDocView) { m_pDocView = pDocView; } | |
112 CXFA_FFDoc* GetDoc(); | |
113 CXFA_FFApp* GetApp(); | |
114 IXFA_AppProvider* GetAppProvider(); | |
115 void InvalidateWidget(const CFX_RectF* pRect = NULL); | |
116 void AddInvalidateRect(const CFX_RectF* pRect = NULL); | |
117 FX_BOOL GetCaptionText(CFX_WideString& wsCap); | |
118 FX_BOOL IsFocused(); | |
119 void Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy); | |
120 void GetRotateMatrix(CFX_Matrix& mt); | |
121 FX_BOOL IsLayoutRectEmpty(); | |
122 CXFA_FFWidget* GetParent(); | |
123 FX_BOOL IsAncestorOf(CXFA_FFWidget* pWidget); | |
124 | |
125 protected: | |
126 virtual FX_BOOL PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); | |
127 void DrawBorder(CFX_Graphics* pGS, | |
128 CXFA_Box box, | |
129 const CFX_RectF& rtBorder, | |
130 CFX_Matrix* pMatrix, | |
131 uint32_t dwFlags = 0); | |
132 void GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth); | |
133 void GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight); | |
134 void GetRectWithoutRotate(CFX_RectF& rtWidget); | |
135 FX_BOOL IsMatchVisibleStatus(uint32_t dwStatus); | |
136 | |
137 void EventKillFocus(); | |
138 FX_BOOL IsButtonDown(); | |
139 void SetButtonDown(FX_BOOL bSet); | |
140 CXFA_FFDocView* m_pDocView; | |
141 CXFA_FFPageView* m_pPageView; | |
142 CXFA_WidgetAcc* m_pDataAcc; | |
143 CFX_RectF m_rtWidget; | |
144 }; | |
145 int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, | |
146 int32_t iStrokeType, | |
147 int32_t iCapType); | |
148 CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap); | |
149 void XFA_DrawImage(CFX_Graphics* pGS, | |
150 const CFX_RectF& rtImage, | |
151 CFX_Matrix* pMatrix, | |
152 CFX_DIBitmap* pDIBitmap, | |
153 int32_t iAspect, | |
154 int32_t iImageXDpi, | |
155 int32_t iImageYDpi, | |
156 int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, | |
157 int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); | |
158 CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, | |
159 CXFA_Image* pImage, | |
160 FX_BOOL& bNameImage, | |
161 int32_t& iImageXDpi, | |
162 int32_t& iImageYDpi); | |
163 CFX_DIBitmap* XFA_LoadImageFromBuffer(IFX_FileRead* pImageFileRead, | |
164 FXCODEC_IMAGE_TYPE type, | |
165 int32_t& iImageXDpi, | |
166 int32_t& iImageYDpi); | |
167 FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideStringC& wsType); | |
168 FX_CHAR* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len); | |
169 void XFA_RectWidthoutMargin(CFX_RectF& rt, | |
170 const CXFA_Margin& mg, | |
171 FX_BOOL bUI = FALSE); | |
172 FX_FLOAT XFA_GetEdgeThickness(const CXFA_StrokeArray& strokes, | |
173 FX_BOOL b3DStyle, | |
174 int32_t nIndex); | |
175 CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem); | |
176 FX_BOOL XFA_IsCreateWidget(XFA_ELEMENT iType); | |
177 #define XFA_DRAWBOX_ForceRound 1 | |
178 #define XFA_DRAWBOX_Lowered3D 2 | |
179 void XFA_DrawBox(CXFA_Box box, | |
180 CFX_Graphics* pGS, | |
181 const CFX_RectF& rtWidget, | |
182 CFX_Matrix* pMatrix, | |
183 uint32_t dwFlags = 0); | |
184 | |
185 #endif // XFA_FXFA_APP_XFA_FFWIDGET_H_ | |
OLD | NEW |