summaryrefslogtreecommitdiff
path: root/xfa/include/fwl/core/fwl_note.h
blob: a838d8047f8bdbd534796c9b269813bc112166d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef _FWL_NOTE_H
#define _FWL_NOTE_H
class IFWL_Target;
class IFWL_Widget;
class IFWL_NoteThread;
class IFWL_ThemeProvider;
class CFWL_Note;
class CFWL_Message;
class CFWL_MsgActivate;
class CFWL_MsgDeactivate;
class CFWL_MsgMouse;
class CFWL_MsgMouseWheel;
class CFWL_MsgKey;
class CFWL_MsgSetFocus;
class CFWL_MsgKillFocus;
class CFWL_MsgCursor;
class CFWL_MsgSize;
class CFWL_MsgWindowMove;
class CFWL_MsgDropFiles;
class CFWL_MsgTaskClicked;
class CFWL_MsgClose;
class CFWL_MsgWindowWillMove;
class CFWL_Event;
class CFWL_EvtMouse;
class CFWL_EvtMouseWheel;
class CFWL_EvtKey;
class CFWL_EvtSetFocus;
class CFWL_EvtKillFocus;
class CFWL_EvtDraw;
class CFWL_EvtClick;
class CFWL_EvtScroll;
class CFWL_EvtClose;
class CFWL_EvtContextMenu;
class CFWL_EvtMenuCommand;
class CFWL_EvtSizeChanged;
class CFWL_EvtIdle;
class IFWL_NoteDriver;
class IFWL_NoteLoop;
#define FWL_MSG_Activate L"FWL_MESSAGE_Activate"
#define FWL_MSG_Deactivate L"FWL_MESSAGE_Deactivate"
#define FWL_MSG_SetFocus L"FWL_MESSAGE_SetFocus"
#define FWL_MSG_KillFocus L"FWL_MESSAGE_KillFocus"
#define FWL_MSG_Mouse L"FWL_MESSAGE_Mouse"
#define FWL_MSG_MouseWheel L"FWL_MESSAGE_MouseWheel"
#define FWL_MSG_Key L"FWL_MESSAGE_Key"
#define FWL_MSG_Cursor L"FWL_MESSAGE_Cursor"
#define FWL_MSG_Size L"FWL_MESSAGE_Size"
#define FWL_MSG_WindowMove L"FWL_MESSAGE_WindowMove"
#define FWL_MSG_DropFiles L"FWL_MESSAGE_DropFiles"
#define FWL_MSG_TaskClicked L"FWL_MESSAGE_TaskClicked"
#define FWL_MSG_Close L"FWL_MESSAGE_Close"
#define FWL_MSG_Post L"FWL_MESSAGE_Post"
#define FWL_MSG_WindowWillMove L"FWL_MESSAGE_WindowWillMove"
#define FWL_MSGHASH_Activate 2410369469
#define FWL_MSGHASH_Deactivate 1184214790
#define FWL_MSGHASH_SetFocus 4174512504
#define FWL_MSGHASH_KillFocus 1557903832
#define FWL_MSGHASH_Mouse 706128309
#define FWL_MSGHASH_MouseWheel 893703466
#define FWL_MSGHASH_Key 3751372405
#define FWL_MSGHASH_Cursor 3182626218
#define FWL_MSGHASH_Size 160077735
#define FWL_MSGHASH_WindowMove 1032269377
#define FWL_MSGHASH_DropFiles 2004165236
#define FWL_MSGHASH_TaskClicked 3128231086
#define FWL_MSGHASH_Close 2977563906
#define FWL_MSGHASH_Post 1969633074
#define FWL_MSGHASH_WindowWillMove 2229175763
#define FWL_EVT_Mouse L"FWL_EVENT_Mouse"
#define FWL_EVT_MouseWheel L"FWL_EVENT_MouseWheel"
#define FWL_EVT_Key L"FWL_EVENT_Key"
#define FWL_EVT_SetFocus L"FWL_EVENT_SetFocus"
#define FWL_EVT_KillFocus L"FWL_EVENT_KillFocus"
#define FWL_EVT_Click L"FWL_EVENT_Click"
#define FWL_EVT_Draw L"FWL_EVENT_Draw"
#define FWL_EVT_Scroll L"FWL_EVENT_Scroll"
#define FWL_EVT_Close L"FWL_EVENT_Close"
#define FWL_EVT_ContextMenu L"FWL_EVENT_ContextMenu"
#define FWL_EVT_MenuCommand L"FWL_EVENT_MenuCommand"
#define FWL_EVT_SizeChanged L"FWL_EVENT_SizeChanged"
#define FWL_EVTHASH_Mouse 1765258002
#define FWL_EVTHASH_MouseWheel 3907114407
#define FWL_EVTHASH_Key 2408354450
#define FWL_EVTHASH_SetFocus 3909721269
#define FWL_EVTHASH_KillFocus 1779363253
#define FWL_EVTHASH_Draw 2430713303
#define FWL_EVTHASH_Click 4026328783
#define FWL_EVTHASH_Scroll 2965158968
#define FWL_EVTHASH_Close 4036693599
#define FWL_EVTHASH_ContextMenu 2717307715
#define FWL_EVTHASH_MenuCommand 497763741
#define FWL_EVTHASH_SizeChanged 3083958510
#define FWL_EVTHASH_Idle 839546759
#define FWL_MSGMOUSECMD_LButtonDown 1
#define FWL_MSGMOUSECMD_LButtonUp 2
#define FWL_MSGMOUSECMD_LButtonDblClk 3
#define FWL_MSGMOUSECMD_RButtonDown 4
#define FWL_MSGMOUSECMD_RButtonUp 5
#define FWL_MSGMOUSECMD_RButtonDblClk 6
#define FWL_MSGMOUSECMD_MButtonDown 7
#define FWL_MSGMOUSECMD_MButtonUp 8
#define FWL_MSGMOUSECMD_MButtonDblClk 9
#define FWL_MSGMOUSECMD_MouseMove 10
#define FWL_MSGMOUSECMD_MouseEnter 11
#define FWL_MSGMOUSECMD_MouseLeave 12
#define FWL_MSGMOUSECMD_MouseHover 13
#define FWL_MSGKEYCMD_KeyDown 1
#define FWL_MSGKEYCMD_KeyUp 2
#define FWL_MSGKEYCMD_Char 3
#define FWL_KEYFLAG_Ctrl (1 << 0)
#define FWL_KEYFLAG_Alt (1 << 1)
#define FWL_KEYFLAG_Shift (1 << 2)
#define FWL_KEYFLAG_Command (1 << 3)
#define FWL_KEYFLAG_LButton (1 << 4)
#define FWL_KEYFLAG_RButton (1 << 5)
#define FWL_KEYFLAG_MButton (1 << 6)

