event.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /*
  2. * File : event.h
  3. * This file is part of RT-Thread GUI Engine
  4. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2009-10-04 Bernard first version
  23. */
  24. #ifndef __RTGUI_EVENT_H__
  25. #define __RTGUI_EVENT_H__
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #include <rtdevice.h>
  30. #include <rtgui/rtgui.h>
  31. #include <rtgui/kbddef.h>
  32. /* NOTE: if you create a new event type, remember to add it into the union
  33. * rtgui_event_generic */
  34. enum _rtgui_event_type
  35. {
  36. /* applications event */
  37. RTGUI_EVENT_APP_CREATE, /* create an application */
  38. RTGUI_EVENT_APP_DESTROY, /* destroy an application */
  39. RTGUI_EVENT_APP_ACTIVATE, /* activate an application */
  40. /* window event */
  41. RTGUI_EVENT_WIN_CREATE, /* create a window */
  42. RTGUI_EVENT_WIN_DESTROY, /* destroy a window */
  43. RTGUI_EVENT_WIN_SHOW, /* show a window */
  44. RTGUI_EVENT_WIN_HIDE, /* hide a window */
  45. RTGUI_EVENT_WIN_ACTIVATE, /* activate a window */
  46. RTGUI_EVENT_WIN_DEACTIVATE, /* deactivate a window */
  47. RTGUI_EVENT_WIN_CLOSE, /* close a window */
  48. RTGUI_EVENT_WIN_MOVE, /* move a window */
  49. RTGUI_EVENT_WIN_RESIZE, /* resize a window */
  50. RTGUI_EVENT_WIN_UPDATE_END, /* update done for window */
  51. RTGUI_EVENT_WIN_MODAL_ENTER, /* the window is entering modal mode.
  52. This event should be sent after the
  53. window got setup and before the
  54. application got setup. */
  55. /* WM event */
  56. RTGUI_EVENT_SET_WM, /* set window manager */
  57. RTGUI_EVENT_UPDATE_BEGIN, /* update a rect */
  58. RTGUI_EVENT_UPDATE_END, /* update a rect */
  59. RTGUI_EVENT_MONITOR_ADD, /* add a monitor rect */
  60. RTGUI_EVENT_MONITOR_REMOVE, /* remove a monitor rect */
  61. RTGUI_EVENT_SHOW, /* the widget is going to be shown */
  62. RTGUI_EVENT_HIDE, /* the widget is going to be hidden */
  63. RTGUI_EVENT_PAINT, /* paint on screen */
  64. RTGUI_EVENT_TIMER, /* timer */
  65. RTGUI_EVENT_UPDATE_TOPLVL, /* update the toplevel */
  66. /* virtual paint event */
  67. RTGUI_EVENT_VPAINT_REQ, /* virtual paint request (server -> client) */
  68. /* clip rect information */
  69. RTGUI_EVENT_CLIP_INFO, /* clip rect info */
  70. /* mouse and keyboard event */
  71. RTGUI_EVENT_MOUSE_MOTION, /* mouse motion */
  72. RTGUI_EVENT_MOUSE_BUTTON, /* mouse button info */
  73. RTGUI_EVENT_KBD, /* keyboard info */
  74. RTGUI_EVENT_TOUCH, /* touch event to server */
  75. RTGUI_EVENT_GESTURE, /* gesture event */
  76. /* widget event */
  77. RTGUI_EVENT_FOCUSED, /* widget focused */
  78. RTGUI_EVENT_SCROLLED, /* scroll bar scrolled */
  79. RTGUI_EVENT_RESIZE, /* widget resize */
  80. RTGUI_EVENT_SELECTED, /* widget selected */
  81. RTGUI_EVENT_UNSELECTED, /* widget un-selected */
  82. RTGUI_EVENT_MV_MODEL, /* data of a model has been changed */
  83. WBUS_NOTIFY_EVENT,
  84. /* user command event. It should always be the last command type. */
  85. RTGUI_EVENT_COMMAND = 0x0100, /* user command */
  86. };
  87. typedef enum _rtgui_event_type rtgui_event_type;
  88. enum
  89. {
  90. RTGUI_STATUS_OK = 0, /* status ok */
  91. RTGUI_STATUS_ERROR, /* generic error */
  92. RTGUI_STATUS_NRC, /* no resource */
  93. };
  94. struct rtgui_event
  95. {
  96. /* the event type */
  97. enum _rtgui_event_type type;
  98. /* user field of event */
  99. rt_uint16_t user;
  100. /* the event sender */
  101. struct rtgui_app *sender;
  102. /* mailbox to acknowledge request */
  103. rt_mailbox_t ack;
  104. };
  105. typedef struct rtgui_event rtgui_event_t;
  106. #define RTGUI_EVENT(e) ((struct rtgui_event*)(e))
  107. extern struct rtgui_app* rtgui_app_self(void);
  108. #define RTGUI_EVENT_INIT(e, t) do \
  109. { \
  110. (e)->type = (t); \
  111. (e)->user = 0; \
  112. (e)->sender = rtgui_app_self(); \
  113. (e)->ack = RT_NULL; \
  114. } while (0)
  115. /*
  116. * RTGUI Application Event
  117. */
  118. struct rtgui_event_application
  119. {
  120. struct rtgui_event parent;
  121. struct rtgui_app *app;
  122. };
  123. /* gui application init */
  124. #define RTGUI_EVENT_APP_CREATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_APP_CREATE)
  125. #define RTGUI_EVENT_APP_DESTROY_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_APP_DESTROY)
  126. #define RTGUI_EVENT_APP_ACTIVATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_APP_ACTIVATE)
  127. /*
  128. * RTGUI Window Event
  129. */
  130. #define _RTGUI_EVENT_WIN_ELEMENTS \
  131. struct rtgui_event parent; \
  132. struct rtgui_win *wid;
  133. /*
  134. * RTGUI Window Event
  135. */
  136. struct rtgui_event_win
  137. {
  138. _RTGUI_EVENT_WIN_ELEMENTS
  139. };
  140. struct rtgui_event_win_create
  141. {
  142. _RTGUI_EVENT_WIN_ELEMENTS
  143. struct rtgui_win *parent_window;
  144. };
  145. struct rtgui_event_win_move
  146. {
  147. _RTGUI_EVENT_WIN_ELEMENTS
  148. rt_int16_t x, y;
  149. };
  150. struct rtgui_event_win_resize
  151. {
  152. _RTGUI_EVENT_WIN_ELEMENTS
  153. rtgui_rect_t rect;
  154. };
  155. struct rtgui_event_win_update_end
  156. {
  157. _RTGUI_EVENT_WIN_ELEMENTS
  158. rtgui_rect_t rect;
  159. };
  160. #define rtgui_event_win_destroy rtgui_event_win
  161. #define rtgui_event_win_show rtgui_event_win
  162. #define rtgui_event_win_hide rtgui_event_win
  163. #define rtgui_event_win_activate rtgui_event_win
  164. #define rtgui_event_win_deactivate rtgui_event_win
  165. #define rtgui_event_win_close rtgui_event_win
  166. #define rtgui_event_win_modal_enter rtgui_event_win
  167. /* window event init */
  168. #define RTGUI_EVENT_WIN_CREATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_CREATE)
  169. #define RTGUI_EVENT_WIN_DESTROY_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_DESTROY)
  170. #define RTGUI_EVENT_WIN_SHOW_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_SHOW)
  171. #define RTGUI_EVENT_WIN_HIDE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_HIDE)
  172. #define RTGUI_EVENT_WIN_ACTIVATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_ACTIVATE)
  173. #define RTGUI_EVENT_WIN_DEACTIVATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_DEACTIVATE)
  174. #define RTGUI_EVENT_WIN_CLOSE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_CLOSE)
  175. #define RTGUI_EVENT_WIN_MOVE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_MOVE)
  176. #define RTGUI_EVENT_WIN_RESIZE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_RESIZE)
  177. #define RTGUI_EVENT_WIN_UPDATE_END_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_UPDATE_END)
  178. #define RTGUI_EVENT_WIN_MODAL_ENTER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_MODAL_ENTER)
  179. /*
  180. * RTGUI set window manager
  181. */
  182. struct rtgui_event_set_wm
  183. {
  184. struct rtgui_event parent;
  185. struct rtgui_app *app;
  186. };
  187. #define RTGUI_EVENT_SET_WM_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SET_WM);
  188. /*
  189. * RTGUI Other Event
  190. */
  191. struct rtgui_event_update_begin
  192. {
  193. struct rtgui_event parent;
  194. /* the update rect */
  195. rtgui_rect_t rect;
  196. };
  197. struct rtgui_event_update_end
  198. {
  199. struct rtgui_event parent;
  200. /* the update rect */
  201. rtgui_rect_t rect;
  202. };
  203. struct rtgui_event_monitor
  204. {
  205. _RTGUI_EVENT_WIN_ELEMENTS
  206. /* the monitor rect */
  207. rtgui_rect_t rect;
  208. };
  209. struct rtgui_event_paint
  210. {
  211. _RTGUI_EVENT_WIN_ELEMENTS
  212. rtgui_rect_t rect; /* rect to be updated */
  213. };
  214. struct rtgui_timer;
  215. struct rtgui_event_timer
  216. {
  217. struct rtgui_event parent;
  218. struct rtgui_timer *timer;
  219. };
  220. typedef struct rtgui_event_timer rtgui_event_timer_t;
  221. struct rtgui_event_clip_info
  222. {
  223. _RTGUI_EVENT_WIN_ELEMENTS
  224. /* the number of rects */
  225. //rt_uint32_t num_rect;
  226. /* rtgui_rect_t *rects */
  227. };
  228. #define RTGUI_EVENT_GET_RECT(e, i) &(((rtgui_rect_t*)(e + 1))[i])
  229. #define RTGUI_EVENT_UPDATE_BEGIN_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_BEGIN)
  230. #define RTGUI_EVENT_UPDATE_END_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_END)
  231. #define RTGUI_EVENT_MONITOR_ADD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MONITOR_ADD)
  232. #define RTGUI_EVENT_MONITOR_REMOVE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MONITOR_REMOVE)
  233. #define RTGUI_EVENT_CLIP_INFO_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_CLIP_INFO)
  234. #define RTGUI_EVENT_PAINT_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PAINT)
  235. #define RTGUI_EVENT_TIMER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_TIMER)
  236. #define rtgui_event_show rtgui_event
  237. #define rtgui_event_hide rtgui_event
  238. #define RTGUI_EVENT_SHOW_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_SHOW)
  239. #define RTGUI_EVENT_HIDE_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_HIDE)
  240. struct rtgui_event_update_toplvl
  241. {
  242. struct rtgui_event parent;
  243. struct rtgui_win *toplvl;
  244. };
  245. #define RTGUI_EVENT_UPDATE_TOPLVL_INIT(e) \
  246. do { \
  247. RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_TOPLVL); \
  248. (e)->toplvl = RT_NULL; \
  249. } while (0)
  250. struct rtgui_event_vpaint_req
  251. {
  252. _RTGUI_EVENT_WIN_ELEMENTS
  253. struct rtgui_event_vpaint_req *sender;
  254. struct rt_completion *cmp;
  255. struct rtgui_dc* buffer;
  256. };
  257. #define RTGUI_EVENT_VPAINT_REQ_INIT(e, win, cm) \
  258. do { \
  259. RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_VPAINT_REQ); \
  260. (e)->wid = win; \
  261. (e)->cmp = cm; \
  262. (e)->sender = (e); \
  263. (e)->buffer = RT_NULL; \
  264. rt_completion_init((e)->cmp); \
  265. } while (0)
  266. /**
  267. * RTGUI Gesture Event
  268. */
  269. enum rtgui_gesture_type
  270. {
  271. RTGUI_GESTURE_NONE = 0x0000,
  272. RTGUI_GESTURE_TAP = 0x0001,
  273. /* Usually used to zoom in and out. */
  274. RTGUI_GESTURE_PINCH = 0x0002,
  275. RTGUI_GESTURE_DRAG = 0x0004,
  276. RTGUI_GESTURE_LONGPRESS = 0x0008,
  277. /* PINCH, DRAG finished. */
  278. RTGUI_GESTURE_FINISH = 0x8000,
  279. /* The corresponding gesture should be canceled. */
  280. RTGUI_GESTURE_CANCEL = 0x4000,
  281. RTGUI_GESTURE_TYPE_MASK = 0x0FFF,
  282. };
  283. struct rtgui_event_gesture
  284. {
  285. _RTGUI_EVENT_WIN_ELEMENTS
  286. enum rtgui_gesture_type type;
  287. };
  288. /*
  289. * RTGUI Mouse and Keyboard Event
  290. */
  291. struct rtgui_event_mouse
  292. {
  293. _RTGUI_EVENT_WIN_ELEMENTS
  294. rt_uint16_t x, y;
  295. rt_uint16_t button;
  296. /* Timestamp of this event sampled in driver. */
  297. rt_tick_t ts;
  298. /* id of touch session(from down to up). Different session should have
  299. * different id. id should never be 0. */
  300. rt_uint32_t id;
  301. };
  302. #define RTGUI_MOUSE_BUTTON_LEFT 0x01
  303. #define RTGUI_MOUSE_BUTTON_RIGHT 0x02
  304. #define RTGUI_MOUSE_BUTTON_MIDDLE 0x03
  305. #define RTGUI_MOUSE_BUTTON_WHEELUP 0x04
  306. #define RTGUI_MOUSE_BUTTON_WHEELDOWN 0x08
  307. #define RTGUI_MOUSE_BUTTON_DOWN 0x10
  308. #define RTGUI_MOUSE_BUTTON_UP 0x20
  309. #define RTGUI_EVENT_GESTURE_INIT(e, gtype) \
  310. do { \
  311. RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_GESTURE); \
  312. (e)->type = gtype; \
  313. } while (0)
  314. struct rtgui_event_kbd
  315. {
  316. _RTGUI_EVENT_WIN_ELEMENTS
  317. rt_uint16_t type; /* key down or up */
  318. rt_uint16_t key; /* current key */
  319. rt_uint16_t mod; /* current key modifiers */
  320. rt_uint16_t unicode; /* translated character */
  321. };
  322. #define RTGUI_KBD_IS_SET_CTRL(e) ((e)->mod & (RTGUI_KMOD_LCTRL | RTGUI_KMOD_RCTRL))
  323. #define RTGUI_KBD_IS_SET_ALT(e) ((e)->mod & (RTGUI_KMOD_LALT | RTGUI_KMOD_RALT))
  324. #define RTGUI_KBD_IS_SET_SHIFT(e) ((e)->mod & (RTGUI_KMOD_LSHIFT| RTGUI_KMOD_RSHIFT))
  325. #define RTGUI_KBD_IS_UP(e) ((e)->type == RTGUI_KEYUP)
  326. #define RTGUI_KBD_IS_DOWN(e) ((e)->type == RTGUI_KEYDOWN)
  327. #define RTGUI_EVENT_MOUSE_MOTION_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_MOTION)
  328. #define RTGUI_EVENT_MOUSE_BUTTON_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_BUTTON)
  329. #define RTGUI_EVENT_KBD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_KBD)
  330. /**
  331. * RTGUI Touch Event
  332. * NOTE: There is not touch event to user applications, it's handled by server.
  333. */
  334. struct rtgui_event_touch
  335. {
  336. struct rtgui_event parent;
  337. rt_uint16_t x, y;
  338. rt_uint16_t up_down;
  339. rt_uint16_t resv;
  340. };
  341. #define RTGUI_TOUCH_UP 0x01
  342. #define RTGUI_TOUCH_DOWN 0x02
  343. #define RTGUI_TOUCH_MOTION 0x03
  344. #define RTGUI_EVENT_TOUCH_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_TOUCH)
  345. struct rtgui_event_command
  346. {
  347. _RTGUI_EVENT_WIN_ELEMENTS
  348. /* command type */
  349. rt_int32_t type;
  350. /* command id */
  351. rt_int32_t command_id;
  352. /* command string */
  353. char command_string[RTGUI_NAME_MAX];
  354. };
  355. #define RTGUI_EVENT_COMMAND_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_COMMAND)
  356. #define RTGUI_CMD_UNKNOWN 0x00
  357. #define RTGUI_CMD_WM_CLOSE 0x10
  358. #define RTGUI_CMD_USER_INT 0x20
  359. #define RTGUI_CMD_USER_STRING 0x21
  360. /************************************************************************/
  361. /* Widget Event */
  362. /************************************************************************/
  363. #define RTGUI_WIDGET_EVENT_INIT(e, t) do \
  364. { \
  365. (e)->type = (t); \
  366. (e)->sender = RT_NULL; \
  367. (e)->ack = RT_NULL; \
  368. } while (0)
  369. /*
  370. * RTGUI Scrollbar Event
  371. */
  372. struct rtgui_event_scrollbar
  373. {
  374. struct rtgui_event parent;
  375. rt_uint8_t event;
  376. };
  377. #define RTGUI_SCROLL_LINEUP 0x01
  378. #define RTGUI_SCROLL_LINEDOWN 0x02
  379. #define RTGUI_SCROLL_PAGEUP 0x03
  380. #define RTGUI_SCROLL_PAGEDOWN 0x04
  381. #define RTGUI_EVENT_SCROLLED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SCROLLED)
  382. /*
  383. * RTGUI Widget Focused Event
  384. */
  385. struct rtgui_event_focused
  386. {
  387. struct rtgui_event parent;
  388. struct rtgui_widget *widget;
  389. };
  390. #define RTGUI_EVENT_FOCUSED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_FOCUSED)
  391. /*
  392. * RTGUI Widget Resize Event
  393. */
  394. struct rtgui_event_resize
  395. {
  396. struct rtgui_event parent;
  397. rt_int16_t x, y;
  398. rt_int16_t w, h;
  399. };
  400. #define RTGUI_EVENT_RESIZE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_RESIZE)
  401. /*
  402. * RTGUI Model/View Event
  403. */
  404. enum rtgui_event_model_mode
  405. {
  406. RTGUI_MV_DATA_ADDED,
  407. RTGUI_MV_DATA_CHANGED,
  408. RTGUI_MV_DATA_DELETED,
  409. };
  410. struct rtgui_event_mv_model
  411. {
  412. struct rtgui_event parent;
  413. struct rtgui_mv_model *model;
  414. struct rtgui_mv_view *view;
  415. rt_size_t first_data_changed_idx;
  416. rt_size_t last_data_changed_idx;
  417. };
  418. #define _RTGUI_EVENT_MV_INIT_TYPE(T) \
  419. rt_inline void RTGUI_EVENT_MV_MODEL_##T##_INIT(struct rtgui_event_mv_model *e) \
  420. { \
  421. RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MV_MODEL); \
  422. (e)->parent.user = RTGUI_MV_DATA_##T; \
  423. } \
  424. /* useless struct to allow trailing semicolon */ \
  425. struct dummy
  426. _RTGUI_EVENT_MV_INIT_TYPE(ADDED);
  427. _RTGUI_EVENT_MV_INIT_TYPE(CHANGED);
  428. _RTGUI_EVENT_MV_INIT_TYPE(DELETED);
  429. #undef _RTGUI_EVENT_MV_INIT_TYPE
  430. #define _RTGUI_EVENT_MV_IS_TYPE(T) \
  431. rt_inline rt_bool_t RTGUI_EVENT_MV_MODEL_IS_##T(struct rtgui_event_mv_model *e) \
  432. { \
  433. return e->parent.user == RTGUI_MV_DATA_##T; \
  434. } \
  435. /* useless struct to allow trailing semicolon */ \
  436. struct dummy
  437. _RTGUI_EVENT_MV_IS_TYPE(ADDED);
  438. _RTGUI_EVENT_MV_IS_TYPE(CHANGED);
  439. _RTGUI_EVENT_MV_IS_TYPE(DELETED);
  440. #undef _RTGUI_EVENT_MV_IS_TYPE
  441. #undef _RTGUI_EVENT_WIN_ELEMENTS
  442. union rtgui_event_generic
  443. {
  444. struct rtgui_event base;
  445. struct rtgui_event_application app_create;
  446. struct rtgui_event_application app_destroy;
  447. struct rtgui_event_application app_activate;
  448. struct rtgui_event_set_wm set_wm;
  449. struct rtgui_event_win win_base;
  450. struct rtgui_event_win_create win_create;
  451. struct rtgui_event_win_move win_move;
  452. struct rtgui_event_win_resize win_resize;
  453. struct rtgui_event_win_destroy win_destroy;
  454. struct rtgui_event_win_show win_show;
  455. struct rtgui_event_win_hide win_hide;
  456. struct rtgui_event_win_activate win_activate;
  457. struct rtgui_event_win_deactivate win_deactivate;
  458. struct rtgui_event_win_close win_close;
  459. struct rtgui_event_win_modal_enter win_modal_enter;
  460. struct rtgui_event_update_begin update_begin;
  461. struct rtgui_event_update_end update_end;
  462. struct rtgui_event_monitor monitor;
  463. struct rtgui_event_paint paint;
  464. struct rtgui_event_timer timer;
  465. struct rtgui_event_update_toplvl update_toplvl;
  466. struct rtgui_event_vpaint_req vpaint_req;
  467. struct rtgui_event_clip_info clip_info;
  468. struct rtgui_event_mouse mouse;
  469. struct rtgui_event_kbd kbd;
  470. struct rtgui_event_touch touch;
  471. struct rtgui_event_gesture gesture;
  472. struct rtgui_event_scrollbar scrollbar;
  473. struct rtgui_event_focused focused;
  474. struct rtgui_event_resize resize;
  475. struct rtgui_event_mv_model model;
  476. struct rtgui_event_command command;
  477. };
  478. #ifdef __cplusplus
  479. }
  480. #endif
  481. #endif