OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef XFA_FWL_CORE_FWL_FORMIMP_H_ | |
8 #define XFA_FWL_CORE_FWL_FORMIMP_H_ | |
9 | |
10 #include <memory> | |
11 | |
12 #include "xfa/fwl/core/fwl_widgetimp.h" | |
13 #include "xfa/fwl/core/ifwl_form.h" | |
14 | |
15 class CFWL_MsgMouse; | |
16 class CFWL_MsgClose; | |
17 class CFWL_MsgWindowMove; | |
18 class CFWL_NoteLoop; | |
19 class CFWL_WidgetImpProperties; | |
20 class IFWL_Widget; | |
21 class IFWL_ThemeProvider; | |
22 class CFWL_SysBtn; | |
23 class CFWL_FormImp; | |
24 class CFWL_FormImpDelegate; | |
25 | |
26 #define FWL_SYSBUTTONSTATE_Hover 0x0001 | |
27 #define FWL_SYSBUTTONSTATE_Pressed 0x0002 | |
28 #define FWL_SYSBUTTONSTATE_Disabled 0x0010 | |
29 | |
30 class CFWL_SysBtn { | |
31 public: | |
32 CFWL_SysBtn(); | |
33 | |
34 bool IsDisabled() const; | |
35 uint32_t GetPartState() const; | |
36 | |
37 void SetNormal(); | |
38 void SetPressed(); | |
39 void SetHover(); | |
40 void SetDisabled(FX_BOOL bDisabled); | |
41 | |
42 CFX_RectF m_rtBtn; | |
43 uint32_t m_dwState; | |
44 }; | |
45 | |
46 enum FORM_RESIZETYPE { | |
47 FORM_RESIZETYPE_None = 0, | |
48 FORM_RESIZETYPE_Cap, | |
49 }; | |
50 | |
51 typedef struct RestoreResizeInfo { | |
52 RestoreResizeInfo(); | |
53 ~RestoreResizeInfo(); | |
54 | |
55 CFX_PointF m_ptStart; | |
56 CFX_SizeF m_szStart; | |
57 } RestoreInfo; | |
58 | |
59 class CFWL_FormImp : public CFWL_WidgetImp { | |
60 public: | |
61 CFWL_FormImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); | |
62 ~CFWL_FormImp() override; | |
63 | |
64 // CFWL_WidgetImp | |
65 FWL_Error GetClassName(CFX_WideString& wsClass) const override; | |
66 FWL_Type GetClassID() const override; | |
67 FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const override; | |
68 FWL_Error Initialize() override; | |
69 FWL_Error Finalize() override; | |
70 | |
71 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | |
72 FWL_Error GetClientRect(CFX_RectF& rect) override; | |
73 FWL_Error Update() override; | |
74 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | |
75 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | |
76 const CFX_Matrix* pMatrix = nullptr) override; | |
77 | |
78 FWL_FORMSIZE GetFormSize(); | |
79 FWL_Error SetFormSize(FWL_FORMSIZE eFormSize); | |
80 IFWL_Widget* DoModal(); | |
81 IFWL_Widget* DoModal(uint32_t& dwCommandID); | |
82 FWL_Error EndDoModal(); | |
83 FWL_Error SetBorderRegion(CFX_Path* pPath); | |
84 void DrawBackground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); | |
85 CFWL_WidgetImp* GetSubFocus(); | |
86 void SetSubFocus(CFWL_WidgetImp* pWidget); | |
87 | |
88 protected: | |
89 void ShowChildWidget(IFWL_Widget* pParent); | |
90 void RemoveSysButtons(); | |
91 void CalcContentRect(CFX_RectF& rtContent); | |
92 CFWL_SysBtn* GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy); | |
93 CFWL_SysBtn* GetSysBtnByState(uint32_t dwState); | |
94 CFWL_SysBtn* GetSysBtnByIndex(int32_t nIndex); | |
95 int32_t GetSysBtnIndex(CFWL_SysBtn* pBtn); | |
96 FX_FLOAT GetCaptionHeight(); | |
97 void DrawCaptionText(CFX_Graphics* pGs, | |
98 IFWL_ThemeProvider* pTheme, | |
99 const CFX_Matrix* pMatrix = nullptr); | |
100 void DrawIconImage(CFX_Graphics* pGs, | |
101 IFWL_ThemeProvider* pTheme, | |
102 const CFX_Matrix* pMatrix = nullptr); | |
103 void GetEdgeRect(CFX_RectF& rtEdge); | |
104 void SetWorkAreaRect(); | |
105 void SetCursor(FX_FLOAT fx, FX_FLOAT fy); | |
106 void Layout(); | |
107 void ReSetSysBtn(); | |
108 void RegisterForm(); | |
109 void UnRegisterForm(); | |
110 FX_BOOL IsDoModal(); | |
111 void SetThemeData(); | |
112 FX_BOOL HasIcon(); | |
113 void UpdateIcon(); | |
114 void UpdateCaption(); | |
115 void DoWidthLimit(FX_FLOAT& fLeft, | |
116 FX_FLOAT& fWidth, | |
117 FX_FLOAT fCurX, | |
118 FX_FLOAT fSpace, | |
119 FX_FLOAT fLimitMin, | |
120 FX_FLOAT fLimitMax, | |
121 FX_BOOL bLeft); | |
122 void DoHeightLimit(FX_FLOAT& fTop, | |
123 FX_FLOAT& fHeight, | |
124 FX_FLOAT fCurY, | |
125 FX_FLOAT fSpace, | |
126 FX_FLOAT fLimitMin, | |
127 FX_FLOAT fLimitMax, | |
128 FX_BOOL bTop); | |
129 | |
130 CFX_RectF m_rtRestore; | |
131 CFX_RectF m_rtCaptionText; | |
132 CFX_RectF m_rtRelative; | |
133 CFX_RectF m_rtCaption; | |
134 CFX_RectF m_rtIcon; | |
135 CFWL_SysBtn* m_pCloseBox; | |
136 CFWL_SysBtn* m_pMinBox; | |
137 CFWL_SysBtn* m_pMaxBox; | |
138 CFWL_SysBtn* m_pCaptionBox; | |
139 std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop; | |
140 CFWL_WidgetImp* m_pSubFocus; | |
141 RestoreInfo m_InfoStart; | |
142 FX_FLOAT m_fCXBorder; | |
143 FX_FLOAT m_fCYBorder; | |
144 int32_t m_iCaptureBtn; | |
145 int32_t m_iSysBox; | |
146 int32_t m_eResizeType; | |
147 FX_BOOL m_bLButtonDown; | |
148 bool m_bMaximized; | |
149 FX_BOOL m_bSetMaximize; | |
150 FX_BOOL m_bCustomizeLayout; | |
151 FWL_FORMSIZE m_eFormSize; | |
152 FX_BOOL m_bDoModalFlag; | |
153 FX_FLOAT m_fSmallIconSz; | |
154 FX_FLOAT m_fBigIconSz; | |
155 CFX_DIBitmap* m_pBigIcon; | |
156 CFX_DIBitmap* m_pSmallIcon; | |
157 FX_BOOL m_bMouseIn; | |
158 friend class CFWL_FormImpDelegate; | |
159 }; | |
160 | |
161 class CFWL_FormImpDelegate : public CFWL_WidgetImpDelegate { | |
162 public: | |
163 CFWL_FormImpDelegate(CFWL_FormImp* pOwner); | |
164 void OnProcessMessage(CFWL_Message* pMessage) override; | |
165 void OnProcessEvent(CFWL_Event* pEvent) override; | |
166 void OnDrawWidget(CFX_Graphics* pGraphics, | |
167 const CFX_Matrix* pMatrix = nullptr) override; | |
168 | |
169 protected: | |
170 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
171 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
172 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
173 void OnMouseHover(CFWL_MsgMouse* pMsg); | |
174 void OnMouseLeave(CFWL_MsgMouse* pMsg); | |
175 void OnLButtonDblClk(CFWL_MsgMouse* pMsg); | |
176 void OnWindowMove(CFWL_MsgWindowMove* pMsg); | |
177 void OnClose(CFWL_MsgClose* pMsg); | |
178 CFWL_FormImp* m_pOwner; | |
179 }; | |
180 | |
181 #endif // XFA_FWL_CORE_FWL_FORMIMP_H_ | |
OLD | NEW |