WebViewDummy.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /*
  2. * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
  3. * Copyright 2010 Sony Network Entertainment
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  15. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  18. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  21. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  22. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef _WEBVIEW_H_
  27. #define _WEBVIEW_H_
  28. #include <stdlib.h>
  29. union VarData {
  30. int type_int;
  31. float type_float;
  32. bool type_bool;
  33. char type_char;
  34. char *type_char_ptr;
  35. const char *type_const_char_ptr;
  36. unsigned char type_uchar;
  37. unsigned char *type_uchar_ptr;
  38. const unsigned char *type_const_uchar_ptr;
  39. void *type_void_ptr;
  40. };
  41. typedef VarData CallbackData;
  42. enum CallbackType {
  43. CallbackTypeUndefined = -1,
  44. CALLBACK_ERROR,
  45. CALLBACK_SET_TEXTURE,
  46. CALLBACK_SET_TITLE,
  47. CALLBACK_SET_URL,
  48. CALLBACK_HOVER_LINK_URL,
  49. CALLBACK_HOVER_INPUT_ELEMENT,
  50. CALLBACK_FOCUS_INPUT_ELEMENT,
  51. CALLBACK_FOCUS_CHANGED,
  52. CALLBACK_SCROLL_CHANGED,
  53. CALLBACK_SHOW_POPUP_MENU,
  54. CALLBACK_HIDE_POPUP_MENU,
  55. CALLBACK_LOAD_STARTED,
  56. CALLBACK_LOAD_FINISHED,
  57. CALLBACK_LOAD_FAILED,
  58. CALLBACK_LOAD_PROGRESS_CHANGED,
  59. CALLBACK_JAVASCRIPT_ALERT,
  60. CALLBACK_JAVASCRIPT_CONFIRM,
  61. CALLBACK_JAVASCRIPT_PROMPT,
  62. CallbackTypeCount
  63. };
  64. enum LoadErrorType {
  65. LoadErrorTypeUndefined = -1,
  66. LOAD_ERROR_CANCELLED,
  67. LOAD_ERROR_BLOCKED,
  68. LOAD_ERROR_CANNOT_SHOW_URL,
  69. LOAD_ERROR_INTERRUPTED_FOR_POLICY_CHANGE,
  70. LOAD_ERROR_CANNOT_SHOW_MIME_TYPE,
  71. LOAD_ERROR_FILE_DOES_NOT_EXIST,
  72. LOAD_ERROR_PLUGIN_WILL_HANDLE_LOAD,
  73. LoadErrorTypeCount
  74. };
  75. enum ScrollEventType {
  76. ScrollEventTypeUndefined = -1,
  77. SCROLL_EVENT_UP,
  78. SCROLL_EVENT_DOWN,
  79. SCROLL_EVENT_LEFT,
  80. SCROLL_EVENT_RIGHT,
  81. SCROLL_EVENT_TOP,
  82. SCROLL_EVENT_BOTTOM,
  83. SCROLL_EVENT_PAGE_UP,
  84. SCROLL_EVENT_PAGE_DOWN,
  85. SCROLL_EVENT_SET_POSITION,
  86. ScrollEventTypeCount
  87. };
  88. enum MouseEventType {
  89. MouseEventTypeUndefined = -1,
  90. MOUSE_EVENT_MOVED,
  91. MOUSE_EVENT_PRESSED,
  92. MOUSE_EVENT_RELEASED,
  93. MouseEventTypeCount
  94. };
  95. enum MouseButtonType {
  96. MouseButtonTypeUndefined = -1,
  97. MOUSE_BUTTON_NONE,
  98. MOUSE_BUTTON_LEFT,
  99. MOUSE_BUTTON_MIDDLE,
  100. MOUSE_BUTTON_RIGHT,
  101. MOUSE_WHEEL_UP,
  102. MOUSE_WHEEL_DOWN,
  103. MouseButtonTypeCount
  104. };
  105. enum KeyEventType {
  106. KeyEventTypeUndefined = -1,
  107. KEY_EVENT_PRESSED,
  108. KEY_EVENT_RELEASED,
  109. KeyEventTypeCount
  110. };
  111. enum KeyType {
  112. KeyTypeUndefined = -1,
  113. KEY_A,
  114. KEY_B,
  115. KEY_C,
  116. KEY_D,
  117. KEY_E,
  118. KEY_F,
  119. KEY_G,
  120. KEY_H,
  121. KEY_I,
  122. KEY_J,
  123. KEY_K,
  124. KEY_L,
  125. KEY_M,
  126. KEY_N,
  127. KEY_O,
  128. KEY_P,
  129. KEY_Q,
  130. KEY_R,
  131. KEY_S,
  132. KEY_T,
  133. KEY_U,
  134. KEY_V,
  135. KEY_W,
  136. KEY_X,
  137. KEY_Y,
  138. KEY_Z,
  139. KEY_1,
  140. KEY_2,
  141. KEY_3,
  142. KEY_4,
  143. KEY_5,
  144. KEY_6,
  145. KEY_7,
  146. KEY_8,
  147. KEY_9,
  148. KEY_0,
  149. KEY_F1,
  150. KEY_F2,
  151. KEY_F3,
  152. KEY_F4,
  153. KEY_F5,
  154. KEY_F6,
  155. KEY_F7,
  156. KEY_F8,
  157. KEY_F9,
  158. KEY_F10,
  159. KEY_F11,
  160. KEY_F12,
  161. KEY_ACCENT,
  162. KEY_BACKSLASH,
  163. KEY_BACKSPACE,
  164. KEY_CAPS_LOCK,
  165. KEY_COMMA,
  166. KEY_DELETE,
  167. KEY_DOWN_ARROW,
  168. KEY_END,
  169. KEY_ENTER,
  170. KEY_EQUAL,
  171. KEY_ESC,
  172. KEY_HENKAN,
  173. KEY_HOME,
  174. KEY_INSERT,
  175. KEY_KANA,
  176. KEY_KANJI,
  177. KEY_LEFT_ARROW,
  178. KEY_LEFT_BRACKET,
  179. KEY_MINUS,
  180. KEY_MUHENKAN,
  181. KEY_PAGE_DOWN,
  182. KEY_PAGE_UP,
  183. KEY_PAUSE,
  184. KEY_PERIOD,
  185. KEY_PRINTSCREEN,
  186. KEY_QUOTATION,
  187. KEY_RIGHT_ARROW,
  188. KEY_RIGHT_BRACKET,
  189. KEY_SCROLL_LOCK,
  190. KEY_SEMICOLON,
  191. KEY_SLASH,
  192. KEY_SPACE,
  193. KEY_TAB,
  194. KEY_UP_ARROW,
  195. KEY_NUMPAD_1,
  196. KEY_NUMPAD_2,
  197. KEY_NUMPAD_3,
  198. KEY_NUMPAD_4,
  199. KEY_NUMPAD_5,
  200. KEY_NUMPAD_6,
  201. KEY_NUMPAD_7,
  202. KEY_NUMPAD_8,
  203. KEY_NUMPAD_9,
  204. KEY_NUMPAD_0,
  205. KEY_NUMPAD_ASTERISK,
  206. KEY_NUMPAD_ENTER,
  207. KEY_NUMPAD_MINUS,
  208. KEY_NUMPAD_NUMLOCK,
  209. KEY_NUMPAD_PERIOD,
  210. KEY_NUMPAD_PLUS,
  211. KEY_NUMPAD_SLASH,
  212. KeyTypeCount
  213. };
  214. typedef VarData HtmlEventData;
  215. enum HtmlEventType {
  216. HtmlEventTypeUndefined = -1,
  217. HTML_NODE_FOCUS_NONE,
  218. HTML_NODE_FOCUS_FORWARD,
  219. HTML_NODE_FOCUS_BACKWARD,
  220. HTML_NODE_FOCUS_UP,
  221. HTML_NODE_FOCUS_DOWN,
  222. HTML_NODE_FOCUS_LEFT,
  223. HTML_NODE_FOCUS_RIGHT,
  224. HTML_INPUT_ELEMENT_SET_VALUE,
  225. HtmlEventTypeCount
  226. };
  227. class WebView
  228. {
  229. public:
  230. WebView() {}
  231. ~WebView() {}
  232. void create(int width, int height, bool async) {}
  233. void update() {}
  234. void setCallbackHandler(
  235. bool (*callbackHandler)(WebView *webview, void *userData, CallbackType type, const CallbackData *in, CallbackData *out),
  236. void *userData = NULL) {}
  237. void getContentSize(int &width, int &height) {}
  238. void getScrollPosition(int &x, int &y) {}
  239. void sendScrollEvent(ScrollEventType event, int x=0, int y=0) {}
  240. void sendMouseEvent(MouseEventType event, MouseButtonType button, int x, int y) {}
  241. void sendKeyEvent(KeyEventType event, KeyType key, char ascii = 0, bool shift = false, bool ctrl = false, bool alt = false, bool win = false) {}
  242. void sendHtmlEvent(HtmlEventType event, const HtmlEventData *data = NULL) {}
  243. void loadUrl(const char *url) {}
  244. void loadHtml(const char *html) {}
  245. void reload() {}
  246. void stop() {}
  247. bool canGoBack() { return false; }
  248. void goBack() {}
  249. bool canGoForward() { return false; }
  250. void goForward() {}
  251. bool canIncreaseTextSize() const;
  252. void increaseTextSize() {}
  253. bool canDecreaseTextSize() const;
  254. void decreaseTextSize() {}
  255. void resetTextSize() {}
  256. const char *executeJavaScript(const char *javascript) { return NULL; }
  257. };
  258. #endif//_WEBVIEW_H_