/src/ftk_event.h

http://ftk.googlecode.com/ · C Header · 143 lines · 103 code · 11 blank · 29 comment · 2 complexity · 0096da0428daba81de3041e0457cd376 MD5 · raw file

  1. /*
  2. * File: ftk_event.h
  3. * Author: Li XianJing <xianjimli@hotmail.com>
  4. * Brief:
  5. *
  6. * Copyright (c) 2009 - 2010 Li XianJing <xianjimli@hotmail.com>
  7. *
  8. * Licensed under the Academic Free License version 2.1
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. /*
  25. * History:
  26. * ================================================================
  27. * 2009-10-03 Li XianJing <xianjimli@hotmail.com> created
  28. *
  29. */
  30. #ifndef FTK_EVENT_H
  31. #define FTK_EVENT_H
  32. #include "ftk_typedef.h"
  33. FTK_BEGIN_DECLS
  34. typedef enum _FtkEventType
  35. {
  36. FTK_EVT_NOP = 0,
  37. FTK_EVT_IDLE,
  38. FTK_EVT_INIT,
  39. FTK_EVT_TIMER,
  40. FTK_EVT_QUIT,
  41. FTK_EVT_KEY_UP,
  42. FTK_EVT_KEY_DOWN,
  43. FTK_EVT_MOUSE_MOVE,
  44. FTK_EVT_MOUSE_DOWN,
  45. FTK_EVT_MOUSE_LONG_PRESS,
  46. FTK_EVT_KEY_LONG_PRESS,
  47. FTK_EVT_MOUSE_UP,
  48. FTK_EVT_HIDE,
  49. FTK_EVT_SHOW,
  50. FTK_EVT_MAP,
  51. FTK_EVT_UNMAP,
  52. FTK_EVT_UPDATE,
  53. FTK_EVT_MOVE,
  54. FTK_EVT_RESIZE,
  55. FTK_EVT_MOVE_RESIZE,
  56. FTK_EVT_FOCUS_IN,
  57. FTK_EVT_FOCUS_OUT,
  58. FTK_EVT_ADD_CHILD,
  59. FTK_EVT_IM_COMMIT,
  60. FTK_EVT_IM_PREEDIT,
  61. FTK_EVT_SET_TEXT,
  62. FTK_EVT_GET_TEXT,
  63. FTK_EVT_IM_ACT_COMMIT,
  64. FTK_EVT_OS_IM_COMMIT,
  65. FTK_EVT_REMOVE_CHILD,
  66. FTK_EVT_WND_DESTROY,
  67. FTK_EVT_RELAYOUT_WND,
  68. FTK_EVT_ADD_SOURCE,
  69. FTK_EVT_REMOVE_SOURCE,
  70. FTK_EVT_THEME_CHANGED,
  71. FTK_EVT_SCREEN_ROTATED,
  72. FTK_EVT_DISABLE_CURSOR,
  73. FTK_EVT_ENABLE_CURSOR,
  74. FTK_EVT_OS_SCREEN_ROTATED,
  75. FTK_EVT_LOCALE_CHANGED,
  76. FTK_EVT_DISPLAY_CHANGED,
  77. FTK_EVT_TOP_WND_CHANGED,
  78. FTK_EVT_WND_CONFIG_CHANGED,
  79. FTK_EVT_TAB_PAGE_ACTIVATE,
  80. FTK_EVT_TAB_PAGE_DEACTIVATE
  81. }FtkEventType;
  82. typedef struct _FtkEvent
  83. {
  84. FtkEventType type;
  85. void* widget;
  86. size_t time;
  87. union
  88. {
  89. struct _Idle
  90. {
  91. FtkIdle action;
  92. void* user_data;
  93. }idle;
  94. struct _Timer
  95. {
  96. FtkTimer action;
  97. int interval;
  98. void* user_data;
  99. }timer;
  100. struct _Key
  101. {
  102. int code;
  103. }key;
  104. struct _Mouse
  105. {
  106. unsigned char press;
  107. unsigned char button;
  108. unsigned short x;
  109. unsigned short y;
  110. }mouse;
  111. struct _Display
  112. {
  113. void* display;
  114. int width;
  115. int height;
  116. }display;
  117. FtkRect rect;
  118. void* extra;
  119. }u;
  120. }FtkEvent;
  121. typedef Ret (*FtkOnEvent)(void* user_data, FtkEvent* event);
  122. static inline Ret ftk_event_init(FtkEvent* event, FtkEventType type)
  123. {
  124. if(event != NULL)
  125. {
  126. memset(event, 0x00, sizeof(FtkEvent));
  127. event->type = type;
  128. }
  129. return RET_OK;
  130. }
  131. FTK_END_DECLS
  132. #endif/*FTK_EVENT_H*/