123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- #ifndef zori_H_INCLUDED
- #define zori_H_INCLUDED
- #include "eruta.h"
- #include "rebox.h"
- #include "miao.h"
- /* Typedefs for possible later portability. */
- typedef ALLEGRO_COLOR zori_color ;
- typedef ALLEGRO_BITMAP zori_bitmap ;
- typedef ALLEGRO_FONT zori_font ;
- typedef ALLEGRO_EVENT zori_system_event;
- typedef ALLEGRO_EVENT_TYPE zori_event_type;
- typedef ALLEGRO_DISPLAY zori_display;
- typedef Point zori_point;
- typedef Rebox zori_rebox;
- typedef int zori_id;
- #define ZORI_ID_OK_P(ID) ((ID) > -1)
- #define ZORI_ID_OK ((zori_id)(0))
- #define ZORI_ID_ERROR ((zori_id)(-1))
- #define ZORI_ID_ENOMEM ((zori_id)(-2))
- #define ZORI_ID_EINVAL ((zori_id)(-3))
- struct zori_widget;
- struct zori_event {
- zori_system_event sysev;
- struct zori_widget * widget;
- void * data;
- };
- struct zori_stylepart {
- zori_color color;
- zori_bitmap * image;
- zori_font * font;
- };
- struct zori_style {
- struct zori_stylepart fore;
- struct zori_stylepart back;
- struct zori_stylepart text;
- };
- struct zori_widget;
- typedef int zori_handler_func(struct zori_event * event);
- struct zori_handler {
- zori_event_type type;
- zori_handler_func * handler;
- void * data;
- };
- /* System event handlers. */
- struct zori_handlers miao_of_type(struct zori_handler);
- /*
- struct zori_handlers {
- size_t size;
- struct zori_handler * handlers;
- };
- */
- /* Mouse or keyboard/joystick cursor. */
- struct zori_cursor {
- zori_point p;
- struct zori_widget * hover;
- struct zori_widget * focus;
- zori_bitmap * bitmap;
- };
- /* Support multiple cursors... */
- struct zori_cursors {
- struct zori_cursor mouse;
- struct zori_cursor keyjoy;
- };
- /*
- on_enter
- on_enter(data = {})
- on_event(*args)
- on_event(*data)
- on_key_down(*args)
- on_leave(name=nil)
- on_mouse_axes(t, x, y, z, w, dx, dy, dz, dw)
- on_mouse_button_down(t, x, y, z, w, b)
- on_mouse_button_up(t, x, y, z, w, b)
- on_mouse_in(x, y, from)
- on_mouse_out(x, y, to)
- on_resize
- */
- struct zori_widget {
- /* ID of the widget, used in most external API's. */
- zori_id id;
-
- /* Root level widget under which this widget is active. */
- struct zori_widget * root;
-
- /* Position and size of the widget. */
- zori_rebox box;
- /* Z ordering. */
- int z;
-
- /* Style. */
- struct zori_style style;
-
- /* Handlers. */
- struct zori_handlers handlers;
-
- /* Related widgets. */
- struct zori_widget * parent;
- struct zori_widget * child;
- struct zori_widget * sibling;
- };
- /* An array of widget pointers. */
- struct zori_widget_array {
- struct zori_widget * array;
- size_t size;
- };
- /* Root level widget. */
- struct zori_root {
- /* A root is a widget. */
- struct zori_widget widget;
- /* It also manages the cursors*/
- struct zori_cursors cursors;
- /* It has an array of all widgets it manages. */
- struct zori_widget_array * widgets;
- /* It is linked to a particular display. */
- zori_display * display;
- };
- zori_id zori_set_background_color(zori_id id, zori_color color);
- zori_id zori_set_foreground_color(zori_id id, zori_color color);
- zori_id zori_new_root_widget(const struct zori_style * style);
- zori_id zori_new_frame_widget(zori_id parent);
- zori_id zori_register(zori_id id, zori_event_type type, zori_handler_func handler, void * extra);
- #endif
|