Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / include / fwl / core / fwl_widget.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_H\r
8 #define _FWL_WIDGET_H\r
9 class IFWL_Target;\r
10 class IFWL_ThemeProvider;\r
11 class CFWL_WidgetImpProperties;\r
12 class IFWL_DataProvider;\r
13 class IFWL_Widget;\r
14 class IFWL_WidgetDelegate;\r
15 class IFWL_Custom;\r
16 class IFWL_Proxy;\r
17 class IFWL_Form;\r
18 class IFWL_DataProvider\r
19 {\r
20 public:\r
21     virtual FWL_ERR             GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption) = 0;\r
22 };\r
23 class IFWL_Widget : public IFWL_Target\r
24 {\r
25 public:\r
26     FWL_ERR                     GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);\r
27     FWL_ERR                     GetGlobalRect(CFX_RectF &rect);\r
28     FWL_ERR                     SetWidgetRect(const CFX_RectF &rect);\r
29     FWL_ERR                     GetClientRect(CFX_RectF &rect);\r
30     IFWL_Widget*        GetParent();\r
31     FWL_ERR                     SetParent(IFWL_Widget *pParent);\r
32     IFWL_Widget*        GetOwner();\r
33     FWL_ERR                     SetOwner(IFWL_Widget *pOwner);\r
34     IFWL_Widget*        GetOuter();\r
35     FX_DWORD            GetStyles();\r
36     FWL_ERR                     ModifyStyles(FX_DWORD dwStylesAdded, FX_DWORD dwStylesRemoved);\r
37     FX_DWORD            GetStylesEx();\r
38     FWL_ERR                     ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);\r
39     FX_DWORD            GetStates();\r
40     FWL_ERR                     SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);\r
41     FWL_ERR                     SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);\r
42     FX_LPVOID           GetPrivateData(FX_LPVOID module_id);\r
43     FWL_ERR                     Update();\r
44     FWL_ERR                     LockUpdate();\r
45     FWL_ERR                     UnlockUpdate();\r
46     FX_DWORD            HitTest(FX_FLOAT fx, FX_FLOAT fy);\r
47     FWL_ERR                     TransformTo(IFWL_Widget *pWidget, FX_FLOAT &fx, FX_FLOAT &fy);\r
48     FWL_ERR                     TransformTo(IFWL_Widget *pWidget, CFX_RectF &rt);\r
49     FWL_ERR                     GetMatrix(CFX_Matrix &matrix, FX_BOOL bGlobal = FALSE);\r
50     FWL_ERR                     SetMatrix(const CFX_Matrix &matrix);\r
51     FWL_ERR                     DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
52     IFWL_ThemeProvider*         GetThemeProvider();\r
53     FWL_ERR                                     SetThemeProvider(IFWL_ThemeProvider *pThemeProvider);\r
54     FWL_ERR                                     SetDataProvider(IFWL_DataProvider *pDataProvider);\r
55     IFWL_WidgetDelegate*        SetDelegate(IFWL_WidgetDelegate *pDelegate);\r
56     IFWL_NoteThread*            GetOwnerThread() const;\r
57     CFX_SizeF                           GetOffsetFromParent(IFWL_Widget *pParent);\r
58 };\r
59 class IFWL_WidgetDelegate\r
60 {\r
61 public:\r
62     virtual int32_t     OnProcessMessage(CFWL_Message *pMessage) = 0;\r
63     virtual FWL_ERR             OnProcessEvent(CFWL_Event *pEvent) = 0;\r
64     virtual FWL_ERR             OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL) = 0;\r
65 };\r
66 class CFWL_WidgetImpProperties\r
67 {\r
68 public:\r
69     CFWL_WidgetImpProperties()\r
70     {\r
71         m_ctmOnParent.Reset();\r
72         m_rtWidget.Set(0, 0, 0, 0);\r
73         m_dwStyles              = FWL_WGTSTYLE_Child;\r
74         m_dwStyleExes   = 0;\r
75         m_dwStates              = 0;\r
76         m_pThemeProvider = NULL;\r
77         m_pDataProvider = NULL;\r
78         m_pParent               = NULL;\r
79         m_pOwner                = NULL;\r
80     }\r
81     CFX_Matrix                                  m_ctmOnParent;\r
82     CFX_RectF                                   m_rtWidget;\r
83     FX_DWORD                                    m_dwStyles;\r
84     FX_DWORD                                    m_dwStyleExes;\r
85     FX_DWORD                                    m_dwStates;\r
86     IFWL_ThemeProvider             *m_pThemeProvider;\r
87     IFWL_DataProvider              *m_pDataProvider;\r
88     IFWL_Widget                            *m_pParent;\r
89     IFWL_Widget                            *m_pOwner;\r
90 };\r
91 class IFWL_Custom : public IFWL_Widget\r
92 {\r
93 public:\r
94     static IFWL_Custom* Create();\r
95 \r
96     FWL_ERR             Initialize(IFWL_Widget *pOuter = NULL);\r
97     FWL_ERR             Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
98     FWL_ERR             SetProxy(IFWL_Proxy *pProxy);\r
99 protected:\r
100     IFWL_Custom();\r
101     virtual ~IFWL_Custom();\r
102 };\r
103 class IFWL_Proxy\r
104 {\r
105 public:\r
106     virtual     FWL_ERR         GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE) = 0;\r
107     virtual     FWL_ERR         Update() = 0;\r
108 };\r
109 #define FWL_ACCEL_Control       (1L << 0)\r
110 #define FWL_ACCEL_Alt           (1L << 1)\r
111 #define FWL_ACCEL_Shift         (1L << 2)\r
112 #define FWL_ACCEL_VirtKey       (1L << 3)\r
113 typedef struct _FWL_ACCEL {\r
114     FX_DWORD dwKey;\r
115     FX_DWORD dwCmd;\r
116 } FWL_ACCEL;\r
117 typedef CFX_MapPtrTemplate <FX_DWORD, FX_DWORD> CFX_MapAccelerators;\r
118 FWL_ERR FWL_Accelerator_SetApp(CFX_MapAccelerators *pMapAccel);\r
119 FWL_ERR FWL_Accelerator_SetThread(CFX_MapAccelerators *pMapAccel);\r
120 FWL_ERR FWL_Accelerator_SetForm(IFWL_Form *pFrom, CFX_MapAccelerators *pMapAccel);\r
121 FWL_ERR FWL_EnabelWidget(IFWL_Widget *widget, FX_BOOL bEnable);\r
122 #endif\r