Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / include / fwl / core / fwl_note.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_NOTE_H\r
8 #define _FWL_NOTE_H\r
9 class IFWL_Target;\r
10 class IFWL_Widget;\r
11 class IFWL_NoteThread;\r
12 class IFWL_ThemeProvider;\r
13 class CFWL_Note;\r
14 class CFWL_Message;\r
15 class CFWL_MsgActivate;\r
16 class CFWL_MsgDeactivate;\r
17 class CFWL_MsgMouse;\r
18 class CFWL_MsgMouseWheel;\r
19 class CFWL_MsgKey;\r
20 class CFWL_MsgSetFocus;\r
21 class CFWL_MsgKillFocus;\r
22 class CFWL_MsgCursor;\r
23 class CFWL_MsgSize;\r
24 class CFWL_MsgWindowMove;\r
25 class CFWL_MsgDropFiles;\r
26 class CFWL_MsgTaskClicked;\r
27 class CFWL_MsgClose;\r
28 class CFWL_MsgWindowWillMove;\r
29 class CFWL_Event;\r
30 class CFWL_EvtMouse;\r
31 class CFWL_EvtMouseWheel;\r
32 class CFWL_EvtKey;\r
33 class CFWL_EvtSetFocus;\r
34 class CFWL_EvtKillFocus;\r
35 class CFWL_EvtDraw;\r
36 class CFWL_EvtClick;\r
37 class CFWL_EvtScroll;\r
38 class CFWL_EvtClose;\r
39 class CFWL_EvtContextMenu;\r
40 class CFWL_EvtMenuCommand;\r
41 class CFWL_EvtSizeChanged;\r
42 class CFWL_EvtIdle;\r
43 class IFWL_NoteDriver;\r
44 class IFWL_NoteLoop;\r
45 #define FWL_MSG_Activate                                        L"FWL_MESSAGE_Activate"\r
46 #define FWL_MSG_Deactivate                                      L"FWL_MESSAGE_Deactivate"\r
47 #define FWL_MSG_SetFocus                                        L"FWL_MESSAGE_SetFocus"\r
48 #define FWL_MSG_KillFocus                                       L"FWL_MESSAGE_KillFocus"\r
49 #define FWL_MSG_Mouse                                           L"FWL_MESSAGE_Mouse"\r
50 #define FWL_MSG_MouseWheel                                      L"FWL_MESSAGE_MouseWheel"\r
51 #define FWL_MSG_Key                                                     L"FWL_MESSAGE_Key"\r
52 #define FWL_MSG_Cursor                                          L"FWL_MESSAGE_Cursor"\r
53 #define FWL_MSG_Size                                            L"FWL_MESSAGE_Size"\r
54 #define FWL_MSG_WindowMove                                      L"FWL_MESSAGE_WindowMove"\r
55 #define FWL_MSG_DropFiles                                       L"FWL_MESSAGE_DropFiles"\r
56 #define FWL_MSG_TaskClicked                                     L"FWL_MESSAGE_TaskClicked"\r
57 #define FWL_MSG_Close                                           L"FWL_MESSAGE_Close"\r
58 #define FWL_MSG_Post                                            L"FWL_MESSAGE_Post"\r
59 #define FWL_MSG_WindowWillMove                          L"FWL_MESSAGE_WindowWillMove"\r
60 #define FWL_MSGHASH_Activate                            2410369469\r
61 #define FWL_MSGHASH_Deactivate                          1184214790\r
62 #define FWL_MSGHASH_SetFocus                            4174512504\r
63 #define FWL_MSGHASH_KillFocus                           1557903832\r
64 #define FWL_MSGHASH_Mouse                                       706128309\r
65 #define FWL_MSGHASH_MouseWheel                          893703466\r
66 #define FWL_MSGHASH_Key                                         3751372405\r
67 #define FWL_MSGHASH_Cursor                                      3182626218\r
68 #define FWL_MSGHASH_Size                                        160077735\r
69 #define FWL_MSGHASH_WindowMove                          1032269377\r
70 #define FWL_MSGHASH_DropFiles                           2004165236\r
71 #define FWL_MSGHASH_TaskClicked                         3128231086\r
72 #define FWL_MSGHASH_Close                                       2977563906\r
73 #define FWL_MSGHASH_Post                                        1969633074\r
74 #define FWL_MSGHASH_WindowWillMove                      2229175763\r
75 #define FWL_EVT_Mouse                                           L"FWL_EVENT_Mouse"\r
76 #define FWL_EVT_MouseWheel                                      L"FWL_EVENT_MouseWheel"\r
77 #define FWL_EVT_Key                                                     L"FWL_EVENT_Key"\r
78 #define FWL_EVT_SetFocus                                        L"FWL_EVENT_SetFocus"\r
79 #define FWL_EVT_KillFocus                                       L"FWL_EVENT_KillFocus"\r
80 #define FWL_EVT_Click                                           L"FWL_EVENT_Click"\r
81 #define FWL_EVT_Draw                                            L"FWL_EVENT_Draw"\r
82 #define FWL_EVT_Scroll                                          L"FWL_EVENT_Scroll"\r
83 #define FWL_EVT_Close                                           L"FWL_EVENT_Close"\r
84 #define FWL_EVT_ContextMenu                                     L"FWL_EVENT_ContextMenu"\r
85 #define FWL_EVT_MenuCommand                                     L"FWL_EVENT_MenuCommand"\r
86 #define FWL_EVT_SizeChanged                                     L"FWL_EVENT_SizeChanged"\r
87 #define FWL_EVTHASH_Mouse                                       1765258002\r
88 #define FWL_EVTHASH_MouseWheel                          3907114407\r
89 #define FWL_EVTHASH_Key                                         2408354450\r
90 #define FWL_EVTHASH_SetFocus                            3909721269\r
91 #define FWL_EVTHASH_KillFocus                           1779363253\r
92 #define FWL_EVTHASH_Draw                                        2430713303\r
93 #define FWL_EVTHASH_Click                                       4026328783\r
94 #define FWL_EVTHASH_Scroll                                      2965158968\r
95 #define FWL_EVTHASH_Close                                       4036693599\r
96 #define FWL_EVTHASH_ContextMenu                         2717307715\r
97 #define FWL_EVTHASH_MenuCommand                         497763741\r
98 #define FWL_EVTHASH_SizeChanged                         3083958510\r
99 #define FWL_EVTHASH_Idle                                        839546759\r
100 #define FWL_MSGMOUSECMD_LButtonDown                     1\r
101 #define FWL_MSGMOUSECMD_LButtonUp                       2\r
102 #define FWL_MSGMOUSECMD_LButtonDblClk           3\r
103 #define FWL_MSGMOUSECMD_RButtonDown                     4\r
104 #define FWL_MSGMOUSECMD_RButtonUp                       5\r
105 #define FWL_MSGMOUSECMD_RButtonDblClk           6\r
106 #define FWL_MSGMOUSECMD_MButtonDown                     7\r
107 #define FWL_MSGMOUSECMD_MButtonUp                       8\r
108 #define FWL_MSGMOUSECMD_MButtonDblClk           9\r
109 #define FWL_MSGMOUSECMD_MouseMove                       10\r
110 #define FWL_MSGMOUSECMD_MouseEnter                      11\r
111 #define FWL_MSGMOUSECMD_MouseLeave                      12\r
112 #define FWL_MSGMOUSECMD_MouseHover                      13\r
113 #define FWL_MSGKEYCMD_KeyDown                           1\r
114 #define FWL_MSGKEYCMD_KeyUp                                     2\r
115 #define FWL_MSGKEYCMD_Char                                      3\r
116 #define FWL_KEYFLAG_Ctrl                                        (1 << 0)\r
117 #define FWL_KEYFLAG_Alt                                         (1 << 1)\r
118 #define FWL_KEYFLAG_Shift                                       (1 << 2)\r
119 #define FWL_KEYFLAG_Command                                     (1 << 3)\r
120 #define FWL_KEYFLAG_LButton                                     (1 << 4)\r
121 #define FWL_KEYFLAG_RButton                                     (1 << 5)\r
122 #define FWL_KEYFLAG_MButton                                     (1 << 6)\r
123 class CFWL_Note\r
124 {\r
125 public:\r
126     virtual FX_DWORD            Release()\r
127     {\r
128         m_dwRefCount --;\r
129         FX_DWORD dwRefCount = m_dwRefCount;\r
130         if (!m_dwRefCount) {\r
131             delete this;\r
132         }\r
133         return dwRefCount;\r
134     }\r
135     virtual IFWL_Target*        Retain()\r
136     {\r
137         m_dwRefCount ++;\r
138         return (IFWL_Target*)this;\r
139     }\r
140     virtual FWL_ERR                     GetClassName(CFX_WideString &wsClass) const\r
141     {\r
142         wsClass = L"CFWL_Note";\r
143         return FWL_ERR_Succeeded;\r
144     }\r
145     virtual FX_DWORD            GetClassID() const\r
146     {\r
147         return 0;\r
148     }\r
149     virtual FX_BOOL                     IsInstance(FX_WSTR wsClass) const\r
150     {\r
151         return TRUE;\r
152     }\r
153     virtual     CFWL_Note*              Clone()\r
154     {\r
155         return NULL;\r
156     }\r
157     FX_BOOL                                     IsEvent() const\r
158     {\r
159         return m_bIsEvent;\r
160     }\r
161     IFWL_Widget *m_pSrcTarget;\r
162     IFWL_Widget *m_pDstTarget;\r
163 protected:\r
164     CFWL_Note(FX_BOOL bIsEvent)\r
165         : m_pSrcTarget(NULL)\r
166         , m_pDstTarget(NULL)\r
167         , m_dwRefCount(1)\r
168         , m_bIsEvent(bIsEvent)\r
169         , m_dwExtend(0)\r
170     {\r
171     }\r
172     virtual ~CFWL_Note() {}\r
173     virtual FX_BOOL                     Initialize()\r
174     {\r
175         return TRUE;\r
176     }\r
177     virtual int32_t             Finalize()\r
178     {\r
179         return 0;\r
180     }\r
181     FX_DWORD            m_dwRefCount;\r
182     FX_BOOL                     m_bIsEvent;\r
183 public:\r
184     FX_DWORD        m_dwExtend;\r
185 };\r
186 class CFWL_Message : public CFWL_Note\r
187 {\r
188 public:\r
189     CFWL_Message() : CFWL_Note(FALSE) {}\r
190     virtual ~CFWL_Message() {}\r
191     virtual CFWL_Event* CloneToEvent()\r
192     {\r
193         return NULL;\r
194     }\r
195 };\r
196 #define BEGIN_FWL_MESSAGE_DEF(classname, msghashcode) \\r
197     class classname : public CFWL_Message \\r
198     { \\r
199     public: \\r
200         classname() : CFWL_Message() {} \\r
201         virtual CFWL_Note*      Clone() {return FX_NEW classname(*this);} \\r
202         virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const {wsClass = L" ## classname ## "; return FWL_ERR_Succeeded;} \\r
203         virtual FX_DWORD        GetClassID() const {return msghashcode;} \\r
204         virtual CFWL_Event* CloneToEvent() {classname *pEvent = FX_NEW classname; pEvent->m_bIsEvent = TRUE; return (CFWL_Event*)pEvent;}\r
205 #define END_FWL_MESSAGE_DEF \\r
206     };\r
207 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, FWL_MSGHASH_Activate)\r
208 END_FWL_MESSAGE_DEF\r
209 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, FWL_MSGHASH_Deactivate)\r
210 END_FWL_MESSAGE_DEF\r
211 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, FWL_MSGHASH_Mouse)\r
212 FX_FLOAT        m_fx;\r
213 FX_FLOAT        m_fy;\r
214 FX_DWORD        m_dwFlags;\r
215 FX_DWORD        m_dwCmd;\r
216 END_FWL_MESSAGE_DEF\r
217 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, FWL_MSGHASH_MouseWheel)\r
218 FX_FLOAT        m_fx;\r
219 FX_FLOAT        m_fy;\r
220 FX_FLOAT        m_fDeltaX;\r
221 FX_FLOAT        m_fDeltaY;\r
222 FX_DWORD        m_dwFlags;\r
223 END_FWL_MESSAGE_DEF\r
224 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, FWL_MSGHASH_SetFocus)\r
225 IFWL_Widget *m_pKillFocus;\r
226 END_FWL_MESSAGE_DEF\r
227 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, FWL_MSGHASH_KillFocus)\r
228 IFWL_Widget *m_pSetFocus;\r
229 END_FWL_MESSAGE_DEF\r
230 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, FWL_MSGHASH_Key)\r
231 FX_DWORD        m_dwKeyCode;\r
232 FX_DWORD        m_dwFlags;\r
233 FX_DWORD        m_dwCmd;\r
234 END_FWL_MESSAGE_DEF\r
235 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, FWL_MSGHASH_Cursor)\r
236 END_FWL_MESSAGE_DEF\r
237 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, FWL_MSGHASH_Size)\r
238 int32_t m_iWidth;\r
239 int32_t m_iHeight;\r
240 END_FWL_MESSAGE_DEF\r
241 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, FWL_MSGHASH_WindowMove)\r
242 FX_FLOAT        m_fx;\r
243 FX_FLOAT        m_fy;\r
244 END_FWL_MESSAGE_DEF\r
245 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, FWL_MSGHASH_DropFiles)\r
246 CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy)\r
247 {\r
248     m_pDstTarget = copy.m_pDstTarget;\r
249     m_pSrcTarget = copy.m_pSrcTarget;\r
250     m_fx = copy.m_fx;\r
251     m_fy = copy.m_fy;\r
252     m_files.Append(copy.m_files);\r
253 }\r
254 FX_FLOAT        m_fx;\r
255 FX_FLOAT        m_fy;\r
256 CFX_WideStringArray     m_files;\r
257 END_FWL_MESSAGE_DEF\r
258 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, FWL_MSGHASH_TaskClicked)\r
259 FX_FLOAT        m_fx;\r
260 FX_FLOAT        m_fy;\r
261 END_FWL_MESSAGE_DEF\r
262 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, FWL_MSGHASH_Close)\r
263 END_FWL_MESSAGE_DEF\r
264 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, FWL_MSGHASH_WindowWillMove)\r
265 END_FWL_MESSAGE_DEF\r
266 class CFWL_Event : public CFWL_Note\r
267 {\r
268 public:\r
269     CFWL_Event() : CFWL_Note(TRUE) {}\r
270     virtual ~CFWL_Event() {}\r
271 };\r
272 #define BEGIN_FWL_EVENT_DEF(classname, eventhashcode)   \\r
273     class classname : public CFWL_Event \\r
274     { \\r
275     public: \\r
276         classname() : CFWL_Event() {} \\r
277         virtual FWL_ERR         GetClassName(CFX_WideString &wsClass) const {wsClass = L" ## classname ## "; return FWL_ERR_Succeeded;} \\r
278         virtual FX_DWORD        GetClassID() const {return eventhashcode;}\r
279 #define END_FWL_EVENT_DEF \\r
280     };\r
281 BEGIN_FWL_EVENT_DEF(CFWL_EvtMouse, FWL_EVTHASH_Mouse)\r
282 FX_FLOAT        m_fx;\r
283 FX_FLOAT        m_fy;\r
284 FX_DWORD        m_dwFlags;\r
285 FX_DWORD        m_dwCmd;\r
286 END_FWL_EVENT_DEF\r
287 BEGIN_FWL_EVENT_DEF(CFWL_EvtMouseWheel, FWL_EVTHASH_MouseWheel)\r
288 FX_FLOAT        m_fx;\r
289 FX_FLOAT        m_fy;\r
290 FX_FLOAT        m_fDeltaX;\r
291 FX_FLOAT        m_fDeltaY;\r
292 FX_DWORD        m_dwFlags;\r
293 END_FWL_EVENT_DEF\r
294 BEGIN_FWL_EVENT_DEF(CFWL_EvtKey, FWL_EVTHASH_Key)\r
295 FX_DWORD        m_dwKeyCode;\r
296 FX_DWORD        m_dwFlags;\r
297 FX_DWORD        m_dwCmd;\r
298 END_FWL_EVENT_DEF\r
299 BEGIN_FWL_EVENT_DEF(CFWL_EvtSetFocus, FWL_EVTHASH_SetFocus)\r
300 IFWL_Widget *m_pSetFocus;\r
301 END_FWL_EVENT_DEF\r
302 BEGIN_FWL_EVENT_DEF(CFWL_EvtKillFocus, FWL_EVTHASH_KillFocus)\r
303 IFWL_Widget *m_pKillFocus;\r
304 END_FWL_EVENT_DEF\r
305 BEGIN_FWL_EVENT_DEF(CFWL_EvtDraw, FWL_EVTHASH_Draw)\r
306 CFX_Graphics    *m_pGraphics;\r
307 IFWL_Widget             *m_pWidget;\r
308 END_FWL_EVENT_DEF\r
309 BEGIN_FWL_EVENT_DEF(CFWL_EvtClick, FWL_EVTHASH_Click)\r
310 END_FWL_EVENT_DEF\r
311 BEGIN_FWL_EVENT_DEF(CFWL_EvtScroll, FWL_EVTHASH_Scroll)\r
312 FX_DWORD m_iScrollCode;\r
313 FX_FLOAT m_fPos;\r
314 FX_BOOL *m_pRet;\r
315 END_FWL_EVENT_DEF\r
316 BEGIN_FWL_EVENT_DEF(CFWL_EvtClose, FWL_EVTHASH_Close)\r
317 END_FWL_EVENT_DEF\r
318 BEGIN_FWL_EVENT_DEF(CFWL_EvtContextMenu, FWL_EVTHASH_ContextMenu)\r
319 FX_FLOAT   m_fPosX;\r
320 FX_FLOAT   m_fPosY;\r
321 IFWL_Widget *m_pOwner;\r
322 END_FWL_EVENT_DEF\r
323 BEGIN_FWL_EVENT_DEF(CFWL_EvtMenuCommand, FWL_EVTHASH_MenuCommand)\r
324 int32_t m_iCommand;\r
325 FX_LPVOID m_pData;\r
326 END_FWL_EVENT_DEF\r
327 BEGIN_FWL_EVENT_DEF(CFWL_EvtSizeChanged, FWL_EVTHASH_SizeChanged)\r
328 IFWL_Widget *m_pWidget;\r
329 CFX_RectF       m_rtOld;\r
330 CFX_RectF       m_rtNew;\r
331 END_FWL_MESSAGE_DEF\r
332 BEGIN_FWL_EVENT_DEF(CFWL_EvtIdle, FWL_EVTHASH_Idle)\r
333 END_FWL_EVENT_DEF\r
334 typedef enum {\r
335     FWL_EVENT_MOUSE_MASK                        = 1 << 0,\r
336     FWL_EVENT_MOUSEWHEEL_MASK           = 1 << 1,\r
337     FWL_EVENT_KEY_MASK                          = 1 << 2,\r
338     FWL_EVENT_FOCUSCHANGED_MASK         = 1 << 3,\r
339     FWL_EVENT_DRAW_MASK                         = 1 << 4,\r
340     FWL_EVENT_CLOSE_MASK                        = 1 << 5,\r
341     FWL_EVENT_SIZECHANGED_MASK          = 1 << 6,\r
342     FWL_EVENT_IDLE_MASK             = 1 << 7,\r
343     FWL_EVENT_CONTROL_MASK          = 1 << 8,\r
344     FWL_EVENT_ALL_MASK                          = 0xFF\r
345 } FWLEventMask;\r
346 class IFWL_NoteDriver\r
347 {\r
348 public:\r
349     virtual FX_BOOL             SendNote(CFWL_Note *pNote) = 0;\r
350     virtual FX_BOOL             PostMessage(CFWL_Message *pMessage) = 0;\r
351     virtual FWL_ERR             RegisterEventTarget(IFWL_Widget *pListener, IFWL_Widget *pEventSource = NULL, FX_DWORD dwFilter = FWL_EVENT_ALL_MASK) = 0;\r
352     virtual FWL_ERR             UnregisterEventTarget(IFWL_Widget *pListener) = 0;\r
353     virtual void                ClearEventTargets(FX_BOOL bRemoveAll) = 0;\r
354     virtual int32_t     GetQueueMaxSize() const = 0;\r
355     virtual FWL_ERR             SetQueueMaxSize(const int32_t size) = 0;\r
356     virtual IFWL_NoteThread* GetOwnerThread() const = 0;\r
357     virtual FWL_ERR             PushNoteLoop(IFWL_NoteLoop *pNoteLoop) = 0;\r
358     virtual IFWL_NoteLoop*      PopNoteLoop() = 0;\r
359     virtual FX_BOOL             SetFocus(IFWL_Widget *pFocus, FX_BOOL bNotify = FALSE) = 0;\r
360     virtual     FWL_ERR         Run() = 0;\r
361 };\r
362 IFWL_Widget* FWL_GetCurrentThreadModalWidget(IFWL_NoteThread *pNoteThread);\r
363 class IFWL_NoteLoop\r
364 {\r
365 public:\r
366     virtual FX_BOOL PreProcessMessage(CFWL_Message *pMessage) = 0;\r
367     virtual FWL_ERR     Idle(int32_t count) = 0;\r
368 };\r
369 class IFWL_ToolTipTarget\r
370 {\r
371 public:\r
372     virtual IFWL_Widget*        GetWidget() = 0;\r
373     virtual FX_BOOL                     IsShowed() = 0;\r
374     virtual     FWL_ERR                 DrawToolTip(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix, IFWL_Widget *pToolTip) = 0;\r
375     virtual FX_BOOL                     UseDefaultTheme() = 0;\r
376     virtual     FWL_ERR                 GetCaption(CFX_WideString &wsCaption) = 0;\r
377     virtual     FWL_ERR                 GetToolTipSize(CFX_SizeF &sz) = 0;\r
378     virtual     FWL_ERR                 GetToolTipPos(CFX_PointF &pt)\r
379     {\r
380         return FWL_ERR_Indefinite;\r
381     }\r
382 };\r
383 FWL_ERR FWL_AddToolTipTarget(IFWL_ToolTipTarget *pTarget);\r
384 FWL_ERR FWL_RemoveToolTipTarget(IFWL_ToolTipTarget *pTarget);\r
385 FWL_ERR FWL_SetToolTipInitialDelay(int32_t iDelayTime);\r
386 FWL_ERR FWL_SetToolTipAutoPopDelay(int32_t iDelayTime);\r
387 typedef FX_BOOL (*FWLMessageHookCallback)(CFWL_Message *msg, FX_LPVOID info);\r
388 FWL_ERR FWL_SetHook(IFWL_NoteDriver *driver, FWLMessageHookCallback callback, FX_LPVOID info);\r
389 #endif\r