|
@@ -121,6 +121,7 @@ typedef ALLEGRO_USTR zori_text;
|
|
/* Zori ID's. */
|
|
/* Zori ID's. */
|
|
#define ZORI_ID_OK_P(ID) ((ID) > -1)
|
|
#define ZORI_ID_OK_P(ID) ((ID) > -1)
|
|
#define ZORI_ID_OK ((zori_id)(0))
|
|
#define ZORI_ID_OK ((zori_id)(0))
|
|
|
|
+#define ZOTI_ID_GENERATE ((zori_id)(-1))
|
|
#define ZORI_ID_ERROR ((zori_id)(-1))
|
|
#define ZORI_ID_ERROR ((zori_id)(-1))
|
|
#define ZORI_ID_ENOMEM ((zori_id)(-2))
|
|
#define ZORI_ID_ENOMEM ((zori_id)(-2))
|
|
#define ZORI_ID_EINVAL ((zori_id)(-3))
|
|
#define ZORI_ID_EINVAL ((zori_id)(-3))
|
|
@@ -284,22 +285,36 @@ static inline void * zori_event_set_data(union zori_event * event, void * data)
|
|
return event->any.data = data;
|
|
return event->any.data = data;
|
|
}
|
|
}
|
|
|
|
|
|
-/* A style part is a color, image, font, and font flags applied to a part of the GUI. */
|
|
|
|
-struct zori_stylepart {
|
|
|
|
|
|
+/* Style flags */
|
|
|
|
+enum zori_style_flag {
|
|
|
|
+ ZORI_STYLE_FLAG_BORDER = 1,
|
|
|
|
+ ZORI_STYLE_FLAG_FILL = 2,
|
|
|
|
+ ZORI_STYLE_FLAG_DEFAULT= (ZORI_STYLE_FLAG_BORDER | ZORI_STYLE_FLAG_FILL),
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/* A graphic is a color, image, and style flags applied to a part of the GUI. */
|
|
|
|
+struct zori_graphic_style {
|
|
zori_color color;
|
|
zori_color color;
|
|
zori_bitmap * bitmap;
|
|
zori_bitmap * bitmap;
|
|
|
|
+ int style_flags;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/* A text style has all elements needed to style a piece of text. I consists of the text color, font and font flags flags applied to a part of the GUI.
|
|
|
|
+ */
|
|
|
|
+struct zori_text_style {
|
|
|
|
+ zori_color color;
|
|
zori_font * font;
|
|
zori_font * font;
|
|
- int font_flags;
|
|
|
|
|
|
+ int font_flags;
|
|
};
|
|
};
|
|
|
|
|
|
/* A style is a set of style parts for different parts of the GUI. */
|
|
/* A style is a set of style parts for different parts of the GUI. */
|
|
struct zori_style {
|
|
struct zori_style {
|
|
- struct zori_stylepart fore;
|
|
|
|
- struct zori_stylepart back;
|
|
|
|
- struct zori_stylepart text;
|
|
|
|
- struct zori_stylepart border;
|
|
|
|
- struct zori_stylepart hover;
|
|
|
|
- struct zori_stylepart mark;
|
|
|
|
|
|
+ struct zori_graphic_style fore;
|
|
|
|
+ struct zori_graphic_style back;
|
|
|
|
+ struct zori_graphic_style border;
|
|
|
|
+ struct zori_graphic_style hover;
|
|
|
|
+ struct zori_graphic_style mark;
|
|
|
|
+ struct zori_text_style text;
|
|
};
|
|
};
|
|
|
|
|
|
struct zori_widget;
|
|
struct zori_widget;
|
|
@@ -361,6 +376,9 @@ enum zori_flag {
|
|
ZORI_FLAG_HOVERED = 1 << 2,
|
|
ZORI_FLAG_HOVERED = 1 << 2,
|
|
/* The object is "marked" for activation by the keyjoy cursor */
|
|
/* The object is "marked" for activation by the keyjoy cursor */
|
|
ZORI_FLAG_MARKED = 1 << 3,
|
|
ZORI_FLAG_MARKED = 1 << 3,
|
|
|
|
+ /* The object is ready to report a "result".
|
|
|
|
+ * What that is depends on the object. */
|
|
|
|
+ ZORI_FLAG_READY = 1 << 4,
|
|
};
|
|
};
|
|
|
|
|
|
/* Typedef for the type of a widget.
|
|
/* Typedef for the type of a widget.
|
|
@@ -381,6 +399,7 @@ struct zori_cursor {
|
|
struct zori_widget * focus;
|
|
struct zori_widget * focus;
|
|
zori_bitmap * bitmap;
|
|
zori_bitmap * bitmap;
|
|
enum zori_flag flags;
|
|
enum zori_flag flags;
|
|
|
|
+ struct zori_style style;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -390,6 +409,21 @@ struct zori_cursors {
|
|
struct zori_cursor keyjoy;
|
|
struct zori_cursor keyjoy;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+/* The value of a result of a widget, see below. */
|
|
|
|
+union zori_result_value {
|
|
|
|
+ int integer;
|
|
|
|
+ zori_string * string;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/* The "result" of a widget. If the flag ready is set, the
|
|
|
|
+ * widget has a result to report . This normally happens when it was
|
|
|
|
+ * clicked, or when a menu item was selected, */
|
|
|
|
+struct zori_result {
|
|
|
|
+ int ready;
|
|
|
|
+ union zori_result_value value;
|
|
|
|
+ void * extra;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
|
|
/*
|
|
/*
|
|
on_enter
|
|
on_enter
|
|
@@ -445,8 +479,8 @@ struct zori_widget {
|
|
/* Type of the widget. */
|
|
/* Type of the widget. */
|
|
zori_widget_type type;
|
|
zori_widget_type type;
|
|
|
|
|
|
- /* Generic "result", of last operation on widget, normally zero. */
|
|
|
|
- int result;
|
|
|
|
|
|
+ /* Generic "result", of last operation on widget. */
|
|
|
|
+ struct zori_result result;
|
|
|
|
|
|
/* Cannot easily use the handers for destroying the widget, so in stead
|
|
/* Cannot easily use the handers for destroying the widget, so in stead
|
|
* provide a destructor. */
|
|
* provide a destructor. */
|
|
@@ -539,84 +573,6 @@ void zori_update(double dt);
|
|
zori_id zori_register(zori_id id, zori_event_type type, zori_handler_func handler, void * extra);
|
|
zori_id zori_register(zori_id id, zori_event_type type, zori_handler_func handler, void * extra);
|
|
|
|
|
|
|
|
|
|
-int zori_registry_entry_compare(const void *v1, const void *v2);
|
|
|
|
-zori_id zori_registry_init(struct zori_registry *registry);
|
|
|
|
-zori_id zori_registry_add(struct zori_registry *registry, zori_id id, struct zori_widget *widget);
|
|
|
|
-struct zori_registry_entry *zori_registry_lookup_entry(struct zori_registry *registry, zori_id id);
|
|
|
|
-struct zori_widget *zori_registry_lookup(struct zori_registry *registry, zori_id id);
|
|
|
|
-zori_id zori_registry_remove(struct zori_registry *registry, zori_id id);
|
|
|
|
-int zori_handler_compare(const void *v1, const void *v2);
|
|
|
|
-struct zori_handler *zori_handlers_add(struct zori_handlers *me, zori_event_type type, zori_handler_func *handler, void *data);
|
|
|
|
-void zori_handlers_done(struct zori_handlers *me);
|
|
|
|
-void zori_handlers_init(struct zori_handlers *me);
|
|
|
|
-struct zori_handler *zori_handlers_search(struct zori_handlers *me, zori_event_type type);
|
|
|
|
-int zori_handlers_handle(struct zori_handlers *me, union zori_event *event);
|
|
|
|
-
|
|
|
|
-int zori_widget_raise_system_event(struct zori_widget *widget, zori_system_event *sysev);
|
|
|
|
-int zori_widget_raise_draw_event(struct zori_widget *widget);
|
|
|
|
-int zori_widget_raise_done_event(struct zori_widget *widget);
|
|
|
|
-int zori_widget_raise_free_event(struct zori_widget *widget);
|
|
|
|
-int zori_widget_raise_update_event(struct zori_widget *widget, double dt);
|
|
|
|
-int zori_widget_raise_action_event(struct zori_widget *widget);
|
|
|
|
-int zori_widget_raise_close_event(struct zori_widget *widget, struct zori_widget * from);
|
|
|
|
-
|
|
|
|
-int zori_widget_compare(const void *v1, const void *v2);
|
|
|
|
-struct zori_widget *zori_get_widget(zori_id id);
|
|
|
|
-zori_id zori_get_unused_id(void);
|
|
|
|
-struct zori_handler *zori_widget_add_handler(struct zori_widget *widget, zori_event_type type, zori_handler_func *handler, void *data);
|
|
|
|
-struct zori_handler *zori_widget_add_handlers(struct zori_widget *widget, struct zori_handler *handlers, size_t amount);
|
|
|
|
-zori_id zori_start(struct zori_style *default_style);
|
|
|
|
-struct zori_widget *zori_widget_done(struct zori_widget *widget);
|
|
|
|
-void zori_widget_free(struct zori_widget *widget);
|
|
|
|
-struct zori_widget *zori_widget_add_child(struct zori_widget *parent, struct zori_widget *child);
|
|
|
|
-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);
|
|
|
|
-zori_id zori_shutdown(void);
|
|
|
|
-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);
|
|
|
|
-void zori_draw_all(void);
|
|
|
|
-
|
|
|
|
-int zori_widget_visible(struct zori_widget *widget);
|
|
|
|
-int zori_widget_visible_(struct zori_widget *widget, int set);
|
|
|
|
-int zori_widget_active(struct zori_widget *widget);
|
|
|
|
-int zori_widget_active_(struct zori_widget *widget, int set);
|
|
|
|
-int zori_widget_hover(struct zori_widget *widget);
|
|
|
|
-int zori_widget_hover_(struct zori_widget *widget, int set);
|
|
|
|
-int zori_widget_marked(struct zori_widget *widget);
|
|
|
|
-int zori_widget_marked_(struct zori_widget *widget, int set);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-int zori_widget_active_(struct zori_widget *widget, int set);
|
|
|
|
-void zori_update(double dt);
|
|
|
|
-zori_font *zori_widget_font(struct zori_widget *widget);
|
|
|
|
-zori_color zori_widget_forecolor(struct zori_widget *widget);
|
|
|
|
-zori_color zori_widget_backcolor(struct zori_widget *widget);
|
|
|
|
-int zori_widget_h(struct zori_widget *widget);
|
|
|
|
-int zori_widget_w(struct zori_widget *widget);
|
|
|
|
-int zori_widget_x(struct zori_widget *widget);
|
|
|
|
-int zori_widget_y(struct zori_widget *widget);
|
|
|
|
-int zori_xy_inside_widget_p(struct zori_widget * widget, double x, double y);
|
|
|
|
-
|
|
|
|
-zori_font * zori_widget_text_font(struct zori_widget * widget);
|
|
|
|
-zori_font * zori_text_font(zori_id id);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-void zori_widget_drawroundframe(struct zori_widget *self);
|
|
|
|
-
|
|
|
|
-int zori_handle_system_event(zori_system_event * sysev);
|
|
|
|
-
|
|
|
|
-int zori_result(int zori_id);
|
|
|
|
-
|
|
|
|
-int zori_mark_widget(struct zori_widget * widget);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-int zori_registry_entry_compare(const void *v1, const void *v2);
|
|
|
|
-zori_id zori_registry_init(struct zori_registry *registry);
|
|
|
|
-zori_id zori_registry_add(struct zori_registry *registry, zori_id id, struct zori_widget *widget);
|
|
|
|
-struct zori_registry_entry *zori_registry_lookup_entry(struct zori_registry *registry, zori_id id);
|
|
|
|
-struct zori_widget *zori_registry_lookup(struct zori_registry *registry, zori_id id);
|
|
|
|
-zori_id zori_registry_remove(struct zori_registry *registry, zori_id id);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
int zori_handler_compare(const void *v1, const void *v2);
|
|
int zori_handler_compare(const void *v1, const void *v2);
|
|
struct zori_handler *zori_handlers_add(struct zori_handlers *me, zori_event_type type, zori_handler_func *handler, void *data);
|
|
struct zori_handler *zori_handlers_add(struct zori_handlers *me, zori_event_type type, zori_handler_func *handler, void *data);
|
|
void zori_handlers_done(struct zori_handlers *me);
|
|
void zori_handlers_done(struct zori_handlers *me);
|
|
@@ -624,14 +580,17 @@ void zori_handlers_init(struct zori_handlers *me);
|
|
struct zori_handler *zori_handlers_search(struct zori_handlers *me, zori_event_type type);
|
|
struct zori_handler *zori_handlers_search(struct zori_handlers *me, zori_event_type type);
|
|
int zori_handlers_handle(struct zori_handlers *me, union zori_event *event);
|
|
int zori_handlers_handle(struct zori_handlers *me, union zori_event *event);
|
|
struct zori_root *zori_get_root(void);
|
|
struct zori_root *zori_get_root(void);
|
|
|
|
+struct zori_widget *zori_get_root_widget(void);
|
|
struct zori_widget *zori_get_widget(zori_id id);
|
|
struct zori_widget *zori_get_widget(zori_id id);
|
|
zori_id zori_get_unused_id(void);
|
|
zori_id zori_get_unused_id(void);
|
|
|
|
+zori_id zori_initialize_root(void);
|
|
zori_id zori_start(struct zori_style *default_style);
|
|
zori_id zori_start(struct zori_style *default_style);
|
|
zori_id zori_set_margins(zori_id id, int left, int top, int right, int bottom);
|
|
zori_id zori_set_margins(zori_id id, int left, int top, int right, int bottom);
|
|
zori_id zori_set_margin(zori_id id, int size);
|
|
zori_id zori_set_margin(zori_id id, int size);
|
|
zori_id zori_set_paddings(zori_id id, int left, int top, int right, int bottom);
|
|
zori_id zori_set_paddings(zori_id id, int left, int top, int right, int bottom);
|
|
zori_id zori_set_padding(zori_id id, int size);
|
|
zori_id zori_set_padding(zori_id id, int size);
|
|
zori_font *zori_text_font(zori_id id);
|
|
zori_font *zori_text_font(zori_id id);
|
|
|
|
+void zori_destroy_root(void);
|
|
zori_id zori_shutdown(void);
|
|
zori_id zori_shutdown(void);
|
|
void zori_draw_all(void);
|
|
void zori_draw_all(void);
|
|
int zori_handle_system_event(zori_system_event *sysev);
|
|
int zori_handle_system_event(zori_system_event *sysev);
|
|
@@ -639,6 +598,7 @@ void zori_update(double dt);
|
|
int zori_result(zori_id id);
|
|
int zori_result(zori_id id);
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|