Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / core / include / fwl_widgetimp.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_WIDGET_IMP_H\r
8 #define _FWL_WIDGET_IMP_H\r
9 class CFWL_NoteTarget;\r
10 class CFWL_NoteThread;\r
11 class CFWL_WidgetImpProperties;\r
12 class CFWL_WidgetMgr;\r
13 class IFWL_Widget;\r
14 class IFWL_ThemeProvider;\r
15 class IFWL_DataProvider;\r
16 class IFWL_WidgetDelegate;\r
17 class CFWL_WidgetImp;\r
18 class CFWL_WidgetImp : public CFWL_Target\r
19 {\r
20 public:\r
21     virtual FWL_ERR             Initialize();\r
22     virtual FWL_ERR             Finalize();\r
23 \r
24     virtual FWL_ERR             GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);\r
25     virtual FWL_ERR             GetGlobalRect(CFX_RectF &rect);\r
26     virtual FWL_ERR             SetWidgetRect(const CFX_RectF &rect);\r
27     virtual     FWL_ERR         GetClientRect(CFX_RectF &rect);\r
28     virtual     IFWL_Widget* GetParent();\r
29     virtual FWL_ERR              SetParent(IFWL_Widget *pParent);\r
30     virtual     IFWL_Widget* GetOwner();\r
31     virtual FWL_ERR              SetOwner(IFWL_Widget *pOwner);\r
32     virtual IFWL_Widget* GetOuter();\r
33     virtual FX_DWORD    GetStyles();\r
34     virtual FWL_ERR             ModifyStyles(FX_DWORD dwStylesAdded, FX_DWORD dwStylesRemoved);\r
35     virtual FX_DWORD    GetStylesEx();\r
36     virtual FWL_ERR             ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);\r
37     virtual FX_DWORD    GetStates();\r
38     virtual FWL_ERR             SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);\r
39     virtual FWL_ERR             SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);\r
40     virtual FX_LPVOID   GetPrivateData(FX_LPVOID module_id);\r
41     virtual     FWL_ERR         Update();\r
42     virtual FWL_ERR             LockUpdate();\r
43     virtual FWL_ERR             UnlockUpdate();\r
44     virtual FX_DWORD    HitTest(FX_FLOAT fx, FX_FLOAT fy);\r
45     virtual     FWL_ERR         TransformTo(IFWL_Widget *pWidget, FX_FLOAT &fx, FX_FLOAT &fy);\r
46     virtual FWL_ERR             TransformTo(IFWL_Widget *pWidget, CFX_RectF &rt);\r
47     virtual FWL_ERR             GetMatrix(CFX_Matrix &matrix, FX_BOOL bGlobal = FALSE);\r
48     virtual FWL_ERR             SetMatrix(const CFX_Matrix &matrix);\r
49     virtual FWL_ERR             DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
50     virtual IFWL_ThemeProvider* GetThemeProvider();\r
51     virtual FWL_ERR                             SetThemeProvider(IFWL_ThemeProvider *pThemeProvider);\r
52     virtual FWL_ERR                             SetDataProvider(IFWL_DataProvider *pDataProvider);\r
53     virtual IFWL_WidgetDelegate*SetDelegate(IFWL_WidgetDelegate *pDelegate);\r
54     virtual     IFWL_NoteThread*        GetOwnerThread() const;\r
55     FWL_ERR                             SetOwnerThread(CFWL_NoteThread *pOwnerThread);\r
56     FWL_ERR                             GetProperties(CFWL_WidgetImpProperties &properties);\r
57     FWL_ERR                             SetProperties(const CFWL_WidgetImpProperties &properties);\r
58     IFWL_Widget*                GetInterface();\r
59     void                                SetInterface(IFWL_Widget *pInterface);\r
60     CFX_SizeF                   GetOffsetFromParent(IFWL_Widget *pParent);\r
61 protected:\r
62     CFWL_WidgetImp(IFWL_Widget *pOuter = NULL);\r
63     CFWL_WidgetImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
64     virtual ~CFWL_WidgetImp();\r
65     FX_BOOL     IsEnabled();\r
66     FX_BOOL     IsVisible();\r
67     FX_BOOL IsActive();\r
68     FX_BOOL IsOverLapper();\r
69     FX_BOOL IsPopup();\r
70     FX_BOOL IsChild();\r
71     FX_BOOL     IsLocked();\r
72     FX_BOOL IsOffscreen();\r
73     FX_BOOL     HasBorder();\r
74     FX_BOOL     HasEdge();\r
75     void                GetEdgeRect(CFX_RectF &rtEdge);\r
76     FX_FLOAT    GetBorderSize(FX_BOOL bCX = TRUE);\r
77     FX_FLOAT    GetEdgeWidth();\r
78     void                GetRelativeRect(CFX_RectF &rect);\r
79     FX_LPVOID   GetThemeCapacity(FX_DWORD dwCapacity);\r
80     IFWL_ThemeProvider* GetAvailableTheme();\r
81     CFWL_WidgetImp*     GetRootOuter();\r
82     CFWL_WidgetImp*     GetSameAncestor(CFWL_WidgetImp *pWidget);\r
83     CFX_SizeF   GetOffsetFromAncestor(CFWL_WidgetImp *pAncestor);\r
84     FX_BOOL             TransformToOuter(FX_FLOAT &fx, FX_FLOAT &fy);\r
85     FX_BOOL             TransformFromOuter(FX_FLOAT &fx, FX_FLOAT &fy);\r
86     CFX_SizeF   CalcTextSize(const CFX_WideString &wsText, IFWL_ThemeProvider *pTheme, FX_BOOL bMultiLine = FALSE, FX_INT32 iLineWidth = -1);\r
87     void                CalcTextRect(const CFX_WideString &wsText, IFWL_ThemeProvider *pTheme, FX_DWORD dwTTOStyles, FX_INT32 iTTOAlign, CFX_RectF &rect);\r
88     void                SetFocus(FX_BOOL bFocus);\r
89     void                SetGrab(FX_BOOL bSet);\r
90     FX_BOOL             GetPopupPos(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);\r
91     FX_BOOL             GetPopupPosMenu(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);\r
92     FX_BOOL             GetPopupPosComboBox(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);\r
93     FX_BOOL             GetPopupPosGeneral(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);\r
94     FX_BOOL             GetScreenSize(FX_FLOAT &fx, FX_FLOAT &fy);\r
95     void                RegisterEventTarget(IFWL_Widget *pEventSource = NULL, FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);\r
96     void                UnregisterEventTarget();\r
97     void                DispatchKeyEvent(CFWL_MsgKey *pNote);\r
98     void                DispatchEvent(CFWL_Event *pEvent);\r
99     void                Repaint(const CFX_RectF *pRect = NULL);\r
100     void                DrawBackground(CFX_Graphics *pGraphics, FX_INT32 iPartBk, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);\r
101     void                DrawBorder(CFX_Graphics *pGraphics, FX_INT32 iPartBorder, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);\r
102     void                DrawEdge(CFX_Graphics *pGraphics, FX_INT32 iPartEdge, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);\r
103     void                NotifyDriver();\r
104 \r
105     FX_BOOL             IsParent(IFWL_Widget *pParent);\r
106     CFWL_WidgetMgr                         *m_pWidgetMgr;\r
107     CFWL_NoteThread                        *m_pOwnerThread;\r
108     CFWL_WidgetImpProperties   *m_pProperties;\r
109     CFX_PrivateData                        *m_pPrivateData;\r
110     IFWL_WidgetDelegate            *m_pDelegate;\r
111     IFWL_WidgetDelegate            *m_pCurDelegate;\r
112     IFWL_Widget                        *m_pOuter;\r
113     IFWL_Widget                            *m_pInterface;\r
114     FX_INT32                                    m_iLock;\r
115     friend class CFWL_WidgetImpDelegate;\r
116     friend void FWL_SetWidgetRect(IFWL_Widget *widget, const CFX_RectF &rect);\r
117     friend void FWL_SetWidgetStates(IFWL_Widget *widget, FX_DWORD dwStates);\r
118     friend void FWL_SetWidgetStyles(IFWL_Widget *widget, FX_DWORD dwStyles);\r
119 };\r
120 class CFWL_WidgetImpDelegate : public CFX_Object\r
121 {\r
122 public:\r
123     CFWL_WidgetImpDelegate();\r
124     virtual FX_INT32    OnProcessMessage(CFWL_Message *pMessage);\r
125     virtual FWL_ERR             OnProcessEvent(CFWL_Event *pEvent);\r
126     virtual FWL_ERR             OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
127 };\r
128 #endif\r