Replace XFA_HWIDGET with IXFA_Widget*
[pdfium.git] / xfa / src / fxfa / src / app / xfa_fwladapter.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../../foxitlib.h"\r
8 #include "../common/xfa_common.h"\r
9 #include "xfa_fwladapter.h"\r
10 #include "xfa_ffwidget.h"\r
11 #include "xfa_fffield.h"\r
12 #include "xfa_ffdoc.h"\r
13 IFWL_AdapterNative * FWL_CreateFuelAdapterNative()\r
14 {\r
15     return NULL;\r
16 }\r
17 void FWL_ReleaseFuelAdapterNative(IFWL_AdapterNative * native)\r
18 {\r
19 }\r
20 void FWL_PostMessageToMainRoop(CFWL_Message *pMessage)\r
21 {\r
22 }\r
23 IFWL_AdapterSemaphore * IFWL_AdapterSemaphore::Create()\r
24 {\r
25     return NULL;\r
26 }\r
27 FX_BOOL FWL_ShowCaret(IFWL_Widget *pWidget, FX_BOOL bVisible, const CFX_RectF *pRtAnchor)\r
28 {\r
29     CXFA_FFWidget* pXFAWidget = (CXFA_FFWidget*)pWidget->GetPrivateData(pWidget);\r
30     if (!pXFAWidget) {\r
31         return FALSE;\r
32     }\r
33     IXFA_DocProvider* pDocProvider = pXFAWidget->GetDoc()->GetDocProvider();\r
34     if (!pDocProvider) {\r
35         return FALSE;\r
36     }\r
37     if (bVisible) {\r
38         CFX_Matrix mt;\r
39         pXFAWidget->GetRotateMatrix(mt);\r
40         CFX_RectF rt(*pRtAnchor);\r
41         mt.TransformRect(rt);\r
42         pDocProvider->DisplayCaret(pXFAWidget, bVisible, &rt);\r
43         return TRUE;\r
44     }\r
45     pDocProvider->DisplayCaret(pXFAWidget, bVisible, pRtAnchor);\r
46     return TRUE;\r
47 }\r
48 FWL_ERR CXFA_FWLAdapterWidgetMgr::RepaintWidget(IFWL_Widget *pWidget, const CFX_RectF *pRect)\r
49 {\r
50     _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Indefinite);\r
51     CXFA_FFField *pField = (CXFA_FFField*)pWidget->GetPrivateData(pWidget);\r
52     _FWL_RETURN_VALUE_IF_FAIL(pField, FWL_ERR_Indefinite);\r
53 #ifdef _XFA_EMB\r
54     CFX_RectF rtInvalidate;\r
55     pWidget->GetWidgetRect(rtInvalidate);\r
56     if (pRect) {\r
57         rtInvalidate.left += pRect->left;\r
58         rtInvalidate.top += pRect->top;\r
59         rtInvalidate.width = pRect->width;\r
60         rtInvalidate.height = pRect->height;\r
61     }\r
62     CFX_Matrix mt;\r
63     pField->GetRotateMatrix(mt);\r
64     mt.TransformRect(rtInvalidate);\r
65     pField->AddInvalidateRect(&rtInvalidate);\r
66 #else\r
67     pField->AddInvalidateRect(NULL);\r
68 #endif\r
69     return FWL_ERR_Succeeded;\r
70 }\r
71 FX_BOOL CXFA_FWLAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup)\r
72 {\r
73     CXFA_FFWidget* pFFWidget = (CXFA_FFWidget*)(pWidget->GetPrivateData(pWidget));\r
74     CFX_Matrix mt;\r
75     pFFWidget->GetRotateMatrix(mt);\r
76     CFX_RectF rtRotateAnchor(rtAnchor);\r
77     mt.TransformRect(rtRotateAnchor);\r
78     pFFWidget->GetDoc()->GetDocProvider()->GetPopupPos(pFFWidget, fMinHeight, fMaxHeight, rtRotateAnchor, rtPopup);\r
79     return TRUE;\r
80 }\r