// Separate hierarchy not related to IFWL_* hierarchy. These should not
// get cast to IFWL_* types.
class CFWL_Note {
 public:
  virtual FX_DWORD Release() {
    m_dwRefCount--;
    FX_DWORD dwRefCount = m_dwRefCount;
    if (!m_dwRefCount) {
      delete this;
    }
    return dwRefCount;
  }
  virtual CFWL_Note* Retain() {
    m_dwRefCount++;
    return this;
  }
  virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const {
    wsClass = L"CFWL_Note";
    return FWL_ERR_Succeeded;
  }
  virtual FX_DWORD GetClassID() const { return 0; }
  virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const {
    return TRUE;
  }
  virtual CFWL_Note* Clone() { return NULL; }
  FX_BOOL IsEvent() const { return m_bIsEvent; }
  IFWL_Widget* m_pSrcTarget;
  IFWL_Widget* m_pDstTarget;

 protected:
  CFWL_Note(FX_BOOL bIsEvent)
      : m_pSrcTarget(NULL),
        m_pDstTarget(NULL),
        m_dwRefCount(1),
        m_bIsEvent(bIsEvent),
        m_dwExtend(0) {}
  virtual ~CFWL_Note() {}
  virtual FX_BOOL Initialize() { return TRUE; }
  virtual int32_t Finalize() { return 0; }
  FX_DWORD m_dwRefCount;
  FX_BOOL m_bIsEvent;

