Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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 | |
dsinclair | 7222ea6 | 2016-04-06 14:33:07 -0700 | [diff] [blame] | 7 | #ifndef XFA_FXFA_INCLUDE_XFA_FFWIDGET_H_ |
| 8 | #define XFA_FXFA_INCLUDE_XFA_FFWIDGET_H_ |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 9 | |
| 10 | #include <vector> |
| 11 | |
dsinclair | 86e5474 | 2016-04-06 12:30:31 -0700 | [diff] [blame] | 12 | #include "core/fxcodec/include/fx_codec_def.h" |
dsinclair | 48baa5f | 2016-04-06 10:00:40 -0700 | [diff] [blame] | 13 | #include "core/fxge/include/fx_ge.h" |
dsinclair | 7222ea6 | 2016-04-06 14:33:07 -0700 | [diff] [blame] | 14 | #include "xfa/fxfa/include/fxfa.h" |
dsinclair | 0b851ff | 2016-07-21 12:03:01 -0700 | [diff] [blame^] | 15 | #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 16 | |
| 17 | class CXFA_FFPageView; |
| 18 | class CXFA_FFDocView; |
| 19 | class CXFA_FFDoc; |
| 20 | class CXFA_FFApp; |
dsinclair | 89fcde8 | 2016-05-03 13:00:25 -0700 | [diff] [blame] | 21 | enum class FWL_WidgetHit; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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 | }; |
tsepez | bb0d446 | 2016-04-27 16:59:30 -0700 | [diff] [blame] | 33 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 34 | class CXFA_CalcData { |
| 35 | public: |
weili | 47bcd4c | 2016-06-16 08:00:06 -0700 | [diff] [blame] | 36 | CXFA_CalcData(); |
| 37 | ~CXFA_CalcData(); |
tsepez | bb0d446 | 2016-04-27 16:59:30 -0700 | [diff] [blame] | 38 | |
| 39 | CFX_ArrayTemplate<CXFA_WidgetAcc*> m_Globals; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 40 | int32_t m_iRefCount; |
| 41 | }; |
tsepez | bb0d446 | 2016-04-27 16:59:30 -0700 | [diff] [blame] | 42 | |
tsepez | 7fa5513 | 2016-05-25 16:57:11 -0700 | [diff] [blame] | 43 | class CXFA_FFWidget : public CXFA_ContentLayoutItem { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 44 | public: |
| 45 | CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); |
weili | 47bcd4c | 2016-06-16 08:00:06 -0700 | [diff] [blame] | 46 | ~CXFA_FFWidget() override; |
| 47 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 48 | virtual FX_BOOL GetBBox(CFX_RectF& rtBox, |
tsepez | deee3d2 | 2016-03-25 14:38:58 -0700 | [diff] [blame] | 49 | uint32_t dwStatus, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 50 | FX_BOOL bDrawFocus = FALSE); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 51 | virtual void RenderWidget(CFX_Graphics* pGS, |
dsinclair | 9d6ca99 | 2016-06-16 10:51:56 -0700 | [diff] [blame] | 52 | CFX_Matrix* pMatrix, |
| 53 | uint32_t dwStatus); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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(); |
tsepez | deee3d2 | 2016-03-25 14:38:58 -0700 | [diff] [blame] | 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, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 67 | int16_t zDelta, |
| 68 | FX_FLOAT fx, |
| 69 | FX_FLOAT fy); |
tsepez | deee3d2 | 2016-03-25 14:38:58 -0700 | [diff] [blame] | 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); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 73 | |
| 74 | virtual FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget); |
| 75 | virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget); |
tsepez | deee3d2 | 2016-03-25 14:38:58 -0700 | [diff] [blame] | 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); |
dsinclair | 89fcde8 | 2016-05-03 13:00:25 -0700 | [diff] [blame] | 79 | virtual FWL_WidgetHit OnHitTest(FX_FLOAT fx, FX_FLOAT fy); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 80 | virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy); |
weili | 47bcd4c | 2016-06-16 08:00:06 -0700 | [diff] [blame] | 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(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 97 | virtual FX_BOOL GetSuggestWords(CFX_PointF pointf, |
weili | 47bcd4c | 2016-06-16 08:00:06 -0700 | [diff] [blame] | 98 | std::vector<CFX_ByteString>& sSuggest); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 99 | virtual FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, |
weili | 47bcd4c | 2016-06-16 08:00:06 -0700 | [diff] [blame] | 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 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 112 | CXFA_FFDocView* GetDocView(); |
weili | 47bcd4c | 2016-06-16 08:00:06 -0700 | [diff] [blame] | 113 | void SetDocView(CXFA_FFDocView* pDocView); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 114 | CXFA_FFDoc* GetDoc(); |
| 115 | CXFA_FFApp* GetApp(); |
| 116 | IXFA_AppProvider* GetAppProvider(); |
dsinclair | 85d1f2c | 2016-06-23 12:40:16 -0700 | [diff] [blame] | 117 | void InvalidateWidget(const CFX_RectF* pRect = nullptr); |
| 118 | void AddInvalidateRect(const CFX_RectF* pRect = nullptr); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 119 | FX_BOOL GetCaptionText(CFX_WideString& wsCap); |
tsepez | 7d89e72 | 2016-05-04 13:38:11 -0700 | [diff] [blame] | 120 | bool IsFocused(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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); |
weili | 47bcd4c | 2016-06-16 08:00:06 -0700 | [diff] [blame] | 129 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 130 | void DrawBorder(CFX_Graphics* pGS, |
| 131 | CXFA_Box box, |
| 132 | const CFX_RectF& rtBorder, |
| 133 | CFX_Matrix* pMatrix, |
tsepez | deee3d2 | 2016-03-25 14:38:58 -0700 | [diff] [blame] | 134 | uint32_t dwFlags = 0); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 135 | void GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth); |
| 136 | void GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight); |
| 137 | void GetRectWithoutRotate(CFX_RectF& rtWidget); |
tsepez | 7d89e72 | 2016-05-04 13:38:11 -0700 | [diff] [blame] | 138 | bool IsMatchVisibleStatus(uint32_t dwStatus); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 139 | void EventKillFocus(); |
| 140 | FX_BOOL IsButtonDown(); |
| 141 | void SetButtonDown(FX_BOOL bSet); |
weili | 47bcd4c | 2016-06-16 08:00:06 -0700 | [diff] [blame] | 142 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 143 | CXFA_FFDocView* m_pDocView; |
| 144 | CXFA_FFPageView* m_pPageView; |
| 145 | CXFA_WidgetAcc* m_pDataAcc; |
| 146 | CFX_RectF m_rtWidget; |
| 147 | }; |
weili | 47bcd4c | 2016-06-16 08:00:06 -0700 | [diff] [blame] | 148 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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); |
tsepez | fc58ad1 | 2016-04-05 12:22:15 -0700 | [diff] [blame] | 171 | FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideString& wsType); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 176 | CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem); |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 177 | FX_BOOL XFA_IsCreateWidget(XFA_Element iType); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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, |
tsepez | deee3d2 | 2016-03-25 14:38:58 -0700 | [diff] [blame] | 184 | uint32_t dwFlags = 0); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 185 | |
dsinclair | 7222ea6 | 2016-04-06 14:33:07 -0700 | [diff] [blame] | 186 | #endif // XFA_FXFA_INCLUDE_XFA_FFWIDGET_H_ |