event.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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. RTGUI_GESTURE_DRAGGED = 0x0001 | 0x0004 | 0x0008,
  278. /* PINCH, DRAG finished. */
  279. RTGUI_GESTURE_FINISH = 0x8000,
  280. /* The corresponding gesture should be canceled. */
  281. RTGUI_GESTURE_CANCEL = 0x4000,
  282. RTGUI_GESTURE_TYPE_MASK = 0x0FFF,
  283. };
  284. struct rtgui_event_gesture
  285. {
  286. _RTGUI_EVENT_WIN_ELEMENTS
  287. enum rtgui_gesture_type type;
  288. rt_uint32_t win_acti_cnt; /* window activate count */
  289. };
  290. /*
  291. * RTGUI Mouse and Keyboard Event
  292. */
  293. struct rtgui_event_mouse
  294. {
  295. _RTGUI_EVENT_WIN_ELEMENTS
  296. rt_uint16_t x, y;
  297. rt_uint16_t button;
  298. /* Timestamp of this event sampled in driver. */
  299. rt_tick_t ts;
  300. /* id of touch session(from down to up). Different session should have
  301. * different id. id should never be 0. */
  302. rt_uint32_t id;
  303. rt_uint32_t win_acti_cnt; /* window activate count */
  304. };
  305. #define RTGUI_MOUSE_BUTTON_LEFT 0x01
  306. #define RTGUI_MOUSE_BUTTON_RIGHT 0x02
  307. #define RTGUI_MOUSE_BUTTON_MIDDLE 0x03
  308. #define RTGUI_MOUSE_BUTTON_WHEELUP 0x04
  309. #define RTGUI_MOUSE_BUTTON_WHEELDOWN 0x08
  310. #define RTGUI_MOUSE_BUTTON_DOWN 0x10
  311. #define RTGUI_MOUSE_BUTTON_UP 0x20
  312. #define RTGUI_EVENT_GESTURE_INIT(e, gtype) \
  313. do { \
  314. RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_GESTURE); \
  315. (e)->type = gtype; \
  316. } while (0)
  317. struct rtgui_event_kbd
  318. {
  319. _RTGUI_EVENT_WIN_ELEMENTS
  320. rt_uint32_t win_acti_cnt; /* window activate count */
  321. rt_uint16_t type; /* key down or up */
  322. rt_uint16_t key; /* current key */
  323. rt_uint16_t mod; /* current key modifiers */
  324. rt_uint16_t unicode; /* translated character */
  325. };
  326. #define RTGUI_KBD_IS_SET_CTRL(e) ((e)->mod & (RTGUI_KMOD_LCTRL | RTGUI_KMOD_RCTRL))
  327. #define RTGUI_KBD_IS_SET_ALT(e) ((e)->mod & (RTGUI_KMOD_LALT | RTGUI_KMOD_RALT))
  328. #define RTGUI_KBD_IS_SET_SHIFT(e) ((e)->mod & (RTGUI_KMOD_LSHIFT| RTGUI_KMOD_RSHIFT))
  329. #define RTGUI_KBD_IS_UP(e) ((e)->type == RTGUI_KEYUP)
  330. #define RTGUI_KBD_IS_DOWN(e) ((e)->type == RTGUI_KEYDOWN)
  331. #define RTGUI_EVENT_MOUSE_MOTION_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_MOTION)
  332. #define RTGUI_EVENT_MOUSE_BUTTON_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_BUTTON)
  333. #define RTGUI_EVENT_KBD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_KBD)
  334. /**
  335. * RTGUI Touch Event
  336. * NOTE: There is not touch event to user applications, it's handled by server.
  337. */
  338. struct rtgui_event_touch
  339. {
  340. struct rtgui_event parent;
  341. rt_uint16_t x, y;
  342. rt_uint16_t up_down;
  343. rt_uint16_t resv;
  344. };
  345. #define RTGUI_TOUCH_UP 0x01
  346. #define RTGUI_TOUCH_DOWN 0x02
  347. #define RTGUI_TOUCH_MOTION 0x03
  348. #define RTGUI_EVENT_TOUCH_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_TOUCH)
  349. struct rtgui_event_command
  350. {
  351. _RTGUI_EVENT_WIN_ELEMENTS
  352. /* command type */
  353. rt_int32_t type;
  354. /* command id */
  355. rt_int32_t command_id;
  356. /* command string */
  357. char command_string[RTGUI_NAME_MAX];
  358. };
  359. #define RTGUI_EVENT_COMMAND_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_COMMAND)
  360. #define RTGUI_CMD_UNKNOWN 0x00
  361. #define RTGUI_CMD_WM_CLOSE 0x10
  362. #define RTGUI_CMD_USER_INT 0x20
  363. #define RTGUI_CMD_USER_STRING 0x21
  364. /************************************************************************/
  365. /* Widget Event */
  366. /************************************************************************/
  367. #define RTGUI_WIDGET_EVENT_INIT(e, t) do \
  368. { \
  369. (e)->type = (t); \
  370. (e)->sender = RT_NULL; \
  371. (e)->ack = RT_NULL; \
  372. } while (0)
  373. /*
  374. * RTGUI Scrollbar Event
  375. */
  376. struct rtgui_event_scrollbar
  377. {
  378. struct rtgui_event parent;
  379. rt_uint8_t event;
  380. };
  381. #define RTGUI_SCROLL_LINEUP 0x01
  382. #define RTGUI_SCROLL_LINEDOWN 0x02
  383. #define RTGUI_SCROLL_PAGEUP 0x03
  384. #define RTGUI_SCROLL_PAGEDOWN 0x04
  385. #define RTGUI_EVENT_SCROLLED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SCROLLED)
  386. /*
  387. * RTGUI Widget Focused Event
  388. */
  389. struct rtgui_event_focused
  390. {
  391. struct rtgui_event parent;
  392. struct rtgui_widget *widget;
  393. };
  394. #define RTGUI_EVENT_FOCUSED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_FOCUSED)
  395. /*
  396. * RTGUI Widget Resize Event
  397. */
  398. struct rtgui_event_resize
  399. {
  400. struct rtgui_event parent;
  401. rt_int16_t x, y;
  402. rt_int16_t w, h;
  403. };
  404. #define RTGUI_EVENT_RESIZE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_RESIZE)
  405. /*
  406. * RTGUI Model/View Event
  407. */
  408. enum rtgui_event_model_mode
  409. {
  410. RTGUI_MV_DATA_ADDED,
  411. RTGUI_MV_DATA_CHANGED,
  412. RTGUI_MV_DATA_DELETED,
  413. };
  414. struct rtgui_event_mv_model
  415. {
  416. struct rtgui_event parent;
  417. struct rtgui_mv_model *model;
  418. struct rtgui_mv_view *view;
  419. rt_size_t first_data_changed_idx;
  420. rt_size_t last_data_changed_idx;
  421. };
  422. #define _RTGUI_EVENT_MV_INIT_TYPE(T) \
  423. rt_inline void RTGUI_EVENT_MV_MODEL_##T##_INIT(struct rtgui_event_mv_model *e) \
  424. { \
  425. RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MV_MODEL); \
  426. (e)->parent.user = RTGUI_MV_DATA_##T; \
  427. } \
  428. /* useless struct to allow trailing semicolon */ \
  429. struct dummy
  430. _RTGUI_EVENT_MV_INIT_TYPE(ADDED);
  431. _RTGUI_EVENT_MV_INIT_TYPE(CHANGED);
  432. _RTGUI_EVENT_MV_INIT_TYPE(DELETED);
  433. #undef _RTGUI_EVENT_MV_INIT_TYPE
  434. #define _RTGUI_EVENT_MV_IS_TYPE(T) \
  435. rt_inline rt_bool_t RTGUI_EVENT_MV_MODEL_IS_##T(struct rtgui_event_mv_model *e) \
  436. { \
  437. return e->parent.user == RTGUI_MV_DATA_##T; \
  438. } \
  439. /* useless struct to allow trailing semicolon */ \
  440. struct dummy
  441. _RTGUI_EVENT_MV_IS_TYPE(ADDED);
  442. _RTGUI_EVENT_MV_IS_TYPE(CHANGED);
  443. _RTGUI_EVENT_MV_IS_TYPE(DELETED);
  444. #undef _RTGUI_EVENT_MV_IS_TYPE
  445. #undef _RTGUI_EVENT_WIN_ELEMENTS
  446. union rtgui_event_generic
  447. {
  448. struct rtgui_event base;
  449. struct rtgui_event_application app_create;
  450. struct rtgui_event_application app_destroy;
  451. struct rtgui_event_application app_activate;
  452. struct rtgui_event_set_wm set_wm;
  453. struct rtgui_event_win win_base;
  454. struct rtgui_event_win_create win_create;
  455. struct rtgui_event_win_move win_move;
  456. struct rtgui_event_win_resize win_resize;
  457. struct rtgui_event_win_destroy win_destroy;
  458. struct rtgui_event_win_show win_show;
  459. struct rtgui_event_win_hide win_hide;
  460. struct rtgui_event_win_activate win_activate;
  461. struct rtgui_event_win_deactivate win_deactivate;
  462. struct rtgui_event_win_close win_close;
  463. struct rtgui_event_win_modal_enter win_modal_enter;
  464. struct rtgui_event_update_begin update_begin;
  465. struct rtgui_event_update_end update_end;
  466. struct rtgui_event_monitor monitor;
  467. struct rtgui_event_paint paint;
  468. struct rtgui_event_timer timer;
  469. struct rtgui_event_update_toplvl update_toplvl;
  470. struct rtgui_event_vpaint_req vpaint_req;
  471. struct rtgui_event_clip_info clip_info;
  472. struct rtgui_event_mouse mouse;
  473. struct rtgui_event_kbd kbd;
  474. struct rtgui_event_touch touch;
  475. struct rtgui_event_gesture gesture;
  476. struct rtgui_event_scrollbar scrollbar;
  477. struct rtgui_event_focused focused;
  478. struct rtgui_event_resize resize;
  479. struct rtgui_event_mv_model model;
  480. struct rtgui_event_command command;
  481. };
  482. #ifdef __cplusplus
  483. }
  484. #endif
  485. #endif