Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / src / fwl / src / core / include / fwl_formimp.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_FORM_IMP_H\r
8 #define _FWL_FORM_IMP_H\r
9 class CFWL_NoteLoop;\r
10 class CFWL_PanelImp;\r
11 class CFWL_WidgetImpProperties;\r
12 class CFWL_WidgetImpDelegate;\r
13 class CFWL_MsgMouse;\r
14 class IFWL_Widget;\r
15 class IFWL_ThemeProvider;\r
16 class CFWL_SysBtn;\r
17 class CFWL_FormImp;\r
18 class CFWL_FormDelegate;\r
19 #define FWL_SYSBUTTONSTATE_Hover                0x0001\r
20 #define FWL_SYSBUTTONSTATE_Pressed              0x0002\r
21 #define FWL_SYSBUTTONSTATE_Disabled             0x0010\r
22 class CFWL_SysBtn\r
23 {\r
24 public:\r
25     CFWL_SysBtn()\r
26     {\r
27         m_rtBtn.Set(0, 0, 0, 0);\r
28         m_dwState = 0;\r
29     }\r
30 \r
31     FX_BOOL IsHover()\r
32     {\r
33         return m_dwState & FWL_SYSBUTTONSTATE_Hover;\r
34     }\r
35     FX_BOOL IsPressed()\r
36     {\r
37         return m_dwState & FWL_SYSBUTTONSTATE_Pressed;\r
38     }\r
39     FX_BOOL IsDisabled()\r
40     {\r
41         return m_dwState & FWL_SYSBUTTONSTATE_Disabled;\r
42     }\r
43     void SetNormal()\r
44     {\r
45         m_dwState &= 0xFFF0;\r
46     }\r
47     void SetPressed()\r
48     {\r
49         SetNormal();\r
50         m_dwState |= FWL_SYSBUTTONSTATE_Pressed;\r
51     }\r
52     void SetHover()\r
53     {\r
54         SetNormal();\r
55         m_dwState |= FWL_SYSBUTTONSTATE_Hover;\r
56     }\r
57     void SetDisabled(FX_BOOL bDisabled)\r
58     {\r
59         bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled;\r
60     }\r
61     int32_t GetPartState()\r
62     {\r
63         return (IsDisabled() ? FWL_PARTSTATE_FRM_Disabled : (m_dwState + 1));\r
64     }\r
65 \r
66     CFX_RectF   m_rtBtn;\r
67     FX_DWORD    m_dwState;\r
68 };\r
69 enum FORM_RESIZETYPE {\r
70     FORM_RESIZETYPE_None = 0,\r
71     FORM_RESIZETYPE_Cap,\r
72     FORM_RESIZETYPE_Left,\r
73     FORM_RESIZETYPE_Top,\r
74     FORM_RESIZETYPE_Right,\r
75     FORM_RESIZETYPE_Bottom,\r
76     FORM_RESIZETYPE_LeftTop,\r
77     FORM_RESIZETYPE_LeftBottom,\r
78     FORM_RESIZETYPE_RightTop,\r
79     FORM_RESIZETYPE_RightBottom\r
80 };\r
81 typedef struct RestoreResizeInfo {\r
82     CFX_PointF  m_ptStart;\r
83     CFX_SizeF   m_szStart;\r
84 } RestoreInfo;\r
85 class CFWL_FormImp : public CFWL_PanelImp\r
86 {\r
87 public:\r
88     CFWL_FormImp(IFWL_Widget *pOuter = NULL);\r
89     CFWL_FormImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
90     virtual ~CFWL_FormImp();\r
91     virtual FWL_ERR                     GetClassName(CFX_WideString &wsClass) const;\r
92     virtual FX_DWORD            GetClassID() const;\r
93     virtual FX_BOOL                     IsInstance(FX_WSTR wsClass) const;\r
94     virtual FWL_ERR                     Initialize();\r
95     virtual FWL_ERR                     Finalize();\r
96 \r
97     virtual FWL_ERR                     GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);\r
98     virtual     FWL_ERR                 GetClientRect(CFX_RectF &rect);\r
99     virtual     FWL_ERR                 Update();\r
100     virtual FX_DWORD            HitTest(FX_FLOAT fx, FX_FLOAT fy);\r
101     virtual FWL_ERR                     DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
102     virtual FWL_FORMSIZE        GetFormSize();\r
103     virtual FWL_ERR                     SetFormSize(FWL_FORMSIZE eFormSize);\r
104     virtual IFWL_Widget*        DoModal();\r
105     virtual IFWL_Widget*        DoModal(FX_DWORD &dwCommandID);\r
106     virtual FWL_ERR                     EndDoModal();\r
107     virtual     FWL_ERR                 SetBorderRegion(CFX_Path *pPath);\r
108     virtual void                        DrawBackground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme);\r
109     CFWL_WidgetImp* GetSubFocus();\r
110     void                        SetSubFocus(CFWL_WidgetImp *pWidget);\r
111     CFX_MapAccelerators&        GetAccelerator();\r
112     void                                        SetAccelerator(CFX_MapAccelerators *pAccelerators);\r
113 protected:\r
114     void                        ShowChildWidget(IFWL_Widget *pParent);\r
115     void                        RemoveSysButtons();\r
116     void                        CalcContentRect(CFX_RectF &rtContent);\r
117     CFWL_SysBtn*        GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy);\r
118     CFWL_SysBtn*        GetSysBtnByState(FX_DWORD dwState);\r
119     CFWL_SysBtn*        GetSysBtnByIndex(int32_t nIndex);\r
120     int32_t             GetSysBtnIndex(CFWL_SysBtn *pBtn);\r
121     FX_FLOAT            GetCaptionHeight();\r
122     void                        DrawCaptionText(CFX_Graphics *pGs, IFWL_ThemeProvider *pTheme, const CFX_Matrix* pMatrix = NULL);\r
123     void                        DrawIconImage(CFX_Graphics *pGs, IFWL_ThemeProvider *pTheme, const CFX_Matrix* pMatrix = NULL);\r
124     void                        GetEdgeRect(CFX_RectF &rtEdge);\r
125     void                        SetWorkAreaRect();\r
126     void                        SetCursor(FX_FLOAT fx, FX_FLOAT fy);\r
127     void                        Layout();\r
128     void                        ReSetSysBtn();\r
129     void                        RegisterForm();\r
130     void                        UnRegisterForm();\r
131     FX_BOOL                     IsDoModal();\r
132     void                        SetThemeData();\r
133     FX_BOOL                     HasIcon();\r
134     void                        UpdateIcon();\r
135     void                        UpdateCaption();\r
136     void            DoWidthLimit(FX_FLOAT &fLeft, FX_FLOAT &fWidth, FX_FLOAT fCurX, FX_FLOAT fSpace, FX_FLOAT fLimitMin, FX_FLOAT fLimitMax, FX_BOOL bLeft);\r
137     void            DoHeightLimit(FX_FLOAT &fTop, FX_FLOAT &fHeight, FX_FLOAT fCurY, FX_FLOAT fSpace, FX_FLOAT fLimitMin, FX_FLOAT fLimitMax, FX_BOOL bTop);\r
138     CFX_MapAccelerators         m_mapAccelerators;\r
139     CFX_RectF                           m_rtRestore;\r
140     CFX_RectF                           m_rtCaptionText;\r
141     CFX_RectF                           m_rtRelative;\r
142     CFX_RectF                           m_rtCaption;\r
143     CFX_RectF                           m_rtIcon;\r
144     CFWL_SysBtn                    *m_pCloseBox;\r
145     CFWL_SysBtn                    *m_pMinBox;\r
146     CFWL_SysBtn                    *m_pMaxBox;\r
147     CFWL_SysBtn                    *m_pCaptionBox;\r
148     CFWL_NoteLoop                  *m_pNoteLoop;\r
149     CFWL_WidgetImp                 *m_pSubFocus;\r
150     RestoreInfo                         m_InfoStart;\r
151     FX_FLOAT                            m_fCXBorder;\r
152     FX_FLOAT                            m_fCYBorder;\r
153     int32_t                             m_iCaptureBtn;\r
154     int32_t                             m_iSysBox;\r
155     int32_t                             m_eResizeType;\r
156     FX_BOOL                                     m_bLButtonDown;\r
157     FX_BOOL                                     m_bMaximized;\r
158     FX_BOOL                                     m_bSetMaximize;\r
159     FX_BOOL                                     m_bCustomizeLayout;\r
160     FWL_FORMSIZE                        m_eFormSize;\r
161     FX_BOOL                                     m_bDoModalFlag;\r
162     FX_FLOAT                            m_fSmallIconSz;\r
163     FX_FLOAT                            m_fBigIconSz;\r
164     CFX_DIBitmap                        *m_pBigIcon;\r
165     CFX_DIBitmap                        *m_pSmallIcon;\r
166     FX_BOOL                                     m_bMouseIn;\r
167     friend class CFWL_FormDelegate;\r
168 };\r
169 class CFWL_FormDelegate : public CFWL_WidgetImpDelegate\r
170 {\r
171 public:\r
172     CFWL_FormDelegate(CFWL_FormImp *pOwner);\r
173     virtual int32_t     OnProcessMessage(CFWL_Message *pMessage);\r
174     virtual FWL_ERR             OnProcessEvent(CFWL_Event *pEvent);\r
175     virtual FWL_ERR             OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
176 protected:\r
177     void        OnLButtonDown(CFWL_MsgMouse *pMsg);\r
178     void        OnLButtonUp(CFWL_MsgMouse *pMsg);\r
179     void        OnMouseMove(CFWL_MsgMouse *pMsg);\r
180     void        OnMouseHover(CFWL_MsgMouse *pMsg);\r
181     void        OnMouseLeave(CFWL_MsgMouse *pMsg);\r
182     void        OnLButtonDblClk(CFWL_MsgMouse *pMsg);\r
183     void        OnWindowMove(CFWL_MsgWindowMove *pMsg);\r
184     void        OnClose(CFWL_MsgClose *pMsg);\r
185     CFWL_FormImp *m_pOwner;\r
186 };\r
187 #endif\r