Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / src / fwl / src / core / include / fwl_widgetmgrimp.h
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 #ifndef _FWL_WIDGETMGR_IMP_H\r
8 #define _FWL_WIDGETMGR_IMP_H\r
9 class CFWL_Target;\r
10 class IFWL_Widget;\r
11 class IFWL_AdapterWidgetMgr;\r
12 class CFWL_WidgetMgrItem;\r
13 class CFWL_WidgetMgr;\r
14 class CFWL_WidgetMgrDelegate;\r
15 class IFWL_AdapterNative;\r
16 class CFWL_WidgetMgrItem\r
17 {\r
18 public:\r
19     CFWL_WidgetMgrItem()\r
20         : pParent(NULL)\r
21         , pOwner(NULL)\r
22         , pChild(NULL)\r
23         , pPrevious(NULL)\r
24         , pNext(NULL)\r
25         , pWidget(NULL)\r
26         , pOffscreen(NULL)\r
27         , iRedrawCounter(0)\r
28 #if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_)\r
29         , bOutsideChanged(FALSE)\r
30 #endif\r
31     {\r
32     }\r
33     ~CFWL_WidgetMgrItem()\r
34     {\r
35         if (pOffscreen) {\r
36             delete pOffscreen;\r
37             pOffscreen = NULL;\r
38         }\r
39     }\r
40     CFWL_WidgetMgrItem  *pParent;\r
41     CFWL_WidgetMgrItem  *pOwner;\r
42     CFWL_WidgetMgrItem  *pChild;\r
43     CFWL_WidgetMgrItem  *pPrevious;\r
44     CFWL_WidgetMgrItem  *pNext;\r
45     IFWL_Widget                 *pWidget;\r
46     CFX_Graphics                *pOffscreen;\r
47     int32_t                     iRedrawCounter;\r
48 #if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_)\r
49     FX_BOOL                             bOutsideChanged;\r
50 #endif\r
51 };\r
52 class CFWL_WidgetMgr\r
53 {\r
54 public:\r
55     CFWL_WidgetMgr(IFWL_AdapterNative *pAdapterNative);\r
56     ~CFWL_WidgetMgr();\r
57     virtual int32_t             CountWidgets(IFWL_Widget *pParent = NULL);\r
58     virtual IFWL_Widget*        GetWidget(int32_t nIndex, IFWL_Widget *pParent = NULL);\r
59     virtual IFWL_Widget*        GetWidget(IFWL_Widget *pWidget, FWL_WGTRELATION eRelation);\r
60     virtual int32_t             GetWidgetIndex(IFWL_Widget *pWidget);\r
61     virtual FX_BOOL                     SetWidgetIndex(IFWL_Widget *pWidget, int32_t nIndex);\r
62     virtual FX_BOOL                     IsWidget(FX_LPVOID pObj);\r
63     virtual FWL_ERR                     RepaintWidget(IFWL_Widget *pWidget, const CFX_RectF *pRect = NULL);\r
64     virtual FX_DWORD            GetCapability()\r
65     {\r
66         return m_dwCapability;\r
67     }\r
68     void                        AddWidget(IFWL_Widget *pWidget);\r
69     void                        InsertWidget(IFWL_Widget *pParent, IFWL_Widget *pChild, int32_t nIndex = -1);\r
70     void                        RemoveWidget(IFWL_Widget *pWidget);\r
71     void                        SetOwner(IFWL_Widget *pOwner, IFWL_Widget *pOwned);\r
72     void                        SetParent(IFWL_Widget *pParent, IFWL_Widget *pChild);\r
73     FX_BOOL                     IsChild(IFWL_Widget *pChild, IFWL_Widget *pParent);\r
74     FWL_ERR                     CreateWidget_Native(IFWL_Widget *pWidget);\r
75     FWL_ERR                     DestroyWidget_Native(IFWL_Widget *pWidget);\r
76     FWL_ERR                     GetWidgetRect_Native(IFWL_Widget *pWidget, CFX_RectF &rect);\r
77     FWL_ERR                     SetWidgetRect_Native(IFWL_Widget *pWidget, const CFX_RectF &rect);\r
78     FWL_ERR                     SetWidgetPosition_Native(IFWL_Widget *pWidget, FX_FLOAT fx, FX_FLOAT fy);\r
79     FWL_ERR                     SetWidgetIcon_Native(IFWL_Widget *pWidget, const CFX_DIBitmap *pIcon, FX_BOOL bBig);\r
80     FWL_ERR                     SetWidgetCaption_Native(IFWL_Widget *pWidget, FX_WSTR wsCaption);\r
81     FWL_ERR                     SetBorderRegion_Native(IFWL_Widget *pWidget, CFX_Path *pPath);\r
82     FWL_ERR                     ShowWidget_Native(IFWL_Widget *pWidget);\r
83     FWL_ERR                     HideWidget_Native(IFWL_Widget *pWidget);\r
84     FWL_ERR                     SetNormal_Native(IFWL_Widget *pWidget);\r
85     FWL_ERR                     SetMaximize_Native(IFWL_Widget *pWidget);\r
86     FWL_ERR                     SetMinimize_Native(IFWL_Widget *pWidget);\r
87     FX_BOOL                     CheckMessage_Native();\r
88     FWL_ERR                     DispatchMessage_Native();\r
89     FX_BOOL                     IsIdleMessage_Native();\r
90     FWL_ERR                     Exit_Native(int32_t iExitCode);\r
91     FWL_ERR                     CreateWidgetWithNativeId_Native(IFWL_Widget *pWidget, void *vp);\r
92     IFWL_Widget*        GetWidgetAtPoint(IFWL_Widget *pParent, FX_FLOAT fx, FX_FLOAT fy);\r
93     void                        NotifySizeChanged(IFWL_Widget *pForm, FX_FLOAT fx, FX_FLOAT fy);\r
94     IFWL_Widget*        nextTab(IFWL_Widget *parent, IFWL_Widget *focus, FX_BOOL &bFind);\r
95     int32_t             CountRadioButtonGroup(IFWL_Widget *pFirst);\r
96     IFWL_Widget*        GetSiblingRadioButton(IFWL_Widget *pWidget, FX_BOOL bNext);\r
97     IFWL_Widget*        GetRadioButtonGroupHeader(IFWL_Widget *pRadioButton);\r
98     void                        GetSameGroupRadioButton(IFWL_Widget *pRadioButton, CFX_PtrArray &group);\r
99     IFWL_Widget*    GetDefaultButton(IFWL_Widget *pParent);\r
100     void                        AddRedrawCounts(IFWL_Widget *pWidget);\r
101     void                        ResetRedrawCounts(IFWL_Widget *pWidget);\r
102     IFWL_AdapterWidgetMgr*      GetAdapterWidgetMgr()\r
103     {\r
104         return m_pAdapter;\r
105     }\r
106     CFWL_WidgetMgrDelegate* GetDelegate()\r
107     {\r
108         return m_pDelegate;\r
109     }\r
110     CFWL_WidgetMgrItem*         GetWidgetMgrItem(IFWL_Widget *pWidget);\r
111     FX_BOOL                                     IsThreadEnabled();\r
112     FX_BOOL                                     IsFormDisabled();\r
113     FX_BOOL                     GetAdapterPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);\r
114 protected:\r
115     int32_t                             TravelWidgetMgr(CFWL_WidgetMgrItem *pParent, int32_t *pIndex, CFWL_WidgetMgrItem *pItem, IFWL_Widget **pWidget = NULL);\r
116     FX_BOOL                                     IsAbleNative(IFWL_Widget *pWidget);\r
117     CFX_MapPtrToPtr                     m_mapWidgetItem;\r
118     IFWL_AdapterWidgetMgr  *m_pAdapter;\r
119     CFWL_WidgetMgrDelegate *m_pDelegate;\r
120     friend class CFWL_WidgetMgrDelegate;\r
121     FX_DWORD                            m_dwCapability;\r
122 #if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_)\r
123     CFX_RectF                           m_rtScreen;\r
124 #endif\r
125 };\r
126 class CFWL_WidgetMgrDelegate\r
127 {\r
128 public:\r
129     CFWL_WidgetMgrDelegate(CFWL_WidgetMgr *pWidgetMgr);\r
130     virtual FWL_ERR             OnSetCapability(FX_DWORD dwCapability = FWL_WGTMGR_DisableThread);\r
131     virtual int32_t     OnProcessMessageToForm(CFWL_Message *pMessage);\r
132     virtual     FWL_ERR         OnDrawWidget(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix );\r
133 protected:\r
134     void        DrawChild(IFWL_Widget *pParent, const CFX_RectF &rtClip, CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix );\r
135     CFX_Graphics* DrawWidgetBefore(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix);\r
136     void        DrawWidgetAfter(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, CFX_RectF &rtClip, const CFX_Matrix *pMatrix);\r
137     FX_BOOL IsNeedRepaint(IFWL_Widget *pWidget, CFX_Matrix *pMatrix, const CFX_RectF &rtDirty);\r
138     FX_BOOL bUseOffscreenDirect(IFWL_Widget *pWidget);\r
139 \r
140     CFWL_WidgetMgr *m_pWidgetMgr;\r
141 };\r
142 #endif\r