zori.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. #ifndef zori_H_INCLUDED
  2. #define zori_H_INCLUDED
  3. /*
  4. * ZORI is a a GUI subsystem for use with Allegro 5 that handles
  5. * the user interface of Eruta.
  6. *
  7. * ZORI is a classic retained-mode GUI system that has an additional
  8. * pseudo-direct mode API. ZORI uses a handler system where events are handled
  9. * by call back functions which can be installed as specific handlers that are
  10. * activated on certain events. But, in the spirit of direct mode GUI's, all
  11. * widgets also keep state flags and value flags that can be used to see if they
  12. * have been activated and that can be inspected in a direct-mode GUI fashion.
  13. * With ZORI you can have your retained mode GUI pie and also eat it in direct
  14. * mode.
  15. *
  16. * In ZORI, there is only one top-level widget, the root, however, every widget
  17. * can contain any amount of child widgets. One level below the root widget are
  18. * the screen widgets which are intent to handle the GUI on one physical screen
  19. * or display. Every GUI page can have different "pages", but only one page
  20. * should be active per screen. The idea is that a GUI page represents a single
  21. * GUI mode such as the main menu, the settings menu, the in game menu, etc,
  22. * where you definitely want only one to be active at any given time.
  23. *
  24. * The box model used in Zori will be as follows (XXX implement this):
  25. * ......................................
  26. * .margin .
  27. * . +-------------border-----------+ .
  28. * . | padding | .
  29. * . | .......................... | .
  30. * . | . . | .
  31. * . | . contents . | .
  32. * . | . . | .
  33. * . | .......................... | .
  34. * . | padding | .
  35. * . +------------------------------+ .
  36. * .margin .
  37. * ......................................
  38. *
  39. * The padding determines the minimal distance between the border or the
  40. * parent widget and it's contents and/or child widgets.
  41. *
  42. * The border's thickness is only relevant for visual effects.
  43. * It does not change the layout. The border is effectively "inside"
  44. * the padding and/or contents of the widget and is unrelated to the padding.
  45. *
  46. * The margin of a widget determines how closely that widget may be packed
  47. * to it's sibling widgets.
  48. *
  49. * The work in UI is divided between the top-level widgets,
  50. * namely the root and the page, and the other widgets.
  51. * The root and the page handle everything that depends on and/or may influence
  52. * several widgets at once, such as event dispatching but also setting the
  53. * focus, determining which widget is being hovered, or dragged, etc.
  54. * The latter functions change the state of several widgets, so they
  55. * are handled on the level of the container widgets.
  56. * The zori_widget and the other concrete widgets handle the individual
  57. * state and actions of the various widgets individually.
  58. *
  59. *
  60. *
  61. *
  62. */
  63. #include <stdbool.h>
  64. #include "eruta.h"
  65. #include "rebox.h"
  66. #include "miao.h"
  67. #include "str.h"
  68. /* Defines for C11/C99/C89 portability */
  69. #ifndef inline
  70. #define inline inline
  71. #endif
  72. /* Macros for possible later system library portability. */
  73. #define ZORI_EVENT_TYPE_IS_USER(T) ALLEGRO_EVENT_TYPE_IS_USER(T)
  74. #define ZORI_SYSTEM_EVENT_KEY_DOWN ALLEGRO_EVENT_KEY_DOWN
  75. #define ZORI_SYSTEM_EVENT_KEY_UP ALLEGRO_EVENT_KEY_UP
  76. #define ZORI_SYSTEM_EVENT_KEY_CHAR ALLEGRO_EVENT_KEY_CHAR
  77. #define ZORI_SYSTEM_EVENT_MOUSE_AXES ALLEGRO_EVENT_MOUSE_AXES
  78. #define ZORI_SYSTEM_EVENT_MOUSE_AXES ALLEGRO_EVENT_MOUSE_AXES
  79. #define ZORI_SYSTEM_EVENT_MOUSE_BUTTON_DOWN ALLEGRO_EVENT_MOUSE_BUTTON_DOWN
  80. #define ZORI_SYSTEM_EVENT_MOUSE_BUTTON_UP ALLEGRO_EVENT_MOUSE_BUTTON_UP
  81. /* Typedefs for possible later system library portability. */
  82. typedef ALLEGRO_COLOR zori_color;
  83. typedef ALLEGRO_BITMAP zori_bitmap;
  84. typedef ALLEGRO_FONT zori_font;
  85. typedef ALLEGRO_EVENT zori_system_event;
  86. typedef ALLEGRO_EVENT_TYPE zori_event_type;
  87. typedef ALLEGRO_DISPLAY zori_display;
  88. typedef Point zori_point;
  89. typedef Rebox zori_rebox;
  90. typedef Rebox zori_box;
  91. typedef int zori_id;
  92. typedef ALLEGRO_USTR zori_string;
  93. typedef ALLEGRO_USTR zori_text;
  94. /* Macros for possible portability. */
  95. #define zori_font_lineheight(FONT) al_get_font_line_height(FONT)
  96. #define zori_font_drawstr(FONT, COLOR, X, Y, ATTR, TEXT) al_draw_ustr(FONT, COLOR, X, Y, ATTR, TEXT)
  97. /* Default sizes of a widget. */
  98. #define ZORI_WIDGET_DEFAULT_W 640
  99. #define ZORI_WIDGET_DEFAULT_H 480
  100. /* Defaut padding and margin. */
  101. #define ZORI_PADDING_DEFAULT 4
  102. #define ZORI_MARGIN_DEFAULT 0
  103. /* Zori ID's. */
  104. #define ZORI_ID_OK_P(ID) ((ID) > -1)
  105. #define ZORI_ID_OK ((zori_id)(0))
  106. #define ZORI_ID_ERROR ((zori_id)(-1))
  107. #define ZORI_ID_ENOMEM ((zori_id)(-2))
  108. #define ZORI_ID_EINVAL ((zori_id)(-3))
  109. /** Macro for the number of elements of an array .*/
  110. #define ZORI_ARRAY_AMOUNT(A) ((size_t)(sizeof(A))/(sizeof(*A)))
  111. /** Macro that expands to the the array itself, and the amount of elements
  112. * in that array, in that order. Only works on a statically sized array. */
  113. #define ZORI_ARRAY_AND_AMOUNT(A) (A), ZORI_ARRAY_AMOUNT(A)
  114. /* Macro: ZORI_CONTAINER_OF(PTR, TYPE, MEMBER)
  115. This macro returns, for the given pointer, a pointer to a containing struct
  116. of type TYPE, in which PTR is a member named MEMBER.
  117. This enables cool ways of type genericity and extension in plain C.
  118. It should not run afoul of strict aliasing since it passes over a char * pointer
  119. and a pointer of a containing struct or union.
  120. */
  121. #define ZORI_CONTAINER_OF(PTR, TYPE, MEMBER) \
  122. ((PTR) ? ((TYPE *)(((char *)(PTR)) - offsetof(TYPE, MEMBER))) : NULL)
  123. /** Custom event types, used in conjunction with Allegro event types. */
  124. enum zori_custom_event_type {
  125. ZORI_EVENT_CUSTOM = ALLEGRO_GET_EVENT_TYPE('z', 'o', 'r', 'i'),
  126. /** Update event, called at regular intervals to update the state of the UI.*/
  127. ZORI_EVENT_UPDATE,
  128. /** First draw pass. */
  129. ZORI_EVENT_DRAW,
  130. /** Second draw pass for cursors. */
  131. ZORI_EVENT_OVERDRAW,
  132. /** Cleanup event. */
  133. ZORI_EVENT_DONE,
  134. /** Destruction event. */
  135. ZORI_EVENT_FREE,
  136. /** Activation event, such as a button being clicked or a menu being opened. */
  137. ZORI_EVENT_ACTION,
  138. /** Close event, such as a menu being closed. Not for cleanup.*/
  139. ZORI_EVENT_CLOSE,
  140. /** Child added event to ease setup. */
  141. ZORI_EVENT_NEW_CHILD,
  142. };
  143. struct zori_widget;
  144. /* Common fields for an event. */
  145. struct zori_any_event {
  146. /* Type of the event, possibly copied from sysev. */
  147. zori_event_type type;
  148. /* Widget the event is sent to. */
  149. struct zori_widget * widget;
  150. /* Data specified in the handler. */
  151. void * data;
  152. };
  153. /* System event, that is coming from the underlying library used, e.g. Allegro. */
  154. struct zori_sys_event {
  155. struct zori_any_event any;
  156. zori_system_event * ev;
  157. };
  158. /* Update event, when UI has to update (animations, etc). */
  159. struct zori_update_event {
  160. struct zori_any_event any;
  161. double dt;
  162. };
  163. /* Draw event when the UI has to draw itself. */
  164. struct zori_draw_event {
  165. struct zori_any_event any;
  166. };
  167. /* Cleanup event. */
  168. struct zori_done_event {
  169. struct zori_any_event any;
  170. };
  171. /* Cleanup event. */
  172. struct zori_free_event {
  173. struct zori_any_event any;
  174. };
  175. /* Action event. */
  176. struct zori_action_event {
  177. struct zori_any_event any;
  178. };
  179. /* Close event. */
  180. struct zori_close_event {
  181. struct zori_any_event any;
  182. /* The widget that was closed and that sent this message to it's parent. */
  183. struct zori_widget * from;
  184. };
  185. /* New child event. */
  186. struct zori_new_child_event {
  187. struct zori_any_event any;
  188. /* The widget that was added as a child and that sent this message to it's parent. */
  189. struct zori_widget * child;
  190. };
  191. /** An event that ZORI can handle. The union is cunningly overlaid so
  192. * that the type field and the any field can be used in all cases. */
  193. union zori_event {
  194. /* Type of the event, possibly copied from sysev. */
  195. zori_event_type type;
  196. struct zori_any_event any;
  197. struct zori_sys_event sys;
  198. struct zori_draw_event draw;
  199. struct zori_update_event update;
  200. struct zori_done_event done;
  201. struct zori_free_event free;
  202. struct zori_action_event action;
  203. struct zori_close_event close;
  204. struct zori_new_child_event new_child;
  205. };
  206. /* Helper functions to get widget from an event. */
  207. static inline struct zori_widget *
  208. zori_event_widget(union zori_event * event) {
  209. if (!event) return NULL;
  210. return event->any.widget;
  211. }
  212. /* Helper functions to get data from an event. */
  213. static inline void * zori_event_data(union zori_event * event) {
  214. if (!event) return NULL;
  215. return event->any.data;
  216. }
  217. /* Helper function that checks if an event is a sys_event. */
  218. static inline bool zori_event_is_sys_event(union zori_event * event) {
  219. if (!event) return false;
  220. return (!ALLEGRO_EVENT_TYPE_IS_USER(event->type));
  221. }
  222. /* Helper functions to get system event from an event. Type checks the type. */
  223. static inline zori_system_event * zori_event_system_event(union zori_event * event) {
  224. if (!event) return NULL;
  225. if (!zori_event_is_sys_event(event)) return NULL;
  226. return event->sys.ev;
  227. }
  228. /* Helper functions to set widget for an event. */
  229. static inline struct zori_widget *
  230. zori_event_set_widget(union zori_event * event, struct zori_widget * widget) {
  231. if (!event) return NULL;
  232. return event->any.widget = widget;
  233. }
  234. /* Helper functions to set data for an event. */
  235. static inline void * zori_event_set_data(union zori_event * event, void * data) {
  236. if (!event) return NULL;
  237. return event->any.data = data;
  238. }
  239. /* A style part is a color, image and font applied to a part of the GUI. */
  240. struct zori_stylepart {
  241. zori_color color;
  242. zori_bitmap * bitmap;
  243. zori_font * font;
  244. };
  245. /* A style is a set of style parts for different parts of the GUI. */
  246. struct zori_style {
  247. struct zori_stylepart fore;
  248. struct zori_stylepart back;
  249. struct zori_stylepart text;
  250. struct zori_stylepart border;
  251. struct zori_stylepart hover;
  252. struct zori_stylepart mark;
  253. };
  254. struct zori_widget;
  255. /* Event handler results. */
  256. enum zori_handle_result {
  257. ZORI_HANDLE_ERROR = -1, /* An error ocurred, stop propagating to children.*/
  258. ZORI_HANDLE_DONE = 0, /* The event was handled and consumed, no need to propagate to children automatically (widget may re-send event manually to children.)*/
  259. ZORI_HANDLE_IGNORE = 1, /* Event wasn't handled, propagate to children. */
  260. ZORI_HANDLE_PASS = 2, /* Event was handled, but needs to be propagated.*/
  261. };
  262. /* Returns whether or not a event needs to be propagated based on the
  263. * result of a handler. */
  264. static int zori_propagate_event_p(enum zori_handle_result result) {
  265. switch(result) {
  266. case ZORI_HANDLE_ERROR: return 0;
  267. case ZORI_HANDLE_DONE: return 0;
  268. case ZORI_HANDLE_IGNORE: return !0;
  269. case ZORI_HANDLE_PASS: return !0;
  270. default: return !0;
  271. }
  272. }
  273. typedef enum zori_handle_result (zori_handler_func)(union zori_event * event);
  274. /* A single event handler */
  275. struct zori_handler {
  276. zori_event_type type;
  277. zori_handler_func * handler;
  278. void * data;
  279. };
  280. /* A dynamic array of event handlers event handlers. */
  281. struct zori_handlers miao_of_type(struct zori_handler);
  282. /* An entry in a widget registry. */
  283. struct zori_registry_entry {
  284. zori_id id;
  285. struct zori_widget * widget;
  286. };
  287. /* A widget registry as a dynamic array of entries. */
  288. struct zori_registry miao_of_type(struct zori_registry_entry);
  289. /* Generic state flags for several zori structs. */
  290. enum zori_flag {
  291. /* The object is not visible, though it may still be interacted with.*/
  292. ZORI_FLAG_HIDDEN = 1 << 0,
  293. /* The object cannot be interacted with, though it is still visible. */
  294. ZORI_FLAG_DISABLED = 1 << 1,
  295. /* The object is both hidden and disabled. */
  296. ZORI_FLAG_DEACTIVATED = ZORI_FLAG_HIDDEN | ZORI_FLAG_DISABLED,
  297. /* The object is being hovered by the mouse cursor. */
  298. ZORI_FLAG_HOVERED = 1 << 2,
  299. /* The object is "marked" for activation by the keyjoy cursor */
  300. ZORI_FLAG_MARKED = 1 << 3,
  301. };
  302. /* Typedef for the type of a widget.
  303. * Not an enum since every widget may define this itself.
  304. */
  305. typedef uint32_t zori_widget_type;
  306. /* Generic widget types. */
  307. #define ZORI_WIDGET_TYPE_NONE ((zori_widget_type)(0))
  308. /* Macro to help generate widget types. */
  309. #define ZORI_WIDGET_TYPE(A, B, C, D) ((zori_widget_type)((A<<24) | (B<<16) | (C<<8) | D))
  310. /* Mouse or keyboard/joystick cursor. */
  311. struct zori_cursor {
  312. zori_point p;
  313. struct zori_widget * hover;
  314. struct zori_widget * focus;
  315. zori_bitmap * bitmap;
  316. enum zori_flag flags;
  317. };
  318. /* Support multiple cursors... */
  319. struct zori_cursors {
  320. struct zori_cursor mouse;
  321. struct zori_cursor keyjoy;
  322. };
  323. /*
  324. on_enter
  325. on_enter(data = {})
  326. on_event(*args)
  327. on_event(*data)
  328. on_key_down(*args)
  329. on_leave(name=nil)
  330. on_mouse_axes(t, x, y, z, w, dx, dy, dz, dw)
  331. on_mouse_button_down(t, x, y, z, w, b)
  332. on_mouse_button_up(t, x, y, z, w, b)
  333. on_mouse_in(x, y, from)
  334. on_mouse_out(x, y, to)
  335. on_resize
  336. */
  337. struct zori_widget;
  338. struct zori_widget_list miao_of_type(struct zori_widget *);
  339. struct zori_widget {
  340. /* ID of the widget, used in most external API's. */
  341. zori_id id;
  342. /* Root level widget under which this widget is active. */
  343. struct zori_widget * root;
  344. /* Position and size of the widget. */
  345. zori_rebox box;
  346. /* Outer rectangle of the widget, with the margin added. */
  347. zori_rebox outer;
  348. /* Inner rectangle of the widget, with the padding removed. */
  349. zori_rebox inner;
  350. /* Z ordering. */
  351. int z;
  352. /* Style. */
  353. struct zori_style style;
  354. /* Handlers. */
  355. struct zori_handlers handlers;
  356. /* Related widgets. */
  357. struct zori_widget * parent;
  358. struct zori_widget_list children;
  359. /* Flags. */
  360. enum zori_flag flags;
  361. /* Type of the widget. */
  362. zori_widget_type type;
  363. /* Generic "result", of last operation on widget, normally zero. */
  364. int result;
  365. };
  366. /* An array of widget pointers. */
  367. struct zori_widget_array miao_of_type(struct zori_widget *);
  368. /* Forward declarations. */
  369. struct zori_screen;
  370. struct zori_console;
  371. /*
  372. * Root level widget, my spread out over several displays.
  373. * In Zori, there can only be a single root level widget active.
  374. * It's ID is always 0;
  375. */
  376. struct zori_root {
  377. /* A root is a widget. */
  378. struct zori_widget widget;
  379. /* Current active screen widget if any. */
  380. struct zori_screen * active_screen;
  381. /* Current active console if any. */
  382. struct zori_console * console;
  383. };
  384. /* Forward declaration of a page. */
  385. struct zori_page;
  386. struct zori_root * zori_get_root(void);
  387. /* Initializes Zori and creates a top level widget. Returns 0 on success
  388. * or negative on error. The style will be copied and set as default
  389. * if it is not NULL. Otherwise a built-in style will be used.
  390. * Not that ZORI will NOT clean up any images or fonts it uses by itself.
  391. */
  392. zori_id zori_start(struct zori_style * default_style);
  393. /* Shut down Zori and destroys all widgets. Return 0 on succes or
  394. * negative on error.
  395. */
  396. zori_id zori_shutdown();
  397. /* Creates a new screen widget. Normally this should be the first widget
  398. * you create after zori_start. */
  399. /* Activates the page on it's display. All other pages are dectivated and
  400. * hidden. */
  401. zori_id zori_activate_page(zori_id page);
  402. /* Creates a new generic widget on the given screen with the given
  403. * dimensions. */
  404. zori_id zori_new(zori_id screen, zori_rebox * box);
  405. /* Sets the flags of a widget. */
  406. zori_id zori_set_flags(zori_id widget, enum zori_flag flags);
  407. /* Sets the whole style of a widget. */
  408. zori_id zori_set_style(zori_id id, struct zori_style * style);
  409. /* Sets the background color of the widget. */
  410. zori_id zori_set_background_color(zori_id id, zori_color color);
  411. /* Sets the foreground color of the widget. */
  412. zori_id zori_set_foreground_color(zori_id id, zori_color color);
  413. /* Creates a new frame widget. */
  414. zori_id zori_new_frame_widget(zori_id parent, zori_rebox box);
  415. /* Creates a new (vertical) menu widget. */
  416. zori_id zori_new_menu_widget(zori_id parent, zori_rebox box, char * text);
  417. /* Creates a new button widget. */
  418. zori_id zori_new_button_widget(zori_id parent, zori_rebox box, char * text);
  419. /* Creates a new conversation widget. */
  420. zori_id zori_new_conversation_widget(zori_id parent, zori_rebox box, char * text);
  421. /* Draws the whole UI and all visible parts. */
  422. void zori_draw_all(void);
  423. /* Updates the state of the UI. Pass in the time passed since last update. */
  424. void zori_update(double dt);
  425. /* Registers an event handler for a widget. */
  426. zori_id zori_register(zori_id id, zori_event_type type, zori_handler_func handler, void * extra);
  427. int zori_registry_entry_compare(const void *v1, const void *v2);
  428. zori_id zori_registry_init(struct zori_registry *registry);
  429. zori_id zori_registry_add(struct zori_registry *registry, zori_id id, struct zori_widget *widget);
  430. struct zori_registry_entry *zori_registry_lookup_entry(struct zori_registry *registry, zori_id id);
  431. struct zori_widget *zori_registry_lookup(struct zori_registry *registry, zori_id id);
  432. zori_id zori_registry_remove(struct zori_registry *registry, zori_id id);
  433. int zori_handler_compare(const void *v1, const void *v2);
  434. struct zori_handler *zori_handlers_add(struct zori_handlers *me, zori_event_type type, zori_handler_func *handler, void *data);
  435. void zori_handlers_done(struct zori_handlers *me);
  436. void zori_handlers_init(struct zori_handlers *me);
  437. struct zori_handler *zori_handlers_search(struct zori_handlers *me, zori_event_type type);
  438. int zori_handlers_handle(struct zori_handlers *me, union zori_event *event);
  439. int zori_widget_raise_system_event(struct zori_widget *widget, zori_system_event *sysev);
  440. int zori_widget_raise_draw_event(struct zori_widget *widget);
  441. int zori_widget_raise_done_event(struct zori_widget *widget);
  442. int zori_widget_raise_free_event(struct zori_widget *widget);
  443. int zori_widget_raise_update_event(struct zori_widget *widget, double dt);
  444. int zori_widget_raise_action_event(struct zori_widget *widget);
  445. int zori_widget_raise_close_event(struct zori_widget *widget, struct zori_widget * from);
  446. int zori_widget_compare(const void *v1, const void *v2);
  447. struct zori_widget *zori_get_widget(zori_id id);
  448. zori_id zori_get_unused_id(void);
  449. struct zori_handler *zori_widget_add_handler(struct zori_widget *widget, zori_event_type type, zori_handler_func *handler, void *data);
  450. struct zori_handler *zori_widget_add_handlers(struct zori_widget *widget, struct zori_handler *handlers, size_t amount);
  451. zori_id zori_start(struct zori_style *default_style);
  452. struct zori_widget *zori_widget_done(struct zori_widget *widget);
  453. void zori_widget_free(struct zori_widget *widget);
  454. struct zori_widget *zori_widget_add_child(struct zori_widget *parent, struct zori_widget *child);
  455. struct zori_widget *zori_widget_init(struct zori_widget *widget, zori_widget_type type, zori_id id, struct zori_widget *parent, zori_rebox *box, struct zori_style *style);
  456. zori_id zori_shutdown(void);
  457. struct zori_widget *zori_widget_initall(struct zori_widget *widget, zori_widget_type type, zori_id id, struct zori_widget *parent, zori_rebox *box, struct zori_style *style, struct zori_handler *handlers, size_t amount);
  458. void zori_draw_all(void);
  459. int zori_widget_visible(struct zori_widget *widget);
  460. int zori_widget_visible_(struct zori_widget *widget, int set);
  461. int zori_widget_active(struct zori_widget *widget);
  462. int zori_widget_active_(struct zori_widget *widget, int set);
  463. int zori_widget_hover(struct zori_widget *widget);
  464. int zori_widget_hover_(struct zori_widget *widget, int set);
  465. int zori_widget_marked(struct zori_widget *widget);
  466. int zori_widget_marked_(struct zori_widget *widget, int set);
  467. int zori_widget_active_(struct zori_widget *widget, int set);
  468. void zori_update(double dt);
  469. zori_font *zori_widget_font(struct zori_widget *widget);
  470. zori_color zori_widget_forecolor(struct zori_widget *widget);
  471. zori_color zori_widget_backcolor(struct zori_widget *widget);
  472. int zori_widget_h(struct zori_widget *widget);
  473. int zori_widget_w(struct zori_widget *widget);
  474. int zori_widget_x(struct zori_widget *widget);
  475. int zori_widget_y(struct zori_widget *widget);
  476. int zori_xy_inside_widget_p(struct zori_widget * widget, double x, double y);
  477. void zori_widget_drawroundframe(struct zori_widget *self);
  478. int zori_handle_system_event(zori_system_event * sysev);
  479. int zori_result(int zori_id);
  480. int zori_mark_widget(struct zori_widget * widget);
  481. #endif