 public:
  FX_DWORD m_dwExtend;
};
class CFWL_Message : public CFWL_Note {
 public:
  CFWL_Message() : CFWL_Note(FALSE) {}
  virtual ~CFWL_Message() {}
};
#define BEGIN_FWL_MESSAGE_DEF(classname, msghashcode)             \
  class classname : public CFWL_Message {                         \
   public:                                                        \
    classname() : CFWL_Message() {}                               \
    virtual CFWL_Note* Clone() { return new classname(*this); }   \
    virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { \
      wsClass = L## #classname;                                   \
      return FWL_ERR_Succeeded;                                   \
    }                                                             \
    virtual FX_DWORD GetClassID() const { return msghashcode; }
#define END_FWL_MESSAGE_DEF \
  }                         \
  ;
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, FWL_MSGHASH_Activate)
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, FWL_MSGHASH_Deactivate)
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, FWL_MSGHASH_Mouse)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
FX_DWORD m_dwFlags;
FX_DWORD m_dwCmd;
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, FWL_MSGHASH_MouseWheel)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
FX_FLOAT m_fDeltaX;
FX_FLOAT m_fDeltaY;
FX_DWORD m_dwFlags;
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, FWL_MSGHASH_SetFocus)
IFWL_Widget* m_pKillFocus;
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, FWL_MSGHASH_KillFocus)
IFWL_Widget* m_pSetFocus;
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, FWL_MSGHASH_Key)
FX_DWORD m_dwKeyCode;
FX_DWORD m_dwFlags;
FX_DWORD m_dwCmd;
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, FWL_MSGHASH_Cursor)
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, FWL_MSGHASH_Size)
int32_t m_iWidth;
int32_t m_iHeight;
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, FWL_MSGHASH_WindowMove)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, FWL_MSGHASH_DropFiles)
CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy) {
  m_pDstTarget = copy.m_pDstTarget;
  m_pSrcTarget = copy.m_pSrcTarget;
  m_fx = copy.m_fx;
  m_fy = copy.m_fy;
  m_files.Append(copy.m_files);
}
FX_FLOAT m_fx;
FX_FLOAT m_fy;
CFX_WideStringArray m_files;
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, FWL_MSGHASH_TaskClicked)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, FWL_MSGHASH_Close)
END_FWL_MESSAGE_DEF
BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, FWL_MSGHASH_WindowWillMove)
END_FWL_MESSAGE_DEF
class CFWL_Event : public CFWL_Note {
 public:
  CFWL_Event() : CFWL_Note(TRUE) {}
  virtual ~CFWL_Event() {}
};
#define BEGIN_FWL_EVENT_DEF(classname, eventhashcode)             \
  class classname : public CFWL_Event {                           \
   public:                                                        \
    classname() : CFWL_Event() {}                                 \
    virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { \
      wsClass = L## #classname;                                   \
      return FWL_ERR_Succeeded;                                   \
    }                                                             \
    virtual FX_DWORD GetClassID() const { return eventhashcode; }
#define END_FWL_EVENT_DEF \
  }                       \
  ;
