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