Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / include / fwl / lightwidget / 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_LIGHT_H\r
8 #define _FWL_WIDGET_LIGHT_H\r
9 class CFWL_WidgetMgr;\r
10 class CFWL_Message;\r
11 class CFWL_Event;\r
12 class IFWL_WidgetDelegate;\r
13 class IFWL_Widget;\r
14 class CFWL_Widget;\r
15 class CFWL_WidgetDelegate;\r
16 class CFWL_WidgetProperties : public CFX_Object\r
17 {\r
18 public:\r
19     CFWL_WidgetProperties()\r
20     {\r
21         m_ctmOnParent.Reset();\r
22         m_rtWidget.Set(0, 0, 0, 0);\r
23         m_dwStyles              = FWL_WGTSTYLE_Child;\r
24         m_dwStyleExes   = 0;\r
25         m_dwStates              = 0;\r
26         m_pParent               = NULL;\r
27         m_pOwner                = NULL;\r
28     }\r
29     CFX_WideString              m_wsWindowclass;\r
30     CFX_Matrix                  m_ctmOnParent;\r
31     CFX_RectF                   m_rtWidget;\r
32     FX_DWORD                    m_dwStyles;\r
33     FX_DWORD                    m_dwStyleExes;\r
34     FX_DWORD                    m_dwStates;\r
35     CFWL_Widget                 *m_pParent;\r
36     CFWL_Widget                 *m_pOwner;\r
37 };\r
38 class CFWL_Widget : public CFX_Object\r
39 {\r
40 public:\r
41     IFWL_Widget*        GetWidget();\r
42     FX_DWORD            Release();\r
43     CFWL_Widget*        Retain();\r
44     FX_DWORD            GetRefCount() const;\r
45     FWL_ERR                     GetClassName(CFX_WideString &wsClass) const;\r
46     FX_DWORD            GetClassID() const;\r
47     virtual FX_BOOL     IsInstance(FX_WSTR wsClass) const;\r
48 protected:\r
49     FWL_ERR                     Initialize(const CFWL_WidgetProperties *pProperties = NULL);\r
50 public:\r
51     FWL_ERR                     GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);\r
52     FWL_ERR                     GetGlobalRect(CFX_RectF &rect);\r
53     FWL_ERR                     SetWidgetRect(const CFX_RectF &rect);\r
54     FWL_ERR                     GetClientRect(CFX_RectF &rtClient);\r
55     CFWL_Widget*        GetParent();\r
56     FWL_ERR                     SetParent(CFWL_Widget *pParent);\r
57     CFWL_Widget*        GetOwner();\r
58     FWL_ERR                     SetOwner(CFWL_Widget *pOwner);\r
59     FX_DWORD            GetStyles();\r
60     FWL_ERR                     ModifyStyles(FX_DWORD dwStylesAdded, FX_DWORD dwStylesRemoved);\r
61     FX_DWORD            GetStylesEx();\r
62     FWL_ERR                     ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);\r
63     FX_DWORD            GetStates();\r
64     FWL_ERR                     SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);\r
65     FWL_ERR                     SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);\r
66     FX_LPVOID           GetPrivateData(FX_LPVOID module_id);\r
67     FWL_ERR                     Update();\r
68     FWL_ERR                     LockUpdate();\r
69     FWL_ERR                     UnlockUpdate();\r
70     FX_DWORD            HitTest(FX_FLOAT fx, FX_FLOAT fy);\r
71     FWL_ERR                     TransformTo(CFWL_Widget *pWidget, FX_FLOAT &fx, FX_FLOAT &fy);\r
72     FWL_ERR                     TransformTo(CFWL_Widget *pWidget, CFX_RectF &rt);\r
73     FWL_ERR                     GetMatrix(CFX_Matrix &matrix, FX_BOOL bGlobal = FALSE);\r
74     FWL_ERR                     SetMatrix(const CFX_Matrix &matrix);\r
75     FWL_ERR                     DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
76     FWL_ERR                     GetProperties(CFWL_WidgetProperties &properties);\r
77     FWL_ERR                     SetProperties(const CFWL_WidgetProperties &properties);\r
78     IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);\r
79     FWL_ERR                     Repaint(const CFX_RectF *pRect = NULL);\r
80     FWL_ERR                     SetFocus(FX_BOOL bFocus);\r
81     FWL_ERR                     SetGrab(FX_BOOL bSet);\r
82     CFWL_Widget();\r
83     virtual ~CFWL_Widget();\r
84     void                RegisterEventTarget(CFWL_Widget *pEventSource = NULL, FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);\r
85     void                DispatchEvent(CFWL_Event *pEvent);\r
86     CFX_SizeF   CalcTextSize(const CFX_WideString &wsText, FX_BOOL bMultiLine = FALSE, FX_INT32 iLineWidth = -1);\r
87     IFWL_Widget                 *m_pImp;\r
88     IFWL_WidgetDelegate *m_pDelegate;\r
89     CFWL_WidgetMgr              *m_pWidgetMgr;\r
90     CFWL_WidgetProperties *m_pProperties;\r
91 };\r
92 class CFWL_WidgetDelegate : public CFX_Object, public IFWL_WidgetDelegate\r
93 {\r
94 public:\r
95     CFWL_WidgetDelegate();\r
96     virtual ~CFWL_WidgetDelegate();\r
97     virtual FX_INT32    OnProcessMessage(CFWL_Message *pMessage);\r
98     virtual FWL_ERR             OnProcessEvent(CFWL_Event *pEvent);\r
99     virtual FWL_ERR             OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
100 };\r
101 #endif\r