BEGIN_FWL_EVENT_DEF(CFWL_EvtMouse, FWL_EVTHASH_Mouse)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
FX_DWORD m_dwFlags;
FX_DWORD m_dwCmd;
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtMouseWheel, FWL_EVTHASH_MouseWheel)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
FX_FLOAT m_fDeltaX;
FX_FLOAT m_fDeltaY;
FX_DWORD m_dwFlags;
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtKey, FWL_EVTHASH_Key)
FX_DWORD m_dwKeyCode;
FX_DWORD m_dwFlags;
FX_DWORD m_dwCmd;
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtSetFocus, FWL_EVTHASH_SetFocus)
IFWL_Widget* m_pSetFocus;
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtKillFocus, FWL_EVTHASH_KillFocus)
IFWL_Widget* m_pKillFocus;
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtDraw, FWL_EVTHASH_Draw)
CFX_Graphics* m_pGraphics;
IFWL_Widget* m_pWidget;
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtClick, FWL_EVTHASH_Click)
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtScroll, FWL_EVTHASH_Scroll)
FX_DWORD m_iScrollCode;
FX_FLOAT m_fPos;
FX_BOOL* m_pRet;
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtClose, FWL_EVTHASH_Close)
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtContextMenu, FWL_EVTHASH_ContextMenu)
FX_FLOAT m_fPosX;
FX_FLOAT m_fPosY;
IFWL_Widget* m_pOwner;
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtMenuCommand, FWL_EVTHASH_MenuCommand)
int32_t m_iCommand;
void* m_pData;
END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtSizeChanged, FWL_EVTHASH_SizeChanged)
IFWL_Widget* m_pWidget;
CFX_RectF m_rtOld;
CFX_RectF m_rtNew;
END_FWL_MESSAGE_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtIdle, FWL_EVTHASH_Idle)
END_FWL_EVENT_DEF
typedef enum {
  FWL_EVENT_MOUSE_MASK = 1 << 0,
  FWL_EVENT_MOUSEWHEEL_MASK = 1 << 1,
  FWL_EVENT_KEY_MASK = 1 << 2,
  FWL_EVENT_FOCUSCHANGED_MASK = 1 << 3,
  FWL_EVENT_DRAW_MASK = 1 << 4,
  FWL_EVENT_CLOSE_MASK = 1 << 5,
  FWL_EVENT_SIZECHANGED_MASK = 1 << 6,
  FWL_EVENT_IDLE_MASK = 1 << 7,
  FWL_EVENT_CONTROL_MASK = 1 << 8,
  FWL_EVENT_ALL_MASK = 0xFF
} FWLEventMask;
class IFWL_NoteDriver {
 public:
  virtual ~IFWL_NoteDriver() {}
  virtual FX_BOOL SendNote(CFWL_Note* pNote) = 0;
  virtual FX_BOOL PostMessage(CFWL_Message* pMessage) = 0;
  virtual FWL_ERR RegisterEventTarget(
      IFWL_Widget* pListener,
      IFWL_Widget* pEventSource = NULL,
      FX_DWORD dwFilter = FWL_EVENT_ALL_MASK) = 0;
  virtual FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener) = 0;
  virtual void ClearEventTargets(FX_BOOL bRemoveAll) = 0;
  virtual int32_t GetQueueMaxSize() const = 0;
  virtual FWL_ERR SetQueueMaxSize(const int32_t size) = 0;
  virtual IFWL_NoteThread* GetOwnerThread() const = 0;
  virtual FWL_ERR PushNoteLoop(IFWL_NoteLoop* pNoteLoop) = 0;
  virtual IFWL_NoteLoop* PopNoteLoop() = 0;
  virtual FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE) = 0;
  virtual FWL_ERR Run() = 0;
};
IFWL_Widget* FWL_GetCurrentThreadModalWidget(IFWL_NoteThread* pNoteThread);
class IFWL_NoteLoop {
 public:
  virtual ~IFWL_NoteLoop() {}
  virtual FX_BOOL PreProcessMessage(CFWL_Message* pMessage) = 0;
  virtual FWL_ERR Idle(int32_t count) = 0;
};
class IFWL_ToolTipTarget {
 public:
  virtual ~IFWL_ToolTipTarget() {}
  virtual IFWL_Widget* GetWidget() = 0;
  virtual FX_BOOL IsShowed() = 0;
  virtual FWL_ERR DrawToolTip(CFX_Graphics* pGraphics,
                              const CFX_Matrix* pMatrix,
                              IFWL_Widget* pToolTip) = 0;
  virtual FX_BOOL UseDefaultTheme() = 0;
  virtual FWL_ERR GetCaption(CFX_WideString& wsCaption) = 0;
  virtual FWL_ERR GetToolTipSize(CFX_SizeF& sz) = 0;
  virtual FWL_ERR GetToolTipPos(CFX_PointF& pt) { return FWL_ERR_Indefinite; }
};
FWL_ERR FWL_AddToolTipTarget(IFWL_ToolTipTarget* pTarget);
FWL_ERR FWL_RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget);
FWL_ERR FWL_SetToolTipInitialDelay(int32_t iDelayTime);
FWL_ERR FWL_SetToolTipAutoPopDelay(int32_t iDelayTime);
typedef FX_BOOL (*FWLMessageHookCallback)(CFWL_Message* msg, void* info);
FWL_ERR FWL_SetHook(IFWL_NoteDriver* driver,
                    FWLMessageHookCallback callback,
                    void* info);
#endif