Enlightenment CVS committal
Author : smugg
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src
Modified Files:
Ewl.h Makefile.am ewl_box.c ewl_box.h ewl_button.c
ewl_button.h ewl_callback.c ewl_callback.h ewl_container.c
ewl_container.h ewl_entry.c ewl_entry.h ewl_enums.h
ewl_events.c ewl_events.h ewl_fx.c ewl_fx.h ewl_list.c
ewl_list.h ewl_macros.h ewl_misc.c ewl_misc.h ewl_object.c
ewl_object.h ewl_prefs.c ewl_prefs.h ewl_seeker.c ewl_seeker.h
ewl_spinner.c ewl_spinner.h ewl_table.c ewl_table.h ewl_text.c
ewl_text.h ewl_theme.c ewl_theme.h ewl_widget.c ewl_widget.h
ewl_window.c ewl_window.h getopt.c getopt.h
Added Files:
ewl_checkbutton.c ewl_checkbutton.h ewl_colors.h ewl_debug.h
ewl_image.c ewl_image.h ewl_radiobutton.c ewl_radiobutton.h
Log Message:
Whoa
Nathan and I have worked alot lately.....
We have improved themeing support..
Cleaned up almost every widget....
The table widget isn't quite finished yet tough.... and therefor it makes the
list widget unworkable.....
I made this commit now since i was experiencing strange behaviour in the test
program, and i want too see if the same on other systems.....
I'll work alot on ewl today... so ill probably make a couple of more commits
this day...
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/Ewl.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- Ewl.h 2001/05/01 10:08:59 1.5
+++ Ewl.h 2001/07/20 07:31:54 1.6
@@ -21,8 +21,12 @@
#define EWL_USER_DIR ".e/ewl"
#endif
-typedef struct _ewl_container Ewl_Container;
+unsigned int ewl_size_allocated;
+unsigned int ewl_size_freed;
+#include <ewl_debug.h>
+#include <ewl_macros.h>
+
#include <ewl_enums.h>
#include <ewl_object.h>
@@ -32,7 +36,6 @@
#include <ewl_callback.h>
#include <ewl_events.h>
-#include <ewl_macros.h>
#include <ewl_misc.h>
#include <ewl_box.h>
@@ -52,3 +55,6 @@
#include <ewl_seeker.h>
#include <ewl_spinner.h>
#include <ewl_list.h>
+#include <ewl_image.h>
+#include <ewl_checkbutton.h>
+#include <ewl_radiobutton.h>
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- Makefile.am 2001/05/02 23:12:42 1.6
+++ Makefile.am 2001/07/20 07:31:54 1.7
@@ -11,16 +11,20 @@
ewl_box.h \
ewl_button.h \
ewl_callback.h \
+ ewl_checkbutton.h \
ewl_container.h \
+ ewl_debug.h \
ewl_entry.h \
ewl_enums.h \
ewl_events.h \
ewl_fx.h \
+ ewl_image.h \
ewl_list.h \
ewl_macros.h \
ewl_misc.h \
ewl_object.h \
ewl_prefs.h \
+ ewl_radiobutton.h \
ewl_seeker.h \
ewl_spinner.h \
ewl_text.h \
@@ -33,14 +37,17 @@
ewl_box.c \
ewl_button.c \
ewl_callback.c \
+ ewl_checkbutton.c \
ewl_container.c \
ewl_entry.c \
ewl_events.c \
ewl_fx.c \
+ ewl_image.c \
ewl_list.c \
ewl_misc.c \
ewl_object.c \
ewl_prefs.c \
+ ewl_radiobutton.c \
ewl_seeker.c \
ewl_spinner.c \
ewl_table.c \
@@ -50,5 +57,5 @@
ewl_window.c \
getopt.c
-libewl_la_LIBADD = @ebits_libs@ @ecore_libs@ @evas_libs@ @ewd_libs@ -lm -letox
+libewl_la_LIBADD = @ebits_libs@ @ecore_libs@ @evas_libs@ @ewd_libs@ -lm
libewl_la_LDFLAGS = -version-info 0:0:0
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_box.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_box.c 2001/05/02 23:12:42 1.4
+++ ewl_box.c 2001/07/20 07:31:54 1.5
@@ -1,315 +1,465 @@
-
#include <Ewl.h>
-
-static Ewl_Widget * ewl_box_new(Ewl_Orientation orientation);
-static void ewl_box_init(Ewl_Box * box, Ewl_Orientation orientation);
-static void ewl_box_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_box_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_box_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_box_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_box_configure(Ewl_Widget * widget, Ewl_Callback * cb);
-static Ewl_Widget *
-ewl_box_new(Ewl_Orientation orientation)
+static void __ewl_box_init(Ewl_Box * b, Ewl_Orientation o);
+static void __ewl_box_realize(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_box_show(Ewl_Widget * w, void *event_data, void *user_data);
+static void __ewl_box_hide(Ewl_Widget * w, void *event_data, void *user_data);
+static void __ewl_box_destroy(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_box_destroy_recursive(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_box_configure(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_box_theme_update(Ewl_Widget * w, void *event_data,
+ void *user_data);
+
+/*
+ * Create and initialize a new box container with the specified orientation
+ */
+Ewl_Widget *
+ewl_box_new(int orientation)
{
- Ewl_Box * box = NULL;
+ Ewl_Box *box;
box = NEW(Ewl_Box, 1);
+ if (box)
+ __ewl_box_init(box, orientation);
- ewl_box_init(box, orientation);
-
- return EWL_WIDGET(box);
+ DRETURN_PTR(EWL_WIDGET(box));
}
-Ewl_Widget *
-ewl_hbox_new(void)
+/*
+ * Initialize the specified box to sane starting values and the given
+ * orientation
+ */
+static void
+__ewl_box_init(Ewl_Box * box, Ewl_Orientation o)
{
- return ewl_box_new(EWL_ORIENTATION_HORISONTAL);
-}
+ DENTER_FUNCTION;
-Ewl_Widget *
-ewl_vbox_new(void)
-{
- return ewl_box_new(EWL_ORIENTATION_VERTICAL);
+ DCHECK_PARAM_PTR("box", box);
+
+ /*
+ * Clear the object and assign some minimum, starting, and maximum
+ * dimensions
+ */
+ memset(box, 0, sizeof(Ewl_Box));
+ ewl_container_init(EWL_CONTAINER(box), EWL_WIDGET_BOX, 10, 10,
+ 2048, 2048);
+
+ /*
+ * Now attach callbacks that will be executed when events occur
+ */
+ ewl_callback_append(EWL_WIDGET(box),
+ EWL_CALLBACK_REALIZE, __ewl_box_realize, NULL);
+ ewl_callback_append(EWL_WIDGET(box), EWL_CALLBACK_SHOW,
+ __ewl_box_show, NULL);
+ ewl_callback_append(EWL_WIDGET(box), EWL_CALLBACK_HIDE,
+ __ewl_box_hide, NULL);
+ ewl_callback_append(EWL_WIDGET(box), EWL_CALLBACK_DESTROY,
+ __ewl_box_destroy, NULL);
+ ewl_callback_append(EWL_WIDGET(box),
+ EWL_CALLBACK_DESTROY_RECURSIVE,
+ __ewl_box_destroy_recursive, NULL);
+ ewl_callback_append(EWL_WIDGET(box), EWL_CALLBACK_CONFIGURE,
+ __ewl_box_configure, NULL);
+ ewl_callback_append(EWL_WIDGET(box), EWL_CALLBACK_THEME_UPDATE,
+ __ewl_box_theme_update, NULL);
+
+ /*
+ * Set the box's appropriate orientation
+ */
+ box->orientation = o;
+ box->spacing = 5;
+ box->homogeneous = 0;
}
+/*
+ * Change the specified box's orientation
+ */
void
-ewl_box_set_orientation(Ewl_Widget * widget, Ewl_Orientation orientation)
+ewl_box_set_orientation(Ewl_Widget * w, Ewl_Orientation o)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+
+ DCHECK_PARAM_PTR("w", w);
- EWL_BOX(widget)->orientation = orientation;
+ /*
+ * Set the orientation and reconfigure the widget so that child
+ * widgets now have the new orientation layout
+ */
+ EWL_BOX(w)->orientation = o;
+ ewl_widget_configure(w);
- ewl_widget_configure(widget);
+ DLEAVE_FUNCTION;
}
+/*
+ * Adjust the spacing between the objects in the box
+ */
void
-ewl_box_set_spacing(Ewl_Widget * widget, unsigned int spacing)
+ewl_box_set_spacing(Ewl_Widget * w, unsigned int spacing)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
- EWL_BOX(widget)->spacing = spacing;
+ DCHECK_PARAM_PTR("w", w);
- ewl_widget_configure(widget);
+ /*
+ * Adjust the spacing and reconfigure to apply the new spacing
+ */
+ EWL_BOX(w)->spacing = spacing;
+ ewl_widget_configure(w);
+
+ DLEAVE_FUNCTION;
}
+/*
+ * Change whether or not the box is laid out in a homogenous style
+ */
void
-ewl_box_set_homogeneous(Ewl_Widget * widget, unsigned int homogeneous)
+ewl_box_set_homogeneous(Ewl_Widget * w, unsigned int homogeneous)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
- EWL_BOX(widget)->homogeneous = homogeneous;
+ DCHECK_PARAM_PTR("w", w);
- ewl_widget_configure(widget);
-}
+ /*
+ * Set homogenous and reconfigure to apply the new setting
+ */
+ EWL_BOX(w)->homogeneous = homogeneous;
+ ewl_widget_configure(w);
+ DLEAVE_FUNCTION;
+}
static void
-ewl_box_init(Ewl_Box * box, Ewl_Orientation orientation)
+__ewl_box_realize(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("box", box);
+ DENTER_FUNCTION;
- memset(box, 0, sizeof(Ewl_Box));
+ ewl_fx_clip_box_create(w);
- ewl_callback_append(EWL_WIDGET(box),
- EWL_CALLBACK_REALIZE, ewl_box_realize, NULL);
- ewl_callback_append(EWL_WIDGET(box),
- EWL_CALLBACK_SHOW, ewl_box_show, NULL);
- ewl_callback_append(EWL_WIDGET(box),
- EWL_CALLBACK_HIDE, ewl_box_hide, NULL);
- ewl_callback_append(EWL_WIDGET(box),
- EWL_CALLBACK_DESTROY, ewl_box_destroy, NULL);
- ewl_callback_append(EWL_WIDGET(box),
- EWL_CALLBACK_CONFIGURE, ewl_box_configure, NULL);
+ if (w->parent && EWL_CONTAINER(w->parent)->clip_box)
+ {
+ evas_set_clip(w->evas, w->fx_clip_box,
+ EWL_CONTAINER(w->parent)->clip_box);
- EWL_WIDGET(box)->container.recursive = TRUE;
+ evas_set_clip(w->evas, EWL_CONTAINER(w)->clip_box,
+ w->fx_clip_box);
+ }
- box->orientation = orientation;
- box->spacing = 5;
- box->homogeneous = 0;
+ ewl_widget_theme_update(w);
- EWL_OBJECT(box)->current.w = 10;
- EWL_OBJECT(box)->current.h = 10;
- EWL_OBJECT(box)->maximum.w = 2024;
- EWL_OBJECT(box)->maximum.h = 2024;
- EWL_OBJECT(box)->minimum.w = 10;
- EWL_OBJECT(box)->minimum.h = 10;
- EWL_OBJECT(box)->request.w = 10;
- EWL_OBJECT(box)->request.h = 10;
+ DLEAVE_FUNCTION;
}
static void
-ewl_box_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_box_show(Ewl_Widget * w, void *event_data, void *user_data)
{
- char * image = NULL;
-
- if (EWL_BOX(widget)->orientation == EWL_ORIENTATION_HORISONTAL)
- image = ewl_theme_ebit_get("box", "horisontal", "base");
- else if (EWL_BOX(widget)->orientation == EWL_ORIENTATION_VERTICAL)
- image = ewl_theme_ebit_get("box", "vertical", "base");
-
- EWL_BOX(widget)->ebits_object = ebits_load(image);
- IF_FREE(image);
- ebits_add_to_evas(EWL_BOX(widget)->ebits_object, widget->evas);
- ebits_set_layer(EWL_BOX(widget)->ebits_object, widget->object.layer);
-
- ewl_fx_clip_box_create(widget);
+ DENTER_FUNCTION;
- ebits_show(EWL_BOX(widget)->ebits_object);
+ DCHECK_PARAM_PTR("w", w);
- if (widget->parent && widget->parent->container.clip_box)
- {
- evas_set_clip(widget->evas, widget->fx_clip_box,
- widget->parent->container.clip_box);
- ebits_set_clip(EWL_BOX(widget)->ebits_object,
- widget->fx_clip_box);
- evas_set_clip(widget->evas, widget->container.clip_box,
- widget->fx_clip_box);
- }
+ evas_show(w->evas, w->fx_clip_box);
- evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
+ DLEAVE_FUNCTION;
}
static void
-ewl_box_show(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_box_hide(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+
+ DCHECK_PARAM_PTR("w", w);
+
+ evas_hide(w->evas, w->fx_clip_box);
- evas_show(widget->evas, widget->fx_clip_box);
+ DLEAVE_FUNCTION;
}
static void
-ewl_box_hide(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_box_destroy(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ Ewl_Box *b;
+
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
+
+ b = EWL_BOX(w);
+
+ if (w->ebits_object)
+ {
+ ebits_hide(w->ebits_object);
+ ebits_unset_clip(w->ebits_object);
+ ebits_free(w->ebits_object);
+ }
+
+ evas_hide(w->evas, w->fx_clip_box);
+ evas_unset_clip(w->evas, w->fx_clip_box);
+ evas_del_object(w->evas, w->fx_clip_box);
- evas_hide(widget->evas, widget->fx_clip_box);
+ evas_hide(w->evas, EWL_CONTAINER(w)->clip_box);
+ evas_unset_clip(w->evas, EWL_CONTAINER(w)->clip_box);
+ evas_del_object(w->evas, EWL_CONTAINER(w)->clip_box);
+
+ ewl_callback_del_all(w);
+
+ ewl_theme_deinit_widget(w);
+
+ FREE(w);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_box_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_box_destroy_recursive(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ Ewl_Widget *child;
- ebits_hide(EWL_BOX(widget)->ebits_object);
- ebits_unset_clip(EWL_BOX(widget)->ebits_object);
- ebits_free(EWL_BOX(widget)->ebits_object);
+ DENTER_FUNCTION;
- evas_hide(widget->evas, widget->fx_clip_box);
- evas_unset_clip(widget->evas, widget->fx_clip_box);
- evas_del_object(widget->evas, widget->fx_clip_box);
+ DCHECK_PARAM_PTR("w", w);
- evas_hide(widget->evas, widget->container.clip_box);
- evas_unset_clip(widget->evas, widget->container.clip_box);
- evas_del_object(widget->evas, widget->container.clip_box);
+ if (!EWL_CONTAINER(w)->children)
+ DLEAVE_FUNCTION;
- FREE(widget);
+ while ((child = ewd_list_remove_last(EWL_CONTAINER(w)->children))
+ != NULL)
+ ewl_widget_destroy_recursive(child);
+
+ DLEAVE_FUNCTION;
}
+/*
+ * Update the size and position of the box and its child widgets
+ */
static void
-ewl_box_configure(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_box_configure(Ewl_Widget * w, void *event_data, void *user_data)
{
+
+ Ewl_Widget *child;
int l = 0, r = 0, t = 0, b = 0;
+ int height = 0, width = 0, x = 0, y = 0;
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
- EWL_OBJECT(widget)->current.x = EWL_OBJECT(widget)->request.x;
- EWL_OBJECT(widget)->current.y = EWL_OBJECT(widget)->request.y;
- EWL_OBJECT(widget)->current.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->current.h = EWL_OBJECT(widget)->request.h;
+ DCHECK_PARAM_PTR("w", w);
- ebits_get_insets(EWL_BOX(widget)->ebits_object, &l, &r, &t, &b);
+ CURRENT_X(w) = REQUEST_X(w);
+ CURRENT_Y(w) = REQUEST_Y(w);
+ CURRENT_W(w) = REQUEST_W(w);
+ CURRENT_H(w) = REQUEST_H(w);
- if (EWL_OBJECT(widget)->realized)
+ if (w->ebits_object)
+ ebits_get_insets(w->ebits_object, &l, &r, &t, &b);
+
+ /*
+ * If the widget has been realized, then the graphics need to be
+ * updated to reflect the changes
+ */
+ if (EWL_OBJECT(w)->realized)
{
- ebits_move(EWL_BOX(widget)->ebits_object,
- EWL_OBJECT(widget)->request.x,
- EWL_OBJECT(widget)->request.y);
- ebits_resize(EWL_BOX(widget)->ebits_object,
- EWL_OBJECT(widget)->request.w,
- EWL_OBJECT(widget)->request.h);
- ewl_fx_clip_box_resize(widget);
- if (widget->container.clip_box)
- {
- evas_move(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->current.x + l,
- EWL_OBJECT(widget)->current.y + t);
- evas_resize(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->current.w - (l+r),
- EWL_OBJECT(widget)->current.h - (t+b));
- }
+ if (CUSTOM_W(w))
+ REQUEST_W(w) = CUSTOM_W(w);
+
+ if (CUSTOM_H(w))
+ REQUEST_H(w) = CUSTOM_H(w);
+
+ /*
+ * Adjust the size and position of the ebits object
+ */
+ if (w->ebits_object)
+ {
+ ebits_move(w->ebits_object, REQUEST_X(w),
+ REQUEST_Y(w));
+ ebits_resize(w->ebits_object, REQUEST_W(w),
+ REQUEST_H(w));
+ }
+ ewl_fx_clip_box_resize(w);
+
+ /*
+ * Move the widgets clip box to the appropriate size and
+ * place
+ */
+ if (EWL_CONTAINER(w)->clip_box)
+ {
+ evas_move(w->evas, EWL_CONTAINER(w)->clip_box,
+ CURRENT_X(w) + l, CURRENT_Y(w) + t);
+ evas_resize(w->evas, EWL_CONTAINER(w)->clip_box,
+ CURRENT_W(w) - (l + r),
+ CURRENT_H(w) - (t + b));
+ }
}
- if (!widget->container.children || !widget->container.children->nodes)
- return;
+ /*
+ * If their aren't any children to this widget, then we're done
+ */
+ if (!EWL_CONTAINER(w)->children || !EWL_CONTAINER(w)->children->nodes)
+ DRETURN;
+
+ ewd_list_goto_first(EWL_CONTAINER(w)->children);
+
+ /*
+ * The starting x, y values are the same whether or not this is a
+ * vertical or horizontal box.
+ */
+ x = CURRENT_X(w) + l;
+ y = CURRENT_Y(w) + t;
+
+ /*
+ * The values for the width and height are dependant on the
+ * orientation of the box
+ */
+ if (EWL_BOX(w)->orientation == EWL_ORIENTATION_VERTICAL)
+ {
+ width = CURRENT_W(w) - (l + r);
+ height = CURRENT_H(w) /
+ ewd_list_nodes(EWL_CONTAINER(w)->children);
+ height -= t + b;
+ }
+ else
+ {
+ width = CURRENT_W(w) / EWL_CONTAINER(w)->children->nodes;
+ width -= l + r;
+ height = CURRENT_H(w) - (t + b);
+ }
- if (EWL_BOX(widget)->orientation == EWL_ORIENTATION_HORISONTAL)
+ while ((child = ewd_list_next(EWL_CONTAINER(w)->children)) != NULL)
{
- Ewl_Widget * child;
- int w = 0, x = 0;
+ REQUEST_X(child) = x;
+ REQUEST_Y(child) = y;
+ REQUEST_W(child) = width;
+ REQUEST_H(child) = height;
+
+ if (REQUEST_W(child) < MIN_W(child))
+ {
+ REQUEST_X(child) += (REQUEST_W(child) / 2) -
+ (MIN_W(child) / 2);
+ REQUEST_W(child) = MIN_W(child);
+ }
+
+ if (REQUEST_H(child) < MIN_H(child))
+ {
+ REQUEST_Y(child) += (REQUEST_H(child) / 2) -
+ (MIN_H(child) / 2);
+ REQUEST_H(child) = MIN_H(child);
+ }
+
+ if (REQUEST_W(child) > MAX_W(child))
+ {
+ REQUEST_X(child) += (REQUEST_W(child) / 2) -
+ (MAX_W(child) / 2);
+ REQUEST_W(child) = MAX_W(child);
+ }
+
+ if (REQUEST_H(child) > MAX_H(child))
+ {
+ REQUEST_Y(child) += (REQUEST_H(child) / 2) -
+ (MAX_H(child) / 2);
+ REQUEST_H(child) = MAX_H(child);
+ }
+
+ if (EWL_BOX(w)->orientation == EWL_ORIENTATION_VERTICAL)
+ {
+ if (REQUEST_X(child) < CURRENT_X(w) + l)
+ REQUEST_X(child) = CURRENT_X(w) + l;
+ y += height + EWL_BOX(w)->spacing;
+ }
+ else
+ {
+ if (REQUEST_Y(child) < CURRENT_Y(w) + t)
+ REQUEST_Y(child) = CURRENT_Y(w) + t;
+ x += width + EWL_BOX(w)->spacing;
+ }
+
+ ewl_widget_configure(child);
- ewd_list_goto_first(widget->container.children);
+ }
- w = EWL_OBJECT(widget)->current.w / widget->container.children->nodes;
- x = EWL_OBJECT(widget)->current.x + l;
+ DLEAVE_FUNCTION;
+}
- while ((child = ewd_list_next(widget->container.children)) != NULL)
- {
- EWL_OBJECT(child)->request.x = x;
- EWL_OBJECT(child)->request.y = EWL_OBJECT(widget)->current.y + t;
- EWL_OBJECT(child)->request.w = w - (l + r);
- EWL_OBJECT(child)->request.h = EWL_OBJECT(widget)->current.h - (t + b);
-
- if (EWL_OBJECT(child)->request.w < EWL_OBJECT(child)->minimum.w)
- {
- EWL_OBJECT(child)->request.x +=
- (EWL_OBJECT(child)->request.w / 2) -
- (EWL_OBJECT(child)->minimum.w / 2);
- EWL_OBJECT(child)->request.w = EWL_OBJECT(child)->minimum.w;
- }
-
- if (EWL_OBJECT(child)->request.h < EWL_OBJECT(child)->minimum.h)
- {
- EWL_OBJECT(child)->request.y += (EWL_OBJECT(child)->request.h / 2) -
- (EWL_OBJECT(child)->minimum.h / 2);
- EWL_OBJECT(child)->request.h = EWL_OBJECT(child)->minimum.h;
- }
-
- if (EWL_OBJECT(child)->request.w > EWL_OBJECT(child)->maximum.w)
- {
- EWL_OBJECT(child)->request.x += (EWL_OBJECT(child)->request.w / 2) -
- (EWL_OBJECT(child)->maximum.w / 2);
- EWL_OBJECT(child)->request.w = EWL_OBJECT(child)->maximum.w;
- }
-
- if (EWL_OBJECT(child)->request.h > EWL_OBJECT(child)->maximum.h)
- {
- EWL_OBJECT(child)->request.y += (EWL_OBJECT(child)->request.h / 2) -
- (EWL_OBJECT(child)->maximum.h / 2);
- EWL_OBJECT(child)->request.h = EWL_OBJECT(child)->maximum.h;
- }
+/*
+ * Apply any new theme data and redraw the box
+ */
+static void
+__ewl_box_theme_update(Ewl_Widget * w, void *event_data, void *user_data)
+{
+ Ewl_Box *b;
+ char *i = NULL;
+ char *v = NULL;
+
+ DENTER_FUNCTION;
+
+ DCHECK_PARAM_PTR("w", w);
+
+ /*
+ * Shouldn't do anything if the widget isn't realized yet
+ */
+ if (!w->object.realized)
+ DRETURN;
+
+ b = EWL_BOX(w);
+
+ /*
+ * Check if GFX should be visible or not
+ */
+ if (EWL_BOX(w)->orientation == EWL_ORIENTATION_HORIZONTAL)
+ v = ewl_theme_data_get(w,
+ "/appearance/box/horizontal/base/visible");
+ else if (EWL_BOX(w)->orientation == EWL_ORIENTATION_VERTICAL)
+ v = ewl_theme_data_get(w,
+ "/appearance/box/vertical/base/visible");
+
+ /*
+ * Destroy old image (if any)
+ */
+ if (w->ebits_object)
+ {
+ ebits_hide(w->ebits_object);
+ ebits_unset_clip(w->ebits_object);
+ ebits_free(w->ebits_object);
+ }
- if (EWL_OBJECT(child)->request.y < EWL_OBJECT(widget)->current.y + t)
- EWL_OBJECT(child)->request.y = EWL_OBJECT(widget)->current.y + t;
+ /*
+ * If the graphics aren't to be shown, just jump to the end for
+ * cleanup
+ */
+ if (v && strncasecmp(v, "yes", 3) != 0)
+ goto done_update_box_theme;
+
+ if (EWL_BOX(w)->orientation == EWL_ORIENTATION_HORIZONTAL)
+ i = ewl_theme_image_get(w, "/appearance/box/horizontal/base");
+ else
+ i = ewl_theme_image_get(w, "/appearance/box/vertical/base");
- x += w - (l + r) + EWL_BOX(widget)->spacing;
+ if (i)
+ {
+ w->ebits_object = ebits_load(i);
+ FREE(i);
- ewl_widget_configure(child);
+ /*
+ * Set all the clipping and layering for the image
+ */
+ if (w->ebits_object)
+ {
+ ebits_add_to_evas(w->ebits_object, w->evas);
+ ebits_set_layer(w->ebits_object,
+ EWL_OBJECT(w)->layer);
+ ebits_set_clip(w->ebits_object, w->fx_clip_box);
- }
+ ebits_show(w->ebits_object);
+ }
}
- else if (EWL_BOX(widget)->orientation == EWL_ORIENTATION_VERTICAL)
- {
- Ewl_Widget * child;
- int h = 0;
- int y = 0;
-
- ewd_list_goto_first(widget->container.children);
-
- h = EWL_OBJECT(widget)->current.h / widget->container.children->nodes;
- y = EWL_OBJECT(widget)->current.y + t;
-
- while ((child = ewd_list_next(widget->container.children)) != NULL)
- {
- EWL_OBJECT(child)->request.x = EWL_OBJECT(widget)->current.x + l;
- EWL_OBJECT(child)->request.y = y;
- EWL_OBJECT(child)->request.w = EWL_OBJECT(widget)->current.w - (l + r);
- EWL_OBJECT(child)->request.h = h - (t + b);
-
- if (EWL_OBJECT(child)->request.w < EWL_OBJECT(child)->minimum.w)
- {
- EWL_OBJECT(child)->request.x += (EWL_OBJECT(child)->request.w / 2) -
- (EWL_OBJECT(child)->minimum.w / 2);
- EWL_OBJECT(child)->request.w = EWL_OBJECT(child)->minimum.w;
- }
-
- if (EWL_OBJECT(child)->request.h < EWL_OBJECT(child)->minimum.h)
- {
- EWL_OBJECT(child)->request.y += (EWL_OBJECT(child)->request.h / 2) -
- (EWL_OBJECT(child)->minimum.h / 2);
- EWL_OBJECT(child)->request.h = EWL_OBJECT(child)->minimum.h;
- }
-
- if (EWL_OBJECT(child)->request.w > EWL_OBJECT(child)->maximum.w)
- {
- EWL_OBJECT(child)->request.x += (EWL_OBJECT(child)->request.w / 2) -
- (EWL_OBJECT(child)->maximum.w / 2);
- EWL_OBJECT(child)->request.w = EWL_OBJECT(child)->maximum.w;
- }
-
- if (EWL_OBJECT(child)->request.h > EWL_OBJECT(child)->maximum.h)
- {
- EWL_OBJECT(child)->request.y += (EWL_OBJECT(child)->request.h / 2) -
- (EWL_OBJECT(child)->maximum.h / 2);
- EWL_OBJECT(child)->request.h = EWL_OBJECT(child)->maximum.h;
- }
- if (EWL_OBJECT(child)->request.x < EWL_OBJECT(widget)->current.x + l)
- EWL_OBJECT(child)->request.x = EWL_OBJECT(widget)->current.x + l;
+ done_update_box_theme:
- y += h - (t + b) + EWL_BOX(widget)->spacing;
+ IF_FREE(v);
- ewl_widget_configure(child);
- }
- }
+ /*
+ * Finally configure the widget to update changes
+ */
+ ewl_widget_configure(w);
+
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_box.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_box.h 2001/05/01 04:00:38 1.3
+++ ewl_box.h 2001/07/20 07:31:54 1.4
@@ -1,29 +1,33 @@
-#ifndef __EWL_BOX_H
-#define __EWL_BOX_H
+/*\
+|*|
+|*| The box widget is a layout manager and orders widget either horizontally
+|*| or vertically.
+|*|
+\*/
-struct _ewl_box {
- Ewl_Widget widget;
- Ewl_Orientation orientation;
- Ebits_Object * ebits_object;
- unsigned int homogeneous;
- unsigned int spacing;
+#ifndef __EWL_BOX_H__
+#define __EWL_BOX_H__
+
+typedef struct _ewl_box Ewl_Box;
+#define EWL_BOX(box) ((Ewl_Box *) box)
+
+struct _ewl_box
+{
+ Ewl_Container container;
+ Ewl_Orientation orientation;
+ unsigned int homogeneous;
+ unsigned int spacing;
};
-typedef struct _ewl_box Ewl_Box;
+#define ewl_hbox_new() ewl_box_new(EWL_ORIENTATION_HORIZONTAL)
+#define ewl_vbox_new() ewl_box_new(EWL_ORIENTATION_VERTICAL)
-#define EWL_BOX(box) ((Ewl_Box *) box)
-Ewl_Widget * ewl_hbox_new(void);
-Ewl_Widget * ewl_vbox_new(void);
-Ewl_Widget * ewl_box_new_all(Ewl_Orientation orientation,
- unsigned int spacing,
- unsigned int homogeneous);
+Ewl_Widget *ewl_box_new(int orientation);
void ewl_box_set_orientation(Ewl_Widget * widget,
- Ewl_Orientation orientation);
-void ewl_box_set_spacing(Ewl_Widget * widget,
- unsigned int spacing);
-void ewl_box_set_homogeneous(Ewl_Widget * widget,
- unsigned int homogeneous);
+ Ewl_Orientation orientation);
+void ewl_box_set_spacing(Ewl_Widget * widget, unsigned int spacing);
+void ewl_box_set_homogeneous(Ewl_Widget * widget, unsigned int homogeneous);
-#endif
+#endif /* __EWL_BOX_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_button.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_button.c 2001/05/02 23:12:42 1.6
+++ ewl_button.c 2001/07/20 07:31:54 1.7
@@ -1,465 +1,421 @@
#include <Ewl.h>
-static void ewl_button_init(Ewl_Widget * widget, Ewl_Button_Type type);
-static void ewl_button_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_configure(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_key_down(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_key_up(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_mouse_down(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_mouse_up(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_focus_in(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_focus_out(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_select(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_button_unselect(Ewl_Widget * widget, Ewl_Callback * cb);
+/*\
+|*|
+|*| The button widget is really a merge of many diffrent button types.
+|*| Normal - You but whatever widget you want in here
+|*| Label - You specify label for button..
+|*|
+\*/
+
+static void __ewl_button_init(Ewl_Button * b, char *label);
+static void __ewl_button_realize(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_show(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_hide(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_destroy(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_destroy_recursive(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_configure(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_focus_in(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_focus_out(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_mouse_down(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_mouse_up(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_button_theme_update(Ewl_Widget * w, void *event_data,
+ void *user_data);
-static void ewl_button_set_state(Ewl_Widget * widget, void * func_data);
-
Ewl_Widget *
-ewl_button_new()
+ewl_button_new(char *l)
{
- Ewl_Button * button = NULL;
+ Ewl_Button *b;
+
+ DENTER_FUNCTION;
- button = NEW(Ewl_Button, 1);
+ b = NEW(Ewl_Button, 1);
- ewl_button_init(EWL_WIDGET(button), EWL_BUTTON_TYPE_NORMAL);
+ __ewl_button_init(b, l);
- return EWL_WIDGET(button);
+ DRETURN_PTR(EWL_WIDGET(b));
}
-Ewl_Widget *
-ewl_button_new_with_label(const char * label)
+static void
+__ewl_button_init(Ewl_Button * b, char *label)
{
- Ewl_Widget * button;
- Ewl_Widget * text;
+ DENTER_FUNCTION;
- button = ewl_button_new();
- EWL_BUTTON(button)->type = EWL_BUTTON_TYPE_LABEL;
+ /*
+ * Blank out the structure and initialize it's theme
+ */
+ memset(b, 0, sizeof(Ewl_Button));
+ ewl_container_init(EWL_CONTAINER(b), EWL_WIDGET_BUTTON, 10, 10,
+ 2048, 2048);
- text = ewl_text_new();
- ewl_text_set_text(text, label);
- ewl_text_set_font_size(text, 8);
- ewl_container_append_child(button, text);
+ /*
+ * Override the default recursive setting on containers. This prevents
+ * the coordinate->object mapping from searching below the button
+ * class.
+ */
+ EWL_WIDGET(b)->recursive = FALSE;
- return button;
+ /*
+ * Add the label if desired
+ */
+ if (label)
+ b->label = strdup(label);
+
+ /*
+ * Attach necessary callback mechanisms
+ */
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_REALIZE,
+ __ewl_button_realize, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_SHOW,
+ __ewl_button_show, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_HIDE,
+ __ewl_button_hide, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_DESTROY,
+ __ewl_button_destroy, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_DESTROY_RECURSIVE,
+ __ewl_button_destroy_recursive, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_CONFIGURE,
+ __ewl_button_configure, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_MOUSE_DOWN,
+ __ewl_button_mouse_down, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_MOUSE_UP,
+ __ewl_button_mouse_up, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_FOCUS_IN,
+ __ewl_button_focus_in, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_FOCUS_OUT,
+ __ewl_button_focus_out, NULL);
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_THEME_UPDATE,
+ __ewl_button_theme_update, NULL);
+
+ DLEAVE_FUNCTION;
}
-static void
-ewl_button_init(Ewl_Widget * widget, Ewl_Button_Type type)
+/*
+ * Change the label of the specified button
+ */
+void
+ewl_button_set_label(Ewl_Widget * w, char *l)
{
- CHECK_PARAM_POINTER("widget", widget);
+ Ewl_Button *b;
- memset(EWL_BUTTON(widget), 0, sizeof(Ewl_Button));
+ DENTER_FUNCTION;
- EWL_WIDGET(widget)->type = EWL_WIDGET_BUTTON;
+ b = EWL_BUTTON(w);
- ewl_callback_append(widget, EWL_CALLBACK_REALIZE,
- ewl_button_realize, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_SHOW,
- ewl_button_show, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_HIDE,
- ewl_button_hide, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_DESTROY,
- ewl_button_destroy, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_CONFIGURE,
- ewl_button_configure, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_KEY_DOWN,
- ewl_button_key_down, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_KEY_UP,
- ewl_button_key_up, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_MOUSE_DOWN,
- ewl_button_mouse_down, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_MOUSE_UP,
- ewl_button_mouse_up, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_FOCUS_IN,
- ewl_button_focus_in, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_FOCUS_OUT,
- ewl_button_focus_out, NULL);
+ DLEAVE_FUNCTION;
+}
+
+/*
+ * Change the state of the specified button
+ */
+void
+ewl_button_set_state(Ewl_Widget * w, int s)
+{
+ Ewl_Button *b;
- widget->container.recursive = FALSE;
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- EWL_BUTTON(widget)->type = type;
+ b = EWL_BUTTON(w);
- EWL_OBJECT(widget)->current.w = 80;
- EWL_OBJECT(widget)->current.h = 35;
- EWL_OBJECT(widget)->minimum.w = 80;
- EWL_OBJECT(widget)->minimum.h = 35;
- EWL_OBJECT(widget)->maximum.w = 80;
- EWL_OBJECT(widget)->maximum.h = 35;
- EWL_OBJECT(widget)->request.w = 85;
- EWL_OBJECT(widget)->request.h = 35;
+ DLEAVE_FUNCTION;
}
+
static void
-ewl_button_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_button_realize(Ewl_Widget * w, void *event_data, void *user_data)
{
- char * image = NULL;
+ Ewl_Button *b;
+ Ewl_Widget *t;
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- if (EWL_BUTTON(widget)->type == EWL_BUTTON_TYPE_CHECK)
- image = ewl_theme_ebit_get("button", "check", "base");
- else if (EWL_BUTTON(widget)->type == EWL_BUTTON_TYPE_NORMAL ||
- EWL_BUTTON(widget)->type == EWL_BUTTON_TYPE_LABEL)
- image = ewl_theme_ebit_get("button", "default", "base");
- else if (EWL_BUTTON(widget)->type == EWL_BUTTON_TYPE_RADIO)
- image = ewl_theme_ebit_get("button", "radio", "base");
+ b = EWL_BUTTON(w);
- EWL_BUTTON(widget)->ebits_object = ebits_load(image);
- FREE(image);
- ebits_add_to_evas(EWL_BUTTON(widget)->ebits_object, widget->evas);
- ebits_set_layer(EWL_BUTTON(widget)->ebits_object, widget->object.layer);
+ ewl_fx_clip_box_create(w);
- ewl_fx_clip_box_create(widget);
+ if (w->parent && EWL_CONTAINER(w->parent)->clip_box)
+ evas_set_clip(w->evas, w->fx_clip_box,
+ EWL_CONTAINER(w->parent)->clip_box);
- if (widget->container.children)
+ if (b->label)
{
- Ewl_Widget * child;
+ t = ewl_text_new();
+ ewl_text_set_text(t, b->label);
+ ewl_text_set_font_size(t, 10);
+ ewl_container_append_child(EWL_CONTAINER(b), t);
- ewd_list_goto_first(widget->container.children);
-
- while ((child = ewd_list_next(widget->container.children)) != NULL)
- ewl_widget_realize(child);
+ ewl_widget_realize(t);
}
-
- ebits_show(EWL_BUTTON(widget)->ebits_object);
- if (widget->parent && widget->parent->container.clip_box)
- {
- evas_set_clip(widget->evas, widget->fx_clip_box,
- widget->parent->container.clip_box);
- ebits_set_clip(EWL_BUTTON(widget)->ebits_object,
- widget->fx_clip_box);
- evas_set_clip(widget->evas, widget->container.clip_box,
- widget->fx_clip_box);
- }
+ ewl_widget_theme_update(w);
- evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
+ DLEAVE_FUNCTION;
}
static void
-ewl_button_show(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_button_show(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- if (widget->container.children)
+ if (EWL_CONTAINER(w)->children &&
+ !ewd_list_is_empty(EWL_CONTAINER(w)->children))
{
- Ewl_Widget * child;
+ Ewl_Widget *c;
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(EWL_CONTAINER(w)->children);
- while ((child = ewd_list_next(widget->container.children)) != NULL)
- {
- ewl_widget_show(child);
- EWL_OBJECT(widget)->minimum.w = EWL_OBJECT(child)->current.w + 10;
- EWL_OBJECT(widget)->minimum.h = EWL_OBJECT(child)->current.h + 10;
- EWL_OBJECT(widget)->maximum.w = EWL_OBJECT(child)->current.w + 10;
- EWL_OBJECT(widget)->maximum.h = EWL_OBJECT(child)->current.h + 10;
- }
+ while ((c = ewd_list_next(EWL_CONTAINER(w)->children))
+ != NULL)
+ ewl_widget_show(c);
}
+
+ evas_show(w->evas, w->fx_clip_box);
- evas_show(widget->evas, widget->fx_clip_box);
+ DLEAVE_FUNCTION;
}
static void
-ewl_button_hide(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_button_hide(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- evas_hide(widget->evas, widget->fx_clip_box);
+ evas_hide(w->evas, w->fx_clip_box);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_button_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_button_destroy(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ Ewl_Button *b;
- ebits_hide(EWL_BUTTON(widget)->ebits_object);
- ebits_unset_clip(EWL_BUTTON(widget)->ebits_object);
- ebits_free(EWL_BUTTON(widget)->ebits_object);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- evas_hide(widget->evas, widget->fx_clip_box);
- evas_unset_clip(widget->evas, widget->fx_clip_box);
- evas_del_object(widget->evas, widget->fx_clip_box);
+ b = EWL_BUTTON(w);
- evas_hide(widget->evas, widget->fx_clip_box);
- evas_unset_clip(widget->evas, widget->container.clip_box);
- evas_del_object(widget->evas, widget->container.clip_box);
+ if (w->ebits_object)
+ {
+ ebits_hide(w->ebits_object);
+ ebits_unset_clip(w->ebits_object);
+ ebits_free(w->ebits_object);
+ }
- FREE(EWL_BUTTON(widget));
-}
+ evas_hide(w->evas, w->fx_clip_box);
+ evas_unset_clip(w->evas, w->fx_clip_box);
+ evas_del_object(w->evas, w->fx_clip_box);
-static void
-ewl_button_configure(Ewl_Widget * widget, Ewl_Callback * cb)
-{
- Ewl_Widget * child = NULL;
- int l = 0, r = 0, t = 0, b = 0;
+ ewl_callback_del_all(w);
- CHECK_PARAM_POINTER("widget", widget);
+ ewl_theme_deinit_widget(w);
- EWL_OBJECT(widget)->current.x = EWL_OBJECT(widget)->request.x;
- EWL_OBJECT(widget)->current.y = EWL_OBJECT(widget)->request.y;
+ FREE(b);
- if (EWL_BUTTON(widget)->ebits_object)
- ebits_get_insets(EWL_BUTTON(widget)->ebits_object, &l, &r, &t, &b);
+ DLEAVE_FUNCTION;
+}
- if (!widget->container.children || !widget->container.children->nodes) {
- EWL_OBJECT(widget)->minimum.w = 80;
- EWL_OBJECT(widget)->minimum.h = 35;
- EWL_OBJECT(widget)->maximum.w = 80;
- EWL_OBJECT(widget)->maximum.h = 35;
- EWL_OBJECT(widget)->request.w = EWL_OBJECT(widget)->minimum.w;
- EWL_OBJECT(widget)->request.h = EWL_OBJECT(widget)->minimum.h;
- } else {
- int w = 6, h = 6, x, y;
+static void
+__ewl_button_destroy_recursive(Ewl_Widget * w, void *event_data,
+ void *user_data)
+{
+ Ewl_Widget *c;
- ewd_list_goto_first(widget->container.children);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- x = EWL_OBJECT(widget)->current.x + l + 2;
- y = EWL_OBJECT(widget)->current.y + t + 2;
+ if (EWL_CONTAINER(w)->children)
+ while ((c =
+ ewd_list_remove_last(EWL_CONTAINER(w)->children))
+ != NULL)
+ ewl_widget_destroy_recursive(c);
- while ((child = ewd_list_next(widget->container.children)) != NULL) {
- EWL_OBJECT(child)->request.x = x;
- EWL_OBJECT(child)->request.y = y;
- ewl_widget_configure(child);
- x += EWL_OBJECT(child)->current.w + 3;
+ DLEAVE_FUNCTION;
+}
- w += EWL_OBJECT(child)->current.w;
- h += EWL_OBJECT(child)->current.h;
- }
- EWL_OBJECT(widget)->request.w = w + 3;
- EWL_OBJECT(widget)->request.h = h;
- }
+static void
+__ewl_button_configure(Ewl_Widget * w, void *event_data, void *user_data)
+{
+ Ewl_Button *b;
+ Ewl_Widget *t;
+ int req_x, req_y, req_w, req_h;
+ int cur_w, cur_h;
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- if (EWL_BUTTON(widget)->type == EWL_BUTTON_TYPE_LABEL)
- {
- child = widget->container.children->first->data;
- EWL_OBJECT(widget)->minimum.w = 130;
- EWL_OBJECT(widget)->maximum.w = 100;
- EWL_OBJECT(child)->request.x =
- EWL_OBJECT(widget)->current.x;
- EWL_OBJECT(child)->request.x +=
- (130 / 2)-(EWL_OBJECT(child)->current.w /2);
- ewl_widget_configure(child);
- }
+ b = EWL_BUTTON(w);
- if (EWL_OBJECT(widget)->custom.w)
- {
- EWL_OBJECT(widget)->minimum.w = EWL_OBJECT(widget)->custom.w;
- EWL_OBJECT(widget)->maximum.w = EWL_OBJECT(widget)->custom.w;
- EWL_OBJECT(widget)->request.w = EWL_OBJECT(widget)->custom.w;
-
- if (EWL_BUTTON(widget)->type == EWL_BUTTON_TYPE_LABEL)
- {
- EWL_OBJECT(child)->request.x = EWL_OBJECT(widget)->current.x + l +2;
- ewl_widget_configure(child);
- }
-
- }
+ ewl_object_requested_geometry(EWL_OBJECT(w), &req_x, &req_y,
+ &req_w, &req_h);
- if (EWL_OBJECT(widget)->custom.h)
+ if (w->ebits_object)
{
- EWL_OBJECT(widget)->minimum.h = EWL_OBJECT(widget)->custom.h;
- EWL_OBJECT(widget)->maximum.h = EWL_OBJECT(widget)->custom.h;
- EWL_OBJECT(widget)->request.h = EWL_OBJECT(widget)->custom.h;
+ ebits_move(w->ebits_object, req_x, req_y);
+ ebits_resize(w->ebits_object, req_w, req_h);
+
+ evas_move(w->evas, w->fx_clip_box, req_x, req_y);
+ evas_resize(w->evas, w->fx_clip_box, req_w, req_h);
+ evas_move(w->evas, EWL_CONTAINER(w)->clip_box, req_x,
+ req_y);
+ evas_resize(w->evas, EWL_CONTAINER(w)->clip_box, req_w,
+ req_h);
}
- if (EWL_BUTTON(widget)->ebits_object)
- {
- if (EWL_OBJECT(widget)->request.w > EWL_OBJECT(widget)->maximum.w)
- EWL_OBJECT(widget)->request.w = EWL_OBJECT(widget)->maximum.w;
+ ewl_object_set_current_geometry(EWL_OBJECT(w), req_x, req_y, req_w,
+ req_h);
- if (EWL_OBJECT(widget)->request.w < EWL_OBJECT(widget)->minimum.w)
- EWL_OBJECT(widget)->request.w = EWL_OBJECT(widget)->minimum.w;
- ebits_move(EWL_BUTTON(widget)->ebits_object,
- EWL_OBJECT(widget)->request.x, EWL_OBJECT(widget)->request.y);
+ ewd_list_goto_first(EWL_CONTAINER(w)->children);
+ t = ewd_list_current(EWL_CONTAINER(w)->children);
- ebits_resize(EWL_BUTTON(widget)->ebits_object,
- EWL_OBJECT(widget)->request.w, EWL_OBJECT(widget)->request.h);
+ if (!t)
+ DRETURN;
- ewl_fx_clip_box_resize(widget);
- }
+ ewl_object_get_current_size(EWL_OBJECT(t), &cur_w, &cur_h);
- if (widget->container.clip_box)
- {
- evas_move(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->current.x + l,
- EWL_OBJECT(widget)->current.y + t);
- evas_resize(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->current.w - (l+r),
- EWL_OBJECT(widget)->current.h - (t+b));
- }
+ ewl_object_request_geometry(EWL_OBJECT(t),
+ req_x + ((req_w / 2) - (cur_w / 2)),
+ req_y + ((req_h / 2) - (cur_h / 2)),
+ cur_w, cur_h);
+ ewl_widget_configure(t);
- EWL_OBJECT(widget)->current.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->current.h = EWL_OBJECT(widget)->request.h;
- EWL_OBJECT(widget)->minimum.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->minimum.h = EWL_OBJECT(widget)->request.h;
- EWL_OBJECT(widget)->maximum.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->maximum.h = EWL_OBJECT(widget)->request.h;
+ DLEAVE_FUNCTION;
}
+
static void
-ewl_button_key_down(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_button_focus_in(Ewl_Widget * w, void *event_data, void *user_data)
{
- Ev_Key_Down * ev = NULL;
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- CHECK_PARAM_POINTER("widget", widget);
+ ewl_widget_theme_update(w);
- ev = cb->func_data;
-
- if (!strcmp(ev->key, "Return")) {
- ewl_button_set_state(widget, (void *) EWL_STATE_PRESSED);
- } else if (!strcmp(ev->key, "XP_Enter")) {
- ewl_button_set_state(widget, (void *) EWL_STATE_PRESSED);
- } else if (!strcmp(ev->key, "Space")) {
- ewl_button_set_state(widget, (void *) EWL_STATE_PRESSED);
- }
+ DLEAVE_FUNCTION;
}
static void
-ewl_button_key_up(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_button_focus_out(Ewl_Widget * w, void *event_data, void *user_data)
{
- Ev_Key_Up * ev = NULL;
-
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- ev = cb->func_data;
+ ewl_widget_theme_update(w);
- if (!strcmp(ev->key, "Return")) {
- ewl_button_set_state(widget, (void *) EWL_STATE_NORMAL);
- } else if (!strcmp(ev->key, "XP_Enter")) {
- ewl_button_set_state(widget, (void *) EWL_STATE_NORMAL);
- } else if (!strcmp(ev->key, "Space")) {
- ewl_button_set_state(widget, (void *) EWL_STATE_NORMAL);
- }
+ DLEAVE_FUNCTION;
}
static void
-ewl_button_mouse_down(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_button_mouse_down(Ewl_Widget * w, void *event_data, void *user_data)
{
- Ev_Mouse_Down * ev = NULL;
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- CHECK_PARAM_POINTER("widget", widget);
+ w->state |= EWL_STATE_PRESSED;
- ev = cb->func_data;
+ ewl_widget_theme_update(w);
- if (ev->button == 1) {
- ewl_button_set_state(widget, (void *) EWL_STATE_PRESSED);
- } else if (ev->button == 2) {
- } else if (ev->button == 3) {
- }
+ DLEAVE_FUNCTION;
}
static void
-ewl_button_mouse_up(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_button_mouse_up(Ewl_Widget * w, void *event_data, void *user_data)
{
- Ev_Mouse_Up * ev = NULL;
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- CHECK_PARAM_POINTER("widget", widget);
+ w->state &= ~EWL_STATE_PRESSED;
- ev = cb->func_data;
+ ewl_widget_theme_update(w);
- if (ev->button == 1) {
- if (ev->x >= EWL_OBJECT(widget)->current.x &&
- ev->y >= EWL_OBJECT(widget)->current.y &&
- EWL_OBJECT(widget)->current.x +
- EWL_OBJECT(widget)->current.w >= ev->x &&
- EWL_OBJECT(widget)->current.y +
- EWL_OBJECT(widget)->current.h >= ev->y)
- ewl_button_set_state(widget, (void *) EWL_STATE_HILITED);
- else
- ewl_button_set_state(widget, (void *) EWL_STATE_NORMAL);
- } else if (ev->button == 2) {
- } else if (ev->button == 3) {
- }
+ if (w->state & EWL_STATE_HILITED)
+ ewl_callback_call(w, EWL_CALLBACK_CLICKED);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_button_set_state(Ewl_Widget * widget, void * func_data)
+__ewl_button_theme_update(Ewl_Widget * w, void *event_data, void *user_data)
{
- char * image = NULL;
+ Ewl_Button *b;
+ char *v;
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
- if (EWL_BUTTON(widget)->type == EWL_BUTTON_TYPE_NORMAL ||
- EWL_BUTTON(widget)->type == EWL_BUTTON_TYPE_LABEL)
- {
- if ((Ewl_State) func_data == EWL_STATE_NORMAL)
- {
- image = ewl_theme_ebit_get("button", "default", "base");
- }
- else if ((Ewl_State) func_data == EWL_STATE_HILITED)
- {
- image = ewl_theme_ebit_get("button", "default", "hilited");
- }
- else if ((Ewl_State) func_data == EWL_STATE_PRESSED)
- {
- image = ewl_theme_ebit_get("button", "default", "clicked");
- }
- ebits_hide(EWL_BUTTON(widget)->ebits_object);
- ebits_free(EWL_BUTTON(widget)->ebits_object);
- EWL_BUTTON(widget)->ebits_object = ebits_load(image);
- ebits_add_to_evas(EWL_BUTTON(widget)->ebits_object, widget->evas);
- ebits_set_layer(EWL_BUTTON(widget)->ebits_object,
- EWL_OBJECT(widget)->layer);
- if (EWL_OBJECT(widget)->visible)
- ebits_show(EWL_BUTTON(widget)->ebits_object);
- ebits_set_clip(EWL_BUTTON(widget)->ebits_object,
- widget->fx_clip_box);
- ewl_widget_configure(widget);
- IF_FREE(image);
-
- if ((Ewl_State) func_data == EWL_STATE_NORMAL)
- {
- if (EWL_BUTTON(widget)->state == EWL_STATE_PRESSED)
- ewl_callback_call(widget, EWL_CALLBACK_CLICKED);
- EWL_BUTTON(widget)->state = EWL_STATE_NORMAL;
- }
- else if ((Ewl_State) func_data == EWL_STATE_HILITED)
- {
- if (EWL_BUTTON(widget)->state == EWL_STATE_PRESSED)
- ewl_callback_call(widget, EWL_CALLBACK_CLICKED);
- EWL_BUTTON(widget)->state = EWL_STATE_HILITED;
- }
- else if ((Ewl_State) func_data == EWL_STATE_PRESSED)
- EWL_BUTTON(widget)->state = EWL_STATE_PRESSED;
- }
-}
+ DCHECK_PARAM_PTR("w", w);
-static void
-ewl_button_focus_in(Ewl_Widget * widget, Ewl_Callback * cb)
-{
- CHECK_PARAM_POINTER("widget", widget);
+ /*
+ * Don't want to update anything if the widget isn't realized.
+ */
+ if (!w->object.realized)
+ DRETURN;
- if (EWL_BUTTON(widget)->state != EWL_STATE_PRESSED)
- ewl_button_set_state(widget, (void *) EWL_STATE_HILITED);
-}
+ b = EWL_BUTTON(w);
-static void
-ewl_button_focus_out(Ewl_Widget * widget, Ewl_Callback * cb)
-{
- CHECK_PARAM_POINTER("widget", widget);
+ if (w->state & EWL_STATE_PRESSED)
+ v = ewl_theme_data_get(w,
+ "/appearance/button/default/clicked/visible");
+ else if (w->state & EWL_STATE_HILITED)
+ v = ewl_theme_data_get(w,
+ "/appearance/button/default/hilited/visible");
+ else
+ v = ewl_theme_data_get(w,
+ "/appearance/button/default/base/visible");
- if (EWL_BUTTON(widget)->state != EWL_STATE_PRESSED)
- ewl_button_set_state(widget, (void *) EWL_STATE_NORMAL);
-}
-static void
-ewl_button_select(Ewl_Widget * widget, Ewl_Callback * cb)
-{
- CHECK_PARAM_POINTER("widget", widget);
+ if (v && !strncasecmp(v, "yes", 3))
+ {
+ char *i;
-
-}
+ if (w->state & EWL_STATE_PRESSED)
+ i = ewl_theme_image_get(w,
+ "/appearance/button/default/clicked");
+ else if (w->state & EWL_STATE_HILITED)
+ i = ewl_theme_image_get(w,
+ "/appearance/button/default/hilited");
+ else
+ i = ewl_theme_image_get(w,
+ "/appearance/button/default/base");
+
+ if (i)
+ {
+ w->ebits_object = ebits_load(i);
+ FREE(i);
+
+ if (w->ebits_object)
+ {
+ ebits_add_to_evas(w->ebits_object,
+ w->evas);
+ ebits_set_layer(w->ebits_object,
+ EWL_OBJECT(w)->layer);
+ ebits_set_clip(w->ebits_object,
+ w->fx_clip_box);
+
+ ebits_show(w->ebits_object);
+ }
+ }
+ }
-static void
-ewl_button_unselect(Ewl_Widget * widget, Ewl_Callback * cb)
-{
- CHECK_PARAM_POINTER("widget", widget);
+ IF_FREE(v);
+
+ /*
+ * Finally comfigure the widget to update the changes
+ */
+ ewl_widget_configure(w);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_button.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_button.h 2001/05/02 23:12:42 1.3
+++ ewl_button.h 2001/07/20 07:31:54 1.4
@@ -1,30 +1,24 @@
+/*
+ * The button class is a basic button with a label. This class is inherited by
+ * the check button and radio button classes.
+ */
+
#ifndef __EWL_BUTTON_H__
#define __EWL_BUTTON_H__
-
-typedef enum _ewl_button_state Ewl_Button_State;
-enum _ewl_button_type {
- EWL_BUTTON_TYPE_NORMAL,
- EWL_BUTTON_TYPE_LABEL,
- EWL_BUTTON_TYPE_CHECK,
- EWL_BUTTON_TYPE_RADIO
-};
-
-typedef enum _ewl_button_type Ewl_Button_Type;
+typedef struct _ewl_button Ewl_Button;
+#define EWL_BUTTON(button) ((Ewl_Button *) button)
-struct _ewl_button {
- Ewl_Widget widget;
- Ebits_Object ebits_object;
- Ewl_State state;
- Ewl_Button_Type type;
+struct _ewl_button
+{
+ Ewl_Container container;
+ char *label;
};
-
-typedef struct _ewl_button Ewl_Button;
-#define EWL_BUTTON(button) ((Ewl_Button *) button)
+Ewl_Widget *ewl_button_new(char *l);
-Ewl_Widget * ewl_button_new();
-Ewl_Widget * ewl_button_new_with_label(const char * label);
+/* Works on all buttons */
+void ewl_button_set_label(Ewl_Widget * w, char *l);
-#endif
+#endif /* __EWL_BUTTON_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_callback.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_callback.c 2001/05/02 23:12:42 1.5
+++ ewl_callback.c 2001/07/20 07:31:54 1.6
@@ -1,41 +1,43 @@
#include <Ewl.h>
+static int callback_id = 0;
+
int
ewl_callback_append(Ewl_Widget * widget, Ewl_Callback_Type type,
- void (* func) (Ewl_Widget * widget, Ewl_Callback * cb),
- void * user_data)
+ Ewl_Cb_Func func, void *user_data)
{
- Ewl_Callback * callback = NULL;
+ Ewl_Callback *callback = NULL;
+
+ DENTER_FUNCTION;
CHECK_PARAM_POINTER_RETURN("widget", widget, -1);
callback = NEW(Ewl_Callback, 1);
-
memset(callback, 0, sizeof(Ewl_Callback));
callback->widget = widget;
callback->func = func;
- callback->func_data = NULL;
callback->user_data = user_data;
callback->type = type;
- if (!widget->callbacks[type])
+ if (!widget->callbacks[type])
widget->callbacks[type] = ewd_list_new();
ewd_list_append(widget->callbacks[type], callback);
- callback->id = widget->callbacks[type]->index;
+ callback->id = ++callback_id;
- return widget->callbacks[type]->index;
+ DRETURN_INT(callback->id);
}
int
ewl_callback_prepend(Ewl_Widget * widget, Ewl_Callback_Type type,
- void (* func) (Ewl_Widget * widget, Ewl_Callback * cb),
- void * user_data)
+ Ewl_Cb_Func func, void *user_data)
{
- Ewl_Callback * callback = NULL;
+ Ewl_Callback *callback = NULL;
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER_RETURN("widget", widget, -1);
callback = NEW(Ewl_Callback, 1);;
@@ -43,7 +45,6 @@
callback->widget = widget;
callback->func = func;
- callback->func_data = NULL;
callback->user_data = user_data;
callback->type = type;
@@ -52,59 +53,115 @@
ewd_list_prepend(widget->callbacks[type], callback);
- callback->id = widget->callbacks[type]->index;
+ callback->id = ++callback_id;
- return widget->callbacks[type]->index;
+ DRETURN_INT(callback->id);
}
void
-ewl_callback_del(Ewl_Widget * widget, Ewl_Callback_Type type,
- int cb_id)
+ewl_callback_del(Ewl_Widget * widget, Ewl_Callback_Type type, int cb_id)
{
+ Ewl_Callback *cb;
+
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
if (!widget->callbacks[type] ||
- ewd_list_is_empty(widget->callbacks[type]) ||
- cb_id > widget->callbacks[type]->nodes)
- return;
+ ewd_list_is_empty(widget->callbacks[type]) || cb_id > callback_id)
+ DRETURN;
+
+ while ((cb = ewd_list_next(widget->callbacks[type])) != NULL)
+ if (cb->id == cb_id)
+ {
+ ewd_list_remove(widget->callbacks[type]);
+ FREE(cb);
+ break;
+ }
- ewd_list_goto_index(widget->callbacks[type], cb_id);
- ewd_list_remove(widget->callbacks[type]);
+ DLEAVE_FUNCTION;
}
-void ewl_callback_del_all(Ewl_Widget * widget);
+void
+ewl_callback_del_all(Ewl_Widget * w)
+{
+ int i;
+
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
+
+ for (i = 0; i < EWL_CALLBACK_MAX; i++)
+ {
+ if (w->callbacks[i])
+ ewd_list_destroy(w->callbacks[i]);
+ }
+
+ DLEAVE_FUNCTION;
+}
+
void
ewl_callback_call(Ewl_Widget * widget, Ewl_Callback_Type type)
{
- Ewl_Callback * callback = NULL;
+ Ewl_Callback *callback = NULL;
+
+ DENTER_FUNCTION;
CHECK_PARAM_POINTER("widget", widget);
- if (!widget->callbacks[type] || ewd_list_is_empty(widget->callbacks[type]))
- return;
+ if (!widget->callbacks[type] ||
+ ewd_list_is_empty(widget->callbacks[type]))
+ DRETURN;
ewd_list_goto_first(widget->callbacks[type]);
+
+ while ((callback = ewd_list_next(widget->callbacks[type])) != NULL)
+ callback->func(widget, callback->event_data,
+ callback->user_data);
- while ((callback = ewd_list_next(widget->callbacks[type])) != NULL) {
- callback->func(widget, callback);
- }
+ DLEAVE_FUNCTION;
}
-void ewl_callback_call_with_data(Ewl_Widget * widget,
- Ewl_Callback_Type type, void * func_data)
+void
+ewl_callback_call_with_event_data(Ewl_Widget * widget, Ewl_Callback_Type type,
+ void * event_data)
{
- Ewl_Callback * callback = NULL;
+ Ewl_Callback *callback;
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("widget", widget);
- if (!widget->callbacks[type] || ewd_list_is_empty(widget->callbacks[type]))
- return;
+ if (!widget->callbacks[type] ||
+ ewd_list_is_empty(widget->callbacks[type]))
+ DRETURN;
ewd_list_goto_first(widget->callbacks[type]);
+
+ while ((callback = ewd_list_next(widget->callbacks[type])) != NULL)
+ callback->func(widget, event_data, callback->user_data);
+
+ DLEAVE_FUNCTION;
+}
+
+void
+ewl_callback_set_user_data(Ewl_Widget * w, Ewl_Callback_Type type, Ewl_Cb_Func func, void * user_data)
+{
+ Ewl_Callback * cb;
+
+ DENTER_FUNCTION;
+
+ if (!w->callbacks[type] || ewd_list_is_empty(w->callbacks[type]))
+ DRETURN;
+
+ ewd_list_goto_first(w->callbacks[type]);
+
+ while ((cb = ewd_list_next(w->callbacks[type])) != NULL)
+ {
+ if (cb->func == func)
+ {
+ cb->user_data = user_data;
+ break;
+ }
+ }
- while ((callback = ewd_list_next(widget->callbacks[type])) != NULL) {
- callback->func_data = func_data;
- callback->func(widget, callback);
- }
+ DLEAVE_FUNCTION;
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_callback.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_callback.h 2001/05/02 23:12:42 1.3
+++ ewl_callback.h 2001/07/20 07:31:54 1.4
@@ -1,28 +1,41 @@
+/*\
+|*|
+|*| Functions to add/remove/call callbacks.
+|*| each callback you append will be given a own specific number
+|*| which you should keep if you want to remove the callback later on.
+|*|
+\*/
+
#ifndef __EWL_CALLBACK_H__
#define __EWL_CALLBACK_H__
typedef struct _ewl_callback Ewl_Callback;
+#define EWL_CALLBACK(callback) ((Ewl_Callback *) callback)
-struct _ewl_callback {
- Ewl_Widget * widget;
- void (* func) (Ewl_Widget * widget,
- Ewl_Callback * cb);
- void * func_data;
- void * user_data;
- Ewl_Callback_Type type;
- int id;
+typedef void (*Ewl_Cb_Func) (Ewl_Widget * widget, void *event_data,
+ void *user_data);
+struct _ewl_callback
+{
+ Ewl_Widget *widget;
+ Ewl_Cb_Func func;
+ void *event_data;
+ void *user_data;
+ Ewl_Callback_Type type;
+ int id;
};
int ewl_callback_append(Ewl_Widget * widget, Ewl_Callback_Type type,
- void (* func) (Ewl_Widget * widget, Ewl_Callback * cb),
- void * func_data);
-
-void ewl_callback_del(Ewl_Widget * widget, Ewl_Callback_Type type,
- int cb_id);
+ Ewl_Cb_Func func, void *user_data);
+int ewl_callback_prepend(Ewl_Widget * widget, Ewl_Callback_Type type,
+ Ewl_Cb_Func func, void *user_data);
+void ewl_callback_del(Ewl_Widget * widget, Ewl_Callback_Type type, int cb_id);
void ewl_callback_del_all(Ewl_Widget * widget);
void ewl_callback_call(Ewl_Widget * widget, Ewl_Callback_Type type);
-void ewl_callback_call_with_data(Ewl_Widget * widget,
- Ewl_Callback_Type type, void * func_data);
+void ewl_callback_call_with_event_data(Ewl_Widget * widget,
+ Ewl_Callback_Type type,
+ void *event_data);
+void ewl_callback_set_user_data(Ewl_Widget * w, Ewl_Callback_Type type, Ewl_Cb_Func func, void * user_data);
+
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_container.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_container.c 2001/05/01 04:00:38 1.4
+++ ewl_container.c 2001/07/20 07:31:54 1.5
@@ -1,223 +1,310 @@
#include <Ewl.h>
+static void ewl_container_reparent(Ewl_Widget * w, void *event_data,
+ void *user_data);
+
void
-ewl_container_new(Ewl_Widget * widget)
+ewl_container_init(Ewl_Container * widget, int type, int min_w, int min_h,
+ int max_w, int max_h)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
- widget->container.children = ewd_list_new();
+ /*
+ * Initialize the fields inherited from the widget class
+ */
+ ewl_widget_init(EWL_WIDGET(widget), type, min_w, min_h, max_w, max_h);
+ EWL_WIDGET(widget)->recursive = TRUE;
+
+ /*
+ * Initialize the fields specific to the container class.
+ */
+ widget->children = ewd_list_new();
ewl_container_clip_box_create(widget);
+
+ /*
+ * All containers need to perform the function of updating the
+ * children with necessary window and evas information.
+ */
+ ewl_callback_append(EWL_WIDGET(widget), EWL_CALLBACK_REPARENT,
+ ewl_container_reparent, NULL);
+
+ DLEAVE_FUNCTION;
}
void
-ewl_container_append_child(Ewl_Widget * parent, Ewl_Widget * child)
+ewl_container_append_child(Ewl_Container * parent, Ewl_Widget * child)
{
+ int reparent = FALSE;
+
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("parent", parent);
CHECK_PARAM_POINTER("child", child);
- child->evas = parent->evas;
- child->evas_window = parent->evas_window;
- child->parent = parent;
+ if (child->parent)
+ reparent = TRUE;
- EWL_OBJECT(child)->layer = EWL_OBJECT(parent)->layer+1;
+ child->evas = EWL_WIDGET(parent)->evas;
+ child->evas_window = EWL_WIDGET(parent)->evas_window;
+ child->parent = EWL_WIDGET(parent);
- if (!parent->container.children)
- ewl_container_new(parent);
+ EWL_OBJECT(child)->layer = EWL_OBJECT(parent)->layer + 1;
- if (ewd_list_is_empty(parent->container.children))
+ if (ewd_list_is_empty(parent->children))
ewl_container_show_clip(parent);
+
+ if (parent->free_cb)
+ ewd_list_set_free_cb(parent->children, parent->free_cb);
+
+ ewd_list_append(parent->children, child);
- if (parent->container.free_cb)
- ewd_list_set_free_cb(parent->container.children,
- parent->container.free_cb);
+ if (reparent == TRUE)
+ ewl_callback_call(EWL_WIDGET(child), EWL_CALLBACK_REPARENT);
- ewd_list_append(parent->container.children, child);
+ DLEAVE_FUNCTION;
}
void
-ewl_container_prepend_child(Ewl_Widget * parent, Ewl_Widget * child)
+ewl_container_prepend_child(Ewl_Container * parent, Ewl_Widget * child)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("parent", parent);
CHECK_PARAM_POINTER("child", child);
-
- child->evas = parent->evas;
- child->evas_window = parent->evas_window;
- child->parent = parent;
- EWL_OBJECT(child)->layer = EWL_OBJECT(parent)->layer+1;
+ child->evas = EWL_WIDGET(parent)->evas;
+ child->evas_window = EWL_WIDGET(parent)->evas_window;
+ child->parent = EWL_WIDGET(parent);
- if (!parent->container.children)
- ewl_container_new(parent);
+ EWL_OBJECT(child)->layer = EWL_OBJECT(parent)->layer + 1;
- if (ewd_list_is_empty(parent->container.children))
+ if (ewd_list_is_empty(parent->children))
ewl_container_show_clip(parent);
- if (parent->container.free_cb)
- ewd_list_set_free_cb(parent->container.children,
- parent->container.free_cb);
+ if (parent->free_cb)
+ ewd_list_set_free_cb(parent->children, parent->free_cb);
- ewd_list_prepend(parent->container.children, child);
+ ewd_list_prepend(parent->children, child);
+
+ DLEAVE_FUNCTION;
}
void
-ewl_container_set_free_callback(Ewl_Widget * widget, Ewd_Free_Cb cb)
+ewl_container_set_free_callback(Ewl_Container * widget, Ewd_Free_Cb cb)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
+
+ ewd_list_set_free_cb(widget->children, cb);
- ewd_list_set_free_cb(widget->container.children, cb);
+ DLEAVE_FUNCTION;
}
void
-ewl_container_insert_child(Ewl_Widget * parent, Ewl_Widget * child, int index)
+ewl_container_insert_child(Ewl_Container * parent, Ewl_Widget * child,
+ int index)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("parent", parent);
CHECK_PARAM_POINTER("child", child);
-
- child->evas = parent->evas;
- child->evas_window = parent->evas_window;
- child->parent = parent;
- EWL_OBJECT(child)->layer = EWL_OBJECT(parent)->layer+1;
+ child->evas = EWL_WIDGET(parent)->evas;
+ child->evas_window = EWL_WIDGET(parent)->evas_window;
+ child->parent = EWL_WIDGET(parent);
- if (!parent->container.children)
- ewl_container_new(parent);
+ EWL_OBJECT(child)->layer = EWL_OBJECT(parent)->layer + 1;
- if (ewd_list_is_empty(parent->container.children))
+ if (ewd_list_is_empty(parent->children))
ewl_container_show_clip(parent);
- if (parent->container.free_cb)
- ewd_list_set_free_cb(parent->container.children,
- parent->container.free_cb);
+ if (parent->free_cb)
+ ewd_list_set_free_cb(parent->children, parent->free_cb);
- ewd_list_goto_index(parent->container.children, index);
- ewd_list_insert(parent->container.children, child);
+ ewd_list_goto_index(parent->children, index);
+ ewd_list_insert(parent->children, child);
+
+ DLEAVE_FUNCTION;
}
Ewl_Widget *
-ewl_container_get_child_at(Ewl_Widget * widget, int x, int y)
+ewl_container_get_child_at(Ewl_Container * widget, int x, int y)
{
CHECK_PARAM_POINTER_RETURN("widget", widget, NULL);
- if (!widget->container.children ||
- ewd_list_is_empty(widget->container.children))
+ if (!widget->children || ewd_list_is_empty(widget->children))
return NULL;
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(widget->children);
- if (widget->type == EWL_WIDGET_TABLE)
+ if (EWL_WIDGET(widget)->type == EWL_WIDGET_TABLE)
{
- Ewl_Table_Child * child = NULL;
+ Ewl_Table_Child *child = NULL;
- while ((child = ewd_list_next(widget->container.children)) != NULL)
- {
- if (x >= EWL_OBJECT(child->child)->current.x &&
- y >= EWL_OBJECT(child->child)->current.y &&
- EWL_OBJECT(child->child)->current.x +
- EWL_OBJECT(child->child)->current.w >= x &&
- EWL_OBJECT(child->child)->current.y +
- EWL_OBJECT(child->child)->current.h >= y)
- return child->child;
- }
+ while ((child = ewd_list_next(widget->children)) != NULL)
+ {
+ if (x >= EWL_OBJECT(child->widget)->current.x
+ && y >= EWL_OBJECT(child->widget)->current.y
+ && EWL_OBJECT(child->widget)->current.x +
+ EWL_OBJECT(child->widget)->current.w >= x
+ && EWL_OBJECT(child->widget)->current.y +
+ EWL_OBJECT(child->widget)->current.h >= y)
+ return child->widget;
+ }
}
else
{
- Ewl_Widget * child = NULL;
- while ((child = ewd_list_next(widget->container.children)) != NULL)
- {
- if (x >= EWL_OBJECT(child)->current.x &&
- y >= EWL_OBJECT(child)->current.y &&
- EWL_OBJECT(child)->current.x + EWL_OBJECT(child)->current.w >= x &&
- EWL_OBJECT(child)->current.y + EWL_OBJECT(child)->current.h >= y)
- return child;
- }
- }
+ Ewl_Widget *child = NULL;
+ while ((child =
+ ewd_list_next(EWL_CONTAINER(widget)->children)) !=
+ NULL)
+ {
+ if (x >= EWL_OBJECT(child)->current.x
+ && y >= EWL_OBJECT(child)->current.y
+ && EWL_OBJECT(child)->current.x +
+ EWL_OBJECT(child)->current.w >= x
+ && EWL_OBJECT(child)->current.y +
+ EWL_OBJECT(child)->current.h >= y)
+ return child;
+ }
+ }
+
return NULL;
}
Ewl_Widget *
-ewl_container_get_child_at_recursive(Ewl_Widget * widget, int x, int y)
+ewl_container_get_child_at_recursive(Ewl_Container * widget, int x, int y)
{
- Ewl_Widget * child = NULL, * child2 = NULL;
+ Ewl_Container *child = NULL;
+ Ewl_Widget *child2 = NULL;
CHECK_PARAM_POINTER_RETURN("widget", widget, NULL);
- if (!widget->container.children ||
- ewd_list_is_empty(widget->container.children))
+ if (!widget->children || ewd_list_is_empty(widget->children))
return NULL;
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(widget->children);
child = widget;
while ((child2 = ewl_container_get_child_at(child, x, y)) != NULL)
{
- if (child2->container.recursive)
- child = ewl_container_get_child_at(child, x, y);
- else
- return child2;
+ if (child2->recursive)
+ child = EWL_CONTAINER(ewl_container_get_child_at
+ (child, x, y));
+ else
+ return child2;
}
return NULL;
}
void
-ewl_container_clip_box_create(Ewl_Widget * widget)
+ewl_container_clip_box_create(Ewl_Container * widget)
{
- if (!widget->container.clip_box)
+ DENTER_FUNCTION;
+
+ if (!widget->clip_box)
{
- widget->container.clip_box = evas_add_rectangle(widget->evas);
- evas_set_color(widget->evas, widget->container.clip_box,
- 255, 255, 255, 255);
- evas_move(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->current.x, EWL_OBJECT(widget)->current.y);
- evas_resize(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->current.w,
- EWL_OBJECT(widget)->current.h);
- evas_set_layer(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->layer);
- }
+ widget->clip_box =
+ evas_add_rectangle(EWL_WIDGET(widget)->evas);
+ evas_set_color(EWL_WIDGET(widget)->evas, widget->clip_box,
+ 255, 255, 255, 255);
+ evas_move(EWL_WIDGET(widget)->evas, widget->clip_box,
+ EWL_OBJECT(widget)->current.x,
+ EWL_OBJECT(widget)->current.y);
+ evas_resize(EWL_WIDGET(widget)->evas, widget->clip_box,
+ EWL_OBJECT(widget)->current.w,
+ EWL_OBJECT(widget)->current.h);
+ evas_set_layer(EWL_WIDGET(widget)->evas, widget->clip_box,
+ EWL_OBJECT(widget)->layer);
+ evas_show(EWL_WIDGET(widget)->evas, widget->clip_box);
+ }
+
+ DLEAVE_FUNCTION;
}
void
-ewl_container_clip_box_resize(Ewl_Widget * widget)
+ewl_container_clip_box_resize(Ewl_Container * widget)
{
- if (widget->container.clip_box)
+ DENTER_FUNCTION;
+
+ if (EWL_CONTAINER(widget)->clip_box)
{
- evas_move(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->request.x, EWL_OBJECT(widget)->request.y);
- evas_resize(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->request.w,
- EWL_OBJECT(widget)->request.h);
- }
+ evas_move(EWL_WIDGET(widget)->evas,
+ EWL_CONTAINER(widget)->clip_box,
+ EWL_OBJECT(widget)->request.x,
+ EWL_OBJECT(widget)->request.y);
+ evas_resize(EWL_WIDGET(widget)->evas,
+ EWL_CONTAINER(widget)->clip_box,
+ EWL_OBJECT(widget)->request.w,
+ EWL_OBJECT(widget)->request.h);
+ }
+
+ DLEAVE_FUNCTION;
}
void
-ewl_container_set_clip(Ewl_Widget * widget)
+ewl_container_set_clip(Ewl_Container * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
- if (widget->parent &&
- widget->fx_clip_box &&
- widget->container.clip_box)
- evas_set_clip(widget->evas, widget->container.clip_box,
- widget->fx_clip_box);
+ if (EWL_WIDGET(widget)->parent && EWL_WIDGET(widget)->fx_clip_box &&
+ widget->clip_box)
+ evas_set_clip(EWL_WIDGET(widget)->evas, widget->clip_box,
+ EWL_WIDGET(widget)->fx_clip_box);
+
+ DLEAVE_FUNCTION;
}
void
-ewl_container_show_clip(Ewl_Widget * widget)
+ewl_container_show_clip(Ewl_Container * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
+
+ if (widget->clip_box)
+ evas_show(EWL_WIDGET(widget)->evas, widget->clip_box);
- if (widget->container.clip_box)
- evas_show(widget->evas, widget->container.clip_box);
+ DLEAVE_FUNCTION;
}
void
-ewl_container_hide_clip(Ewl_Widget * widget)
+ewl_container_hide_clip(Ewl_Container * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
+
+ if (widget->clip_box)
+ evas_hide(EWL_WIDGET(widget)->evas, widget->clip_box);
- if (widget->container.clip_box)
- evas_hide(widget->evas, widget->container.clip_box);
+ DLEAVE_FUNCTION;
+}
+
+static void
+ewl_container_reparent(Ewl_Widget * w, void *event_data, void *user_data)
+{
+ Ewl_Widget *child;
+ Ewd_List *old;
+
+ DENTER_FUNCTION;
+
+ CHECK_PARAM_POINTER("w", w);
+
+ old = EWL_CONTAINER(w)->children;
+ EWL_CONTAINER(w)->children = ewd_list_new();
+
+ while ((child = ewd_list_remove_first(old)) != NULL)
+ {
+ ewl_container_append_child(EWL_CONTAINER(w), child);
+ ewl_callback_call(child, EWL_CALLBACK_REPARENT);
+ }
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_container.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_container.h 2001/05/01 04:00:38 1.3
+++ ewl_container.h 2001/07/20 07:31:54 1.4
@@ -1,34 +1,40 @@
+/*\
+|*|
+|*| The container is a sub class for each widget, Ewl_Widget structure holds it
+|*| and is used to keep all subwidgets for a widget.
+|*|
+\*/
+
#ifndef __EWL_CONTAINER_H__
#define __EWL_CONTAINER_H__
+
+typedef struct _ewl_container Ewl_Container;
+#define EWL_CONTAINER(widget) ((Ewl_Container *) widget)
-struct _ewl_container {
- Ewd_List * children;
- Ewd_Free_Cb free_cb;
- int recursive;
- Evas_Object clip_box;
+struct _ewl_container
+{
+ Ewl_Widget widget;
+ Ewd_List *children;
+ Ewd_Free_Cb free_cb;
+ Evas_Object clip_box;
};
-#define EWL_CONTAINER(widget) ((Ewl_Container *) widget)
+void ewl_container_init(Ewl_Container * widget, int type, int min_w,
+ int min_h, int max_w, int max_h);
+void ewl_container_append_child(Ewl_Container * parent, Ewl_Widget * child);
+void ewl_container_prepend_child(Ewl_Container * parent, Ewl_Widget * child);
+void ewl_container_insert_child(Ewl_Container * parent,
+ Ewl_Widget * child, int index);
+Ewl_Widget *ewl_container_get_child_at(Ewl_Container * widget, int x, int y);
+Ewl_Widget *ewl_container_get_child_at_recursive(Ewl_Container * widget,
+ int x, int y);
+void ewl_container_clip_box_create(Ewl_Container * widget);
+void ewl_container_clip_box_resize(Ewl_Container * widget);
+void ewl_container_set_clip(Ewl_Container * widget);
+void ewl_container_show_clip(Ewl_Container * widget);
+void ewl_container_hide_clip(Ewl_Container * widget);
-void ewl_container_new(Ewl_Widget * widget);
-void ewl_container_append_child(Ewl_Widget * parent,
- Ewl_Widget * child);
-void ewl_container_prepend_child(Ewl_Widget * parent,
- Ewl_Widget * child);
-void ewl_container_insert_child(Ewl_Widget * parent,
- Ewl_Widget * child,
- int index);
-Ewl_Widget * ewl_container_get_child_at(Ewl_Widget * widget,
- int x,
- int y);
-Ewl_Widget * ewl_container_get_child_at_recursive(Ewl_Widget * widget,
- int x,
- int y);
-void ewl_container_clip_box_create(Ewl_Widget * widget);
-void ewl_container_clip_box_resize(Ewl_Widget * widget);
-void ewl_container_set_clip(Ewl_Widget * widget);
-void ewl_container_show_clip(Ewl_Widget * widget);
-void ewl_container_hide_clip(Ewl_Widget * widget);
+#define RECURSIVE(w) EWL_CONTAINER(w)->recursive
-#endif
+#endif /* __EWL_CONTAINER_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_entry.c 2001/05/02 23:12:42 1.6
+++ ewl_entry.c 2001/07/20 07:31:54 1.7
@@ -3,17 +3,28 @@
static void ewl_entry_init(Ewl_Widget * widget);
-static void ewl_entry_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_configure(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_key_down(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_key_up(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_mouse_down(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_mouse_up(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_select(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_entry_unselect(Ewl_Widget * widget, Ewl_Callback * cb);
+static void ewl_entry_realize(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_show(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_hide(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_destroy(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_configure(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_key_down(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_key_up(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_mouse_down(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_mouse_up(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_select(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_entry_unselect(Ewl_Widget * widget, void *event_data,
+ void *user_data);
static void ewl_entry_delete_to_left(Ewl_Widget * widget);
static void ewl_entry_delete_to_right(Ewl_Widget * widget);
@@ -22,143 +33,156 @@
static void ewl_entry_move_cursor_to_end(Ewl_Widget * widget);
static void ewl_entry_move_cursor_to_left(Ewl_Widget * widget);
static void ewl_entry_move_cursor_to_right(Ewl_Widget * widget);
-static void ewl_entry_insert_text(Ewl_Widget * widget, char * text);
+static void ewl_entry_insert_text(Ewl_Widget * widget, char *text);
Ewl_Widget *
ewl_entry_new()
{
- Ewl_Entry * entry = NULL;
+ Ewl_Entry *entry = NULL;
+ DENTER_FUNCTION;
+
entry = NEW(Ewl_Entry, 1);
ewl_entry_init(EWL_WIDGET(entry));
- return EWL_WIDGET(entry);
+ DRETURN_PTR(EWL_WIDGET(entry));
}
static void
ewl_entry_init(Ewl_Widget * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
memset(EWL_ENTRY(widget), 0, sizeof(Ewl_Entry));
- EWL_WIDGET(widget)->type = EWL_WIDGET_ENTRY;
-
+ /*
+ * Initialize the inherited container fields
+ */
+ ewl_container_init(EWL_CONTAINER(widget), EWL_WIDGET_ENTRY, 300, 35,
+ 640, 130);
+
+ /*
+ * Attach necessary callbacks
+ */
ewl_callback_append(widget, EWL_CALLBACK_REALIZE,
- ewl_entry_realize, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_SHOW,
- ewl_entry_show, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_HIDE,
- ewl_entry_hide, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_DESTROY,
- ewl_entry_destroy, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_CONFIGURE,
- ewl_entry_configure, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_KEY_DOWN,
- ewl_entry_key_down, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_KEY_UP,
- ewl_entry_key_up, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_MOUSE_DOWN,
- ewl_entry_mouse_down, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_MOUSE_UP,
- ewl_entry_mouse_up, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_SELECT,
- ewl_entry_select, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_UNSELECT,
- ewl_entry_unselect, NULL);
-
- widget->container.recursive = FALSE;
+ ewl_entry_realize, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_SHOW, ewl_entry_show, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_HIDE, ewl_entry_hide, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_DESTROY,
+ ewl_entry_destroy, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_CONFIGURE,
+ ewl_entry_configure, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_KEY_DOWN,
+ ewl_entry_key_down, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_KEY_UP, ewl_entry_key_up,
+ NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_MOUSE_DOWN,
+ ewl_entry_mouse_down, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_MOUSE_UP,
+ ewl_entry_mouse_up, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_SELECT, ewl_entry_select,
+ NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_UNSELECT,
+ ewl_entry_unselect, NULL);
EWL_ENTRY(widget)->text = ewl_text_new();
-
+
EWL_ENTRY(widget)->font = strdup("borzoib");
EWL_ENTRY(widget)->font_size = 8;
- EWL_OBJECT(widget)->current.w = 300;
- EWL_OBJECT(widget)->current.h = 35;
- EWL_OBJECT(widget)->minimum.w = 256;
- EWL_OBJECT(widget)->minimum.h = 130;
- EWL_OBJECT(widget)->maximum.w = 640;
- EWL_OBJECT(widget)->maximum.h = 20;
- EWL_OBJECT(widget)->request.w = 300;
- EWL_OBJECT(widget)->request.h = 35;
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_realize(Ewl_Widget * w, void *event_data, void *user_data)
{
- char * image = NULL;
+ char *image = NULL;
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+
+ CHECK_PARAM_POINTER("w", w);
- image = ewl_theme_ebit_get("entry", "default", "base");
+ image = ewl_theme_image_get(w, "/appearance/entry/default/base");
- EWL_ENTRY(widget)->ebits_object = ebits_load(image);
+ w->ebits_object = ebits_load(image);
IF_FREE(image);
- ebits_add_to_evas(EWL_ENTRY(widget)->ebits_object, widget->evas);
- ebits_set_layer(EWL_ENTRY(widget)->ebits_object, widget->object.layer);
+ ebits_add_to_evas(w->ebits_object, w->evas);
+ ebits_set_layer(w->ebits_object, w->object.layer);
- image = ewl_theme_ebit_get("entry", "cursor", "base");
+ image = ewl_theme_image_get(w, "/appearance/entry/cursor/base");
- EWL_ENTRY(widget)->cursor = ebits_load(image);
+ EWL_ENTRY(w)->cursor = ebits_load(image);
IF_FREE(image);
- ebits_add_to_evas(EWL_ENTRY(widget)->cursor, widget->evas);
- ebits_set_layer(EWL_ENTRY(widget)->cursor, widget->object.layer +3);
+ ebits_add_to_evas(EWL_ENTRY(w)->cursor, w->evas);
+ ebits_set_layer(EWL_ENTRY(w)->cursor, w->object.layer + 3);
- EWL_WIDGET(EWL_ENTRY(widget)->text)->parent = widget;
- EWL_WIDGET(EWL_ENTRY(widget)->text)->evas = widget->evas;
- EWL_OBJECT(EWL_ENTRY(widget)->text)->layer = EWL_OBJECT(widget)->layer +1;
- ewl_text_set_font_size(EWL_ENTRY(widget)->text, 10);
- ewl_widget_realize(EWL_WIDGET(EWL_ENTRY(widget)->text));
+ EWL_WIDGET(EWL_ENTRY(w)->text)->parent = w;
+ EWL_WIDGET(EWL_ENTRY(w)->text)->evas = w->evas;
+ EWL_OBJECT(EWL_ENTRY(w)->text)->layer = EWL_OBJECT(w)->layer + 1;
+ ewl_text_set_font_size(EWL_ENTRY(w)->text, 10);
+ ewl_widget_realize(EWL_WIDGET(EWL_ENTRY(w)->text));
- ewl_fx_clip_box_create(widget);
- ewl_container_clip_box_create(widget);
- ewl_container_show_clip(widget);
+ ewl_fx_clip_box_create(w);
+ ewl_container_show_clip(EWL_CONTAINER(w));
- ebits_set_clip(EWL_ENTRY(widget)->ebits_object, widget->fx_clip_box);
- evas_set_clip(widget->evas, widget->fx_clip_box,
- widget->parent->container.clip_box);
- evas_set_clip(widget->evas, widget->container.clip_box,widget->fx_clip_box);
- evas_show(widget->evas, widget->fx_clip_box);
- ebits_show(EWL_ENTRY(widget)->ebits_object);
+ ebits_set_clip(w->ebits_object, w->fx_clip_box);
+ evas_set_clip(w->evas, w->fx_clip_box,
+ EWL_CONTAINER(w->parent)->clip_box);
+ evas_set_clip(w->evas, EWL_CONTAINER(w)->clip_box, w->fx_clip_box);
+ evas_show(w->evas, w->fx_clip_box);
+ ebits_show(w->ebits_object);
- ebits_set_clip(EWL_ENTRY(widget)->cursor, widget->fx_clip_box);
+ ebits_set_clip(EWL_ENTRY(w)->cursor, w->fx_clip_box);
- ewl_widget_show(EWL_ENTRY(widget)->text);
+ ewl_widget_show(EWL_ENTRY(w)->text);
- evas_show(widget->evas, widget->container.clip_box);
+ evas_show(w->evas, EWL_CONTAINER(w)->clip_box);
- evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
+ evas_set_color(w->evas, w->fx_clip_box, 255, 255, 255, 255);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_show(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_show(Ewl_Widget * widget, void *event_data, void *user_data)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
- evas_show(widget->evas, widget->container.clip_box);
+ evas_show(widget->evas, EWL_CONTAINER(widget)->clip_box);
evas_show(widget->evas, widget->fx_clip_box);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_hide(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_hide(Ewl_Widget * widget, void *event_data, void *user_data)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
evas_hide(widget->evas, widget->fx_clip_box);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_destroy(Ewl_Widget * widget, void *event_data, void *user_data)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
- ebits_hide(EWL_ENTRY(widget)->ebits_object);
- ebits_unset_clip(EWL_ENTRY(widget)->ebits_object);
- ebits_free(EWL_ENTRY(widget)->ebits_object);
+ ebits_hide(widget->ebits_object);
+ ebits_unset_clip(widget->ebits_object);
+ ebits_free(widget->ebits_object);
ebits_hide(EWL_ENTRY(widget)->cursor);
ebits_unset_clip(EWL_ENTRY(widget)->cursor);
@@ -170,89 +194,98 @@
evas_unset_clip(widget->evas, widget->fx_clip_box);
evas_del_object(widget->evas, widget->fx_clip_box);
- evas_hide(widget->evas, widget->container.clip_box);
- evas_unset_clip(widget->evas, widget->container.clip_box);
- evas_del_object(widget->evas, widget->container.clip_box);
+ evas_hide(widget->evas, EWL_CONTAINER(widget)->clip_box);
+ evas_unset_clip(widget->evas, EWL_CONTAINER(widget)->clip_box);
+ evas_del_object(widget->evas, EWL_CONTAINER(widget)->clip_box);
+ ewl_callback_del_all(widget);
+
+ ewl_theme_deinit_widget(widget);
+
FREE(widget);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_configure(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_configure(Ewl_Widget * widget, void *event_data, void *user_data)
{
int l, r, t, b;
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
- EWL_OBJECT(widget)->current.x = EWL_OBJECT(widget)->request.x;
- EWL_OBJECT(widget)->current.y = EWL_OBJECT(widget)->request.y;
- EWL_OBJECT(widget)->current.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->current.h = EWL_OBJECT(widget)->maximum.h;
+ CURRENT_X(widget) = REQUEST_X(widget);
+ CURRENT_Y(widget) = REQUEST_Y(widget);
+ CURRENT_W(widget) = REQUEST_W(widget);
+ CURRENT_H(widget) = REQUEST_H(widget);
if (EWL_OBJECT(widget)->realized)
{
- ebits_move(EWL_ENTRY(widget)->ebits_object, EWL_OBJECT(widget)->current.x,
- EWL_OBJECT(widget)->current.y);
- ebits_resize(EWL_ENTRY(widget)->ebits_object, EWL_OBJECT(widget)->current.w,
- EWL_OBJECT(widget)->current.h);
+ ebits_move(widget->ebits_object, CURRENT_X(widget),
+ CURRENT_Y(widget));
+ ebits_resize(widget->ebits_object, CURRENT_W(widget),
+ CURRENT_H(widget));
- ewl_fx_clip_box_resize(widget);
+ ewl_fx_clip_box_resize(widget);
- ebits_get_insets(EWL_ENTRY(widget)->ebits_object, &l, &r, &t, &b);
+ ebits_get_insets(widget->ebits_object, &l, &r, &t, &b);
- evas_move(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->current.x + l,
- EWL_OBJECT(widget)->current.y + t);
- evas_resize(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->current.w - (l+r),
- EWL_OBJECT(widget)->current.h - (t+b));
+ evas_move(widget->evas, EWL_CONTAINER(widget)->clip_box,
+ CURRENT_X(widget) + l, CURRENT_Y(widget) + t);
+ evas_resize(widget->evas, EWL_CONTAINER(widget)->clip_box,
+ CURRENT_W(widget) - (l + r),
+ CURRENT_H(widget) - (t + b));
- l += 2;
+ l += 2;
- EWL_OBJECT(EWL_ENTRY(widget)->text)->request.x =
- EWL_OBJECT(widget)->current.x +l;
- EWL_OBJECT(EWL_ENTRY(widget)->text)->request.y =
- EWL_OBJECT(widget)->current.y +t;
+ REQUEST_X(EWL_ENTRY(widget)->text) = CURRENT_X(widget) + l;
+ REQUEST_Y(EWL_ENTRY(widget)->text) = CURRENT_Y(widget) + t;
- ewl_widget_configure(EWL_ENTRY(widget)->text);
+ ewl_widget_configure(EWL_ENTRY(widget)->text);
- ewl_entry_set_cursor_pos(widget, EWL_ENTRY(widget)->cursor_pos);
+ ewl_entry_set_cursor_pos(widget,
+ EWL_ENTRY(widget)->cursor_pos);
}
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_key_down(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_key_down(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ev_Key_Down * ev;
+ Ev_Key_Down *ev;
+
+ DENTER_FUNCTION;
CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("cb", cb);
- ev = cb->func_data;
+ ev = (Ev_Key_Down *) event_data;
if (!strcmp(ev->key, "Left"))
{
- ewl_entry_move_cursor_to_left(widget);
+ ewl_entry_move_cursor_to_left(widget);
}
else if (!strcmp(ev->key, "Right"))
{
- ewl_entry_move_cursor_to_right(widget);
+ ewl_entry_move_cursor_to_right(widget);
}
else if (!strcmp(ev->key, "Home"))
{
- ewl_entry_move_cursor_to_start(widget);
+ ewl_entry_move_cursor_to_start(widget);
}
else if (!strcmp(ev->key, "End"))
{
- ewl_entry_move_cursor_to_end(widget);
+ ewl_entry_move_cursor_to_end(widget);
}
else if (!strcmp(ev->key, "BackSpace"))
{
- ewl_entry_delete_to_left(widget);
+ ewl_entry_delete_to_left(widget);
}
else if (!strcmp(ev->key, "Delete"))
{
- ewl_entry_delete_to_right(widget);
+ ewl_entry_delete_to_right(widget);
}
else if (!strcmp(ev->key, "Return"))
{
@@ -262,45 +295,58 @@
}
else if (ev->compose && strlen(ev->compose) == 1)
{
- ewl_entry_insert_text(widget, ev->compose);
+ ewl_entry_insert_text(widget, ev->compose);
}
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_key_up(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_key_up(Ewl_Widget * widget, void *event_data, void *user_data)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_mouse_down(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_mouse_down(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ev_Mouse_Down * ev;
- int x, y, w, h;
- int px, py, pw, ph;
+ Ev_Mouse_Down *ev;
+ double x, y, w, h;
+ double px, py, pw, ph;
int i;
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("cb", cb);
- ev = cb->func_data;
+ ev = (Ev_Mouse_Down *) event_data;
if (ev->button == 1)
{
- ewl_text_get_letter_geometry_at(EWL_ENTRY(widget)->text,
- ev->x, ev->y, &x, &y, &w, &h);
- for (i=0;i<strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text);i++)
- {
- ewl_text_get_letter_geometry(EWL_ENTRY(widget)->text, i,
- &px, &py, &pw, &ph);
- if (px == x && py == y && pw == w && ph == h)
- {
- ewl_entry_set_cursor_pos(widget, i);
- return;
- }
- }
- ewl_entry_set_cursor_pos(widget,
- strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text));
+ ewl_text_get_letter_geometry_at(EWL_ENTRY(widget)->text,
+ ev->x, ev->y, &x, &y, &w,
+ &h);
+ for (i = 0;
+ i < strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text);
+ i++)
+ {
+ ewl_text_get_letter_geometry(EWL_ENTRY(widget)->
+ text, i, &px, &py,
+ &pw, &ph);
+ if (px == x && py == y && pw == w && ph == h)
+ {
+ ewl_entry_set_cursor_pos(widget, i);
+ DRETURN;
+ }
+ }
+ ewl_entry_set_cursor_pos(widget,
+ strlen(EWL_TEXT
+ (EWL_ENTRY(widget)->text)->
+ text));
}
else if (ev->button == 2)
{
@@ -308,192 +354,254 @@
else if (ev->button == 3)
{
}
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_mouse_up(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_mouse_up(Ewl_Widget * widget, void *event_data, void *user_data)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_select(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_select(Ewl_Widget * widget, void *event_data, void *user_data)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
ebits_show(EWL_ENTRY(widget)->cursor);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_unselect(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_entry_unselect(Ewl_Widget * widget, void *event_data, void *user_data)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
ebits_hide(EWL_ENTRY(widget)->cursor);
+
+ DLEAVE_FUNCTION;
}
static void
ewl_entry_move_cursor_to_start(Ewl_Widget * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
if (!EWL_ENTRY(widget)->cursor_pos)
- return;
+ DRETURN;
ewl_entry_set_cursor_pos(widget, 0);
+
+ DLEAVE_FUNCTION;
}
static void
ewl_entry_move_cursor_to_end(Ewl_Widget * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
if (strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text) <=
- EWL_ENTRY(widget)->cursor_pos)
- return;
+ EWL_ENTRY(widget)->cursor_pos)
+ DRETURN;
ewl_entry_set_cursor_pos(widget,
- strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text));
+ strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->
+ text));
+
+ DLEAVE_FUNCTION;
}
static void
ewl_entry_move_cursor_to_left(Ewl_Widget * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
if (!EWL_ENTRY(widget)->cursor_pos)
- return;
+ DRETURN;
+
+ ewl_entry_set_cursor_pos(widget, EWL_ENTRY(widget)->cursor_pos - 1);
- ewl_entry_set_cursor_pos(widget, EWL_ENTRY(widget)->cursor_pos -1);
+ DLEAVE_FUNCTION;
}
static void
ewl_entry_move_cursor_to_right(Ewl_Widget * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
if (strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text) <=
- EWL_ENTRY(widget)->cursor_pos)
- return;
+ EWL_ENTRY(widget)->cursor_pos)
+ DRETURN;
+
+ ewl_entry_set_cursor_pos(widget, EWL_ENTRY(widget)->cursor_pos + 1);
- ewl_entry_set_cursor_pos(widget, EWL_ENTRY(widget)->cursor_pos +1);
+ DLEAVE_FUNCTION;
}
static void
ewl_entry_delete_to_left(Ewl_Widget * widget)
{
- char * str = NULL;
+ char *str = NULL;
+
+ DENTER_FUNCTION;
CHECK_PARAM_POINTER("widget", widget);
if (!ewl_entry_get_cursor_pos(widget))
- return;
+ DRETURN;
str = ewl_entry_get_text(widget);
- strcpy(&(str[ewl_entry_get_cursor_pos(widget) -1]),
- &(ewl_entry_get_text(widget)[ewl_entry_get_cursor_pos(widget)]));
+ strcpy(&(str[ewl_entry_get_cursor_pos(widget) - 1]),
+ &(ewl_entry_get_text(widget)
+ [ewl_entry_get_cursor_pos(widget)]));
ewl_entry_set_text(widget, str);
- ewl_entry_set_cursor_pos(widget, ewl_entry_get_cursor_pos(widget) -1);
+ ewl_entry_set_cursor_pos(widget,
+ ewl_entry_get_cursor_pos(widget) - 1);
IF_FREE(str);
+
+ DLEAVE_FUNCTION;
}
static void
ewl_entry_delete_to_right(Ewl_Widget * widget)
{
- char * str = NULL;
+ char *str = NULL;
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
-
+
if (!strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text) ||
- strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text) <=
- ewl_entry_get_cursor_pos(widget))
- return;
+ strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text) <=
+ ewl_entry_get_cursor_pos(widget))
+ DRETURN;
str = ewl_entry_get_text(widget);
strcpy(&(str[ewl_entry_get_cursor_pos(widget)]),
- &ewl_entry_get_text(widget)[ewl_entry_get_cursor_pos(widget) +1]);
+ &ewl_entry_get_text(widget)[ewl_entry_get_cursor_pos(widget)
+ + 1]);
ewl_entry_set_text(widget, str);
ewl_entry_set_cursor_pos(widget, ewl_entry_get_cursor_pos(widget));
IF_FREE(str);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_entry_insert_text(Ewl_Widget * widget, char * text)
+ewl_entry_insert_text(Ewl_Widget * widget, char *text)
{
- char * str = NULL;
+ char *str = NULL;
CHECK_PARAM_POINTER("widget", widget);
CHECK_PARAM_POINTER("text", text);
- str = malloc(strlen(ewl_entry_get_text(widget)) + strlen(text) +1);
- str [0] = 0;
+ str = malloc(strlen(ewl_entry_get_text(widget)) + strlen(text) + 1);
+ str[0] = 0;
strncat(str, ewl_entry_get_text(widget),
- EWL_ENTRY(widget)->cursor_pos);
+ EWL_ENTRY(widget)->cursor_pos);
strcat(str, text);
- strcat(str, &ewl_entry_get_text(widget)[EWL_ENTRY(widget)->cursor_pos]);
+ strcat(str,
+ &ewl_entry_get_text(widget)[EWL_ENTRY(widget)->cursor_pos]);
ewl_entry_set_text(widget, str);
ewl_entry_set_cursor_pos(widget,
- EWL_ENTRY(widget)->cursor_pos + strlen(text));
+ EWL_ENTRY(widget)->cursor_pos +
+ strlen(text));
+
+ DLEAVE_FUNCTION;
}
void
ewl_entry_set_cursor_pos(Ewl_Widget * widget, int pos)
{
int l = 0, r = 0, t = 0, b = 0;
- int x = 0, y = 0, w = 0;
+ double x = 0, y = 0, w = 0;
+
+ DENTER_FUNCTION;
CHECK_PARAM_POINTER("widget", widget);
- ebits_get_insets(EWL_ENTRY(widget)->ebits_object, &l, &r, &t, &b);
+ ebits_get_insets(widget->ebits_object, &l, &r, &t, &b);
if (strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text) > pos)
- ewl_text_get_letter_geometry(EWL_WIDGET(EWL_ENTRY(widget)->text), pos,
- &x, &y, &w, 0);
+ ewl_text_get_letter_geometry(EWL_WIDGET
+ (EWL_ENTRY(widget)->text),
+ pos, &x, &y, &w, 0);
else if (!strlen(EWL_TEXT(EWL_ENTRY(widget)->text)->text))
{
- x = 0;
- y = 0;
- w = 3;
+ x = 0;
+ y = 0;
+ w = 3;
}
else
{
- ewl_text_get_letter_geometry(EWL_WIDGET(EWL_ENTRY(widget)->text), pos-1,
- &x, &y, &w, 0);
- x += w + 1;
- w = 3;
+ ewl_text_get_letter_geometry(EWL_WIDGET
+ (EWL_ENTRY(widget)->text),
+ pos - 1, &x, &y, &w, 0);
+ x += w + 1;
+ w = 3;
}
EWL_OBJECT(EWL_ENTRY(widget)->cursor)->request.w = w + 4;
EWL_OBJECT(EWL_ENTRY(widget)->cursor)->request.h =
- EWL_OBJECT(widget)->current.h - t - b;
+ EWL_OBJECT(widget)->current.h - t - b;
ebits_move(EWL_ENTRY(widget)->cursor,
- EWL_OBJECT(widget)->current.x + x + l,
- EWL_OBJECT(widget)->current.y + y + t);
+ EWL_OBJECT(widget)->current.x + x + l,
+ EWL_OBJECT(widget)->current.y + y + t);
ebits_resize(EWL_ENTRY(widget)->cursor,
- w + 4, EWL_OBJECT(widget)->current.h - t - b);
+ w + 4, EWL_OBJECT(widget)->current.h - t - b);
EWL_ENTRY(widget)->cursor_pos = pos;
+
+ DLEAVE_FUNCTION;
}
int
ewl_entry_get_cursor_pos(Ewl_Widget * widget)
{
- return EWL_ENTRY(widget)->cursor_pos;
+ DENTER_FUNCTION;
+
+ DRETURN_INT(EWL_ENTRY(widget)->cursor_pos);
+
+ DLEAVE_FUNCTION;
}
void
-ewl_entry_set_text(Ewl_Widget * widget, const char * text)
+ewl_entry_set_text(Ewl_Widget * widget, const char *text)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
ewl_text_set_text(EWL_ENTRY(widget)->text, text);
+
+ DLEAVE_FUNCTION;
}
char *
ewl_entry_get_text(Ewl_Widget * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER_RETURN("widget", widget, NULL);
- return strdup(EWL_TEXT(EWL_ENTRY(widget)->text)->text);
+ DRETURN_PTR(strdup(EWL_TEXT(EWL_ENTRY(widget)->text)->text));
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_entry.h 2001/05/01 04:00:38 1.3
+++ ewl_entry.h 2001/07/20 07:31:54 1.4
@@ -1,27 +1,34 @@
-#ifndef __EWL_ENTRY_H
-#define __EWL_ENTRY_H
+/*\
+|*|
+|*| The entry widget is used to get input from a user.
+|*|
+\*/
-struct _ewl_entry {
- Ewl_Widget widget;
- Ebits_Object ebits_object;
- Ebits_Object cursor;
- int cursor_pos;
- Ewl_Widget * selection;
- Ewl_Widget * text;
- char * font;
- int font_size;
- Window paste_win;
-};
+
-typedef struct _ewl_entry Ewl_Entry;
+#ifndef __EWL_ENTRY_H__
+#define __EWL_ENTRY_H__
+typedef struct _ewl_entry Ewl_Entry;
#define EWL_ENTRY(entry) ((Ewl_Entry *) entry)
+
+struct _ewl_entry
+{
+ Ewl_Container container;
+ Ebits_Object cursor;
+ int cursor_pos;
+ Ewl_Widget *selection;
+ Ewl_Widget *text;
+ char *font;
+ int font_size;
+ Window paste_win;
+};
-Ewl_Widget * ewl_entry_new();
-void ewl_entry_set_text(Ewl_Widget * widget, const char * text);
-char * ewl_entry_get_text(Ewl_Widget * widget);
-void ewl_entry_set_cursor_pos(Ewl_Widget * widget, int pos);
-int ewl_entry_get_cursor_pos(Ewl_Widget * widget);
+Ewl_Widget *ewl_entry_new();
+void ewl_entry_set_text(Ewl_Widget * widget, const char *text);
+char *ewl_entry_get_text(Ewl_Widget * widget);
+void ewl_entry_set_cursor_pos(Ewl_Widget * widget, int pos);
+int ewl_entry_get_cursor_pos(Ewl_Widget * widget);
-#endif
+#endif /* __EWL_ENTRY_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_enums.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_enums.h 2001/05/02 23:12:42 1.3
+++ ewl_enums.h 2001/07/20 07:31:54 1.4
@@ -1,72 +1,95 @@
-#ifndef __EWL_ENUMS_H
-#define __EWL_ENUMS_H
+/*\
+|*|
+|*| Keeps track of most of enums in EWL
+|*|
+\*/
-enum _ewl_callback_type {
- EWL_CALLBACK_DELETE_WINDOW,
- EWL_CALLBACK_REALIZE,
- EWL_CALLBACK_SHOW,
- EWL_CALLBACK_HIDE,
- EWL_CALLBACK_DESTROY,
- EWL_CALLBACK_CONFIGURE,
- EWL_CALLBACK_KEY_DOWN,
- EWL_CALLBACK_KEY_UP,
- EWL_CALLBACK_MOUSE_DOWN,
- EWL_CALLBACK_MOUSE_UP,
- EWL_CALLBACK_MOUSE_MOVE,
- EWL_CALLBACK_FOCUS_IN,
- EWL_CALLBACK_FOCUS_OUT,
- EWL_CALLBACK_SELECT,
- EWL_CALLBACK_UNSELECT,
- EWL_CALLBACK_CLICKED,
- EWL_CALLBACK_RELEASED,
- EWL_CALLBACK_HILITED,
- EWL_CALLBACK_VALUE_CHANGED,
- EWL_CALLBACK_MAX
-};
+#ifndef __EWL_ENUMS_H__
+#define __EWL_ENUMS_H__
+
+/*
+ * This defines the various types of callbacks that can be hooked up for each
+ * widget.
+ */
typedef enum _ewl_callback_type Ewl_Callback_Type;
-enum _ewl_orientation {
- EWL_ORIENTATION_HORISONTAL,
- EWL_ORIENTATION_VERTICAL
+enum _ewl_callback_type
+{
+ EWL_CALLBACK_REALIZE,
+ EWL_CALLBACK_SHOW,
+ EWL_CALLBACK_HIDE,
+ EWL_CALLBACK_DESTROY,
+ EWL_CALLBACK_DESTROY_RECURSIVE,
+ EWL_CALLBACK_DELETE_WINDOW,
+ EWL_CALLBACK_CONFIGURE,
+ EWL_CALLBACK_REPARENT,
+ EWL_CALLBACK_KEY_DOWN,
+ EWL_CALLBACK_KEY_UP,
+ EWL_CALLBACK_MOUSE_DOWN,
+ EWL_CALLBACK_MOUSE_UP,
+ EWL_CALLBACK_MOUSE_MOVE,
+ EWL_CALLBACK_FOCUS_IN,
+ EWL_CALLBACK_FOCUS_OUT,
+ EWL_CALLBACK_SELECT,
+ EWL_CALLBACK_UNSELECT,
+ EWL_CALLBACK_CLICKED,
+ EWL_CALLBACK_HILITED,
+ EWL_CALLBACK_VALUE_CHANGED,
+ EWL_CALLBACK_THEME_UPDATE,
+ EWL_CALLBACK_MAX
};
+/*
+ * The orientation enum is used in a few widgets to specify whether the widget
+ * should be laid out in a horizontal or vertical fashion.
+ */
typedef enum _ewl_orientation Ewl_Orientation;
-enum _ewl_position {
- EWL_POSITION_LEFT,
- EWL_POSITION_RIGHT,
- EWL_POSITION_TOP,
- EWL_POSITION_BOTTOM,
- EWL_POSITION_TOP_LEFT,
- EWL_POSITION_TOP_RIGHT,
- EWL_POSITION_BOTTOM_LEFT,
- EWL_POSITION_BOTTOM_RIGHT,
- EWL_POSITION_LEFT_TOP,
- EWL_POSITION_LEFT_BOTTOM,
- EWL_POSITION_RIGHT_TOP,
- EWL_POSITION_RIGHT_BOTTOM
+enum _ewl_orientation
+{
+ EWL_ORIENTATION_HORIZONTAL,
+ EWL_ORIENTATION_VERTICAL
};
-typedef enum _ewl_position Ewl_Position;
+/*
+ * The state enum specifies the current state of a widget, ie. has it been
+ * clicked, does it have the keyboard focus, etc.
+ */
+typedef enum _ewl_state Ewl_State;
-enum _ewl_state {
- EWL_STATE_NORMAL,
- EWL_STATE_HILITED,
- EWL_STATE_PRESSED,
- EWL_STATE_SELECTED,
- EWL_STATE_DND
+enum _ewl_state
+{
+ EWL_STATE_HILITED = 1,
+ EWL_STATE_PRESSED = 2,
+ EWL_STATE_SELECTED = 4,
+ EWL_STATE_DND = 8
};
-typedef enum _ewl_state Ewl_State;
+
+/*
+ * The alignment enumeration allows for specifying how an element is aligned
+ * within it's container.
+ */
+typedef enum _ewl_alignment Ewl_Alignment;
-enum _ewl_alignment {
- EWL_ALIGNMENT_LEFT,
- EWL_ALIGNMENT_CENTER,
- EWL_ALIGNMENT_RIGHT
+enum _ewl_alignment
+{
+ EWL_ALIGNMENT_LEFT = 0x1,
+ EWL_ALIGNMENT_CENTER = 0x2,
+ EWL_ALIGNMENT_RIGHT = 0x3,
+ EWL_ALIGNMENT_TOP = 0x10,
+ EWL_ALIGNMENT_VCENTER = 0x20,
+ EWL_ALIGNMENT_BOTTOM = 0x30,
};
-typedef enum _ewl_alignment Ewl_Alignment;
+typedef enum _ewl_fill_policy Ewl_Fill_Policy;
+
+enum _ewl_fill_policy
+{
+ EWL_FILL_POLICY_NORMAL,
+ EWL_FILL_POLICY_FILL
+};
-#endif
+#endif /* __EWL_ENUMS_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_events.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_events.c 2001/05/02 23:12:42 1.5
+++ ewl_events.c 2001/07/20 07:31:54 1.6
@@ -1,205 +1,267 @@
#include <Ewl.h>
-static Ewl_Widget * last_selected;
-static Ewl_Widget * last_key;
-static Ewl_Widget * last_focused;
-static Ewl_Widget * dnd_widget;
-
-static void ewl_ev_window_expose(Eevent * _ev);
-static void ewl_ev_window_configure(Eevent * _ev);
-static void ewl_ev_window_delete(Eevent * _ev);
-static void ewl_ev_key_down(Eevent * _ev);
-static void ewl_ev_key_up(Eevent * _ev);
-static void ewl_ev_mouse_down(Eevent * _ev);
-static void ewl_ev_mouse_up(Eevent * _ev);
-static void ewl_ev_mouse_move(Eevent * _ev);
+Ewl_Widget *last_selected;
+Ewl_Widget *last_key;
+Ewl_Widget *last_focused;
+Ewl_Widget *dnd_widget;
+
+unsigned int mouse_down;
+
+static void ewl_ev_window_expose(Eevent * _ev);
+static void ewl_ev_window_configure(Eevent * _ev);
+static void ewl_ev_window_delete(Eevent * _ev);
+static void ewl_ev_window_reparent(Eevent * _ev);
+static void ewl_ev_key_down(Eevent * _ev);
+static void ewl_ev_key_up(Eevent * _ev);
+static void ewl_ev_mouse_down(Eevent * _ev);
+static void ewl_ev_mouse_up(Eevent * _ev);
+static void ewl_ev_mouse_move(Eevent * _ev);
void
ewl_ev_init(void)
{
- e_event_filter_handler_add(EV_WINDOW_EXPOSE, ewl_ev_window_expose);
- e_event_filter_handler_add(EV_WINDOW_CONFIGURE, ewl_ev_window_configure);
- e_event_filter_handler_add(EV_WINDOW_DELETE, ewl_ev_window_delete);
- e_event_filter_handler_add(EV_KEY_DOWN, ewl_ev_key_down);
- e_event_filter_handler_add(EV_KEY_UP, ewl_ev_key_up);
- e_event_filter_handler_add(EV_MOUSE_DOWN, ewl_ev_mouse_down);
- e_event_filter_handler_add(EV_MOUSE_UP, ewl_ev_mouse_up);
- e_event_filter_handler_add(EV_MOUSE_MOVE, ewl_ev_mouse_move);
+ last_selected = NULL;
+ last_key = NULL;
+ last_focused = NULL;
+ dnd_widget = NULL;
+ mouse_down = FALSE;
+
+ e_event_filter_handler_add(EV_WINDOW_EXPOSE, ewl_ev_window_expose);
+ e_event_filter_handler_add(EV_WINDOW_CONFIGURE,
+ ewl_ev_window_configure);
+ e_event_filter_handler_add(EV_WINDOW_DELETE, ewl_ev_window_delete);
+ e_event_filter_handler_add(EV_WINDOW_REPARENT,
+ ewl_ev_window_reparent);
+ e_event_filter_handler_add(EV_KEY_DOWN, ewl_ev_key_down);
+ e_event_filter_handler_add(EV_KEY_UP, ewl_ev_key_up);
+ e_event_filter_handler_add(EV_MOUSE_DOWN, ewl_ev_mouse_down);
+ e_event_filter_handler_add(EV_MOUSE_UP, ewl_ev_mouse_up);
+ e_event_filter_handler_add(EV_MOUSE_MOVE, ewl_ev_mouse_move);
}
static void
ewl_ev_window_expose(Eevent * _ev)
{
- Ev_Window_Expose * ev;
- Ewl_Window * window;
+ Ev_Window_Expose *ev;
+ Ewl_Window *window;
ev = _ev->event;
window = ewl_window_find_window_by_evas_window(ev->win);
if (window)
{
- evas_update_rect(EWL_WIDGET(window)->evas, ev->x, ev->y, ev->w, ev->h);
+ evas_update_rect(EWL_WIDGET(window)->evas, ev->x, ev->y,
+ ev->w, ev->h);
}
}
static void
ewl_ev_window_configure(Eevent * _ev)
{
- Ev_Window_Configure * ev;
- Ewl_Window * window;
+ Ev_Window_Configure *ev;
+ Ewl_Window *window;
ev = _ev->event;
window = ewl_window_find_window(ev->win);
if (window)
{
- EWL_OBJECT(window)->request.x = ev->x;
- EWL_OBJECT(window)->request.y = ev->y;
- EWL_OBJECT(window)->request.w = ev->w;
- EWL_OBJECT(window)->request.h = ev->h;
- ewl_callback_call(EWL_WIDGET(window), EWL_CALLBACK_CONFIGURE);
+ EWL_OBJECT(window)->request.x = ev->x;
+ EWL_OBJECT(window)->request.y = ev->y;
+ EWL_OBJECT(window)->request.w = ev->w;
+ EWL_OBJECT(window)->request.h = ev->h;
+ ewl_callback_call(EWL_WIDGET(window),
+ EWL_CALLBACK_CONFIGURE);
}
}
static void
+ewl_ev_window_reparent(Eevent * _ev)
+{
+ Ev_Window_Reparent *ev = _ev->event;
+ Ewl_Window *window;
+
+ window = ewl_window_find_window(ev->win);
+ if (window)
+ {
+ ewl_callback_call(EWL_WIDGET(window),
+ EWL_CALLBACK_REPARENT);
+ }
+}
+
+/*
+ * Retrieve the appropriate ewl_window using the x window id that is held
+ * in the eevent, and call it's handlers for a window delete event.
+ */
+static void
ewl_ev_window_delete(Eevent * _ev)
{
- Ev_Window_Delete * ev;
- Ewl_Window * window;
+ Ev_Window_Delete *ev;
+ Ewl_Window *window;
ev = _ev->event;
window = ewl_window_find_window(ev->win);
if (window)
{
- ewl_callback_call(EWL_WIDGET(window), EWL_CALLBACK_DELETE_WINDOW);
+ ewl_callback_call(EWL_WIDGET(window),
+ EWL_CALLBACK_DELETE_WINDOW);
}
}
static void
ewl_ev_key_down(Eevent * _ev)
{
- Ewl_Window * window;
- Ev_Key_Down * ev;
+ Ewl_Window *window;
+ Ev_Key_Down *ev;
ev = _ev->event;
window = ewl_window_find_window_by_evas_window(ev->win);
if (window)
{
- if (last_selected)
- ewl_callback_call_with_data(last_selected,EWL_CALLBACK_KEY_DOWN,ev);
- last_key = last_selected;
+ if (last_selected)
+ ewl_callback_call_with_event_data(last_selected,
+ EWL_CALLBACK_KEY_DOWN,
+ ev);
+ last_key = last_selected;
}
}
static void
ewl_ev_key_up(Eevent * _ev)
{
- Ewl_Window * window;
- Ev_Key_Up * ev;
+ Ewl_Window *window;
+ Ev_Key_Up *ev;
ev = _ev->event;
window = ewl_window_find_window_by_evas_window(ev->win);
if (window)
{
- if (last_key)
- ewl_callback_call_with_data(last_key, EWL_CALLBACK_KEY_UP, ev);
+ if (last_key)
+ ewl_callback_call_with_event_data(last_key,
+ EWL_CALLBACK_KEY_UP,
+ ev);
}
}
static void
ewl_ev_mouse_down(Eevent * _ev)
{
- Ewl_Widget * widget;
- Ewl_Window * window;
- Ev_Mouse_Down * ev;
+ Ewl_Widget *widget;
+ Ewl_Window *window;
+ Ev_Mouse_Down *ev;
ev = _ev->event;
window = ewl_window_find_window_by_evas_window(ev->win);
if (window)
{
- widget = ewl_container_get_child_at_recursive(EWL_WIDGET(window),
+ widget = ewl_container_get_child_at_recursive(EWL_CONTAINER
+ (window),
ev->x, ev->y);
- if (widget != last_selected)
- {
- if (last_selected)
- {
- last_selected->state = last_selected->state&!EWL_STATE_SELECTED;
- ewl_callback_call(last_selected, EWL_CALLBACK_UNSELECT);
- }
- if (widget)
- {
- widget->state = widget->state | EWL_STATE_SELECTED;
- ewl_callback_call(widget, EWL_CALLBACK_SELECT);
- }
- }
+ if (widget != last_selected)
+ {
+ if (last_selected)
+ {
+ last_selected->state &=
+ ~EWL_STATE_SELECTED;
+ ewl_callback_call(last_selected,
+ EWL_CALLBACK_UNSELECT);
+ }
+ if (widget)
+ {
+ widget->state |= EWL_STATE_SELECTED;
+ ewl_callback_call(widget,
+ EWL_CALLBACK_SELECT);
+ }
+ }
+
+ if (widget)
+ {
+ widget->state |= EWL_STATE_PRESSED;
+ ewl_callback_call_with_event_data(widget,
+ EWL_CALLBACK_MOUSE_DOWN,
+ ev);
+ }
- if (widget)
- ewl_callback_call_with_data(widget, EWL_CALLBACK_MOUSE_DOWN, ev);
-
- last_selected = widget;
+ last_selected = widget;
+ mouse_down = 1;
}
}
static void
ewl_ev_mouse_up(Eevent * _ev)
{
- Ewl_Window * window;
- Ev_Mouse_Up * ev;
+ Ewl_Window *window;
+ Ev_Mouse_Up *ev;
ev = _ev->event;
window = ewl_window_find_window_by_evas_window(ev->win);
if (window)
if (last_selected)
- ewl_callback_call_with_data(last_selected,
- EWL_CALLBACK_MOUSE_UP, ev);
+ {
+ last_selected->state &= ~EWL_STATE_PRESSED;
+ ewl_callback_call_with_event_data(last_selected,
+ EWL_CALLBACK_MOUSE_UP,
+ ev);
+ }
}
static void
ewl_ev_mouse_move(Eevent * _ev)
{
- Ewl_Widget * widget;
- Ewl_Window * window;
- Ev_Mouse_Move * ev;
+ Ewl_Widget *widget;
+ Ewl_Window *window;
+ Ev_Mouse_Move *ev;
ev = _ev->event;
window = ewl_window_find_window_by_evas_window(ev->win);
if (window)
{
- widget = ewl_container_get_child_at_recursive(EWL_WIDGET(window),
- ev->x, ev->y);
-
- if (widget)
- {
- widget->state = widget->state | EWL_STATE_HILITED;
- ewl_callback_call(widget, EWL_CALLBACK_FOCUS_IN);
- DPRINT(8, "Focus In on %p", widget);
- ewl_callback_call_with_data(widget, EWL_CALLBACK_MOUSE_MOVE,ev);
- }
- if (last_focused != widget && last_focused)
- {
- last_focused->state = widget->state & !EWL_STATE_HILITED;
- ewl_callback_call(last_focused, EWL_CALLBACK_FOCUS_OUT);
- DPRINT(8, "Focus Out off %p", last_focused);
- }
-
- if (last_focused && last_focused->state & EWL_STATE_DND)
- dnd_widget = last_focused;
+ widget = ewl_container_get_child_at_recursive(EWL_CONTAINER
+ (window),
+ ev->x, ev->y);
- if (dnd_widget && dnd_widget->state & EWL_STATE_DND)
- ewl_callback_call_with_data(dnd_widget,
- EWL_CALLBACK_MOUSE_MOVE, ev);
- else
- dnd_widget = NULL;
+ if (widget)
+ {
+ widget->state |= EWL_STATE_HILITED;
+ if (last_focused != widget)
+ ewl_callback_call(widget,
+ EWL_CALLBACK_FOCUS_IN);
+
+ ewl_callback_call_with_event_data(widget,
+ EWL_CALLBACK_MOUSE_MOVE,
+ ev);
+ }
+ if (last_focused != widget && last_focused)
+ {
+ last_focused->state &= ~EWL_STATE_HILITED;
+ ewl_callback_call(last_focused,
+ EWL_CALLBACK_FOCUS_OUT);
+ }
+
+ if (last_focused && last_focused->state & EWL_STATE_DND)
+ dnd_widget = last_focused;
+
+ if (dnd_widget && dnd_widget->state & EWL_STATE_DND)
+ ewl_callback_call_with_event_data(dnd_widget,
+ EWL_CALLBACK_MOUSE_MOVE,
+ ev);
+
+ if (last_selected &&
+ last_selected->state & EWL_STATE_PRESSED)
+ ewl_callback_call_with_event_data(last_selected,
+ EWL_CALLBACK_MOUSE_MOVE,
+ ev);
+ else
+ dnd_widget = NULL;
- last_focused = widget;
+ last_focused = widget;
}
}
-
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_events.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_events.h 2001/05/01 04:00:38 1.2
+++ ewl_events.h 2001/07/20 07:31:54 1.3
@@ -1,7 +1,13 @@
-#ifndef __EWL_EVENTS_H
-#define __EWL_EVENTS_H
+/*\
+|*|
+|*| Main events code, handles X events and translate them to EWL callbacks
+|*|
+\*/
+#ifndef __EWL_EVENTS_H__
+#define __EWL_EVENTS_H__
+
void ewl_ev_init(void);
-#endif
+#endif /* __EWL_EVENTS_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_fx.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_fx.c 2001/05/02 23:12:42 1.2
+++ ewl_fx.c 2001/07/20 07:31:54 1.3
@@ -1,9 +1,9 @@
#include <Ewl.h>
-static void ewl_fx_handle_fade_in(int val, void * data);
-static void ewl_fx_handle_fade_out(int val, void * data);
-static void ewl_fx_handle_glow(int val, void * data);
+static void ewl_fx_handle_fade_in(int val, void *data);
+static void ewl_fx_handle_fade_out(int val, void *data);
+static void ewl_fx_handle_glow(int val, void *data);
static double fx_max_fps;
static double fx_timeout;
@@ -11,13 +11,19 @@
void
ewl_fx_init()
{
+ DENTER_FUNCTION;
+
fx_max_fps = ewl_prefs_get_fx_max_fps();
fx_timeout = ewl_prefs_get_fx_timeout();
+
+ DLEAVE_FUNCTION;
}
void
ewl_fx_clip_box_create(Ewl_Widget * widget)
{
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
if (widget->fx_clip_box)
@@ -25,15 +31,16 @@
widget->fx_clip_box = evas_add_rectangle(widget->evas);
evas_move(widget->evas, widget->fx_clip_box,
- EWL_OBJECT(widget)->current.x,
- EWL_OBJECT(widget)->current.y);
+ EWL_OBJECT(widget)->current.x,
+ EWL_OBJECT(widget)->current.y);
evas_resize(widget->evas, widget->fx_clip_box,
- EWL_OBJECT(widget)->current.w,
- EWL_OBJECT(widget)->current.h);
- evas_set_color(widget->evas, widget->fx_clip_box,
- 255, 255, 255, 5);
+ EWL_OBJECT(widget)->current.w,
+ EWL_OBJECT(widget)->current.h);
+ evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
evas_set_layer(widget->evas, widget->fx_clip_box,
- EWL_OBJECT(widget)->layer - 1);
+ EWL_OBJECT(widget)->layer - 1);
+
+ DLEAVE_FUNCTION;
}
void
@@ -45,20 +52,23 @@
return;
evas_move(widget->evas, widget->fx_clip_box,
- EWL_OBJECT(widget)->request.x,
- EWL_OBJECT(widget)->request.y);
+ EWL_OBJECT(widget)->request.x,
+ EWL_OBJECT(widget)->request.y);
evas_resize(widget->evas, widget->fx_clip_box,
- EWL_OBJECT(widget)->request.w,
- EWL_OBJECT(widget)->request.h);
+ EWL_OBJECT(widget)->request.w,
+ EWL_OBJECT(widget)->request.h);
}
void
-ewl_fx_add(Ewl_Widget * widget, Ewl_FX_Type type,
- void (*func) (Ewl_Widget * widget, void * func_data),
- void * func_data)
+ewl_fx_add(Ewl_Widget * widget,
+ Ewl_FX_Type type,
+ void (*func) (Ewl_Widget * widget,
+ void *func_data), void *func_data)
{
- Ewl_FX_Timer * timer = NULL;
+ Ewl_FX_Timer *timer = NULL;
+ DENTER_FUNCTION;
+
CHECK_PARAM_POINTER("widget", widget);
timer = NEW(Ewl_FX_Timer, 1);
@@ -76,182 +86,167 @@
switch (timer->type)
{
- case EWL_FX_TYPE_FADE_IN:
- timer->start_val = (int) fx_timeout % (int) fx_max_fps;
- timer->increase = timer->start_val;
- break;
- case EWL_FX_TYPE_FADE_OUT:
- timer->start_val = 255;
- timer->increase = (int) fx_timeout % (int) fx_max_fps;
- break;
- case EWL_FX_TYPE_GLOW:
- timer->start_val = 5;
- break;
- default:
- break;
+ case EWL_FX_TYPE_FADE_IN:
+ timer->start_val = (int) fx_timeout % (int) fx_max_fps;
+ timer->increase = timer->start_val;
+ break;
+ case EWL_FX_TYPE_FADE_OUT:
+ timer->start_val = 255;
+ timer->increase = (int) fx_timeout % (int) fx_max_fps;
+ break;
+ case EWL_FX_TYPE_GLOW:
+ timer->start_val = 5;
+ break;
+ default:
+ break;
}
if (timer->type == EWL_FX_TYPE_FADE_IN)
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_fade_in,
- timer->start_val,
- timer);
+ e_add_event_timer(timer->name,
+ timer->timeout,
+ ewl_fx_handle_fade_in, timer->start_val,
+ timer);
else if (timer->type == EWL_FX_TYPE_FADE_OUT)
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_fade_out,
- timer->start_val,
- timer);
- else if (timer->type == EWL_FX_TYPE_GLOW)
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_glow,
- timer->start_val,
- timer);
+ e_add_event_timer(timer->name,
+ timer->timeout,
+ ewl_fx_handle_fade_out, timer->start_val,
+ timer);
+ else if (timer->type == EWL_FX_TYPE_GLOW)
+ e_add_event_timer(timer->name,
+ timer->timeout,
+ ewl_fx_handle_glow, timer->start_val,
+ timer);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_fx_handle_fade_in(int val, void * data)
+ewl_fx_handle_fade_in(int val, void *data)
{
- Ewl_FX_Timer * timer = NULL;
- Ewl_Widget * widget = NULL;
+ Ewl_FX_Timer *timer = NULL;
+ Ewl_Widget *widget = NULL;
CHECK_PARAM_POINTER("data", data);
timer = data;
widget = timer->widget;
- evas_set_color(widget->evas,
- widget->fx_clip_box,
- 255, 255, 255, val);
+ evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, val);
e_del_event_timer(timer->name);
if (val < 255)
{
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_fade_in,
- val + timer->increase,
- timer);
+ e_add_event_timer(timer->name,
+ timer->timeout,
+ ewl_fx_handle_fade_in,
+ val + timer->increase, timer);
}
else
{
- timer->completed = timer->completed++;
- if (timer->completed < timer->repeat)
- {
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_fade_in,
- timer->start_val,
- timer);
- }
- else
- {
- if (timer->func)
- timer->func(timer->widget, timer->func_data);
- }
+ timer->completed = timer->completed++;
+ if (timer->completed < timer->repeat)
+ {
+ e_add_event_timer(timer->name,
+ timer->timeout,
+ ewl_fx_handle_fade_in,
+ timer->start_val, timer);
+ }
+ else
+ {
+ if (timer->func)
+ timer->func(timer->widget,
+ timer->func_data);
+ }
}
}
static void
-ewl_fx_handle_fade_out(int val, void * data)
+ewl_fx_handle_fade_out(int val, void *data)
{
- Ewl_FX_Timer * timer = NULL;
- Ewl_Widget * widget = NULL;
+ Ewl_FX_Timer *timer = NULL;
+ Ewl_Widget *widget = NULL;
CHECK_PARAM_POINTER("data", data);
timer = data;
widget = timer->widget;
- evas_set_color(widget->evas,
- widget->fx_clip_box,
- 255, 255, 255, val);
+ evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, val);
e_del_event_timer(timer->name);
if (val > 0)
{
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_fade_out,
- val - timer->increase,
- timer);
+ e_add_event_timer(timer->name,
+ timer->timeout,
+ ewl_fx_handle_fade_out,
+ val - timer->increase, timer);
}
else
{
- timer->completed = timer->completed++;
- if (timer->completed < timer->repeat)
- {
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_fade_out,
- timer->start_val,
- timer);
- }
- else
- {
- if (timer->func)
- timer->func(timer->widget, timer->func_data);
- }
+ timer->completed = timer->completed++;
+ if (timer->completed < timer->repeat)
+ {
+ e_add_event_timer(timer->name,
+ timer->timeout,
+ ewl_fx_handle_fade_out,
+ timer->start_val, timer);
+ }
+ else
+ {
+ if (timer->func)
+ timer->func(timer->widget,
+ timer->func_data);
+ }
}
}
static void
-ewl_fx_handle_glow(int val, void * data)
+ewl_fx_handle_glow(int val, void *data)
{
- Ewl_FX_Timer * timer = NULL;
- Ewl_Widget * widget = NULL;
+ Ewl_FX_Timer *timer = NULL;
+ Ewl_Widget *widget = NULL;
CHECK_PARAM_POINTER("data", data);
timer = data;
widget = timer->widget;
- evas_set_color(widget->evas,
- widget->fx_clip_box,
- 255, 255, 255, val);
+ evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, val);
e_del_event_timer(timer->name);
if (timer->start_val == 5 && val < 255)
{
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_glow,
- val + 5,
- timer);
+ e_add_event_timer(timer->name,
+ timer->timeout, ewl_fx_handle_glow,
+ val + 5, timer);
}
else if (timer->start_val == 255 && val > 5)
{
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_glow,
- val - 5,
- timer);
+ e_add_event_timer(timer->name,
+ timer->timeout, ewl_fx_handle_glow,
+ val - 5, timer);
}
if (timer->start_val == 255 && val == 5)
{
- timer->start_val = 5;
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_glow,
- timer->start_val,
- timer);
+ timer->start_val = 5;
+ e_add_event_timer(timer->name,
+ timer->timeout,
+ ewl_fx_handle_glow, timer->start_val,
+ timer);
}
if (timer->start_val == 5 && val == 255)
{
- timer->start_val = 255;
- e_add_event_timer(timer->name,
- timer->timeout,
- ewl_fx_handle_glow,
- timer->start_val,
- timer);
+ timer->start_val = 255;
+ e_add_event_timer(timer->name,
+ timer->timeout,
+ ewl_fx_handle_glow, timer->start_val,
+ timer);
}
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_fx.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ewl_fx.h 2001/05/01 04:00:38 1.1
+++ ewl_fx.h 2001/07/20 07:31:54 1.2
@@ -1,9 +1,15 @@
-#ifndef __EWL_FX_H
-#define __EWL_FX_H
+/*\
+|*|
+|*| Play FX code... just temporary
+|*|
+\*/
+#ifndef __EWL_FX_H__
+#define __EWL_FX_H__
-enum _ewl_fx_type {
+enum _ewl_fx_type
+{
EWL_FX_TYPE_FADE_IN,
EWL_FX_TYPE_FADE_OUT,
EWL_FX_TYPE_GLOW,
@@ -12,17 +18,18 @@
typedef enum _ewl_fx_type Ewl_FX_Type;
-struct _ewl_fx_timer {
- Ewl_Widget * widget; /* What widget is it we want to do an effect on ? */
- Ewl_FX_Type type; /* What type ? */
- int repeat; /* How many times should we repeat ? */
- int completed; /* Keep track on how many times we have doon the fx */
- double timeout; /* The initial timeout */
+struct _ewl_fx_timer
+{
+ Ewl_Widget *widget; /* What widget is it we want to do an effect on ? */
+ Ewl_FX_Type type; /* What type ? */
+ int repeat; /* How many times should we repeat ? */
+ int completed; /* Keep track on how many times we have doon the fx */
+ double timeout; /* The initial timeout */
int start_val;
int increase;
- char * name;
- void (*func) (Ewl_Widget * widget, void * func_data);
- void * func_data;
+ char *name;
+ void (*func) (Ewl_Widget * widget, void *func_data);
+ void *func_data;
};
typedef struct _ewl_fx_timer Ewl_FX_Timer;
@@ -30,10 +37,11 @@
#define EWL_FX_TIMER(timer) ((Ewl_FX_Timer *) timer)
void ewl_fx_init();
-void ewl_fx_add(Ewl_Widget * widget, Ewl_FX_Type type,
- void (*func) (Ewl_Widget * widget, void * func_data),
- void * func_data);
+void ewl_fx_add(Ewl_Widget * widget,
+ Ewl_FX_Type type,
+ void (*func) (Ewl_Widget * widget,
+ void *func_data), void *func_data);
void ewl_fx_clip_box_create(Ewl_Widget * widget);
void ewl_fx_clip_box_resize(Ewl_Widget * widget);
-#endif
+#endif /* __EWL_FX_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_list.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_list.c 2001/05/02 23:12:42 1.2
+++ ewl_list.c 2001/07/20 07:31:54 1.3
@@ -2,32 +2,43 @@
#include <Ewl.h>
-struct _ewl_list_selection {
- Ebits_Object * ebits_object;
- int row;
+struct _ewl_list_selection
+{
+ Ebits_Object *ebits_object;
+ int row;
};
typedef struct _ewl_list_selection Ewl_List_Selection;
static void __ewl_list_init(Ewl_List * list);
-static void __ewl_list_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_list_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_list_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_list_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_list_configure(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_list_key_down(Ewl_Widget * widget, Ewl_Callback * cb);
+static void __ewl_list_realize(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_list_show(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_list_hide(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_list_destroy(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_list_configure(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_list_key_down(Ewl_Widget * widget, void *event_data,
+ void *user_data);
static void __ewl_list_select_row(Ewl_Widget * l, int row);
static void __ewl_list_unselect_row(Ewl_Widget * l, int row);
-static void __ewl_list_move_up_selection(Ewl_Widget * l);
-static void __ewl_list_move_down_selection(Ewl_Widget * l);
+static void __ewl_list_move_up_selection(Ewl_Widget * l, int multiple);
+static void __ewl_list_move_down_selection(Ewl_Widget * l, int multiple);
+static int __ewl_list_check_selected(Ewl_Widget * l, int row);
+static void __ewl_list_unselect_all(Ewl_Widget * l);
+static void __ewl_list_selection_hilit(Ewl_Widget * l, int row);
+static void __ewl_list_selection_unhilit(Ewl_Widget * l, int row);
Ewl_Widget *
ewl_list_new(int columns)
{
- Ewl_List * list;
- Ewl_Widget * table;
+ Ewl_List *list;
+ Ewl_Widget *table;
list = NEW(Ewl_List, 1);
@@ -36,18 +47,20 @@
list->selections = ewd_list_new();
table = ewl_table_new_all(FALSE, columns, 1, 0, 3);
- ewl_container_append_child(EWL_WIDGET(list), table);
+ ewl_container_append_child(EWL_CONTAINER(list), table);
ewl_callback_append(table, EWL_CALLBACK_KEY_DOWN,
- __ewl_list_key_down, table);
+ __ewl_list_key_down, table);
ewl_table_set_alignment(table, EWL_ALIGNMENT_LEFT);
+ list->table = table;
+
return EWL_WIDGET(list);
}
Ewl_Widget *
-ewl_list_new_all(int columns, char * titles[])
+ewl_list_new_all(int columns, char *titles[])
{
- Ewl_Widget * widget;
+ Ewl_Widget *widget;
widget = ewl_list_new(columns);
@@ -57,40 +70,43 @@
}
void
-ewl_list_append_text(Ewl_Widget * l, char * text[])
+ewl_list_append_text(Ewl_Widget * l, char *text[])
{
- Ewl_Widget * table;
+ Ewl_Widget *table;
int i;
CHECK_PARAM_POINTER("l", l);
- table = l->container.children->first->data;
+ table = EWL_CONTAINER(l)->children->first->data;
- ewl_table_resize(table, EWL_TABLE(table)->rows +1,
- EWL_TABLE(table)->columns);
+ ewl_table_resize(table, EWL_TABLE(table)->rows + 1,
+ EWL_TABLE(table)->columns);
{
- Ewl_Widget * text_widgets[EWL_TABLE(table)->columns];
+ Ewl_Widget *text_widgets[EWL_TABLE(table)->columns];
- for (i=0;i<EWL_TABLE(table)->columns;i++)
+ for (i = 0; i < EWL_TABLE(table)->columns; i++)
{
- text_widgets[i] = ewl_text_new();
- ewl_text_set_text(text_widgets[i], text[i]);
- ewl_text_set_font_size(text_widgets[i], 8);
- ewl_table_attach(table, text_widgets[i], i+1, i+1,
- EWL_TABLE(table)->rows, EWL_TABLE(table)->rows);
- ewl_widget_show(text_widgets[i]);
+ text_widgets[i] = ewl_text_new();
+ ewl_text_set_text(text_widgets[i], text[i]);
+ ewl_text_set_font_size(text_widgets[i], 8);
+ ewl_table_attach(table, text_widgets[i],
+ EWL_ALIGNMENT_LEFT,
+ EWL_FILL_POLICY_NORMAL, i + 1,
+ i + 1, EWL_TABLE(table)->rows,
+ EWL_TABLE(table)->rows);
+ ewl_widget_show(text_widgets[i]);
}
}
}
void
-ewl_list_prepend_text(Ewl_Widget * l, char * text[])
+ewl_list_prepend_text(Ewl_Widget * l, char *text[])
{
}
void
-ewl_list_insert_text(Ewl_Widget * widget, char * text[], int row)
+ewl_list_insert_text(Ewl_Widget * widget, char *text[], int row)
{
}
@@ -114,26 +130,30 @@
}
void
-ewl_list_set_titles(Ewl_Widget * widget, char * titles[])
+ewl_list_set_titles(Ewl_Widget * widget, char *titles[])
{
- Ewl_Widget * table;
+ Ewl_Widget *table;
CHECK_PARAM_POINTER("widget", widget);
- table = widget->container.children->first->data;
+ table = EWL_CONTAINER(widget)->children->first->data;
{
- Ewl_Widget * button[EWL_TABLE(table)->columns];
+ Ewl_Widget *button[EWL_TABLE(table)->columns];
int i;
- for (i=0;i<EWL_TABLE(table)->columns;i++)
+ for (i = 0; i < EWL_TABLE(table)->columns; i++)
{
- button[i] = ewl_button_new_with_label(titles[i]);
- ewl_callback_append(button[i], EWL_CALLBACK_KEY_DOWN,
- __ewl_list_key_down, widget);
- ewl_table_attach(table, button[i], i+1, i+1, 1, 1);
- EWL_OBJECT(button[i])->custom.w = 50;
- ewl_widget_show(button[i]);
+ button[i] = ewl_button_new(titles[i]);
+ ewl_callback_append(button[i],
+ EWL_CALLBACK_KEY_DOWN,
+ __ewl_list_key_down, widget);
+ ewl_table_attach(table, button[i],
+ EWL_ALIGNMENT_LEFT,
+ EWL_FILL_POLICY_FILL, i + 1,
+ i + 1, 1, 1);
+ EWL_OBJECT(button[i])->custom.w = 50;
+ ewl_widget_show(button[i]);
}
}
}
@@ -149,59 +169,57 @@
{
CHECK_PARAM_POINTER("list", list);
+ /*
+ * Initialize the list widget
+ */
memset(list, 0, sizeof(Ewl_List));
+ ewl_container_init(EWL_CONTAINER(list), EWL_WIDGET_LIST, 200, 200,
+ 2048, 2048);
- ewl_callback_append(EWL_WIDGET(list),
- EWL_CALLBACK_REALIZE, __ewl_list_realize, NULL);
- ewl_callback_append(EWL_WIDGET(list),
- EWL_CALLBACK_SHOW, __ewl_list_show, NULL);
- ewl_callback_append(EWL_WIDGET(list),
- EWL_CALLBACK_HIDE, __ewl_list_hide, NULL);
- ewl_callback_append(EWL_WIDGET(list),
- EWL_CALLBACK_DESTROY, __ewl_list_destroy, NULL);
ewl_callback_append(EWL_WIDGET(list),
- EWL_CALLBACK_CONFIGURE, __ewl_list_configure, NULL);
+ EWL_CALLBACK_REALIZE, __ewl_list_realize, NULL);
+ ewl_callback_append(EWL_WIDGET(list), EWL_CALLBACK_SHOW,
+ __ewl_list_show, NULL);
+ ewl_callback_append(EWL_WIDGET(list), EWL_CALLBACK_HIDE,
+ __ewl_list_hide, NULL);
+ ewl_callback_append(EWL_WIDGET(list), EWL_CALLBACK_DESTROY,
+ __ewl_list_destroy, NULL);
+ ewl_callback_append(EWL_WIDGET(list), EWL_CALLBACK_CONFIGURE,
+ __ewl_list_configure, NULL);
- EWL_WIDGET(list)->container.recursive = TRUE;
-
- EWL_OBJECT(list)->current.w = 200;
- EWL_OBJECT(list)->current.h = 200;
- EWL_OBJECT(list)->maximum.w = 2048;
- EWL_OBJECT(list)->maximum.h = 2048;
- EWL_OBJECT(list)->minimum.w = 200;
- EWL_OBJECT(list)->minimum.h = 100;
- EWL_OBJECT(list)->request.w = 200;
- EWL_OBJECT(list)->request.h = 200;
}
static void
-__ewl_list_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_list_realize(Ewl_Widget * widget, void *event_data, void *user_data)
{
CHECK_PARAM_POINTER("widget", widget);
- ewl_fx_clip_box_create(widget);
+ ewl_fx_clip_box_create(widget);
- evas_set_clip(widget->evas, widget->fx_clip_box,
- widget->parent->container.clip_box);
+ evas_set_clip(widget->evas, widget->fx_clip_box,
+ EWL_CONTAINER(widget->parent)->clip_box);
- widget->container.clip_box = widget->fx_clip_box;
+ EWL_CONTAINER(widget)->clip_box = widget->fx_clip_box;
- evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
+ evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
- ewl_widget_realize(widget->container.children->first->data);
+ ewl_widget_realize(EWL_CONTAINER(widget)->children->first->data);
}
static void
-__ewl_list_show(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_list_show(Ewl_Widget * widget, void *event_data, void *user_data)
{
CHECK_PARAM_POINTER("widget", widget);
- ewl_widget_show(widget->container.children->first->data);
+ ewl_widget_show(EWL_CONTAINER(widget)->children->first->data);
evas_show(widget->evas, widget->fx_clip_box);
+
+ if (EWL_LIST(widget)->titles)
+ ewl_list_set_titles(widget, EWL_LIST(widget)->titles);
}
static void
-__ewl_list_hide(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_list_hide(Ewl_Widget * widget, void *event_data, void *user_data)
{
CHECK_PARAM_POINTER("widget", widget);
@@ -209,26 +227,30 @@
}
static void
-__ewl_list_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_list_destroy(Ewl_Widget * widget, void *event_data, void *user_data)
{
CHECK_PARAM_POINTER("widget", widget);
- ewl_widget_destroy(widget->container.children->first->data);
+ ewl_widget_destroy(EWL_LIST(widget)->table);
- ewd_list_destroy(widget->container.children);
+ ewd_list_destroy(EWL_CONTAINER(widget)->children);
evas_hide(widget->evas, widget->fx_clip_box);
evas_unset_clip(widget->evas, widget->fx_clip_box);
evas_del_object(widget->evas, widget->fx_clip_box);
+ ewl_theme_deinit_widget(widget);
+
+ ewl_callback_del_all(widget);
+
FREE(widget);
}
static void
-__ewl_list_configure(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_list_configure(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ewl_Widget * table;
- Ewl_Widget * title;
+ Ewl_Widget *table;
+ Ewl_Widget *title;
int i, w;
CHECK_PARAM_POINTER("widget", widget);
@@ -238,7 +260,8 @@
EWL_OBJECT(widget)->current.w = EWL_OBJECT(widget)->request.w;
EWL_OBJECT(widget)->current.h = EWL_OBJECT(widget)->request.h;
- table = widget->container.children->first->data;
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
+ table = ewd_list_current(EWL_CONTAINER(widget)->children);
EWL_OBJECT(table)->request.x = EWL_OBJECT(widget)->current.x;
EWL_OBJECT(table)->request.y = EWL_OBJECT(widget)->current.y;
@@ -247,55 +270,55 @@
ewl_widget_configure(table);
- for (i=0;i<EWL_TABLE(table)->columns+1;i++)
+ for (i = 0; i < EWL_TABLE(table)->columns + 1; i++)
{
- title = ewl_table_get_child(table, 1, i+1);
- if (title)
- {
- ewl_table_get_col_width(table, i+1, &w);
- EWL_OBJECT(title)->custom.w = w;
- ewl_widget_configure(title);
- }
+ title = ewl_table_get_child(table, 1, i + 1);
+ if (title)
+ {
+ ewl_table_get_column_width(table, i + 1, &w);
+ EWL_OBJECT(title)->custom.w = w;
+ ewl_widget_configure(title);
+ }
}
ewl_fx_clip_box_resize(widget);
}
static void
-__ewl_list_key_down(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_list_key_down(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ev_Key_Down * ev;
- Ewl_Widget * list;
+ Ev_Key_Down *ev;
+ int multiple = 0;
CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("cb", cb);
+
+ ev = (Ev_Key_Down *) event_data;
- ev = cb->func_data;
- list = cb->user_data;
+ if (ev->mods & EV_KEY_MODIFIER_SHIFT)
+ multiple = TRUE;
if (!strcmp(ev->key, "Up"))
{
- __ewl_list_unselect_row(list, EWL_LIST(list)->current_selected);
- __ewl_list_select_row(list, --EWL_LIST(list)->current_selected);
+ __ewl_list_move_up_selection(widget, multiple);
}
else if (!strcmp(ev->key, "Down"))
{
- __ewl_list_unselect_row(list, EWL_LIST(list)->current_selected);
- __ewl_list_select_row(list, ++EWL_LIST(list)->current_selected);
+ __ewl_list_move_down_selection(widget, multiple);
}
}
static void
__ewl_list_select_row(Ewl_Widget * l, int row)
{
- Ewl_List_Selection * sel;
- Ewl_Table * t;
- char * image;
+ Ewl_List_Selection *sel;
+ Ewl_Table *t;
+ char *image;
int x, y, w, h;
CHECK_PARAM_POINTER("l", l);
- t = l->container.children->first->data;
+ ewd_list_goto_first(EWL_CONTAINER(l)->children);
+ t = ewd_list_current(EWL_CONTAINER(l)->children);
if (row > t->rows)
return;
@@ -303,15 +326,17 @@
sel = NEW(Ewl_List_Selection, 1);
sel->row = row;
- image = ewl_theme_ebit_get("list", "default", "selection");
+ image = ewl_theme_image_get(l, "/appearance/list/default/selection");
sel->ebits_object = ebits_load(image);
- ebits_add_to_evas(sel->ebits_object, l->evas);
- ebits_set_layer(sel->ebits_object, t->widget.object.layer + 5);
+ ebits_add_to_evas(sel->ebits_object, l->evas);
+ ebits_set_layer(sel->ebits_object, EWL_OBJECT(t)->layer + 5);
ebits_set_clip(sel->ebits_object, l->fx_clip_box);
- ewl_table_get_row_geometry(EWL_WIDGET(t), row+1, &x, &y, &w, &h);
+ ewl_table_get_row_geometry(EWL_WIDGET(t), row + 1, &x, &y, &w, &h);
ebits_move(sel->ebits_object, x, y - 1);
ebits_resize(sel->ebits_object, w, h + 1);
+ ebits_set_color_class(sel->ebits_object, "Menu BG", 100, 200, 255,
+ 255);
ebits_show(sel->ebits_object);
ewd_list_append(EWL_LIST(l)->selections, sel);
@@ -320,27 +345,152 @@
static void
__ewl_list_unselect_row(Ewl_Widget * l, int row)
{
- Ewl_List_Selection * sel;
+ Ewl_List_Selection *sel;
CHECK_PARAM_POINTER("l", l);
- if (row > EWL_TABLE(l->container.children->first->data)->rows || row < 1)
+ if (row > EWL_TABLE(EWL_LIST(l)->table)->rows || row < 1)
return;
ewd_list_goto_first(EWL_LIST(l)->selections);
while ((sel = ewd_list_next(EWL_LIST(l)->selections)) != NULL)
{
- printf("Jahaja\n");
- if (sel->row == row)
- {
- ebits_hide(sel->ebits_object);
- ebits_unset_clip(sel->ebits_object);
- ebits_free(sel->ebits_object);
- ewd_list_remove(EWL_LIST(l)->selections);
- DPRINT(0, "Removing row #%i from list %p", row, l);
- FREE(sel);
- break;
- }
+ if (sel->row == row)
+ {
+ ebits_hide(sel->ebits_object);
+ ebits_unset_clip(sel->ebits_object);
+ ebits_free(sel->ebits_object);
+ ewd_list_remove(EWL_LIST(l)->selections);
+ FREE(sel);
+ break;
+ }
+ }
+}
+
+static void
+__ewl_list_move_up_selection(Ewl_Widget * l, int multiple)
+{
+ CHECK_PARAM_POINTER("l", l);
+
+ if (EWL_LIST(l)->current_selected - 1 <= 0)
+ return;
+
+ if (!multiple)
+ __ewl_list_unselect_all(l);
+
+ if (__ewl_list_check_selected(l, EWL_LIST(l)->current_selected - 1))
+ {
+ __ewl_list_selection_unhilit(l,
+ EWL_LIST(l)->current_selected);
+ EWL_LIST(l)->current_selected--;
+ __ewl_list_selection_hilit(l,
+ EWL_LIST(l)->current_selected);
+ return;
+ }
+
+ __ewl_list_selection_unhilit(l, EWL_LIST(l)->current_selected);
+ __ewl_list_select_row(l, --EWL_LIST(l)->current_selected);
+ __ewl_list_selection_hilit(l, EWL_LIST(l)->current_selected);
+}
+
+static void
+__ewl_list_move_down_selection(Ewl_Widget * l, int multiple)
+{
+ CHECK_PARAM_POINTER("l", l);
+
+ if (EWL_LIST(l)->current_selected + 1 >=
+ EWL_TABLE(EWL_LIST(l)->table)->rows)
+ return;
+
+ if (!multiple)
+ __ewl_list_unselect_all(l);
+
+ if (__ewl_list_check_selected(l, EWL_LIST(l)->current_selected + 1))
+ {
+ __ewl_list_selection_unhilit(l,
+ EWL_LIST(l)->current_selected);
+ EWL_LIST(l)->current_selected++;
+ __ewl_list_selection_hilit(l,
+ EWL_LIST(l)->current_selected);
+ return;
+ }
+
+ __ewl_list_selection_unhilit(l, EWL_LIST(l)->current_selected);
+ __ewl_list_select_row(l, ++EWL_LIST(l)->current_selected);
+ __ewl_list_selection_hilit(l, EWL_LIST(l)->current_selected);
+}
+
+static int
+__ewl_list_check_selected(Ewl_Widget * l, int row)
+{
+ Ewl_List_Selection *sel;
+
+ CHECK_PARAM_POINTER_RETURN("l", l, FALSE);
+
+ ewd_list_goto_first(EWL_LIST(l)->selections);
+
+ while ((sel = ewd_list_next(EWL_LIST(l)->selections)) != NULL)
+ {
+ if (sel->row == row)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+__ewl_list_unselect_all(Ewl_Widget * l)
+{
+ Ewl_List_Selection *sel;
+
+ CHECK_PARAM_POINTER("l", l);
+
+ if (!EWL_LIST(l)->selections
+ || ewd_list_is_empty(EWL_LIST(l)->selections))
+ return;
+
+ ewd_list_goto_first(EWL_LIST(l)->selections);
+
+ while ((sel = ewd_list_remove_last(EWL_LIST(l)->selections)) != NULL)
+ {
+ ebits_hide(sel->ebits_object);
+ ebits_unset_clip(sel->ebits_object);
+ ebits_free(sel->ebits_object);
+ FREE(sel);
+ }
+}
+
+static void
+__ewl_list_selection_hilit(Ewl_Widget * l, int row)
+{
+ Ewl_List_Selection *sel;
+
+ CHECK_PARAM_POINTER("l", l);
+
+ ewd_list_goto_first(EWL_LIST(l)->selections);
+
+ while ((sel = ewd_list_next(EWL_LIST(l)->selections)) != NULL)
+ {
+ if (sel->row == row)
+ ebits_set_color_class(sel->ebits_object, "Menu BG",
+ 100, 200, 255, 255);
+ }
+}
+
+static void
+__ewl_list_selection_unhilit(Ewl_Widget * l, int row)
+{
+ Ewl_List_Selection *sel;
+
+ CHECK_PARAM_POINTER("l", l);
+
+ ewd_list_goto_first(EWL_LIST(l)->selections);
+
+ while ((sel = ewd_list_next(EWL_LIST(l)->selections)) != NULL)
+ {
+ if (sel->row == row)
+ ebits_set_color_class(sel->ebits_object, "Menu BG",
+ 255, 255, 255, 255);
}
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_list.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_list.h 2001/05/02 23:12:42 1.2
+++ ewl_list.h 2001/07/20 07:31:54 1.3
@@ -1,31 +1,38 @@
-#ifndef __EWL_LIST_H
-#define __EWL_LIST_H
-
-struct _ewl_list {
- Ewl_Widget widget;
- char **titles;
- Ewd_List * row_data;
- Ewd_List * selections;
- int current_selected;
+/*\
+|*|
+|*| This code is starting to get along..
+|*|
+\*/
+
+#ifndef __EWL_LIST_H__
+#define __EWL_LIST_H__
+
+struct _ewl_list
+{
+ Ewl_Container container;
+ char **titles;
+ Ewl_Widget *table;
+ Ewd_List *row_data;
+ Ewd_List *selections;
+ int current_selected;
};
typedef struct _ewl_list Ewl_List;
#define EWL_LIST(list) ((Ewl_List *) list)
-Ewl_Widget * ewl_list_new(int columns);
-Ewl_Widget * ewl_list_new_all(int columns, char * titles[]);
+Ewl_Widget *ewl_list_new(int columns);
+Ewl_Widget *ewl_list_new_all(int columns, char *titles[]);
-void ewl_list_append_text(Ewl_Widget * widget, char * text[]);
-void ewl_list_prepend_text(Ewl_Widget * widget, char * text[]);
-void ewl_list_insert_text(Ewl_Widget * widget, char * text[], int pos);
+void ewl_list_append_text(Ewl_Widget * widget, char *text[]);
+void ewl_list_prepend_text(Ewl_Widget * widget, char *text[]);
+void ewl_list_insert_text(Ewl_Widget * widget, char *text[], int pos);
void ewl_list_append_widgets(Ewl_Widget * widget, Ewl_Widget * widgets[]);
void ewl_list_preppend_widgets(Ewl_Widget * widget, Ewl_Widget * widgets[]);
-void ewl_list_insert_widgets(Ewl_Widget * widget,
- Ewl_Widget * widgets[],
- int pos);
+void ewl_list_insert_widgets(Ewl_Widget * widget, Ewl_Widget * widgets[],
+ int pos);
void ewl_list_select_row(Ewl_Widget * list, int row);
-#endif
+#endif /* __EWL_LIST_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_macros.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_macros.h 2001/05/02 23:12:42 1.6
+++ ewl_macros.h 2001/07/20 07:31:54 1.7
@@ -1,36 +1,45 @@
-#ifndef __EWL_MACROS_H
-#define __EWL_MACROS_H
-
-#define DPRINT(lvl, format, args...) { \
- extern Ewl_Options ewl_options; \
- if (ewl_options.debug_level >= lvl) { \
- fprintf(stderr, "--> "); \
- fprintf(stderr, format, args); \
- fprintf(stderr, "\n"); \
- } \
-}
-
-#define DERROR(format, args...) { \
- fprintf(stderr, "***** EWL Internal Error ***** :\n" \
- "\tThis program encountered a error in:\n\n" \
- "\t%s();\n\n" \
- "\tLeaving this error msg:\n\n", __FUNCTION__); \
- fprintf(stderr, format, args); \
+/*\
+|*|
+|*| Convension macros used to provide some debug information.
+|*|
+\*/
+
+#ifndef __EWL_MACROS_H__
+#define __EWL_MACROS_H__
+
+#undef NEW
+#define NEW(dat, num) \
+ malloc(sizeof(dat) * (num)); \
+ { \
+ ewl_size_allocated += sizeof(dat); \
+ }
+
+#undef REALLOC
+#define REALLOC(dat, type, num) \
+{ \
+ if (dat) \
+ { \
+ ewl_size_allocated += sizeof(dat)/* + *(sizeof(type) * num);*/; \
+ dat = realloc(dat, sizeof(type) * num); \
+ } \
}
-#define NEW(dat, num) malloc(sizeof(dat) * (num))
-
-
#undef FREE
#define FREE(dat) \
- DPRINT(12, "About to FREE %i bytes", sizeof(dat)); \
- free(dat); dat = NULL;
-
+{ \
+/* ewl_size_freed += sizeof(dat);*/ \
+ D(12, ("About to FREE %i bytes", sizeof(dat))); \
+ free(dat); dat = NULL; \
+}
+
#undef IF_FREE
#define IF_FREE(dat) \
- DPRINT(12, "About to IF_FREE %i bytes", sizeof(dat)); \
- if (dat) free(dat); dat = NULL;
+{ \
+/* ewl_size_freed += sizeof(dat);*/ \
+ D(12, ("About to IF_FREE %i bytes", sizeof(dat))); \
+ if (dat) free(dat); dat = NULL; \
+}
-#endif
+#endif /* __EWL_MACROS_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_misc.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_misc.c 2001/05/01 10:08:59 1.5
+++ ewl_misc.c 2001/07/20 07:31:54 1.6
@@ -1,9 +1,9 @@
#include <Ewl.h>
-void ewl_idle_render(void * data);
+void ewl_idle_render(void *data);
-extern Ewd_List * ewl_window_list;
+extern Ewd_List *ewl_window_list;
Ewl_Options ewl_options;
@@ -11,14 +11,24 @@
static void ewl_parse_option_array(int argc, char **argv);
void
-ewl_init(int argc, char ** argv)
+ewl_init(int argc, char **argv)
{
+ char *xdisplay = NULL;
+
+ DENTER_FUNCTION;
+
+ ewl_size_allocated = 0;
+ ewl_size_freed = 0;
+
ewl_init_parse_options(argc, argv);
- if (!e_display_init(NULL))
+ if (ewl_options.xdisplay)
+ xdisplay = ewl_options.xdisplay;
+
+ if (!e_display_init(xdisplay))
{
- fprintf(stderr, "ERRR: Cannot connect to X display!\n");
- exit(-1);
+ fprintf(stderr, "ERRR: Cannot connect to X display!\n");
+ exit(-1);
}
e_event_filter_init();
@@ -26,43 +36,61 @@
e_ev_x_init();
ewl_prefs_init();
- ewl_theme_init();
ewl_ev_init();
ewl_fx_init();
+ ewl_theme_init();
e_event_filter_idle_handler_add(ewl_idle_render, NULL);
+
+ DLEAVE_FUNCTION;
}
void
ewl_main()
{
+ DENTER_FUNCTION;
+
e_event_loop();
+
+ DLEAVE_FUNCTION;
}
void
-ewl_idle_render(void * data)
+ewl_idle_render(void *data)
{
- Ewl_Widget * widget;
+ Ewl_Widget *widget;
+
+ DENTER_FUNCTION;
if (!ewl_window_list || ewd_list_is_empty(ewl_window_list))
- return;
+ DRETURN;
ewd_list_goto_first(ewl_window_list);
while ((widget = EWL_WIDGET(ewd_list_next(ewl_window_list))) != NULL)
{
- if (widget->evas)
- evas_render(widget->evas);
+ if (widget->evas)
+ evas_render(widget->evas);
}
- return;
+ DRETURN;
data = NULL;
}
void
ewl_main_quit()
{
- ewd_list_goto_first(ewl_window_list);
+ Ewl_Widget *widget;
+
+ DENTER_FUNCTION;
+
+ if (ewl_window_list)
+ {
+ ewd_list_goto_first(ewl_window_list);
+
+ while ((widget = ewd_list_next(ewl_window_list)) != NULL)
+ ewl_widget_destroy_recursive(widget);
+ }
exit(-1);
}
@@ -70,36 +98,52 @@
static void
ewl_init_parse_options(int argc, char **argv)
{
+ DENTER_FUNCTION;
+
memset(&ewl_options, 0, sizeof(Ewl_Options));
ewl_parse_option_array(argc, argv);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_parse_option_array(int argc, char ** argv)
+ewl_parse_option_array(int argc, char **argv)
{
char stropts[] =
"a:A:b:BcC:dD:e:f:Fg:hH:iIklL:mM:nNo:O:pPqQrR:sS:tT:uUvVwW:xXy:zZ1:2:3:4:56:78:90:";
struct option lopts[] = {
{"ewl_debug-level", 1, 0, '@'},
+ {"ewl_display", 1, 0, '$'},
{0, 0, 0, 0}
};
int optch = 0, cmdx = 0;
- while ((optch = getopt_long_only(argc, argv, stropts, lopts, &cmdx)) != EOF)
+ DENTER_FUNCTION;
+
+ while ((optch =
+ getopt_long_only(argc, argv, stropts, lopts, &cmdx)) != EOF)
{
- switch (optch)
- {
- case 0:
- break;
-
- case '@':
- ewl_options.debug_level = atoi(optarg);
- DPRINT(0, "Setting debug level to %i", ewl_options.debug_level);
- break;
-
- default:
- break;
- }
+ switch (optch)
+ {
+ case 0:
+ break;
+
+ case '@':
+ ewl_options.debug_level = atoi(optarg);
+ D(0,
+ ("Setting debug level to %i",
+ ewl_options.debug_level));
+ break;
+
+ case '$':
+ ewl_options.xdisplay = optarg;
+ break;
+
+ default:
+ break;
+ }
}
+
+ DLEAVE_FUNCTION;
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_misc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_misc.h 2001/04/16 11:58:11 1.2
+++ ewl_misc.h 2001/07/20 07:31:54 1.3
@@ -1,15 +1,23 @@
-#ifndef __EWL_MISC_H
-#define __EWL_MISC_H
+/*\
+|*|
+|*|
+|*|
+\*/
-struct _ewl_options {
+#ifndef __EWL_MISC_H__
+#define __EWL_MISC_H__
+
+struct _ewl_options
+{
int debug_level;
+ char *xdisplay;
};
typedef struct _ewl_options Ewl_Options;
-void ewl_init(int argc, char ** argv);
+void ewl_init(int argc, char **argv);
void ewl_main();
void ewl_main_quit();
-#endif
+#endif /* __EWL_MISC_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_object.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_object.c 2001/05/01 10:08:59 1.3
+++ ewl_object.c 2001/07/20 07:31:54 1.4
@@ -2,19 +2,220 @@
#include <Ewl.h>
void
-ewl_object_set_minimum_size(Ewl_Object * object, int w, int h)
+ewl_object_set_current_geometry(Ewl_Object * o, int x, int y, int w, int h)
{
- CHECK_PARAM_POINTER("object", object);
+ CHECK_PARAM_POINTER("o", o);
- object->minimum.w = w;
- object->minimum.h = h;
+ o->current.x = x;
+ o->current.y = y;
+ o->current.w = w;
+ o->current.h = h;
}
void
-ewl_object_set_maximum_size(Ewl_Object * object, int w, int h)
+ewl_object_get_current_geometry(Ewl_Object * o,
+ int *x, int *y, int *w, int *h)
{
- CHECK_PARAM_POINTER("object", object);
+ CHECK_PARAM_POINTER("o", o);
- object->maximum.w = w;
- object->maximum.h = h;
+ if (x)
+ *x = o->current.x;
+ if (y)
+ *y = o->current.y;
+ if (w)
+ *w = o->current.w;
+ if (h)
+ *h = o->current.h;
+}
+
+void
+ewl_object_set_current_size(Ewl_Object * o, int w, int h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->current.w = w;
+ o->current.h = h;
+}
+
+void
+ewl_object_get_current_size(Ewl_Object * o, int *w, int *h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ if (w)
+ *w = o->current.w;
+ if (h)
+ *h = o->current.h;
+}
+
+void
+ewl_object_request_geometry(Ewl_Object * o, int x, int y, int w, int h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->request.x = x;
+ o->request.y = y;
+ o->request.w = w;
+ o->request.h = h;
+}
+
+inline void
+ewl_object_request_x(Ewl_Object * o, int x)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->request.x = x;
+}
+
+inline void
+ewl_object_request_y(Ewl_Object * o, int y)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->request.y = y;
+}
+
+inline void
+ewl_object_request_w(Ewl_Object * o, int w)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->request.w = w;
+}
+
+inline void
+ewl_object_request_h(Ewl_Object * o, int h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->request.h = h;
+}
+
+void
+ewl_object_requested_geometry(Ewl_Object * o, int *x, int *y, int *w, int *h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ if (x)
+ *x = o->request.x;
+ if (y)
+ *y = o->request.y;
+ if (w)
+ *w = o->request.w;
+ if (h)
+ *h = o->request.h;
+}
+
+void
+ewl_object_set_minimum_size(Ewl_Object * o, int w, int h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->minimum.w = w;
+ o->minimum.h = h;
+}
+
+void
+ewl_object_get_minimum_size(Ewl_Object * o, int *w, int *h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ if (w)
+ *w = o->minimum.w;
+ if (h)
+ *h = o->minimum.h;
+}
+
+void
+ewl_object_set_maximum_size(Ewl_Object * o, int w, int h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->maximum.w = w;
+ o->maximum.h = h;
+}
+
+void
+ewl_object_get_maximum_size(Ewl_Object * o, int *w, int *h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ if (w)
+ *w = o->maximum.w;
+ if (h)
+ *h = o->maximum.h;
+}
+
+void
+ewl_object_set_custom_size(Ewl_Object * o, int w, int h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->custom.w = w;
+ o->custom.h = h;
+ o->maximum.w = w;
+ o->maximum.h = h;
+ o->minimum.w = w;
+ o->minimum.h = h;
+}
+
+void
+ewl_object_get_custom_size(Ewl_Object * o, int *w, int *h)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ if (w)
+ *w = o->custom.w;
+ if (h)
+ *h = o->custom.h;
+}
+
+void
+ewl_object_set_realized(Ewl_Object * o, int r)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->realized = r;
+}
+
+void
+ewl_object_get_realized(Ewl_Object * o, int *r)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ if (r)
+ *r = o->realized;
+}
+
+void
+ewl_object_set_visible(Ewl_Object * o, int v)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->visible = v;
+}
+
+void
+ewl_object_get_visible(Ewl_Object * o, int *v)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ if (v)
+ *v = o->visible;
+}
+
+void
+ewl_object_set_layer(Ewl_Object * o, int l)
+{
+ CHECK_PARAM_POINTER("o", o);
+
+ o->layer = l;
+}
+
+int
+ewl_object_get_layer(Ewl_Object * o)
+{
+ CHECK_PARAM_POINTER_RETURN("o", o, 0);
+
+ return o->layer;
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_object.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_object.h 2001/05/02 23:12:42 1.3
+++ ewl_object.h 2001/07/20 07:31:54 1.4
@@ -3,22 +3,82 @@
#define __EWL_OBJECT_H__
typedef struct _ewl_object Ewl_Object;
+#define EWL_OBJECT(object) ((Ewl_Object *) object)
-struct _ewl_object {
- struct {
+struct _ewl_object
+{
+ struct
+ {
int x, y, w, h;
- } current, request;
- struct {
+ }
+ current, request;
+
+ struct
+ {
int w, h;
- } maximum, minimum, custom;
+ }
+ maximum, minimum, custom;
+
int realized;
int visible;
int layer;
};
-#define EWL_OBJECT(object) ((Ewl_Object *) object)
+void ewl_object_set_current_geometry(Ewl_Object * o, int x, int y, int w,
+ int h);
+void ewl_object_get_current_geometry(Ewl_Object * o, int *x, int *y,
+ int *w, int *h);
+
+void ewl_object_set_current_size(Ewl_Object * o, int w, int h);
+void ewl_object_get_current_size(Ewl_Object * o, int *w, int *h);
+
+void ewl_object_request_geometry(Ewl_Object * o, int x, int y, int w, int h);
+inline void ewl_object_request_x(Ewl_Object * o, int x);
+inline void ewl_object_request_y(Ewl_Object * o, int y);
+inline void ewl_object_request_w(Ewl_Object * o, int w);
+inline void ewl_object_request_h(Ewl_Object * o, int h);
+inline void ewl_object_requested_geometry(Ewl_Object * o, int *x,
+ int *y, int *w, int *h);
+
+void ewl_object_set_minimum_size(Ewl_Object * o, int w, int h);
+void ewl_object_get_minimum_size(Ewl_Object * o, int *w, int *h);
+
+void ewl_object_set_maximum_size(Ewl_Object * o, int w, int h);
+void ewl_object_get_maximum_size(Ewl_Object * o, int *w, int *h);
+
+void ewl_object_set_custom_size(Ewl_Object * o, int w, int h);
+void ewl_object_get_custom_size(Ewl_Object * o, int *w, int *h);
+
+void ewl_object_set_realized(Ewl_Object * o, int r);
+void ewl_object_get_realized(Ewl_Object * o, int *r);
+
+void ewl_object_set_visible(Ewl_Object * o, int v);
+void ewl_object_get_visible(Ewl_Object * o, int *v);
+
+void ewl_object_set_layer(Ewl_Object * o, int l);
+int ewl_object_get_layer(Ewl_Object * o);
+
+#define CURRENT_X(o) EWL_OBJECT(o)->current.x
+#define CURRENT_Y(o) EWL_OBJECT(o)->current.y
+#define CURRENT_W(o) EWL_OBJECT(o)->current.w
+#define CURRENT_H(o) EWL_OBJECT(o)->current.h
+
+#define REQUEST_X(o) EWL_OBJECT(o)->request.x
+#define REQUEST_Y(o) EWL_OBJECT(o)->request.y
+#define REQUEST_W(o) EWL_OBJECT(o)->request.w
+#define REQUEST_H(o) EWL_OBJECT(o)->request.h
+
+#define CUSTOM_W(o) EWL_OBJECT(o)->custom.w
+#define CUSTOM_H(o) EWL_OBJECT(o)->custom.h
+
+#define MAX_W(o) EWL_OBJECT(o)->maximum.w
+#define MAX_H(o) EWL_OBJECT(o)->maximum.h
+
+#define MIN_W(o) EWL_OBJECT(o)->minimum.w
+#define MIN_H(o) EWL_OBJECT(o)->minimum.h
-void ewl_object_set_minimum_size(Ewl_Object * object, int w, int h);
-void ewl_object_set_maximum_size(Ewl_Object * object, int w, int h);
+#define REALIZED(o) EWL_OBJECT(o)->realized
+#define VISIBLE(o) EWL_OBJECT(o)->visible
+#define LAYER(o) EWL_OBJECT(o)->layer
-#endif
+#endif /* __EWL_OBJECT_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_prefs.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_prefs.c 2001/05/01 04:00:38 1.3
+++ ewl_prefs.c 2001/07/20 07:31:54 1.4
@@ -18,20 +18,21 @@
void
ewl_prefs_init(void)
{
- char * home = strdup(getenv("HOME"));
+ char *home = strdup(getenv("HOME"));
snprintf(user_config, PATH_LEN, "%s/%s/%s", home,
- EWL_USER_DIR, EWL_CONFIG_FILE);
+ EWL_USER_DIR, EWL_CONFIG_FILE);
user_prefs = e_db_open(user_config);
global_prefs = e_db_open_read(EWL_GLOBAL_CONFIG);
if (!user_prefs && !global_prefs)
- fprintf(stderr, "Warning!\nNeither Global or user config db found\n");
+ fprintf(stderr,
+ "Warning!\nNeither Global or user config db found\n");
}
int
-ewl_prefs_int_get(char * key)
+ewl_prefs_int_get(char *key)
{
int value = 0;
@@ -39,8 +40,8 @@
if (user_prefs)
{
- if (e_db_int_get(user_prefs, key, &value))
- return value;
+ if (e_db_int_get(user_prefs, key, &value))
+ return value;
}
e_db_int_get(global_prefs, key, &value);
@@ -53,29 +54,30 @@
{
CHECK_PARAM_POINTER_RETURN("key", key, -1);
- if (!user_prefs)
- return FALSE;
+ if (!user_prefs)
+ return FALSE;
- e_db_int_set(user_prefs, key, value);
- return TRUE;
+ e_db_int_set(user_prefs, key, value);
+ return TRUE;
}
char *
ewl_prefs_str_get(char *key)
{
- char *value = NULL;
+ char *value = NULL;
CHECK_PARAM_POINTER_RETURN("key", key, NULL);
if (!user_prefs || !global_prefs)
return NULL;
- if (user_prefs) {
- value = e_db_str_get(user_prefs, key);
- if (value)
- return value;
- }
- return e_db_str_get(global_prefs, key);
+ if (user_prefs)
+ {
+ value = e_db_str_get(user_prefs, key);
+ if (value)
+ return value;
+ }
+ return e_db_str_get(global_prefs, key);
}
int
@@ -84,16 +86,16 @@
CHECK_PARAM_POINTER_RETURN("key", key, -1);
CHECK_PARAM_POINTER_RETURN("value", value, -1);
- if (!user_prefs || !key)
- return FALSE;
+ if (!user_prefs || !key)
+ return FALSE;
- e_db_str_set(user_prefs, key, value);
+ e_db_str_set(user_prefs, key, value);
- return TRUE;
+ return TRUE;
}
int
-ewl_prefs_float_get(char *key, float * value)
+ewl_prefs_float_get(char *key, float *value)
{
CHECK_PARAM_POINTER_RETURN("key", key, -1);
@@ -108,8 +110,8 @@
{
CHECK_PARAM_POINTER_RETURN("key", key, -1);
- if (!user_prefs)
- return FALSE;
+ if (!user_prefs)
+ return FALSE;
e_db_float_set(user_prefs, key, value);
return TRUE;
@@ -118,7 +120,7 @@
char *
ewl_prefs_theme_name_get()
{
- char * str = NULL;
+ char *str = NULL;
str = ewl_prefs_str_get("/theme/name");
@@ -131,18 +133,18 @@
Evas_Render_Method
ewl_prefs_render_method_get()
{
- char * str = NULL;
+ char *str = NULL;
str = ewl_prefs_str_get("/evas/render_method");
if (str)
{
- if (!strcasecmp(str, "software"))
- return RENDER_METHOD_ALPHA_SOFTWARE;
- else if (!strcasecmp(str, "hardware"))
- return RENDER_METHOD_3D_HARDWARE;
- else if (!strcasecmp(str, "x11"))
- return RENDER_METHOD_BASIC_HARDWARE;
+ if (!strcasecmp(str, "software"))
+ return RENDER_METHOD_ALPHA_SOFTWARE;
+ else if (!strcasecmp(str, "hardware"))
+ return RENDER_METHOD_3D_HARDWARE;
+ else if (!strcasecmp(str, "x11"))
+ return RENDER_METHOD_BASIC_HARDWARE;
}
return RENDER_METHOD_ALPHA_SOFTWARE;
@@ -157,7 +159,7 @@
if (!ewl_prefs_float_get("/fx/max_fps", &val))
val = 20.0;
- return (double)(val);
+ return (double) (val);
}
double
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_prefs.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_prefs.h 2001/05/01 04:00:38 1.2
+++ ewl_prefs.h 2001/07/20 07:31:54 1.3
@@ -2,16 +2,16 @@
#ifndef __EWL_PREFS_H
#define __EWL_PREFS_H
-void ewl_prefs_init(void);
-int ewl_prefs_int_get(char * key);
-int ewl_prefs_int_set(char * key, int value);
-char * ewl_prefs_str_get(char * key);
-int ewl_prefs_str_set(char * key, char * value);
-int ewl_prefs_float_get(char * key, float * value);
-int ewl_prefs_float_set(char * key, float value);
-char * ewl_prefs_theme_name_get();
-Evas_Render_Method ewl_prefs_render_method_get();
-double ewl_prefs_get_fx_max_fps();
-double ewl_prefs_get_fx_timeout();
+void ewl_prefs_init(void);
+int ewl_prefs_int_get(char *key);
+int ewl_prefs_int_set(char *key, int value);
+char *ewl_prefs_str_get(char *key);
+int ewl_prefs_str_set(char *key, char *value);
+int ewl_prefs_float_get(char *key, float *value);
+int ewl_prefs_float_set(char *key, float value);
+char *ewl_prefs_theme_name_get();
+Evas_Render_Method ewl_prefs_render_method_get();
+double ewl_prefs_get_fx_max_fps();
+double ewl_prefs_get_fx_timeout();
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_seeker.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_seeker.c 2001/05/02 23:12:42 1.3
+++ ewl_seeker.c 2001/07/20 07:31:54 1.4
@@ -1,485 +1,590 @@
-
#include <Ewl.h>
-
-
-static Ewl_Widget * ewl_seeker_new(Ewl_Orientation orientation);
-static void __ewl_seeker_init(Ewl_Seeker * seeker, Ewl_Orientation orientation);
-static void __ewl_seeker_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_configure(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_set_value(Ewl_Widget * widget, int v);
-
-static void __ewl_seeker_key_down(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_key_up(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_mouse_down(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_mouse_up(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_mouse_move(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_focus_in(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_focus_out(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_seeker_get_button_geometry(Ewl_Widget * widget,
- int * x,
- int * y,
- int * w,
- int * h);
-
-static Ewl_Widget *
+static void __ewl_seeker_init(Ewl_Seeker * s, Ewl_Orientation orientation);
+static void __ewl_seeker_realize(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_show(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_hide(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_destroy(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_destroy_recursive(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_configure(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_theme_update(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_dragbar_mouse_move(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_mouse_up(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_mouse_down(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_focus_in(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_focus_out(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_seeker_mouse_move(Ewl_Widget * w, void *event_data,
+ void *user_data);
+
+/*
+ * Create a new seeker object with the specified orientation
+ */
+Ewl_Widget *
ewl_seeker_new(Ewl_Orientation orientation)
{
- Ewl_Seeker * seeker = NULL;
+ Ewl_Seeker *s;
- seeker = NEW(Ewl_Seeker, 1);
+ DENTER_FUNCTION;
- __ewl_seeker_init(seeker, orientation);
+ s = NEW(Ewl_Seeker, 1);
- return EWL_WIDGET(seeker);
-}
+ __ewl_seeker_init(s, orientation);
-Ewl_Widget *
-ewl_hseeker_new(void)
-{
- return ewl_seeker_new(EWL_ORIENTATION_HORISONTAL);
+ DRETURN_PTR(EWL_WIDGET(s));
}
-Ewl_Widget *
-ewl_vseeker_new(void)
+/*
+ * Set the value and position of the pointer on the seekers dragbar
+ */
+void
+ewl_seeker_set_value(Ewl_Widget * w, double v)
{
- return ewl_seeker_new(EWL_ORIENTATION_VERTICAL);
-}
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
-Ewl_Widget *
-ewl_seeker_new_all(Ewl_Orientation orientation, int range)
-{
- Ewl_Widget * widget;
+ EWL_SEEKER(w)->value = v;
- widget = ewl_seeker_new(orientation);
- EWL_SEEKER(widget)->range = range;
+ ewl_widget_configure(w);
- return widget;
+ DLEAVE_FUNCTION;
}
-void
-ewl_seeker_set_value(Ewl_Widget * widget, int value)
+/*
+ * Retrieve the current value of the seeker widget
+ */
+double
+ewl_seeker_get_value(Ewl_Widget * w)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR_RET("w", w, -1);
- __ewl_seeker_set_value(widget, value);
+ DRETURN_FLOAT(EWL_SEEKER(w)->value);
}
-int
-ewl_seeker_get_value(Ewl_Widget * widget)
+/*
+ * Specify the range of the values represented by the seeker
+ */
+void
+ewl_seeker_set_range(Ewl_Widget * w, double r)
{
- CHECK_PARAM_POINTER_RETURN("widget", widget, 0);
+ int new_val;
- return EWL_SEEKER(widget)->value;
-}
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
-void
-ewl_seeker_set_range(Ewl_Widget * widget, int range)
-{
- CHECK_PARAM_POINTER("widget", widget);
+ new_val = r * (EWL_SEEKER(w)->value / EWL_SEEKER(w)->range);
- EWL_SEEKER(widget)->range = range;
- __ewl_seeker_set_value(widget, EWL_SEEKER(widget)->value);
+ EWL_SEEKER(w)->range = r;
+ EWL_SEEKER(w)->value = new_val;
+
+ ewl_widget_configure(w);
+
+ DLEAVE_FUNCTION;
}
-int
-ewl_seeker_get_range(Ewl_Widget * widget)
+/*
+ * Retrieve the range of values represented by the seeker
+ */
+double
+ewl_seeker_get_range(Ewl_Widget * w)
{
- CHECK_PARAM_POINTER_RETURN("widget", widget, 0);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR_RET("w", w, -1);
- return EWL_SEEKER(widget)->range;
+ DRETURN_FLOAT(EWL_SEEKER(w)->range);
}
-void
-ewl_seeker_set_orientation(Ewl_Widget * widget, Ewl_Orientation orientation)
+/*
+ * Initialize the seeker to some sane starting values
+ */
+static void
+__ewl_seeker_init(Ewl_Seeker * s, Ewl_Orientation orientation)
{
- CHECK_PARAM_POINTER("widget", widget);
+ Ewl_Widget *w;
- EWL_SEEKER(widget)->orientation = orientation;
- if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_HORISONTAL)
- {
- EWL_OBJECT(widget)->current.w = 150;
- EWL_OBJECT(widget)->current.h = 15;
- EWL_OBJECT(widget)->maximum.w = 150;
- EWL_OBJECT(widget)->maximum.h = 15;
- EWL_OBJECT(widget)->minimum.w = 150;
- EWL_OBJECT(widget)->minimum.h = 15;
- EWL_OBJECT(widget)->request.w = 150;
- EWL_OBJECT(widget)->request.h = 15;
- }
- else if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_VERTICAL)
- {
- EWL_OBJECT(widget)->current.w = 15;
- EWL_OBJECT(widget)->current.h = 150;
- EWL_OBJECT(widget)->maximum.w = 15;
- EWL_OBJECT(widget)->maximum.h = 150;
- EWL_OBJECT(widget)->minimum.w = 15;
- EWL_OBJECT(widget)->minimum.h = 150;
- EWL_OBJECT(widget)->request.w = 15;
- EWL_OBJECT(widget)->request.h = 150;
- }
- ewl_widget_configure(widget);
- ewl_widget_configure(widget->parent);
-}
-
-
-static void
-__ewl_seeker_init(Ewl_Seeker * seeker, Ewl_Orientation orientation)
-{
- CHECK_PARAM_POINTER("seeker", seeker);
-
- memset(seeker, 0, sizeof(Ewl_Seeker));
-
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_REALIZE, __ewl_seeker_realize, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_SHOW, __ewl_seeker_show, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_HIDE, __ewl_seeker_hide, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_DESTROY, __ewl_seeker_destroy, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_CONFIGURE, __ewl_seeker_configure, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_KEY_DOWN, __ewl_seeker_key_down, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_KEY_UP, __ewl_seeker_key_up, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_MOUSE_DOWN, __ewl_seeker_mouse_down, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_MOUSE_UP, __ewl_seeker_mouse_up, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_MOUSE_MOVE, __ewl_seeker_mouse_move, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_FOCUS_IN, __ewl_seeker_focus_in, NULL);
- ewl_callback_append(EWL_WIDGET(seeker),
- EWL_CALLBACK_FOCUS_OUT, __ewl_seeker_focus_out, NULL);
-
- EWL_WIDGET(seeker)->container.recursive = FALSE;
-
- seeker->orientation = orientation;
- seeker->value = 0;
- seeker->range = 100;
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("s", s);
- if (seeker->orientation == EWL_ORIENTATION_HORISONTAL)
- {
- EWL_OBJECT(seeker)->current.w = 150;
- EWL_OBJECT(seeker)->current.h = 15;
- EWL_OBJECT(seeker)->maximum.w = 150;
- EWL_OBJECT(seeker)->maximum.h = 15;
- EWL_OBJECT(seeker)->minimum.w = 150;
- EWL_OBJECT(seeker)->minimum.h = 15;
- EWL_OBJECT(seeker)->request.w = 150;
- EWL_OBJECT(seeker)->request.h = 15;
- }
- else if (seeker->orientation == EWL_ORIENTATION_VERTICAL)
- {
- EWL_OBJECT(seeker)->current.w = 15;
- EWL_OBJECT(seeker)->current.h = 150;
- EWL_OBJECT(seeker)->maximum.w = 15;
- EWL_OBJECT(seeker)->maximum.h = 150;
- EWL_OBJECT(seeker)->minimum.w = 15;
- EWL_OBJECT(seeker)->minimum.h = 150;
- EWL_OBJECT(seeker)->request.w = 15;
- EWL_OBJECT(seeker)->request.h = 150;
- }
+
+ w = EWL_WIDGET(s);
+
+ /*
+ * Initialize the widget fields and set appropriate orienation and
+ * type
+ */
+ memset(s, 0, sizeof(Ewl_Seeker));
+ ewl_container_init(EWL_CONTAINER(w), EWL_WIDGET_SEEKER, 100, 15,
+ 512, 15);
+
+ s->orientation = orientation;
+
+ /*
+ * Add necessary configuration callbacks
+ */
+ ewl_callback_append(w, EWL_CALLBACK_REALIZE, __ewl_seeker_realize,
+ NULL);
+ ewl_callback_append(w, EWL_CALLBACK_SHOW, __ewl_seeker_show, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_HIDE, __ewl_seeker_hide, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_DESTROY,
+ __ewl_seeker_destroy, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_DESTROY_RECURSIVE,
+ __ewl_seeker_destroy_recursive, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_CONFIGURE,
+ __ewl_seeker_configure, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_THEME_UPDATE,
+ __ewl_seeker_theme_update, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN,
+ __ewl_seeker_mouse_down, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_MOUSE_UP,
+ __ewl_seeker_mouse_up, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_FOCUS_IN,
+ __ewl_seeker_focus_in, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_FOCUS_OUT,
+ __ewl_seeker_focus_out, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE,
+ __ewl_seeker_mouse_move, NULL);
+
+ /*
+ * Set the starting range and values
+ */
+ s->range = 100;
+ s->value = 0;
+
+ DLEAVE_FUNCTION;
}
+/*
+ * Draw the representation of the seeker
+ */
static void
-__ewl_seeker_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_realize(Ewl_Widget * w, void *event_data, void *user_data)
{
- char * image = NULL;
+ Ewl_Seeker *s;
+ Ewl_Widget *dragbar;
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- image = ewl_theme_ebit_get("seeker", "default", "base");
- EWL_SEEKER(widget)->ebits_bg = ebits_load(image);
- ebits_add_to_evas(EWL_SEEKER(widget)->ebits_bg, widget->evas);
- ebits_set_layer(EWL_SEEKER(widget)->ebits_bg, widget->object.layer);
- IF_FREE(image);
+ s = EWL_SEEKER(w);
- image = ewl_theme_ebit_get("seeker", "default", "dragbar");
- EWL_SEEKER(widget)->ebits_dragbar = ebits_load(image);
- ebits_add_to_evas(EWL_SEEKER(widget)->ebits_dragbar, widget->evas);
- ebits_set_layer(EWL_SEEKER(widget)->ebits_dragbar, widget->object.layer+1);
- IF_FREE(image);
+ ewl_fx_clip_box_create(w);
- ewl_fx_clip_box_create(widget);
-
- ebits_show(EWL_SEEKER(widget)->ebits_bg);
- ebits_show(EWL_SEEKER(widget)->ebits_dragbar);
-
- if (widget->parent && widget->parent->container.clip_box)
- evas_set_clip(widget->evas, widget->fx_clip_box,
- widget->parent->container.clip_box);
+ /*
+ * We have a parent and a clip_box? ok, then we should tell evas to
+ * use them
+ */
+ if (w->parent && EWL_CONTAINER(w->parent)->clip_box)
+ evas_set_clip(w->evas, w->fx_clip_box,
+ EWL_CONTAINER(w->parent)->clip_box);
+ /*
+ * Create a button that will act as the dragbar and append it to the
+ * seeker.
+ */
+ dragbar = ewl_button_new(NULL);
- ebits_set_clip(EWL_SEEKER(widget)->ebits_bg, widget->fx_clip_box);
- ebits_set_clip(EWL_SEEKER(widget)->ebits_dragbar, widget->fx_clip_box);
+ /*
+ * Override the default theme for buttons
+ */
+ if (s->orientation == EWL_ORIENTATION_HORIZONTAL)
+ ewl_theme_data_set(dragbar, "/appearance/button/default/base",
+ "/appearance/seeker/horizontal/dragbar.bits.db");
+ else
+ ewl_theme_data_set(dragbar, "/appearance/button/default/base",
+ "/appearance/seeker/vertical/dragbar.bits.db");
- evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
+ /*
+ * Append a callback for catching mouse movements on the dragbar and
+ * add the dragbar to the seeker
+ */
+ ewl_callback_append(dragbar, EWL_CALLBACK_MOUSE_MOVE,
+ __ewl_seeker_dragbar_mouse_move, NULL);
+ ewl_container_append_child(EWL_CONTAINER(s), dragbar);
+ ewl_widget_show(EWL_WIDGET(dragbar));
+
+ ewl_widget_theme_update(w);
+
+ DLEAVE_FUNCTION;
}
static void
-__ewl_seeker_show(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_show(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
+
+ evas_show(w->evas, w->fx_clip_box);
- evas_show(widget->evas, widget->fx_clip_box);
+ DLEAVE_FUNCTION;
}
static void
-__ewl_seeker_hide(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_hide(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- evas_hide(widget->evas, widget->fx_clip_box);
+ evas_hide(w->evas, w->fx_clip_box);
+
+ DLEAVE_FUNCTION;
}
static void
-__ewl_seeker_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_destroy(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
-
- ebits_hide(EWL_SEEKER(widget)->ebits_bg);
- ebits_unset_clip(EWL_SEEKER(widget)->ebits_bg);
- ebits_free(EWL_SEEKER(widget)->ebits_bg);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- ebits_hide(EWL_SEEKER(widget)->ebits_dragbar);
- ebits_unset_clip(EWL_SEEKER(widget)->ebits_dragbar);
- ebits_free(EWL_SEEKER(widget)->ebits_dragbar);
+ ewl_callback_del_all(w);
- evas_hide(widget->evas, widget->fx_clip_box);
- evas_unset_clip(widget->evas, widget->fx_clip_box);
- evas_del_object(widget->evas, widget->fx_clip_box);
+ ewl_theme_deinit_widget(w);
- FREE(widget);
+ DLEAVE_FUNCTION;
}
static void
-__ewl_seeker_configure(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_destroy_recursive(Ewl_Widget * w, void *event_data,
+ void *user_data)
{
- int l = 0, r = 0, t = 0, b = 0;
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- CHECK_PARAM_POINTER("widget", widget);
+ DLEAVE_FUNCTION;
+}
- ebits_get_insets(EWL_SEEKER(widget)->ebits_bg, &l, &r, &t, &b);
+/*
+ * On a configure event we need to adjust the seeker to fit into it's new
+ * coords and position as well as move the dragbar to the correct size and
+ * position.
+ */
+static void
+__ewl_seeker_configure(Ewl_Widget * w, void *event_data, void *user_data)
+{
+ Ewl_Seeker *s;
+ Ewl_Widget *dragbar;
+ double val;
+ int new_x, new_y, new_w, new_h;
+ int req_x, req_y, req_w, req_h;
+ int l, r, t, b;
- ewl_fx_clip_box_resize(widget);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- ebits_move(EWL_SEEKER(widget)->ebits_bg,
- EWL_OBJECT(widget)->request.x,
- EWL_OBJECT(widget)->request.y);
- ebits_resize(EWL_SEEKER(widget)->ebits_bg,
- EWL_OBJECT(widget)->request.w,
- EWL_OBJECT(widget)->request.h);
-
+ /*
+ * If we don't have a visible ebits object then it's pointless to
+ * continue
+ */
+ if (!w->ebits_object)
+ DRETURN;
- ebits_move(EWL_SEEKER(widget)->ebits_dragbar,
- EWL_OBJECT(widget)->request.x + l,
- EWL_OBJECT(widget)->request.y + t);
+ /*
+ * Retrieve the new geometry of the widget
+ */
+ ewl_object_requested_geometry(EWL_OBJECT(w), &req_x, &req_y,
+ &req_w, &req_h);
- if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_HORISONTAL)
- ebits_resize(EWL_SEEKER(widget)->ebits_dragbar, 25,
- EWL_OBJECT(widget)->request.h - (t+b));
- else if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_VERTICAL)
- ebits_resize(EWL_SEEKER(widget)->ebits_dragbar,
- EWL_OBJECT(widget)->request.w - (r+l),
- 25);
+ s = EWL_SEEKER(w);
- EWL_OBJECT(widget)->current.x = EWL_OBJECT(widget)->request.x;
- EWL_OBJECT(widget)->current.y = EWL_OBJECT(widget)->request.y;
- EWL_OBJECT(widget)->current.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->current.h = EWL_OBJECT(widget)->request.h;
+ /*
+ * Move the base ebits object to the correct size and position
+ */
+ ebits_move(w->ebits_object, req_x, req_y);
+ ebits_resize(w->ebits_object, req_w, req_h);
- __ewl_seeker_set_value(widget, EWL_SEEKER(widget)->value);
-}
+ /*
+ * Now move the clipbox to the correct size and position
+ */
+ evas_move(w->evas, w->fx_clip_box, req_x, req_y);
+ evas_resize(w->evas, w->fx_clip_box, req_w, req_h);
-static void
-__ewl_seeker_set_value(Ewl_Widget * widget, int value)
-{
- int l = 0, r = 0, t = 0, b = 0;
- int x = 0, y = 0;
- float play = 0;
+ ewl_object_set_current_geometry(EWL_OBJECT(w),
+ req_x, req_y, req_w, req_h);
- CHECK_PARAM_POINTER("widget", widget);
+ /*
+ * Get the dragbar's current size
+ */
+ ewd_list_goto_first(EWL_CONTAINER(s)->children);
+ dragbar = ewd_list_current(EWL_CONTAINER(s)->children);
+ ewl_object_get_current_geometry(EWL_OBJECT(dragbar), &new_x, &new_y,
+ &new_w, &new_h);
+ /*
+ * Calculate the dragbar's new position
+ */
+ ebits_get_insets(w->ebits_object, &l, &r, &t, &b);
- if (widget->object.realized)
- {
- if (value > EWL_SEEKER(widget)->range)
- return;
+ val = s->value / s->range;
- ebits_get_insets(EWL_SEEKER(widget)->ebits_bg, &l, &r, &t, &b);
+ new_x = req_x + l;
+ new_y = req_y + t;
+ new_h = req_h - (t + b);
- x = EWL_OBJECT(widget)->current.x + l;
- y = EWL_OBJECT(widget)->current.y + t;
+ new_x += ((req_w - (l + r)) - new_w) * val;
- play = ((float) value / (float) EWL_SEEKER(widget)->range);
+ /*
+ * Now apply the new position to the dragbar
+ */
+ ewl_object_request_geometry(EWL_OBJECT(dragbar), new_x, new_y,
+ new_w, new_h);
+ ewl_widget_configure(dragbar);
- if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_HORISONTAL)
- x += ((EWL_OBJECT(widget)->current.w - (l + r) - 25) * play);
- else if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_VERTICAL)
- y += ((EWL_OBJECT(widget)->current.h - (t + b) - 25) * (1.000 - play));
-
- ebits_move(EWL_SEEKER(widget)->ebits_dragbar, x, y);
- }
- EWL_SEEKER(widget)->value = value;
+ DLEAVE_FUNCTION;
}
+/*
+ * The theme for the seeker has been updated, so reread any theme info we need
+ */
static void
-__ewl_seeker_key_down(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_theme_update(Ewl_Widget * w, void *event_data, void *user_data)
{
- Ev_Key_Down * ev = NULL;
+ char *i = NULL;
+ Ewl_Seeker *s;
+ Ewl_Widget *dragbar;
+ char *v;
- CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("cb", cb);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- ev = cb->func_data;
+ /*
+ * Shouldn't do anything if the widget isn't realized yet
+ */
+ if (!w->object.realized)
+ DRETURN;
- if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_HORISONTAL)
+ s = EWL_SEEKER(w);
+
+ /*
+ * Check if GFX should be visible or not
+ */
+ if (s->orientation == EWL_ORIENTATION_VERTICAL)
+ v = ewl_theme_data_get(w,
+ "/appearance/seeker/vertical/base/visible");
+ else
+ v = ewl_theme_data_get(w,
+ "/appearance/seeker/horizontal/base/visible");
+
+ /*
+ * Check if this piece should be visible, if so grab the path to it's
+ * bit file.
+ */
+ if (v && *v == 'y')
{
- if (!strcmp("Left", ev->key))
- __ewl_seeker_set_value(widget, EWL_SEEKER(widget)->value-1);
- else if (!strcmp("Right", ev->key))
- __ewl_seeker_set_value(widget, EWL_SEEKER(widget)->value+1);
- else if (!strcmp("Home", ev->key))
- __ewl_seeker_set_value(widget, 0);
- else if (!strcmp("End", ev->key))
- __ewl_seeker_set_value(widget, EWL_SEEKER(widget)->range);
+ if (s->orientation == EWL_ORIENTATION_VERTICAL)
+ i = ewl_theme_image_get(w,
+ "/appearance/seeker/horizontal/base");
+ else
+ i = ewl_theme_image_get(w,
+ "/appearance/seeker/horizontal/base");
+ FREE(v);
}
- else if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_VERTICAL)
+
+ /*
+ * Destroy old image (if any)
+ */
+ if (w->ebits_object)
{
- if (!strcmp("Up", ev->key))
- __ewl_seeker_set_value(widget, EWL_SEEKER(widget)->value+1);
- else if (!strcmp("Down", ev->key))
- __ewl_seeker_set_value(widget, EWL_SEEKER(widget)->value-1);
- else if (!strcmp("Home", ev->key))
- __ewl_seeker_set_value(widget, 0);
- else if (!strcmp("End", ev->key))
- __ewl_seeker_set_value(widget, EWL_SEEKER(widget)->range);
+ ebits_hide(w->ebits_object);
+ ebits_unset_clip(w->ebits_object);
+ ebits_free(w->ebits_object);
}
-}
-
-static void
-__ewl_seeker_key_up(Ewl_Widget * widget, Ewl_Callback * cb)
-{
-}
+ /*
+ * If there is a base image to place, load it
+ */
+ if (i)
+ {
+ w->ebits_object = ebits_load(i);
+ FREE(i);
-static void
-__ewl_seeker_mouse_down(Ewl_Widget * widget, Ewl_Callback * cb)
-{
- Ev_Mouse_Down * ev;
- int x, y, w, h;
+ if (w->ebits_object)
+ {
+ ebits_add_to_evas(w->ebits_object, w->evas);
+ ebits_set_layer(w->ebits_object,
+ EWL_OBJECT(w)->layer);
+ ebits_set_clip(w->ebits_object, w->fx_clip_box);
- CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("cb", cb);
+ ebits_show(w->ebits_object);
+ }
+ }
- ev = cb->func_data;
+ ewd_list_goto_first(EWL_CONTAINER(w)->children);
+ dragbar = ewd_list_current(EWL_CONTAINER(w)->children);
- __ewl_seeker_get_button_geometry(widget, &x, &y, &w, &h);
+ ewl_object_set_layer(EWL_OBJECT(dragbar), EWL_OBJECT(w)->layer + 1);
+ ewl_widget_theme_update(dragbar);
- if (ev->x >= x &&
- ev->y >= y &&
- x + w >= ev->x &&
- y + h >= ev->y)
- widget->state = widget->state | EWL_STATE_DND;
+ /*
+ * Finally configure the widget to update changes
+ */
+ ewl_widget_configure(w);
}
static void
-__ewl_seeker_mouse_up(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_mouse_move(Ewl_Widget * w, void *event_data, void *user_data)
{
- Ev_Mouse_Up * ev;
+ Ewl_Widget *dragbar;
- CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("cb", cb);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_PARAM_PTR("event_data", event_data);
- ev = cb->func_data;
+ ewd_list_goto_first(EWL_CONTAINER(w)->children);
+ dragbar = ewd_list_current(EWL_CONTAINER(w)->children);
- if (widget->state & EWL_STATE_DND)
- {
- widget->state = widget->state & !EWL_STATE_DND;
- }
+ ewl_callback_call_with_event_data(EWL_WIDGET(dragbar),
+ EWL_CALLBACK_MOUSE_MOVE, event_data);
}
+/*
+ * Move the cursor to the correct position
+ */
static void
-__ewl_seeker_mouse_move(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_dragbar_mouse_move(Ewl_Widget * w, void *event_data,
+ void *user_data)
{
- float play;
- int value;
- Ev_Mouse_Move * ev;
+ Ewl_Widget *parent;
+ Ev_Mouse_Move *ev;
+
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_PARAM_PTR("event_data", event_data);
- CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("cb", cb);
+ ev = event_data;
- ev = cb->func_data;
+ /*
+ * If the pointer is not pressed we don't care about mouse movements.
+ */
+ if (!(w->state & EWL_STATE_PRESSED))
+ DRETURN;
- if (widget->state & EWL_STATE_DND)
+ parent = EWL_WIDGET(w)->parent;
+
+ /*
+ * The direction of the dragbar move depends on the orientation of the
+ * parent seeker.
+ */
+ if (EWL_SEEKER(parent)->orientation == EWL_ORIENTATION_HORIZONTAL)
{
- if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_HORISONTAL)
- {
- play = ((float) ev->x - EWL_OBJECT(widget)->current.x) /
- EWL_OBJECT(widget)->current.w;
- value = EWL_SEEKER(widget)->range * play;
- ewl_seeker_set_value(widget, value);
- }
- else if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_VERTICAL)
+ if (user_data != NULL)
{
- play = ((float) ev->y - EWL_OBJECT(widget)->current.y) /
- EWL_OBJECT(widget)->current.h;
- play = 1.00 - play;
- value = EWL_SEEKER(widget)->range * play;
- ewl_seeker_set_value(widget, value);
+ printf("%i\n", user_data);
}
}
+ else
+ {
+
+ }
+
+ ewl_widget_theme_update(parent);
+
+ DLEAVE_FUNCTION;
}
+/*
+ * Catch a mouse down event and act on it accordingly
+ */
static void
-__ewl_seeker_focus_in(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_mouse_down(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ Ewl_Seeker *s;
+ Ewl_Widget *dragbar;
+
+ Ev_Mouse_Move *ev = (Ev_Mouse_Move *) event_data;
+ int x, y, width, height;
+ int tmp;
+
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_PARAM_PTR("event_data", event_data);
+
+ w->state |= EWL_STATE_PRESSED;
+ s = EWL_SEEKER(w);
+
+ ewd_list_goto_first(EWL_CONTAINER(w)->children);
+ dragbar = ewd_list_current(EWL_CONTAINER(w)->children);
+ ewl_object_get_current_geometry(EWL_OBJECT(dragbar), &x, &y,
+ &width, &height);
+
+ /*
+ * A click occurred on the dragbar, so we need to increment
+ * the value by the jump amount.
+ */
+ if (EWL_SEEKER(w)->orientation == EWL_ORIENTATION_HORIZONTAL)
+ {
+ if (ev->x > x + width)
+ {
+ tmp = ev->x - (x + width);
+ ewl_callback_set_user_data(dragbar,
+ EWL_CALLBACK_MOUSE_MOVE,
+ __ewl_seeker_dragbar_mouse_move,
+ (void *) tmp);
+ }
+ }
+ else
+ {
+ if (ev->y > y + height)
+ {
+ tmp = ev->y - (y + height);
+ ewl_callback_set_user_data(dragbar,
+ EWL_CALLBACK_MOUSE_MOVE,
+ __ewl_seeker_dragbar_mouse_move,
+ (void *) tmp);
+ }
+ }
+
+ ewl_widget_theme_update(w);
+
+ DLEAVE_FUNCTION;
}
static void
-__ewl_seeker_focus_out(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_seeker_mouse_up(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ Ewl_Widget * dragbar;
+
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_PARAM_PTR("event_data", event_data);
+
+ w->state &= ~EWL_STATE_PRESSED;
+
+ ewd_list_goto_first(EWL_CONTAINER(w)->children);
+ dragbar = ewd_list_current(EWL_CONTAINER(w)->children);
+
+ ewl_callback_set_user_data(dragbar,
+ EWL_CALLBACK_MOUSE_MOVE,
+ __ewl_seeker_dragbar_mouse_move,
+ NULL);
+
+ DLEAVE_FUNCTION;
}
static void
-__ewl_seeker_get_button_geometry(Ewl_Widget * widget,
- int * x,
- int * y,
- int * w,
- int * h)
+__ewl_seeker_focus_in(Ewl_Widget * w, void *event_data, void *user_data)
{
- int l = 0, r = 0, t = 0, b = 0;
- float play = 0;
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- CHECK_PARAM_POINTER("widget", widget);
+ ewl_widget_theme_update(w);
- ebits_get_insets(EWL_SEEKER(widget)->ebits_bg, &l, &r, &t, &b);
+ DLEAVE_FUNCTION;
+}
- *x = EWL_OBJECT(widget)->current.x + l;
- *y = EWL_OBJECT(widget)->current.y + t;
+static void
+__ewl_seeker_focus_out(Ewl_Widget * w, void *event_data, void *user_data)
+{
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- play = ((float) EWL_SEEKER(widget)->value /
- (float) EWL_SEEKER(widget)->range);
+ ewl_widget_theme_update(w);
- if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_HORISONTAL)
- {
- *w = 25;
- *h = EWL_OBJECT(widget)->current.h - (t+b);
- *x += ((EWL_OBJECT(widget)->current.w - (l + r) - 25) * play);
- }
- else if (EWL_SEEKER(widget)->orientation == EWL_ORIENTATION_VERTICAL)
- {
- *w = EWL_OBJECT(widget)->current.w - (l+r);
- *h = 25;
- *y += ((EWL_OBJECT(widget)->current.h - (t + b) - 25) * (1.000 - play));
- }
+ DLEAVE_FUNCTION;
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_seeker.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ewl_seeker.h 2001/05/01 04:00:38 1.1
+++ ewl_seeker.h 2001/07/20 07:31:54 1.2
@@ -1,29 +1,26 @@
-#ifndef __EWL_SEEKER_H
-#define __EWL_SEEKER_H
+#ifndef __EWL_SEEKER_H__
+#define __EWL_SEEKER_H__
-struct _ewl_seeker {
- Ewl_Widget widget;
- Ewl_Orientation orientation;
- Ebits_Object ebits_bg;
- Ebits_Object ebits_dragbar;
- unsigned int value;
- unsigned int range;
- int start_drag;
-};
-
typedef struct _ewl_seeker Ewl_Seeker;
-
#define EWL_SEEKER(seeker) ((Ewl_Seeker *) seeker)
+
+struct _ewl_seeker
+{
+ Ewl_Container container;
+ Ewl_Orientation orientation;
+ double value;
+ double range;
+ double jump;
+};
+
+Ewl_Widget *ewl_seeker_new(Ewl_Orientation orientation);
+#define ewl_vseeker_new() ewl_seeker_new(EWL_ORIENTATION_VERTICAL);
+#define ewl_hseeker_new() ewl_seeker_new(EWL_ORIENTATION_HORIZONTAL);
-Ewl_Widget * ewl_hseeker_new(void);
-Ewl_Widget * ewl_vseeker_new(void);
-Ewl_Widget * ewl_seeker_new_all(Ewl_Orientation orientation, int range);
-void ewl_seeker_set_value(Ewl_Widget * widget, int value);
-int ewl_seeker_get_value(Ewl_Widget * widget);
-void ewl_seeker_set_range(Ewl_Widget * widget, int range);
-int ewl_seeker_get_range(Ewl_Widget * widget);
-void ewl_seeker_set_orientation(Ewl_Widget * widget,
- Ewl_Orientation orientation);
+void ewl_seeker_set_value(Ewl_Widget * w, double v);
+double ewl_seeker_get_value(Ewl_Widget * w);
+void ewl_seeker_set_range(Ewl_Widget * w, double r);
+double ewl_seeker_get_range(Ewl_Widget * w);
-#endif
+#endif /* __EWL_SEEKER_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_spinner.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_spinner.c 2001/05/02 23:12:42 1.3
+++ ewl_spinner.c 2001/07/20 07:31:54 1.4
@@ -2,25 +2,33 @@
#include <Ewl.h>
static void __ewl_spinner_init(Ewl_Spinner * spinner);
-static void __ewl_spinner_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_spinner_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_spinner_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_spinner_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_spinner_configure(Ewl_Widget * widget, Ewl_Callback * cb);
-static void __ewl_spinner_key_down(Ewl_Widget * widget, Ewl_Callback * cb);
-
-static void __ewl_spinner_set_value(Ewl_Widget * widget, double value);
-static double __ewl_spinner_get_value(Ewl_Widget * widget);
-static void __ewl_spinner_set_digits(Ewl_Widget * widget, int digits);
-static void __ewl_spinner_set_min_val(Ewl_Widget * widget, double val);
-static void __ewl_spinner_set_max_val(Ewl_Widget * widget, double val);
-static void __ewl_spinner_increase_value(Ewl_Widget * widget,Ewl_Callback * cb);
-static void __ewl_spinner_decrease_value(Ewl_Widget * widget,Ewl_Callback * cb);
+static void __ewl_spinner_realize(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_spinner_show(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_spinner_hide(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_spinner_destroy(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_spinner_configure(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void __ewl_spinner_key_down(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+
+static void __ewl_spinner_set_value(Ewl_Widget * widget, double value);
+static double __ewl_spinner_get_value(Ewl_Widget * widget);
+static void __ewl_spinner_set_digits(Ewl_Widget * widget, int digits);
+static void __ewl_spinner_set_min_val(Ewl_Widget * widget, double val);
+static void __ewl_spinner_set_max_val(Ewl_Widget * widget, double val);
+static void __ewl_spinner_increase_value(Ewl_Widget * widget,
+ void *event_data, void *user_data);
+static void __ewl_spinner_decrease_value(Ewl_Widget * widget,
+ void *event_data, void *user_data);
Ewl_Widget *
ewl_spinner_new()
{
- Ewl_Spinner * spinner = NULL;
+ Ewl_Spinner *spinner = NULL;
spinner = NEW(Ewl_Spinner, 1);
@@ -82,90 +90,83 @@
CHECK_PARAM_POINTER("spinner", spinner);
memset(spinner, 0, sizeof(Ewl_Spinner));
+ ewl_widget_init(EWL_WIDGET(spinner), EWL_WIDGET_SPINNER, 100, 15,
+ 400, 15);
- EWL_WIDGET(spinner)->container.recursive = TRUE;
- EWL_WIDGET(spinner)->type = EWL_WIDGET_SPINNER;
-
- ewl_callback_append(EWL_WIDGET(spinner),
- EWL_CALLBACK_REALIZE, __ewl_spinner_realize, NULL);
- ewl_callback_append(EWL_WIDGET(spinner),
- EWL_CALLBACK_SHOW, __ewl_spinner_show, NULL);
- ewl_callback_append(EWL_WIDGET(spinner),
- EWL_CALLBACK_HIDE, __ewl_spinner_hide, NULL);
- ewl_callback_append(EWL_WIDGET(spinner),
- EWL_CALLBACK_DESTROY, __ewl_spinner_destroy, NULL);
ewl_callback_append(EWL_WIDGET(spinner),
- EWL_CALLBACK_CONFIGURE, __ewl_spinner_configure, NULL);
+ EWL_CALLBACK_REALIZE, __ewl_spinner_realize,
+ NULL);
+ ewl_callback_append(EWL_WIDGET(spinner), EWL_CALLBACK_SHOW,
+ __ewl_spinner_show, NULL);
+ ewl_callback_append(EWL_WIDGET(spinner), EWL_CALLBACK_HIDE,
+ __ewl_spinner_hide, NULL);
+ ewl_callback_append(EWL_WIDGET(spinner), EWL_CALLBACK_DESTROY,
+ __ewl_spinner_destroy, NULL);
+ ewl_callback_append(EWL_WIDGET(spinner), EWL_CALLBACK_CONFIGURE,
+ __ewl_spinner_configure, NULL);
spinner->min_val = -50.000;
- spinner->max_val = 50.000;
- spinner->value = 0.000;
- spinner->digits = 2;
+ spinner->max_val = 50.000;
+ spinner->value = 0.000;
+ spinner->digits = 2;
- EWL_OBJECT(spinner)->current.w = 150;
- EWL_OBJECT(spinner)->current.h = 15;
- EWL_OBJECT(spinner)->maximum.w = 400;
- EWL_OBJECT(spinner)->maximum.h = 15;
- EWL_OBJECT(spinner)->minimum.w = 100;
- EWL_OBJECT(spinner)->minimum.h = 15;
- EWL_OBJECT(spinner)->request.w = 150;
- EWL_OBJECT(spinner)->request.h = 15;
}
static void
-__ewl_spinner_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_spinner_realize(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ewl_Widget * entry, * button_increase, * button_decrease;
+ Ewl_Widget *entry, *button_increase, *button_decrease;
CHECK_PARAM_POINTER("widget", widget);
- ewl_fx_clip_box_create(widget);
+ ewl_fx_clip_box_create(widget);
- widget->container.clip_box = widget->fx_clip_box;
- evas_set_clip(widget->evas, widget->fx_clip_box,
- widget->parent->container.clip_box);
+ EWL_CONTAINER(widget)->clip_box = widget->fx_clip_box;
+ evas_set_clip(widget->evas, widget->fx_clip_box,
+ EWL_CONTAINER(widget->parent)->clip_box);
- evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
+ evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
- widget->container.children = ewd_list_new();
+ EWL_CONTAINER(widget)->children = ewd_list_new();
entry = ewl_entry_new();
- ewl_container_append_child(widget, entry);
+ ewl_container_append_child(EWL_CONTAINER(widget), entry);
ewl_callback_append(entry, EWL_CALLBACK_KEY_DOWN,
- __ewl_spinner_key_down, NULL);
+ __ewl_spinner_key_down, NULL);
ewl_widget_realize(entry);
- button_increase = ewl_button_new();
- ewl_container_append_child(widget, button_increase);
+ button_increase = ewl_button_new(NULL);
+ ewl_container_append_child(EWL_CONTAINER(widget), button_increase);
EWL_OBJECT(button_increase)->minimum.w = 10;
EWL_OBJECT(button_increase)->minimum.h = 10;
ewl_callback_append(button_increase, EWL_CALLBACK_CLICKED,
- __ewl_spinner_increase_value, widget);
+ __ewl_spinner_increase_value, widget);
ewl_callback_append(button_increase, EWL_CALLBACK_KEY_DOWN,
- __ewl_spinner_key_down, NULL);
+ __ewl_spinner_key_down, NULL);
ewl_widget_realize(button_increase);
- button_decrease = ewl_button_new();
- ewl_container_append_child(widget, button_decrease);
+ button_decrease = ewl_button_new(NULL);
+ ewl_container_append_child(EWL_CONTAINER(widget), button_decrease);
EWL_OBJECT(button_decrease)->minimum.w = 10;
EWL_OBJECT(button_decrease)->minimum.h = 10;
ewl_callback_append(button_decrease, EWL_CALLBACK_CLICKED,
- __ewl_spinner_decrease_value, widget);
+ __ewl_spinner_decrease_value, widget);
ewl_callback_append(button_decrease, EWL_CALLBACK_KEY_DOWN,
- __ewl_spinner_key_down, NULL);
+ __ewl_spinner_key_down, NULL);
ewl_widget_realize(button_decrease);
}
static void
-__ewl_spinner_show(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_spinner_show(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ewl_Widget * child = NULL;
+ Ewl_Widget *child = NULL;
CHECK_PARAM_POINTER("widget", widget);
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
- while ((child = ewd_list_next(widget->container.children)) != NULL)
+ while ((child =
+ ewd_list_next(EWL_CONTAINER(widget)->children)) != NULL)
ewl_widget_show(child);
evas_show(widget->evas, widget->fx_clip_box);
@@ -174,7 +175,7 @@
}
static void
-__ewl_spinner_hide(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_spinner_hide(Ewl_Widget * widget, void *event_data, void *user_data)
{
CHECK_PARAM_POINTER("widget", widget);
@@ -182,7 +183,7 @@
}
static void
-__ewl_spinner_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_spinner_destroy(Ewl_Widget * widget, void *event_data, void *user_data)
{
CHECK_PARAM_POINTER("widget", widget);
@@ -194,42 +195,52 @@
evas_unset_clip(widget->evas, widget->fx_clip_box);
evas_del_object(widget->evas, widget->fx_clip_box);
+ ewl_callback_del_all(widget);
+
+ ewl_theme_deinit_widget(widget);
+
FREE(widget);
}
static void
-__ewl_spinner_configure(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_spinner_configure(Ewl_Widget * widget, void *event_data,
+ void *user_data)
{
- Ewl_Widget * child;
+ Ewl_Widget *child;
int x = 0, y = 0, w = 50;
CHECK_PARAM_POINTER("widget", widget);
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
- while ((child = ewd_list_next(widget->container.children)) != NULL)
+ while ((child =
+ ewd_list_next(EWL_CONTAINER(widget)->children)) != NULL)
{
- if (child->type == EWL_WIDGET_ENTRY)
- {
- EWL_OBJECT(child)->request.x = EWL_OBJECT(widget)->request.x;
- EWL_OBJECT(child)->request.y = EWL_OBJECT(widget)->request.y;
- EWL_OBJECT(child)->request.w = EWL_OBJECT(widget)->request.w - 12;
- ewl_widget_configure(child);
- x = EWL_OBJECT(widget)->request.x + EWL_OBJECT(child)->current.w +2;
- y = EWL_OBJECT(widget)->request.y;
- w = EWL_OBJECT(child)->current.w;
- }
- else if (child->type == EWL_WIDGET_BUTTON)
- {
- EWL_OBJECT(child)->request.x = x;
- EWL_OBJECT(child)->request.y = y;
- EWL_OBJECT(child)->custom.w = 10;
- EWL_OBJECT(child)->custom.h = 10;
- if (y == EWL_OBJECT(widget)->request.y)
- y += 10;
+ if (child->type == EWL_WIDGET_ENTRY)
+ {
+ EWL_OBJECT(child)->request.x =
+ EWL_OBJECT(widget)->request.x;
+ EWL_OBJECT(child)->request.y =
+ EWL_OBJECT(widget)->request.y;
+ EWL_OBJECT(child)->request.w =
+ EWL_OBJECT(widget)->request.w - 12;
+ ewl_widget_configure(child);
+ x = EWL_OBJECT(widget)->request.x +
+ EWL_OBJECT(child)->current.w + 2;
+ y = EWL_OBJECT(widget)->request.y;
+ w = EWL_OBJECT(child)->current.w;
+ }
+ else if (child->type == EWL_WIDGET_BUTTON)
+ {
+ EWL_OBJECT(child)->request.x = x;
+ EWL_OBJECT(child)->request.y = y;
+ EWL_OBJECT(child)->custom.w = 10;
+ EWL_OBJECT(child)->custom.h = 10;
+ if (y == EWL_OBJECT(widget)->request.y)
+ y += 10;
- ewl_widget_configure(child);
- }
+ ewl_widget_configure(child);
+ }
}
@@ -244,27 +255,26 @@
}
static void
-__ewl_spinner_key_down(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_spinner_key_down(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ev_Key_Down * ev;
+ Ev_Key_Down *ev;
CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("cb", cb);
- ev = cb->func_data;
+ ev = (Ev_Key_Down *) event_data;
if (!strcmp(ev->key, "Up"))
- __ewl_spinner_increase_value(widget, NULL);
+ __ewl_spinner_increase_value(widget, NULL, NULL);
else if (!strcmp(ev->key, "Down"))
- __ewl_spinner_decrease_value(widget, NULL);
+ __ewl_spinner_decrease_value(widget, NULL, NULL);
}
static void
__ewl_spinner_set_value(Ewl_Widget * widget, double value)
{
- Ewl_Widget * entry;
- char * format;
- char * str;
+ Ewl_Widget *entry;
+ char *format;
+ char *str;
CHECK_PARAM_POINTER("widget", widget);
@@ -280,7 +290,8 @@
str = malloc(64);
snprintf(str, 64, format, EWL_SPINNER(widget)->value);
- entry = widget->container.children->first->data;
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
+ entry = ewd_list_current(EWL_CONTAINER(widget)->children);
ewl_entry_set_text(entry, str);
@@ -327,7 +338,8 @@
}
static void
-__ewl_spinner_increase_value(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_spinner_increase_value(Ewl_Widget * widget, void *event_data,
+ void *user_data)
{
double val;
@@ -350,32 +362,35 @@
else
val = 0.0000001;
- __ewl_spinner_set_value(widget->parent, EWL_SPINNER(widget->parent)->value + val);
+ __ewl_spinner_set_value(widget->parent,
+ EWL_SPINNER(widget->parent)->value + val);
}
static void
-__ewl_spinner_decrease_value(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_spinner_decrease_value(Ewl_Widget * widget, void *event_data,
+ void *user_data)
{
double val;
CHECK_PARAM_POINTER("widget", widget);
- if (!EWL_SPINNER(widget->parent)->digits)
- val = 1.0;
- else if (EWL_SPINNER(widget->parent)->digits == 1)
- val = 0.1;
- else if (EWL_SPINNER(widget->parent)->digits == 2)
- val = 0.01;
- else if (EWL_SPINNER(widget->parent)->digits == 3)
- val = 0.001;
- else if (EWL_SPINNER(widget->parent)->digits == 4)
- val = 0.0001;
- else if (EWL_SPINNER(widget->parent)->digits == 5)
- val = 0.00001;
- else if (EWL_SPINNER(widget->parent)->digits == 6)
- val = 0.000001;
- else
- val = 0.0000001;
+ if (!EWL_SPINNER(widget->parent)->digits)
+ val = 1.0;
+ else if (EWL_SPINNER(widget->parent)->digits == 1)
+ val = 0.1;
+ else if (EWL_SPINNER(widget->parent)->digits == 2)
+ val = 0.01;
+ else if (EWL_SPINNER(widget->parent)->digits == 3)
+ val = 0.001;
+ else if (EWL_SPINNER(widget->parent)->digits == 4)
+ val = 0.0001;
+ else if (EWL_SPINNER(widget->parent)->digits == 5)
+ val = 0.00001;
+ else if (EWL_SPINNER(widget->parent)->digits == 6)
+ val = 0.000001;
+ else
+ val = 0.0000001;
- __ewl_spinner_set_value(widget->parent, EWL_SPINNER(widget->parent)->value - val);
+ __ewl_spinner_set_value(widget->parent,
+ EWL_SPINNER(widget->parent)->value - val);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_spinner.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ewl_spinner.h 2001/05/01 04:00:38 1.1
+++ ewl_spinner.h 2001/07/20 07:31:54 1.2
@@ -2,10 +2,11 @@
#ifndef __EWL_SPINNER_H
#define __EWL_SPINNER_H
-struct _ewl_spinner {
+struct _ewl_spinner
+{
Ewl_Widget widget;
- Ewl_Widget * entry;
- Ewl_Widget * button_increase, * button_decrease;
+ Ewl_Widget *entry;
+ Ewl_Widget *button_increase, *button_decrease;
double min_val;
double max_val;
double value;
@@ -16,11 +17,11 @@
#define EWL_SPINNER(spinner) ((Ewl_Spinner *) spinner)
-Ewl_Widget * ewl_spinner_new();
-void ewl_spinner_set_value(Ewl_Widget * widget, double value);
-double ewl_spinner_get_value(Ewl_Widget * widget);
-void ewl_spinner_set_digits(Ewl_Widget * widget, int digits);
-void ewl_spinner_set_min_val(Ewl_Widget * widget, double val);
-void ewl_spinner_set_max_val(Ewl_Widget * widget, double val);
+Ewl_Widget *ewl_spinner_new();
+void ewl_spinner_set_value(Ewl_Widget * widget, double value);
+double ewl_spinner_get_value(Ewl_Widget * widget);
+void ewl_spinner_set_digits(Ewl_Widget * widget, int digits);
+void ewl_spinner_set_min_val(Ewl_Widget * widget, double val);
+void ewl_spinner_set_max_val(Ewl_Widget * widget, double val);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_table.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_table.c 2001/05/02 23:12:42 1.5
+++ ewl_table.c 2001/07/20 07:31:54 1.6
@@ -1,517 +1,839 @@
-
#include <Ewl.h>
-static void ewl_table_init(Ewl_Table * table);
-
-
-static void ewl_table_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_table_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_table_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_table_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_table_configure(Ewl_Widget * widget, Ewl_Callback * cb);
+static void __ewl_table_init(Ewl_Table * t);
+static void __ewl_table_realize(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_table_show(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_table_hide(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_table_destroy(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_table_destroy_recursive(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_table_configure(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_table_theme_update(Ewl_Widget * w, void *event_data,
+ void *user_data);
+
+/* make the configure callback smaller by spliting up big stuff into
+ * small functions... */
+static void __ewl_table_configure_gfx(Ewl_Widget * w);
+static void __ewl_table_configure_children(Ewl_Widget * w);
+Ewd_List *__ewl_table_fill_normal(Ewl_Widget * w, int *rem_w, int *rem_h);
+void __ewl_table_fill_fillers(Ewl_Widget * w,
+ int rem_w, int rem_h, Ewd_List * l);
+static void __ewl_table_layout_children(Ewl_Table * w);
-
Ewl_Widget *
-ewl_table_new()
+ewl_table_new(unsigned int columns, unsigned int rows)
{
- Ewl_Table * table = NULL;
-
- table = NEW(Ewl_Table, 1);
-
- ewl_table_init(table);
-
- return EWL_WIDGET(table);
+ return ewl_table_new_all(columns, rows, FALSE, 2, 2);
}
Ewl_Widget *
ewl_table_new_all(unsigned int homogeneous,
- unsigned int columns,
- unsigned int rows,
- unsigned int col_spacing,
- unsigned int row_spacing)
-{
- Ewl_Table * table = NULL;
-
- table = EWL_TABLE(ewl_table_new());
-
- table->homogeneous = homogeneous;
- table->columns = columns;
- table->rows = rows;
- table->col_spacing = col_spacing;
- table->row_spacing = row_spacing;
- table->alignment = EWL_ALIGNMENT_CENTER;
- table->col_w = NEW(int *, columns);
- table->row_h = NEW(int *, rows);
+ unsigned int columns,
+ unsigned int rows,
+ unsigned int col_spacing, unsigned int row_spacing)
+{
+ Ewl_Table *t;
- return EWL_WIDGET(table);
-}
+ t = NEW(Ewl_Table, 1);
-static void
-ewl_table_init(Ewl_Table * table)
-{
- CHECK_PARAM_POINTER("table", table);
+ __ewl_table_init(t);
+
+ t->columns = columns;
+ t->rows = rows;
+ t->homogeneous = homogeneous;
+ t->col_spacing = col_spacing;
+ t->row_spacing = row_spacing;
- memset(table, 0, sizeof(Ewl_Table));
+ t->col_w = NEW(int, columns);
+ memset(t->col_w, 0, columns * sizeof(int));
- EWL_WIDGET(table)->container.recursive = TRUE;
- EWL_WIDGET(table)->type = EWL_WIDGET_TABLE;
+ t->custom_col_w = NEW(int, columns);
+ memset(t->custom_col_w, 0, columns * sizeof(int));
- table->columns = 0;
- table->rows = 0;
- table->homogeneous = 0;
- table->col_spacing = 2;
- table->row_spacing = 2;
+ t->row_h = NEW(int, rows);
+ memset(t->row_h, 0, rows * sizeof(int));
- ewl_callback_append(EWL_WIDGET(table), EWL_CALLBACK_REALIZE,
- ewl_table_realize, NULL);
- ewl_callback_append(EWL_WIDGET(table), EWL_CALLBACK_SHOW,
- ewl_table_show, NULL);
- ewl_callback_append(EWL_WIDGET(table), EWL_CALLBACK_HIDE,
- ewl_table_hide, NULL);
- ewl_callback_append(EWL_WIDGET(table), EWL_CALLBACK_DESTROY,
- ewl_table_destroy, NULL);
- ewl_callback_append(EWL_WIDGET(table), EWL_CALLBACK_CONFIGURE,
- ewl_table_configure, NULL);
+ return EWL_WIDGET(t);
+}
+
+void
+ewl_table_attach(Ewl_Widget * t, Ewl_Widget * c, Ewl_Alignment alignment,
+ Ewl_Fill_Policy fill_policy, unsigned int start_col,
+ unsigned int end_col, unsigned int start_row,
+ unsigned int end_row)
+{
+ int layer;
+ Ewl_Table_Child *child;
+
+ CHECK_PARAM_POINTER("t", t);
+ CHECK_PARAM_POINTER("c", c);
+
+ child = NEW(Ewl_Table_Child, 1);
+ memset(child, 0, sizeof(Ewl_Table_Child));
+
+ child->widget = c;
+ child->alignment = alignment;
+ child->fill_policy = fill_policy;
+ child->start_col = start_col - 1;
+ child->end_col = end_col - 1;
+ child->start_row = start_row - 1;
+ child->end_row = end_row - 1;
+
+ if (!EWL_CONTAINER(t)->children)
+ EWL_CONTAINER(t)->children = ewd_list_new();
+
+ c->parent = t;
+ c->evas = t->evas;
+ c->evas_window = t->evas_window;
+ layer = ewl_object_get_layer(EWL_OBJECT(t));
+ ewl_object_set_layer(EWL_OBJECT(t), layer + 1);
- EWL_OBJECT(table)->current.w = 100;
- EWL_OBJECT(table)->current.h = 50;
- EWL_OBJECT(table)->maximum.w = 2048;
- EWL_OBJECT(table)->maximum.h = 2048;
- EWL_OBJECT(table)->minimum.w = 1;
- EWL_OBJECT(table)->minimum.h = 1;
- EWL_OBJECT(table)->request.w = 100;
- EWL_OBJECT(table)->request.h = 50;
+ ewd_list_append(EWL_CONTAINER(t)->children, child);
}
void
-ewl_table_resize(Ewl_Widget * widget,
- unsigned int rows,
- unsigned int columns)
+ewl_table_detach(Ewl_Widget * t, unsigned int c, unsigned int r)
{
- CHECK_PARAM_POINTER("widget", widget);
+ Ewl_Table_Child *child;
- if (columns != EWL_TABLE(widget)->columns)
- EWL_TABLE(widget)->col_w = realloc(EWL_TABLE(widget)->col_w,
- sizeof(int *) * columns);
+ CHECK_PARAM_POINTER("t", t);
- if (rows != EWL_TABLE(widget)->rows)
- EWL_TABLE(widget)->row_h = realloc(EWL_TABLE(widget)->row_h,
- sizeof(int *) * rows);
+ if (!EWL_CONTAINER(t)->children ||
+ ewd_list_is_empty(EWL_CONTAINER(t)->children))
+ return;
+ ewd_list_goto_first(EWL_CONTAINER(t)->children);
- EWL_TABLE(widget)->rows = rows;
- EWL_TABLE(widget)->columns = columns;
+ while ((child = ewd_list_next(EWL_CONTAINER(t)->children)) != NULL)
+ {
+ if (child->start_col + 1 <= c &&
+ child->end_col + 1 >= c &&
+ child->start_row <= r && child->end_row >= r)
+ {
+ ewd_list_remove(EWL_CONTAINER(t)->children);
+ FREE(child);
+ break;
+ }
+ }
}
void
-ewl_table_attach(Ewl_Widget * table,
- Ewl_Widget * child,
- unsigned int start_col,
- unsigned int end_col,
- unsigned int start_row,
- unsigned int end_row)
+ewl_table_resize(Ewl_Widget * t, unsigned int c, unsigned int r)
{
- Ewl_Table_Child * tb_child = NULL;
+ CHECK_PARAM_POINTER("t", t);
- CHECK_PARAM_POINTER("table", table);
- CHECK_PARAM_POINTER("child", child);
- tb_child = NEW(Ewl_Table_Child, 1);
- memset(tb_child, 0, sizeof(Ewl_Table_Child));
+ EWL_TABLE(t)->columns = c;
+ EWL_TABLE(t)->rows = r;
- tb_child->child = child;
- child->evas = table->evas;
- child->evas_window = table->evas_window;
- child->parent = EWL_WIDGET(table);
- child->object.layer = table->object.layer +10;
- tb_child->start_col = start_col -1;
- tb_child->end_col = end_col -1;
- tb_child->start_row = start_row -1;
- tb_child->end_row = end_row -1;
+ REALLOC(EWL_TABLE(t)->custom_col_w, int, c);
+}
- if (!table->container.children)
- ewl_container_new(table);
+unsigned int
+ewl_table_get_columns(Ewl_Widget * t)
+{
+ CHECK_PARAM_POINTER_RETURN("t", t, 0);
- if (ewd_list_is_empty(table->container.children)) {
- ewl_container_show_clip(table);
- ewl_container_set_clip(table);
- }
+ return EWL_TABLE(t)->columns;
+}
- ewd_list_goto_index(table->container.children, start_row + start_col);
- ewd_list_insert(table->container.children, tb_child);
+unsigned int
+ewl_table_get_rows(Ewl_Widget * t)
+{
+ CHECK_PARAM_POINTER_RETURN("t", t, 0);
- if (table->parent)
- ewl_widget_configure(table->parent);
+ return EWL_TABLE(t)->rows;
}
void
-ewl_table_detach(Ewl_Widget * table,
- unsigned int start_row,
- unsigned int start_col)
+ewl_table_set_homogeneous(Ewl_Widget * t, unsigned int h)
{
- CHECK_PARAM_POINTER("table", table);
-
-
+ CHECK_PARAM_POINTER("t", t);
+
+ EWL_TABLE(t)->homogeneous = h;
+
+ ewl_widget_configure(t);
}
void
-ewl_table_set_homogeneous(Ewl_Widget * widget,
- unsigned int homogeneous)
+ewl_table_set_col_spacing(Ewl_Widget * t, unsigned int cs)
{
- CHECK_PARAM_POINTER("widget", widget);
+ CHECK_PARAM_POINTER("t", t);
- EWL_TABLE(widget)->homogeneous = homogeneous;
+ EWL_TABLE(t)->col_spacing = cs;
- ewl_widget_configure(widget);
- ewl_widget_configure(widget->parent);
+ ewl_widget_configure(t);
}
void
-ewl_table_set_col_spacing(Ewl_Widget * widget,
- unsigned int col_spacing)
+ewl_table_set_row_spacing(Ewl_Widget * t, unsigned int rs)
{
- CHECK_PARAM_POINTER("widget", widget);
+ CHECK_PARAM_POINTER("t", t);
- EWL_TABLE(widget)->col_spacing = col_spacing;
+ EWL_TABLE(t)->row_spacing = rs;
- ewl_widget_configure(widget);
- ewl_widget_configure(widget->parent);
+ ewl_widget_configure(t);
}
void
-ewl_table_set_row_spacing(Ewl_Widget * widget,
- unsigned int row_spacing)
+ewl_table_set_alignment(Ewl_Widget * t, Ewl_Alignment a)
{
- CHECK_PARAM_POINTER("widget", widget);
+ CHECK_PARAM_POINTER("t", t);
- EWL_TABLE(widget)->row_spacing = row_spacing;
-
- ewl_widget_configure(widget);
- ewl_widget_configure(widget->parent);
+ EWL_TABLE(t)->alignment = a;
}
+/*
+ * Set the width of the specified column
+ */
void
-ewl_table_set_alignment(Ewl_Widget * table, Ewl_Alignment alignment)
+ewl_table_column_set_width(Ewl_Widget * t, unsigned int c, unsigned int w)
{
- CHECK_PARAM_POINTER("table", table);
+ CHECK_PARAM_POINTER("t", t);
- if (EWL_TABLE(table)->alignment == alignment)
- return;
+ EWL_TABLE(t)->custom_col_w[c - 1] = w;
+
+ ewl_widget_configure(t);
+}
- EWL_TABLE(table)->alignment = alignment;
- ewl_widget_configure(table);
+/*
+ * Get the width of the specified column
+ */
+void
+ewl_table_get_column_width(Ewl_Widget * t, unsigned int c, unsigned int *w)
+{
+ CHECK_PARAM_POINTER("t", t);
+
+ if (EWL_TABLE(t)->col_w[c - 1])
+ *w = EWL_TABLE(t)->col_w[c - 1];
}
+/*
+ * Set the alignment of the child at the specified row and column
+ */
void
-ewl_table_get_col_width(Ewl_Widget * table, int col_num, int * w)
+ewl_table_child_set_alignment(Ewl_Widget * t,
+ unsigned int c, unsigned int r, Ewl_Alignment a)
{
- CHECK_PARAM_POINTER("table", table);
+ Ewl_Table_Child *child;
- if (col_num > EWL_TABLE(table)->columns)
+ CHECK_PARAM_POINTER("t", t);
+
+ if (!EWL_CONTAINER(t)->children ||
+ ewd_list_is_empty(EWL_CONTAINER(t)->children))
return;
+
+ while ((child = ewd_list_next(EWL_CONTAINER(t)->children)) != NULL)
+ {
+ if (child->start_col + 1 <= c &&
+ child->end_col + 1 >= c &&
+ child->start_row <= r && child->end_row >= r)
+ {
+ child->alignment = a;
+ break;
+ }
+ }
+}
+
+/*
+ * Determine the alignment of the child at the specified row and column
+ */
+Ewl_Alignment
+ewl_table_child_get_alignment(Ewl_Widget * t, unsigned int c, unsigned int r)
+{
+ Ewl_Table_Child *child;
+
+ CHECK_PARAM_POINTER_RETURN("t", t, FALSE);
+
+ ewd_list_goto_first(EWL_CONTAINER(t)->children);
+
+ while ((child = ewd_list_next(EWL_CONTAINER(t)->children)) != NULL)
+ {
+ if (child->start_col <= c &&
+ child->end_col >= c && child->start_row <= r &&
+ child->end_row >= r)
+ return child->alignment;
+ }
- *w = EWL_TABLE(table)->col_w[col_num-1];
+ return FALSE;
}
+/*
+ * Get the child at the specified row and column
+ */
Ewl_Widget *
-ewl_table_get_child(Ewl_Widget * table, int row, int col)
+ewl_table_get_child(Ewl_Widget * t, unsigned int c, unsigned int r)
{
- Ewl_Table_Child * child;
+ Ewl_Table_Child *child;
- CHECK_PARAM_POINTER_RETURN("table", table, NULL);
+ CHECK_PARAM_POINTER_RETURN("t", t, NULL);
- ewd_list_goto_first(table->container.children);
+ ewd_list_goto_first(EWL_CONTAINER(t)->children);
- while ((child = ewd_list_next(table->container.children)) != NULL)
+ while ((child = ewd_list_next(EWL_CONTAINER(t)->children)) != NULL)
{
- if (child->start_row == row-1 && child->start_col == col-1)
- return child->child;
+ if (child->start_col <= c &&
+ child->end_col >= c && child->start_row <= r &&
+ child->end_row >= r)
+ return child->widget;
}
return NULL;
}
+/*
+ * Get the specified row's position and shape
+ */
void
-ewl_table_get_row_height(Ewl_Widget * table, int row_num, int * h)
+ewl_table_get_row_geometry(Ewl_Widget * t, unsigned int r, int *x, int *y,
+ int *w, int *h)
{
- CHECK_PARAM_POINTER("table", table);
+ CHECK_PARAM_POINTER("t", t);
- if (row_num > EWL_TABLE(table)->rows)
- return;
+ if (x);
+
+ if (y);
- *h = EWL_TABLE(table)->row_h[row_num-1];
+ if (w);
+
+ if (h);
}
-void
-ewl_table_get_row_geometry(Ewl_Widget * table, int row_num, int * x,
- int * y,int * w, int * h)
+/*
+ * Initialize the tables fields
+ */
+static void
+__ewl_table_init(Ewl_Table * t)
{
- int row, col;
- int l, r, t, b;
- CHECK_PARAM_POINTER("table", table);
+ CHECK_PARAM_POINTER("t", t);
- if (row_num > EWL_TABLE(table)->rows)
- return;
+ memset(t, 0, sizeof(Ewl_Table));
+ ewl_container_init(EWL_CONTAINER(t), EWL_WIDGET_TABLE, 1, 1, 2048,
+ 2048);
+
+ ewl_callback_append(EWL_WIDGET(t), EWL_CALLBACK_REALIZE,
+ __ewl_table_realize, NULL);
+ ewl_callback_append(EWL_WIDGET(t), EWL_CALLBACK_SHOW,
+ __ewl_table_show, NULL);
+ ewl_callback_append(EWL_WIDGET(t), EWL_CALLBACK_HIDE,
+ __ewl_table_hide, NULL);
+ ewl_callback_append(EWL_WIDGET(t), EWL_CALLBACK_DESTROY,
+ __ewl_table_destroy, NULL);
+ ewl_callback_append(EWL_WIDGET(t), EWL_CALLBACK_DESTROY_RECURSIVE,
+ __ewl_table_destroy_recursive, NULL);
+ ewl_callback_append(EWL_WIDGET(t), EWL_CALLBACK_CONFIGURE,
+ __ewl_table_configure, NULL);
+ ewl_callback_append(EWL_WIDGET(t), EWL_CALLBACK_THEME_UPDATE,
+ __ewl_table_theme_update, NULL);
- ebits_get_insets(EWL_TABLE(table)->ebits_object, &l, &r, &t, &b);
+}
- *x = EWL_OBJECT(table)->current.x + l;
- *y = EWL_OBJECT(table)->current.y + t;
- *w = 0;
- *h = 0;
+/*
+ * Draw the table
+ */
+static void
+__ewl_table_realize(Ewl_Widget * w, void *event_data, void *user_data)
+{
+ char *image = NULL;
- for(row=0;row<row_num-1;row++)
- {
- *y += EWL_TABLE(table)->row_h[row] + EWL_TABLE(table)->row_spacing;
- }
+ CHECK_PARAM_POINTER("w", w);
- for(col=0;col<EWL_TABLE(table)->columns;col++)
+ image = ewl_theme_image_get(w, "/appearance/table/default/base");
+
+ EWL_TABLE(w)->ebits_bg = ebits_load(image);
+ IF_FREE(image);
+
+ ebits_add_to_evas(EWL_TABLE(w)->ebits_bg, w->evas);
+ ebits_set_layer(EWL_TABLE(w)->ebits_bg, EWL_OBJECT(w)->layer);
+
+ ewl_fx_clip_box_create(w);
+ ewl_container_clip_box_create(EWL_CONTAINER(w));
+
+ ebits_show(EWL_TABLE(w)->ebits_bg);
+
+
+ if (w->parent && EWL_CONTAINER(w->parent)->clip_box)
{
- *w += EWL_TABLE(table)->col_w[col];
+ evas_set_clip(w->evas, w->fx_clip_box,
+ EWL_CONTAINER(w->parent)->clip_box);
+
}
+
+ ebits_set_clip(EWL_TABLE(w)->ebits_bg, w->fx_clip_box);
- *h = EWL_TABLE(table)->row_h[row_num -1];
+ evas_set_color(w->evas, w->fx_clip_box, 255, 255, 255, 255);
}
+/*
+ * Display the table
+ */
+static void
+__ewl_table_show(Ewl_Widget * w, void *event_data, void *user_data)
+{
+ CHECK_PARAM_POINTER("w", w);
+
+ evas_show(w->evas, w->fx_clip_box);
+}
-/* Internal functions */
+/*
+ * Hide the table
+ */
static void
-ewl_table_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_table_hide(Ewl_Widget * w, void *event_data, void *user_data)
{
- char * image = NULL;
+ CHECK_PARAM_POINTER("w", w);
- CHECK_PARAM_POINTER("widget", widget);
+ evas_hide(w->evas, w->fx_clip_box);
+}
- image = ewl_theme_ebit_get("table", "default", "base");
+/*
+ * Destroy the table, but don't destroy child widgets
+ */
+static void
+__ewl_table_destroy(Ewl_Widget * w, void *event_data, void *user_data)
+{
+ DENTER_FUNCTION;
+ CHECK_PARAM_POINTER("w", w);
- EWL_TABLE(widget)->ebits_object = ebits_load(image);
- IF_FREE(image);
- ebits_add_to_evas(EWL_TABLE(widget)->ebits_object, widget->evas);
- ebits_set_layer(EWL_TABLE(widget)->ebits_object, EWL_OBJECT(widget)->layer);
+ ebits_hide(EWL_TABLE(w)->ebits_bg);
+ ebits_unset_clip(EWL_TABLE(w)->ebits_bg);
+ ebits_free(EWL_TABLE(w)->ebits_bg);
+
+ if (w->fx_clip_box)
+ {
+ evas_hide(w->evas, w->fx_clip_box);
+ evas_unset_clip(w->evas, w->fx_clip_box);
+ evas_del_object(w->evas, w->fx_clip_box);
+ }
- ewl_fx_clip_box_create(widget);
-
- ebits_show(EWL_TABLE(widget)->ebits_object);
-
- if (widget->parent && widget->parent->container.clip_box)
- {
- evas_set_clip(widget->evas, widget->fx_clip_box,
- widget->parent->container.clip_box);
- ebits_set_clip(EWL_TABLE(widget)->ebits_object,
- widget->fx_clip_box);
- evas_set_clip(widget->evas, widget->container.clip_box,
- widget->fx_clip_box);
- }
-
- evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
+ if (EWL_CONTAINER(w)->clip_box)
+ {
+ evas_hide(w->evas, EWL_CONTAINER(w)->clip_box);
+ evas_unset_clip(w->evas, EWL_CONTAINER(w)->clip_box);
+ evas_del_object(w->evas, EWL_CONTAINER(w)->clip_box);
+ }
+
+ IF_FREE(EWL_TABLE(w)->col_w);
+ IF_FREE(EWL_TABLE(w)->row_h);
+ IF_FREE(EWL_TABLE(w)->custom_col_w);
+
+ ewl_callback_del_all(w);
+
+ ewl_theme_deinit_widget(w);
+
+ FREE(w);
+
+ DLEAVE_FUNCTION;
}
+/*
+ * Recursively destroy the table and it's children
+ */
static void
-ewl_table_show(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_table_destroy_recursive(Ewl_Widget * w, void *event_data,
+ void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ Ewl_Table_Child *child;
+
+ DENTER_FUNCTION;
+ CHECK_PARAM_POINTER("w", w);
- evas_show(widget->evas, widget->fx_clip_box);
+ if (!EWL_CONTAINER(w)->children)
+ DLEAVE_FUNCTION;
+
+ while ((child =
+ ewd_list_remove_last(EWL_CONTAINER(w)->children)) != NULL)
+ {
+ ewl_widget_destroy_recursive(child->widget);
+ FREE(child);
+ }
+
+ DLEAVE_FUNCTION;
}
+/*
+ * This callback configures the table and it's child widgets
+ */
static void
-ewl_table_hide(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_table_configure(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ __ewl_table_configure_children(w);
+ __ewl_table_configure_gfx(w);
+}
- evas_hide(widget->evas, widget->fx_clip_box);
+/*
+ * Configure the graphics of the table
+ */
+void
+__ewl_table_configure_gfx(Ewl_Widget * w)
+{
+ int t_req_x, t_req_y, t_req_w, t_req_h;
+
+ CHECK_PARAM_POINTER("w", w);
+
+ ewl_object_requested_geometry(EWL_OBJECT(w), &t_req_x, &t_req_y,
+ &t_req_w, &t_req_h);
+
+ ebits_move(EWL_TABLE(w)->ebits_bg, t_req_x, t_req_y);
+ ebits_resize(EWL_TABLE(w)->ebits_bg, t_req_w, t_req_h);
+ ewl_fx_clip_box_resize(w);
}
-static void
-ewl_table_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+/*
+ * Reassign sizes and positions to each of the child widgets
+ */
+void
+__ewl_table_configure_children(Ewl_Widget * w)
+{
+ int rem_w, rem_h;
+ Ewd_List *fillers;
+
+ CHECK_PARAM_POINTER("w", w);
+
+ /*
+ * Layout the normal children first, that returns a list of the filler
+ * children, which are then laid out.
+ */
+ fillers = __ewl_table_fill_normal(w, &rem_w, &rem_h);
+ if (fillers)
+ __ewl_table_fill_fillers(w, rem_w, rem_h, fillers);
+
+ __ewl_table_layout_children(EWL_TABLE(w));
+}
+
+/*
+ * Place the child into the table and modify the remaining widths and heights
+ * to indicate space used
+ */
+void
+__ewl_table_normal_span(Ewl_Table * w, Ewl_Table_Child * child, int *rem_w,
+ int *rem_h)
+{
+ int i;
+ int c_span = 1;
+ int r_span = 1;
+ int req_w, req_h;
+ int used_w = 0, used_h = 0;
+ int x, y;
+
+ ewl_object_requested_geometry(EWL_OBJECT
+ (child->widget),
+ &x, &y, &req_w, &req_h);
+ used_w += req_w;
+ used_h += req_h;
+
+ c_span += child->start_col - child->end_col;
+
+ /*
+ * Split up the size of the child between the col's
+ * it spans
+ */
+ for (i = child->start_col; i <= child->end_col; i++)
+ {
+ /*
+ * Only assign the column this width if another child doesn't
+ * need more.
+ */
+ if (req_w / c_span > w->col_w[i])
+ {
+ w->col_w[i] = req_w / c_span;
+ *rem_w -= (req_w / c_span) + w->col_spacing;
+ }
+ }
+
+ /*
+ * The child may have been shorted some of the width it needs, if so
+ * tack it on the end
+ */
+ if ((req_w % c_span) + (req_w / c_span) > w->col_w[i - 1])
+ {
+ w->col_w[i - 1] += req_w % c_span;
+ *rem_w -= req_w % c_span;
+ }
+
+ r_span += child->start_row - child->end_row;
+
+ /*
+ * Split up the size of the child between the row's it
+ * * spans
+ */
+ for (i = 0; i <= r_span; i++)
+ {
+ /*
+ * Only assign the row this height if another child doesn't
+ * need more.
+ */
+ if (req_h > w->row_h[i])
+ {
+ w->row_h[i] = req_h / r_span;
+ *rem_h -= (req_h / r_span) + w->row_spacing;
+ }
+ }
+
+ /*
+ * The child has been shorted some of the height it needs, so tack it
+ * on the end.
+ */
+ if ((req_w % r_span) + (req_h / r_span) > w->row_h[i - 1])
+ {
+ w->row_h[i - 1] += req_h % r_span;
+ *rem_h -= req_h % r_span;
+ }
+}
+
+/* Fill in the widgets that request their sizes normally and are not resized */
+Ewd_List *
+__ewl_table_fill_normal(Ewl_Widget * w, int *rem_w, int *rem_h)
+{
+ int x, y;
+ Ewd_List *fillers = NULL;
+ Ewl_Table_Child *child = NULL;
+
+ CHECK_PARAM_POINTER_RETURN("w", w, 0);
+
+ /*
+ * Grab the size so we know how much room we have to split the
+ * * children up into
+ */
+ ewl_object_requested_geometry(EWL_OBJECT(w), &x, &y, rem_w, rem_h);
+ *rem_w -= EWL_TABLE(w)->columns * EWL_TABLE(w)->col_spacing;
+ *rem_h -= EWL_TABLE(w)->rows * EWL_TABLE(w)->row_spacing;
+
+ ewd_list_goto_first(EWL_CONTAINER(w)->children);
+
+ /*
+ * Loop through and allocate the space for each normal child,
+ * * add any filler children to the list of fillers that will be
+ * * returned
+ */
+ while ((child = ewd_list_next(EWL_CONTAINER(w)->children)) != NULL)
+ {
+
+ /*
+ * Normal children are given their requested space, otherwise
+ * we add them to the list of children to assign the remaining
+ * space.
+ */
+ if (child->fill_policy == EWL_FILL_POLICY_NORMAL)
+ {
+ __ewl_table_normal_span(EWL_TABLE(w), child,
+ rem_w, rem_h);
+ }
+ else
+ {
+ if (!fillers)
+ fillers = ewd_list_new();
+ ewd_list_append(fillers, child);
+ }
+ }
+
+ return fillers;
+}
+
+/* Fill in widgets that are stretched to fill the column they occupy */
+void
+__ewl_table_fill_fillers(Ewl_Widget * w, int rem_w, int rem_h, Ewd_List * l)
{
- CHECK_PARAM_POINTER("widget", widget);
+ int total_cols = 0, total_rows = 0;
+ int num, r_size, c_size;
+ Ewl_Table_Child *child;
+
+ DENTER_FUNCTION;
+ CHECK_PARAM_POINTER("w", w);
+ CHECK_PARAM_POINTER("l", l);
+
+ /*
+ * Determine the number of rows and columns remaining
+ */
+ num = ewd_list_nodes(l);
+ ewd_list_goto_first(l);
+ for (child = ewd_list_next(l); child; child = ewd_list_next(l))
+ {
+ total_cols += child->end_col - child->start_col + 1;
+ total_rows += child->end_row - child->start_row + 1;
+ }
- ebits_hide(EWL_TABLE(widget)->ebits_object);
- ebits_unset_clip(EWL_TABLE(widget)->ebits_object);
- ebits_free(EWL_TABLE(widget)->ebits_object);
+ ewd_list_goto_first(l);
+ for (child = ewd_list_next(l); child; child = ewd_list_next(l))
+ {
+ int i, x, y, cols, rows, req_w, req_h;
- evas_hide(widget->evas, widget->fx_clip_box);
- evas_unset_clip(widget->evas, widget->fx_clip_box);
- evas_del_object(widget->evas, widget->fx_clip_box);
+ /*
+ * Determine the number of rows and columns this item uses
+ */
+ cols = child->end_col - child->start_col + 1;
+ rows = child->end_row - child->start_row + 1;
+ ewl_object_requested_geometry(EWL_OBJECT(child->widget),
+ &x, &y, &req_w, &req_h);
+
+ /*
+ * Now find the pixels each item will use
+ */
+ r_size = rem_h * (float) rows / (float) total_rows;
+ c_size = rem_w * (float) cols / (float) total_rows;
+
+ /*
+ * Loop through and assign the allocation of each row and column
+ */
+ for (i = child->start_row; i < child->end_row; i++)
+ {
+ int test;
+
+ test = req_w / cols;
+ if (test > EWL_TABLE(w)->col_w[i])
+ EWL_TABLE(w)->col_w[i] = test;
+
+ test = req_h / rows;
+ if (test > EWL_TABLE(w)->row_h[i])
+ EWL_TABLE(w)->row_h[i] = test;
+ }
+ }
- evas_hide(widget->evas, widget->container.clip_box);
- evas_unset_clip(widget->evas, widget->container.clip_box);
- evas_del_object(widget->evas, widget->container.clip_box);
+ DLEAVE_FUNCTION;
+}
- FREE(widget);
+static void
+__ewl_table_layout_children(Ewl_Table * w)
+{
+ Ewl_Table_Child *child;
+ int i;
+ int *x_offsets, *y_offsets;
+
+ CHECK_PARAM_POINTER("w", w);
+
+ /*
+ * Keep a temporary table of offsets so that we only have to compute
+ * the starting postition of each row/column once.
+ */
+ x_offsets = (int *) malloc(w->rows * w->columns * sizeof(int));
+ y_offsets = (int *) malloc(w->rows * w->columns * sizeof(int));
+
+ /*
+ * Zero out the data in the location tables
+ */
+ memset(x_offsets, 0, w->rows * w->columns * sizeof(int));
+ memset(y_offsets, 0, w->rows * w->columns * sizeof(int));
+
+ /*
+ * Now run through the table offsets and build up starting x and y
+ * positions for each column.
+ */
+ for (i = 1, x_offsets[0] = CURRENT_X(w); i < w->rows; i++)
+ x_offsets[i] = x_offsets[i - 1] + w->col_w[i - 1];
+
+ for (i = 1, y_offsets[0] = CURRENT_Y(w); i < w->rows; i++)
+ y_offsets[i] = y_offsets[i - 1] + w->row_h[i - 1];
+
+ /*
+ * Loop through the children and determine their starting offsets
+ */
+ ewd_list_goto_first(EWL_CONTAINER(w)->children);
+ while ((child = ewd_list_next(EWL_CONTAINER(w)->children)))
+ {
+ /*
+ * Ok, now that we have offset tables put each child at its
+ * required offset.
+ */
+ ewl_object_set_current_geometry(EWL_OBJECT(child->widget),
+ x_offsets[child->
+ start_col - 1],
+ y_offsets[child->
+ start_row - 1],
+ CURRENT_W(child->widget),
+ CURRENT_H(child->widget));
+ printf("Placed child %p at (%d, %d) dim %dx%d\n",
+ child->widget, CURRENT_X(child->widget),
+ CURRENT_Y(child->widget), CURRENT_W(child->widget),
+ CURRENT_H(child->widget));
+ }
}
+
+/*
+ * Read in any changes to the theme and redraw any elements that are necessary
+ */
static void
-ewl_table_configure(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_table_theme_update(Ewl_Widget * w, void *event_data, void *user_data)
{
- Ewl_Table_Child * child;
- int col, row;
- int l = 0, r = 0, t = 0, b = 0;
- int max_col_w[EWL_TABLE(widget)->columns];
- int max_row_h[EWL_TABLE(widget)->rows];
- int first = 1;
- int x = 0, y = 0;
- int total_w = 0, total_h = 0, total_w2 = 0;
- int top_row_h = 0, top_col_w = 0;
-
- CHECK_PARAM_POINTER("widget", widget);
-
- if (EWL_TABLE(widget)->ebits_object)
- ebits_get_insets(EWL_TABLE(widget)->ebits_object, &l, &r, &t, &b);
-
- if (widget->container.children)
- ewd_list_goto_first(widget->container.children);
-
- x = EWL_OBJECT(widget)->request.x + l;
- y = EWL_OBJECT(widget)->request.y + t;
-
- for (col=0;col<EWL_TABLE(widget)->columns;col++)
- {
- max_col_w[col] = 0;
- }
-
- for (row=0;row<EWL_TABLE(widget)->rows;row++)
- {
- max_row_h[row] = 0;
- }
-
- first = FALSE;
- /* Really really incomplete atm */
- if (widget->container.children)
- for (row=0;row<EWL_TABLE(widget)->rows;row++)
- {
- for (col=0;col<EWL_TABLE(widget)->columns;col++)
- {
- while ((child = ewd_list_next(widget->container.children)) != NULL)
- {
- if (child->start_col == col && child->start_row == row)
- {
- if (EWL_OBJECT(child->child)->current.w > max_col_w[col])
- {
- max_col_w[col] = EWL_OBJECT(child->child)->current.w;
- row = 0;
- col = 0;
- EWL_OBJECT(child->child)->request.x = x -
- (EWL_OBJECT(child->child)->current.w / 2) +
- (max_col_w[col] / 2);
- EWL_OBJECT(child->child)->request.y = y;
- x = EWL_OBJECT(widget)->request.x + l;
- y = EWL_OBJECT(widget)->request.y + t;
- total_h = 0;
- total_w = 0;
- total_w2 = 0;
- }
- if (EWL_OBJECT(child->child)->current.h > max_row_h[row])
- max_row_h[row] = EWL_OBJECT(child->child)->current.h;
-
- if (EWL_TABLE(widget)->alignment == EWL_ALIGNMENT_LEFT)
- {
- EWL_OBJECT(child->child)->request.x = x;
- }
- else if (EWL_TABLE(widget)->alignment ==
- EWL_ALIGNMENT_CENTER)
- {
- EWL_OBJECT(child->child)->request.x = x -
- (EWL_OBJECT(child->child)->current.w / 2) +
- (max_col_w[col] / 2);
- }
- else if (EWL_TABLE(widget)->alignment ==
- EWL_ALIGNMENT_RIGHT)
- {
- EWL_OBJECT(child->child)->request.x = x +
- (max_col_w[col] - EWL_OBJECT(child->child)->current.w);
- }
-
- EWL_OBJECT(child->child)->request.y = y;
-
- if (max_row_h[row] > top_row_h)
- top_row_h = max_row_h[row];
- if (max_col_w[col] > top_col_w)
- top_col_w = max_col_w[col];
- }
- }
- ewd_list_goto_first(widget->container.children);
- x += max_col_w[col] + EWL_TABLE(widget)->col_spacing;
- total_w2 += max_col_w[col] + EWL_TABLE(widget)->col_spacing;
- (int) EWL_TABLE(widget)->col_w[col] = max_col_w[col];
- }
- x = EWL_OBJECT(widget)->request.x + l;
- y += max_row_h[row] + EWL_TABLE(widget)->row_spacing;
- total_h += max_row_h[row] + EWL_TABLE(widget)->row_spacing;
- (int) EWL_TABLE(widget)->row_h[row] = max_row_h[row];
- if (total_w2 > total_w)
- total_w = total_w2;
- total_w2 = 0;
- }
-
- if (widget->container.children)
- ewd_list_goto_first(widget->container.children);
-
- if (widget->container.children)
- if (EWL_TABLE(widget)->homogeneous)
- {
- y = EWL_OBJECT(widget)->request.y + t;
- total_h = 0;
- for (row=0;row<EWL_TABLE(widget)->rows;row++)
- {
- x = EWL_OBJECT(widget)->request.x + l;
- for(col=0;col<EWL_TABLE(widget)->columns;col++)
- {
- while((child = ewd_list_next(widget->container.children)) != NULL)
- {
- if (child->start_col == col && child->start_row == row)
- {
- EWL_OBJECT(child->child)->request.x = x - (top_col_w / 2) +
- (EWL_OBJECT(child->child)->current.w / 2);
- EWL_OBJECT(child->child)->request.y = y - (top_row_h / 2) +
- (EWL_OBJECT(child->child)->current.h / 2);
- }
- }
- ewd_list_goto_first(widget->container.children);
- x += top_col_w + EWL_TABLE(widget)->col_spacing;
- }
- y += top_row_h + EWL_TABLE(widget)->row_spacing;
- total_h += top_row_h + EWL_TABLE(widget)->row_spacing;
- }
- }
-
- if (widget->container.children)
- ewd_list_goto_first(widget->container.children);
-
- if (widget->container.children)
- while ((child = ewd_list_next(widget->container.children)) != NULL)
- {
- ewl_widget_configure(EWL_WIDGET(child->child));
- }
-
- /* Resize and move table bg (if any) */
- if (EWL_OBJECT(widget)->realized) {
- if (total_w)
- EWL_OBJECT(widget)->request.w = (total_w -
- EWL_TABLE(widget)->col_spacing) + l + r;
- if (total_h)
- EWL_OBJECT(widget)->request.h = (total_h -
- EWL_TABLE(widget)->row_spacing) + t + b;
-
- ebits_move(EWL_TABLE(widget)->ebits_object,
- EWL_OBJECT(widget)->request.x,
- EWL_OBJECT(widget)->request.y);
- ebits_resize(EWL_TABLE(widget)->ebits_object,
- EWL_OBJECT(widget)->request.w,
- EWL_OBJECT(widget)->request.h);
- ewl_container_clip_box_resize(widget);
- ewl_fx_clip_box_resize(widget);
- }
-
- EWL_OBJECT(widget)->current.x = EWL_OBJECT(widget)->request.x;
- EWL_OBJECT(widget)->current.y = EWL_OBJECT(widget)->request.y;
- EWL_OBJECT(widget)->current.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->current.h = EWL_OBJECT(widget)->request.h;
- EWL_OBJECT(widget)->maximum.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->maximum.h = EWL_OBJECT(widget)->request.h;
- EWL_OBJECT(widget)->minimum.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->minimum.h = EWL_OBJECT(widget)->request.h;
+ Ewl_Table *b;
+ char *i;
+ char *v;
+
+ DENTER_FUNCTION;
+
+ DCHECK_PARAM_PTR("w", w);
+
+ /*
+ * Shouldn't do anything if the widget isn't realized yet
+ */
+ if (!w->object.realized)
+ DRETURN;
+
+ b = EWL_TABLE(w);
+
+ /*
+ * Check if GFX should be visible or not
+ */
+ v = ewl_theme_data_get(w, "/appearance/table/default/base/visible");
+
+ /*
+ * Destroy old image (if any)
+ */
+ if (w->ebits_object)
+ {
+ ebits_hide(w->ebits_object);
+ ebits_unset_clip(w->ebits_object);
+ ebits_free(w->ebits_object);
+ }
+
+ /*
+ * If we don't want to show the new graphics, then we're pretty much
+ * finished. Lots of people say goto's are evile, but this is the type
+ * of case where they are probably a better choice than alternate
+ * approaches.
+ */
+ if (!v || strncasecmp(v, "yes", 3) != 0)
+ goto table_theme_update_end;
+
+ /*
+ * Determine the path to the bit file we want.
+ */
+ i = ewl_theme_image_get(w, "/appearance/table/default/base");
+
+ if (!i)
+ goto table_theme_update_end;
+
+ /*
+ * Load our new theme bits
+ */
+ w->ebits_object = ebits_load(i);
+ FREE(i);
+
+ if (w->ebits_object)
+ {
+ ebits_add_to_evas(w->ebits_object, w->evas);
+ ebits_set_layer(w->ebits_object, w->object.layer);
+ ebits_set_clip(w->ebits_object, w->fx_clip_box);
+
+ ebits_show(w->ebits_object);
+ }
+
+ table_theme_update_end:
+ /*
+ * We need to make sure v is not NULL when free()ing it.
+ */
+ IF_FREE(v);
+
+ /*
+ * Finally configure the widget to update changes
+ */
+ ewl_widget_configure(w);
+
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_table.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_table.h 2001/05/02 23:12:42 1.4
+++ ewl_table.h 2001/07/20 07:31:54 1.5
@@ -2,86 +2,88 @@
#ifndef __EWL_TABLE_H
#define __EWL_TABLE_H
-struct _ewl_table {
- Ewl_Widget widget;
- Ebits_Object ebits_object;
- unsigned int columns; /* Number of columns */
- unsigned int rows; /* Number of rows */
+typedef struct _ewl_table Ewl_Table;
+#define EWL_TABLE(table) ((Ewl_Table *) table)
+
+struct _ewl_table
+{
+ Ewl_Container widget;
+ Ewl_Alignment alignment;
+ Ebits_Object ebits_bg;
+ unsigned int columns;
+ unsigned int rows;
unsigned int homogeneous;
unsigned int col_spacing;
unsigned int row_spacing;
- int *col_w;
- int *row_h;
- Ewl_Alignment alignment;
+ unsigned int *col_w;
+ unsigned int *row_h;
+ unsigned int *custom_col_w;
};
-
-typedef struct _ewl_table Ewl_Table;
-#define EWL_TABLE(table) ((Ewl_Table *) table)
+typedef struct _ewl_table_child Ewl_Table_Child;
+#define EWL_TABLE_CHILD(child) ((Ewl_Table_Child *) child)
-struct _ewl_table_child {
- Ewl_Widget * child;
- unsigned int start_col;
- unsigned int end_col;
- unsigned int start_row;
- unsigned int end_row;
+struct _ewl_table_child
+{
+ Ewl_Widget *widget;
+ Ewl_Alignment alignment;
+ Ewl_Fill_Policy fill_policy;
+ unsigned int start_col;
+ unsigned int end_col;
+ unsigned int start_row;
+ unsigned int end_row;
};
-typedef struct _ewl_table_child Ewl_Table_Child;
+Ewl_Widget *ewl_table_new(unsigned int columns, unsigned int rows);
-#define EWL_TABLE_CHILD(child) ((Ewl_Table_Child *) child)
+Ewl_Widget *ewl_table_new_all(unsigned int homogeneous,
+ unsigned int columns,
+ unsigned int rows,
+ unsigned int col_spacing,
+ unsigned int row_spacing);
-/* Create a new table wich you do not know the size of yet nor row spacing */
-Ewl_Widget * ewl_table_new();
+void ewl_table_attach(Ewl_Widget * t,
+ Ewl_Widget * c,
+ Ewl_Alignment alignment,
+ Ewl_Fill_Policy fill_policy,
+ unsigned int start_col,
+ unsigned int end_col,
+ unsigned int start_row, unsigned int end_row);
-/* Create a table setting everything */
-Ewl_Widget * ewl_table_new_all(unsigned int homogeneous,
- unsigned int columns,
- unsigned int rows,
- unsigned int col_spacing,
- unsigned int row_spacing);
+void ewl_table_detach(Ewl_Widget * t, unsigned int c, unsigned int r);
-/* Resize the table */
-void ewl_table_resize(Ewl_Widget * widget,
- unsigned int rows,
- unsigned int columns);
+void ewl_table_resize(Ewl_Widget * t, unsigned int c, unsigned int r);
+unsigned int ewl_table_get_columns(Ewl_Widget * t);
-/* Add a child to the table */
-void ewl_table_attach(Ewl_Widget * table,
- Ewl_Widget * child,
- unsigned int start_col,
- unsigned int end_col,
- unsigned int start_row,
- unsigned int end_row);
+unsigned int ewl_table_get_rows(Ewl_Widget * t);
-void ewl_table_detach(Ewl_Widget * table,
- unsigned int start_row,
- unsigned int start_col);
+void ewl_table_set_homogeneous(Ewl_Widget * t, unsigned int h);
-/* Set wether or not the table will set all columns to the widest column */
-void ewl_table_set_homogeneous(Ewl_Widget * widget,
- unsigned int homogeneous);
+void ewl_table_set_col_spacing(Ewl_Widget * t, unsigned int cs);
-/* Space between each column */
-void ewl_table_set_col_spacing(Ewl_Widget * widget,
- unsigned int spacing);
+void ewl_table_set_row_spacing(Ewl_Widget * t, unsigned int rs);
-/* Space between each row */
-void ewl_table_set_row_spacing(Ewl_Widget * widget,
- unsigned int spacing);
+void ewl_table_set_alignment(Ewl_Widget * t, Ewl_Alignment a);
-void ewl_table_set_alignment(Ewl_Widget * table, Ewl_Alignment alignment);
+void ewl_table_column_set_width(Ewl_Widget * t,
+ unsigned int c, unsigned int w);
-void ewl_table_get_col_width(Ewl_Widget * table, int col_num, int * w);
+void ewl_table_get_column_width(Ewl_Widget * t,
+ unsigned int c, unsigned int *w);
-Ewl_Widget * ewl_table_get_child(Ewl_Widget * table, int row, int col);
+void ewl_table_child_set_alignment(Ewl_Widget * t,
+ unsigned int c,
+ unsigned int r, Ewl_Alignment a);
-void ewl_table_get_row_height(Ewl_Widget * table, int row_num, int * h);
+Ewl_Alignment ewl_table_child_get_alignment(Ewl_Widget * t,
+ unsigned int c, unsigned int r);
-void
-ewl_table_get_row_geometry(Ewl_Widget * table, int row_num, int * x,
- int * y,int * w, int * h);
+Ewl_Widget *ewl_table_get_child(Ewl_Widget * t,
+ unsigned int c, unsigned int r);
+void ewl_table_get_row_geometry(Ewl_Widget * t,
+ unsigned int r,
+ int *x, int *y, int *w, int *h);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_text.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_text.c 2001/05/02 23:12:42 1.6
+++ ewl_text.c 2001/07/20 07:31:54 1.7
@@ -1,42 +1,51 @@
#include <Ewl.h>
-struct _ewl_text_row {
- Ewl_Widget widget;
- Evas_Object object;
- char * text;
- struct {
- int r, g, b, a;
- } color;
+struct _ewl_text_row
+{
+ Ewl_Widget widget;
+ Evas_Object object;
+ char *text;
+ struct
+ {
+ int r, g, b, a;
+ }
+ color;
};
typedef struct _ewl_text_row Ewl_Text_Row;
#define EWL_TEXT_ROW(row) ((Ewl_Text_Row *) row)
-static void ewl_text_init(Ewl_Widget * widget);
-static void ewl_text_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_text_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_text_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_text_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_text_configure(Ewl_Widget * widget, Ewl_Callback * cb);
-
-static Ewl_Text_Row * ewl_text_row_new();
-static void ewl_text_row_init(Ewl_Text_Row * row);
-static void ewl_text_row_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_text_row_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_text_row_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_text_row_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_text_row_configure(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_text_row_free(void * func_data);
-static void ewl_text_row_set_text(Ewl_Widget * widget, const char * text);
+static void ewl_text_init(Ewl_Widget * widget);
+static void ewl_text_realize(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_text_show(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_text_hide(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_text_destroy(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_text_configure(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+
+static Ewl_Text_Row *ewl_text_row_new();
+static void ewl_text_row_init(Ewl_Text_Row * row);
+static void ewl_text_row_realize(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_text_row_destroy(Ewl_Widget * widget, void *event_data,
+ void *user_data);
+static void ewl_text_row_configure(Ewl_Widget * widget, void *event_data,
+ void *user_data);
Ewl_Widget *
ewl_text_new()
{
- Ewl_Text * text = NULL;
+ Ewl_Text *text = NULL;
+ DENTER_FUNCTION;
+
text = NEW(Ewl_Text, 1);
ewl_text_init(EWL_WIDGET(text));
@@ -49,97 +58,101 @@
text->color.b = 0;
text->color.a = 200;
- return EWL_WIDGET(text);
+ DRETURN_PTR(EWL_WIDGET(text));
}
static void
ewl_text_init(Ewl_Widget * widget)
{
+ DENTER_FUNCTION;
CHECK_PARAM_POINTER("widget", widget);
+
memset(EWL_TEXT(widget), 0, sizeof(Ewl_Text));
+ ewl_container_init(EWL_CONTAINER(widget), EWL_WIDGET_TEXT, 10, 10,
+ 2048, 2048);
- ewl_callback_append(widget, EWL_CALLBACK_REALIZE,
- ewl_text_realize, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_SHOW,
- ewl_text_show, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_HIDE,
- ewl_text_hide, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_DESTROY,
- ewl_text_destroy, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_REALIZE, ewl_text_realize,
+ NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_SHOW, ewl_text_show, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_HIDE, ewl_text_hide, NULL);
+ ewl_callback_append(widget, EWL_CALLBACK_DESTROY, ewl_text_destroy,
+ NULL);
ewl_callback_append(widget, EWL_CALLBACK_CONFIGURE,
- ewl_text_configure, NULL);
+ ewl_text_configure, NULL);
- widget->container.recursive = TRUE;
- widget->container.free_cb = ewl_text_row_free;
+ EWL_WIDGET(widget)->recursive = TRUE;
- EWL_OBJECT(widget)->current.w = 10;
- EWL_OBJECT(widget)->current.h = 10;
- EWL_OBJECT(widget)->maximum.w = 2024;
- EWL_OBJECT(widget)->maximum.h = 2024;
- EWL_OBJECT(widget)->minimum.w = 10;
- EWL_OBJECT(widget)->minimum.h = 10;
- EWL_OBJECT(widget)->request.w = 10;
- EWL_OBJECT(widget)->request.h = 10;
+ DLEAVE_FUNCTION;
}
static void
-ewl_text_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_text_realize(Ewl_Widget * widget, void *event_data, void *user_data)
{
+ DENTER_FUNCTION;
CHECK_PARAM_POINTER("widget", widget);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_text_show(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_text_show(Ewl_Widget * widget, void *event_data, void *user_data)
{
+ DENTER_FUNCTION;
+
ewl_fx_clip_box_create(widget);
- widget->container.clip_box = widget->fx_clip_box;
+ EWL_CONTAINER(widget)->clip_box = widget->fx_clip_box;
evas_set_clip(widget->evas,
- widget->fx_clip_box,
- widget->parent->container.clip_box);
+ widget->fx_clip_box,
+ EWL_CONTAINER(widget->parent)->clip_box);
if (EWL_TEXT(widget)->text)
ewl_text_set_text(widget, strdup(EWL_TEXT(widget)->text));
evas_set_color(widget->evas, widget->fx_clip_box, 255, 255, 255, 255);
+
+ DLEAVE_FUNCTION;
}
static void
-ewl_text_hide(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_text_hide(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ewl_Text_Row * row;
+ Ewl_Text_Row *row;
CHECK_PARAM_POINTER("widget", widget);
- if (!widget->container.children ||
- ewd_list_is_empty(widget->container.children))
- return;
+ if (!EWL_CONTAINER(widget)->children ||
+ ewd_list_is_empty(EWL_CONTAINER(widget)->children))
+ return;
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
- while ((row = ewd_list_next(widget->container.children)) != NULL) {
- ewl_callback_call(EWL_WIDGET(row), EWL_CALLBACK_HIDE);
- }
+ while ((row = ewd_list_next(EWL_CONTAINER(widget)->children)) != NULL)
+ {
+ ewl_callback_call(EWL_WIDGET(row), EWL_CALLBACK_HIDE);
+ }
}
static void
-ewl_text_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_text_destroy(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ewl_Text_Row * row = NULL;
+ Ewl_Text_Row *row = NULL;
CHECK_PARAM_POINTER("widget", widget);
-
- if (widget->container.children ||
- !ewd_list_is_empty(widget->container.children)) {
- while ((row = ewd_list_next(widget->container.children)) != NULL) {
- ewl_widget_destroy(EWL_WIDGET(row));
- }
- }
+ if (EWL_CONTAINER(widget)->children ||
+ !ewd_list_is_empty(EWL_CONTAINER(widget)->children))
+ {
+ while ((row =
+ ewd_list_remove_last(EWL_CONTAINER(widget)->
+ children)) != NULL)
+ ewl_widget_destroy(EWL_WIDGET(row));
+ }
evas_hide(widget->evas, widget->fx_clip_box);
+ evas_unset_clip(widget->evas, widget->fx_clip_box);
evas_del_object(widget->evas, widget->fx_clip_box);
IF_FREE(EWL_TEXT(widget)->text);
@@ -148,9 +161,9 @@
}
static void
-ewl_text_configure(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_text_configure(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ewl_Text_Row * row;
+ Ewl_Text_Row *row;
int y, h = 0, w = 0;
CHECK_PARAM_POINTER("widget", widget);
@@ -158,25 +171,26 @@
EWL_OBJECT(widget)->current.x = EWL_OBJECT(widget)->request.x;
EWL_OBJECT(widget)->current.y = EWL_OBJECT(widget)->request.y;
- if (!widget->container.children ||
- ewd_list_is_empty(widget->container.children))
- return;
+ if (!EWL_CONTAINER(widget)->children ||
+ ewd_list_is_empty(EWL_CONTAINER(widget)->children))
+ return;
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
y = EWL_OBJECT(widget)->current.y;
ewl_fx_clip_box_resize(widget);
- while ((row = ewd_list_next(widget->container.children)) != NULL) {
- EWL_OBJECT(row)->request.x = EWL_OBJECT(widget)->current.x;
- EWL_OBJECT(row)->request.y = y;
- ewl_callback_call(EWL_WIDGET(row), EWL_CALLBACK_CONFIGURE);
- y += EWL_OBJECT(row)->current.h + 2;
- h += EWL_OBJECT(row)->current.h + 2;
- if (w < EWL_OBJECT(row)->current.w)
- w = EWL_OBJECT(row)->current.w;
- }
+ while ((row = ewd_list_next(EWL_CONTAINER(widget)->children)) != NULL)
+ {
+ EWL_OBJECT(row)->request.x = EWL_OBJECT(widget)->current.x;
+ EWL_OBJECT(row)->request.y = y;
+ ewl_callback_call(EWL_WIDGET(row), EWL_CALLBACK_CONFIGURE);
+ y += EWL_OBJECT(row)->current.h + 2;
+ h += EWL_OBJECT(row)->current.h + 2;
+ if (w < EWL_OBJECT(row)->current.w)
+ w = EWL_OBJECT(row)->current.w;
+ }
EWL_OBJECT(widget)->request.w = w;
EWL_OBJECT(widget)->request.h = h;
@@ -191,7 +205,7 @@
static Ewl_Text_Row *
ewl_text_row_new()
{
- Ewl_Text_Row * row = NULL;
+ Ewl_Text_Row *row = NULL;
row = NEW(Ewl_Text_Row, 1);
@@ -211,129 +225,97 @@
CHECK_PARAM_POINTER("row", row);
memset(row, 0, sizeof(Ewl_Text_Row));
+ ewl_widget_init(EWL_WIDGET(row), EWL_WIDGET_TEXT, 10, 10, 2048, 2048);
- ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_REALIZE,
- ewl_text_row_realize, NULL);
- ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_SHOW,
- ewl_text_row_show, NULL);
- ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_HIDE,
- ewl_text_row_hide, NULL);
- ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_DESTROY,
- ewl_text_row_destroy, NULL);
- ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_CONFIGURE,
- ewl_text_row_configure, NULL);
-
- EWL_OBJECT(row)->current.w = 10;
- EWL_OBJECT(row)->current.h = 10;
- EWL_OBJECT(row)->maximum.w = 2024;
- EWL_OBJECT(row)->maximum.h = 2024;
- EWL_OBJECT(row)->minimum.w = 10;
- EWL_OBJECT(row)->minimum.h = 10;
- EWL_OBJECT(row)->request.w = 10;
- EWL_OBJECT(row)->request.h = 10;
+ ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_REALIZE,
+ ewl_text_row_realize, NULL);
+ ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_DESTROY,
+ ewl_text_row_destroy, NULL);
+ ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_CONFIGURE,
+ ewl_text_row_configure, NULL);
}
static void
-ewl_text_row_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_text_row_realize(Ewl_Widget * widget, void *event_data, void *user_data)
{
- Ewl_Text * text;
+ Ewl_Text *text;
CHECK_PARAM_POINTER("widget", widget);
text = EWL_TEXT(widget->parent);
EWL_TEXT_ROW(widget)->object = evas_add_text(widget->evas,
- text->font, text->font_size, EWL_TEXT_ROW(widget)->text);
+ text->font,
+ text->font_size,
+ EWL_TEXT_ROW(widget)->
+ text);
evas_move(widget->evas, EWL_TEXT_ROW(widget)->object,
- EWL_OBJECT(widget)->request.x, EWL_OBJECT(widget)->request.y);
+ EWL_OBJECT(widget)->request.x,
+ EWL_OBJECT(widget)->request.y);
EWL_OBJECT(widget)->current.x = EWL_OBJECT(widget)->request.x;
EWL_OBJECT(widget)->current.y = EWL_OBJECT(widget)->request.y;
+ evas_set_clip(widget->evas, EWL_TEXT_ROW(widget)->object,
+ EWL_CONTAINER(widget->parent)->clip_box);
+
evas_set_layer(widget->evas, EWL_TEXT_ROW(widget)->object,
- EWL_OBJECT(widget)->layer);
+ EWL_OBJECT(widget)->layer);
evas_set_color(widget->evas, EWL_TEXT_ROW(widget)->object,
- text->color.r, text->color.g, text->color.b, text->color.a);
-}
+ text->color.r, text->color.g, text->color.b,
+ text->color.a);
-static void
-ewl_text_row_show(Ewl_Widget * widget, Ewl_Callback * cb)
-{
- CHECK_PARAM_POINTER("widget", widget);
-
evas_show(widget->evas, EWL_TEXT_ROW(widget)->object);
-
- evas_set_clip(widget->evas, EWL_TEXT_ROW(widget)->object,
- widget->parent->container.clip_box);
}
-static void
-ewl_text_row_hide(Ewl_Widget * widget, Ewl_Callback * cb)
-{
- CHECK_PARAM_POINTER("widget", widget);
- evas_hide(widget->evas, EWL_TEXT_ROW(widget)->object);
-}
-
static void
-ewl_text_row_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_text_row_destroy(Ewl_Widget * widget, void *event_data, void *user_data)
{
CHECK_PARAM_POINTER("widget", widget);
evas_hide(widget->evas, EWL_TEXT_ROW(widget)->object);
evas_unset_clip(widget->evas, EWL_TEXT_ROW(widget)->object);
evas_del_object(widget->evas, EWL_TEXT_ROW(widget)->object);
-
+
IF_FREE(EWL_TEXT_ROW(widget)->text);
FREE(widget);
}
static void
-ewl_text_row_configure(Ewl_Widget * widget, Ewl_Callback * cb)
+ewl_text_row_configure(Ewl_Widget * widget, void *event_data, void *user_data)
{
CHECK_PARAM_POINTER("widget", widget);
evas_move(widget->evas, EWL_TEXT_ROW(widget)->object,
- EWL_OBJECT(widget)->request.x, EWL_OBJECT(widget)->request.y);
+ EWL_OBJECT(widget)->request.x,
+ EWL_OBJECT(widget)->request.y);
EWL_OBJECT(widget)->current.x = EWL_OBJECT(widget)->request.x;
EWL_OBJECT(widget)->current.y = EWL_OBJECT(widget)->request.y;
EWL_OBJECT(widget)->current.w = evas_get_text_width(widget->evas,
- EWL_TEXT_ROW(widget)->object);
- EWL_OBJECT(widget)->current.h = evas_get_text_height(widget->evas,
- EWL_TEXT_ROW(widget)->object);
+ EWL_TEXT_ROW
+ (widget)->object);
+ EWL_OBJECT(widget)->current.h =
+ evas_get_text_height(widget->evas,
+ EWL_TEXT_ROW(widget)->object);
}
-static void
-ewl_text_row_free(void * func_data)
-{
- Ewl_Text_Row * row = NULL;
-
- CHECK_PARAM_POINTER("func_data", func_data);
-
- row = func_data;
-
- IF_FREE(row->text);
- evas_del_object(EWL_WIDGET(row)->evas, row->object);
-}
-
-static void
-ewl_text_row_set_text(Ewl_Widget * widget, const char * text)
-{
- CHECK_PARAM_POINTER("widget", widget);
-}
-
void
-ewl_text_set_text(Ewl_Widget * widget, const char * text)
+ewl_text_set_text(Ewl_Widget * widget, const char *text)
{
- Ewl_Text_Row * row;
- char * string = NULL, * temp = NULL;
+ Ewl_Text_Row *row = NULL;
+ char *string = NULL, *temp = NULL;
CHECK_PARAM_POINTER("widget", widget);
+
+ if (EWL_CONTAINER(widget)->children)
+ while ((row =
+ ewd_list_remove_last(EWL_CONTAINER(widget)->
+ children)) != NULL)
+ ewl_widget_destroy(EWL_WIDGET(row));
- if (widget->container.children)
- ewd_list_clear(widget->container.children);
IF_FREE(EWL_TEXT(widget)->text);
EWL_TEXT(widget)->text = strdup(text);
@@ -341,46 +323,52 @@
if (!EWL_OBJECT(widget)->visible)
return;
- /* This is bad bad!!!!!! REALLY BAD hack! FIXME FIXME */
+ /*
+ * This is bad bad!!!!!! REALLY BAD hack! FIXME FIXME
+ */
string = strdup(text);
temp = strchr(string, '\n');
- while (temp && *temp) {
- char * line;
- row = ewl_text_row_new();
-
- *temp = '\0';
- line = strdup(string);
- string = temp + 1;
- temp = strchr(string, '\n');
-
- row->text = strdup(line);
-
- EWL_WIDGET(row)->parent = widget;
- EWL_WIDGET(row)->evas = widget->evas;
- EWL_WIDGET(row)->container.clip_box = widget->container.clip_box;
-
- if (EWL_OBJECT(widget)->realized)
- ewl_widget_realize(EWL_WIDGET(row));
- if (EWL_OBJECT(widget)->visible)
- ewl_widget_show(EWL_WIDGET(row));
+ while (temp && *temp)
+ {
+ char *line;
+ row = ewl_text_row_new();
+
+ *temp = '\0';
+ line = strdup(string);
+ string = temp + 1;
+ temp = strchr(string, '\n');
+
+ IF_FREE(row->text);
+ row->text = strdup(line);
+
+ EWL_WIDGET(row)->parent = widget;
+ EWL_WIDGET(row)->evas = widget->evas;
+ EWL_CONTAINER(row)->clip_box =
+ EWL_CONTAINER(widget)->clip_box;
+
+ if (EWL_OBJECT(widget)->realized)
+ ewl_widget_realize(EWL_WIDGET(row));
+ if (EWL_OBJECT(widget)->visible)
+ ewl_widget_show(EWL_WIDGET(row));
+
+ ewl_container_append_child(EWL_CONTAINER(widget),
+ EWL_WIDGET(row));
+ }
- ewl_container_append_child(widget, EWL_WIDGET(row));
- }
-
row = ewl_text_row_new();
row->text = strdup(string);
EWL_WIDGET(row)->parent = widget;
EWL_WIDGET(row)->evas = widget->evas;
- EWL_WIDGET(row)->container.clip_box = widget->container.clip_box;
+ EWL_CONTAINER(row)->clip_box = EWL_CONTAINER(widget)->clip_box;
if (EWL_OBJECT(widget)->realized)
ewl_widget_realize(EWL_WIDGET(row));
if (EWL_OBJECT(widget)->visible)
ewl_widget_show(EWL_WIDGET(row));
- ewl_container_append_child(widget, EWL_WIDGET(row));
+ ewl_container_append_child(EWL_CONTAINER(widget), EWL_WIDGET(row));
ewl_widget_configure(widget);
@@ -397,9 +385,9 @@
}
void
-ewl_text_set_font(Ewl_Widget * widget, char * font)
+ewl_text_set_font(Ewl_Widget * widget, char *font)
{
- Ewl_Widget * child = NULL;
+ Ewl_Widget *child = NULL;
CHECK_PARAM_POINTER("widget", widget);
CHECK_PARAM_POINTER("font", font);
@@ -411,18 +399,21 @@
EWL_TEXT(widget)->font = strdup(font);
- if (!widget->container.children)
+ if (!EWL_CONTAINER(widget)->children)
return;
-
- ewd_list_goto_first(widget->container.children);
- while ((child = ewd_list_next(widget->container.children)) != NULL) {
- if (!EWL_TEXT_ROW(child)->object)
- continue;
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
- evas_set_font(child->evas, EWL_TEXT_ROW(child)->object,
- EWL_TEXT(widget)->font, EWL_TEXT(widget)->font_size);
- }
+ while ((child =
+ ewd_list_next(EWL_CONTAINER(widget)->children)) != NULL)
+ {
+ if (!EWL_TEXT_ROW(child)->object)
+ continue;
+
+ evas_set_font(child->evas, EWL_TEXT_ROW(child)->object,
+ EWL_TEXT(widget)->font,
+ EWL_TEXT(widget)->font_size);
+ }
ewl_widget_configure(widget);
if (widget->parent)
@@ -438,35 +429,38 @@
void
ewl_text_set_font_size(Ewl_Widget * widget, int size)
{
- Ewl_Widget * child = NULL;
+ Ewl_Widget *child = NULL;
- CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("size", size);
+ CHECK_PARAM_POINTER("widget", widget);
+ CHECK_PARAM_POINTER("size", size);
if (EWL_TEXT(widget)->font_size == size)
return;
- EWL_TEXT(widget)->font_size = size;
+ EWL_TEXT(widget)->font_size = size;
- if (!widget->container.children)
+ if (!EWL_CONTAINER(widget)->children)
return;
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
- while ((child = ewd_list_next(widget->container.children)) != NULL) {
- if (!EWL_TEXT_ROW(child)->object)
- continue;
-
- evas_set_font(child->evas, EWL_TEXT_ROW(child)->object,
- EWL_TEXT(widget)->font, EWL_TEXT(widget)->font_size);
- }
+ while ((child =
+ ewd_list_next(EWL_CONTAINER(widget)->children)) != NULL)
+ {
+ if (!EWL_TEXT_ROW(child)->object)
+ continue;
+
+ evas_set_font(child->evas, EWL_TEXT_ROW(child)->object,
+ EWL_TEXT(widget)->font,
+ EWL_TEXT(widget)->font_size);
+ }
if (widget->parent)
ewl_widget_configure(widget->parent);
}
void
-ewl_text_get_font_size(Ewl_Widget * widget, int * size)
+ewl_text_get_font_size(Ewl_Widget * widget, int *size)
{
CHECK_PARAM_POINTER("widget", widget);
@@ -476,7 +470,7 @@
void
ewl_text_set_color(Ewl_Widget * widget, int r, int g, int b, int a)
{
- Ewl_Widget * child = NULL;
+ Ewl_Widget *child = NULL;
CHECK_PARAM_POINTER("widget", widget);
@@ -484,22 +478,25 @@
EWL_TEXT(widget)->color.g = g;
EWL_TEXT(widget)->color.b = b;
EWL_TEXT(widget)->color.a = a;
-
- if (!widget->container.children)
- return;
- ewd_list_goto_first(widget->container.children);
+ if (!EWL_CONTAINER(widget)->children)
+ DRETURN;
- while ((child = ewd_list_next(widget->container.children)) != NULL) {
- if (!EWL_TEXT_ROW(child)->object)
- continue;
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
- evas_set_color(child->evas, EWL_TEXT_ROW(child)->object, r, g, b, a);
- }
+ while ((child =
+ ewd_list_next(EWL_CONTAINER(widget)->children)) != NULL)
+ {
+ if (!EWL_TEXT_ROW(child)->object)
+ continue;
+
+ evas_set_color(child->evas, EWL_TEXT_ROW(child)->object, r,
+ g, b, a);
+ }
}
void
-ewl_text_get_color(Ewl_Widget * widget, int * r, int * g, int * b, int * a)
+ewl_text_get_color(Ewl_Widget * widget, int *r, int *g, int *b, int *a)
{
CHECK_PARAM_POINTER("widget", widget);
@@ -508,40 +505,44 @@
*b = EWL_TEXT(widget)->color.b;
*a = EWL_TEXT(widget)->color.a;
}
+
void
ewl_text_get_letter_geometry(Ewl_Widget * widget,
- int index, int * x, int * y, int * w, int * h)
+ int index, double *x, double *y, double *w,
+ double *h)
{
- Ewl_Widget * child = NULL;
+ Ewl_Widget *child = NULL;
CHECK_PARAM_POINTER("widget", widget);
- if (!widget->container.children ||
- ewd_list_is_empty(widget->container.children))
+ if (!EWL_CONTAINER(widget)->children ||
+ ewd_list_is_empty(EWL_CONTAINER(widget)->children))
return;
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
- child = widget->container.children->first->data;
+ child = EWL_CONTAINER(widget)->children->first->data;
evas_text_at(widget->evas, EWL_TEXT_ROW(child)->object, index,
- &*x, &*y, &*w, &*h);
+ x, y, w, h);
}
void
ewl_text_get_letter_geometry_at(Ewl_Widget * widget,
- int x, int y, int * tx, int *ty, int * tw, int *th)
+ int x,
+ int y, double *tx, double *ty, double *tw,
+ double *th)
{
- Ewl_Widget * child = NULL;
+ Ewl_Widget *child = NULL;
CHECK_PARAM_POINTER("widget", widget);
- if (!widget->container.children ||
- ewd_list_is_empty(widget->container.children))
+ if (!EWL_CONTAINER(widget)->children ||
+ ewd_list_is_empty(EWL_CONTAINER(widget)->children))
return;
- ewd_list_goto_first(widget->container.children);
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
- child = widget->container.children->first->data;
+ child = EWL_CONTAINER(widget)->children->first->data;
evas_text_at_position(child->evas, EWL_TEXT_ROW(child)->object,
- x, y, &*tx, &*ty, &*tw, &*th);
+ x, y, &*tx, &*ty, &*tw, &*th);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_text.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_text.h 2001/04/14 19:59:30 1.2
+++ ewl_text.h 2001/07/20 07:31:54 1.3
@@ -2,35 +2,37 @@
#ifndef __EWL_TEXT_H
#define __EWL_TEXT_H
-struct _ewl_text {
- Ewl_Widget widget;
- char * text;
- char * font;
- int font_size;
- struct {
- int r, g, b, a;
- } color;
+struct _ewl_text
+{
+ Ewl_Container container;
+ char *text;
+ char *font;
+ int font_size;
+ struct
+ {
+ int r, g, b, a;
+ }
+ color;
};
typedef struct _ewl_text Ewl_Text;
#define EWL_TEXT(text) ((Ewl_Text *) text)
-Ewl_Widget * ewl_text_new();
+Ewl_Widget *ewl_text_new();
-void ewl_text_set_text(Ewl_Widget * etext, const char * text);
-char * ewl_text_get_text(Ewl_Widget * text);
-void ewl_text_set_font(Ewl_Widget * text, char * font);
-char * ewl_text_get_font(Ewl_Widget * text);
-void ewl_text_set_font_size(Ewl_Widget * text, int size);
-void ewl_text_get_font_size(Ewl_Widget * text, int * size);
-void ewl_text_set_color(Ewl_Widget * widget,
- int r, int g, int b, int a);
-void ewl_text_get_color(Ewl_Widget * widget,
- int * r, int * g, int * b, int * a);
-void ewl_text_get_letter_geometry(Ewl_Widget * widget,
- int index, int * x, int * y, int * w, int * h);
-void ewl_text_get_letter_geometry_at(Ewl_Widget * widget,
- int x, int y, int * tx, int *ty, int * tw, int *th);
+void ewl_text_set_text(Ewl_Widget * etext, const char *text);
+char *ewl_text_get_text(Ewl_Widget * text);
+void ewl_text_set_font(Ewl_Widget * text, char *font);
+char *ewl_text_get_font(Ewl_Widget * text);
+void ewl_text_set_font_size(Ewl_Widget * text, int size);
+void ewl_text_get_font_size(Ewl_Widget * text, int *size);
+void ewl_text_set_color(Ewl_Widget * widget, int r, int g, int b, int a);
+void ewl_text_get_color(Ewl_Widget * widget, int *r, int *g, int *b, int *a);
+void ewl_text_get_letter_geometry(Ewl_Widget * widget, int index, double *x,
+ double *y, double *w, double *h);
+void ewl_text_get_letter_geometry_at(Ewl_Widget * widget, int x, int y,
+ double *tx, double *ty, double *tw,
+ double *th);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_theme.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_theme.c 2001/05/01 04:00:38 1.2
+++ ewl_theme.c 2001/07/20 07:31:54 1.3
@@ -8,145 +8,387 @@
#define EWL_GLOBAL_THEMES PACKAGE_DATA_DIR"/themes"
#define EWL_USER_THEMES EWL_USER_DIR"/themes"
-E_DB_File * theme;
+/* The path where the theme is located */
+static char theme_path[PATH_LEN];
-char theme_path[PATH_LEN];
-char font_path[PATH_LEN];
-char style_path[PATH_LEN];
+/* A global table of theme data that has the default settings */
+static Ewd_Hash *def_theme_data;
+static const char * theme_keys[] = {
+ "/appearance/box/horizontal/base",
+ "/appearance/box/horizontal/base.bits.db",
+ "/appearance/box/horizontal/base/visible", "yes",
+ "/appearance/box/vertical/base",
+ "/appearance/box/vertical/base.bits.db",
+ "/appearance/box/vertical/base/visible", "yes",
+
+ "/appearance/button/default/base",
+ "/appearance/button/default/base.bits.db",
+ "/appearance/button/default/base/visible", "yes",
+ "/appearance/button/default/clicked",
+ "/appearance/button/default/clicked.bits.db",
+ "/appearance/button/default/clicked/visible", "yes",
+ "/appearance/button/default/hilited",
+ "/appearance/button/default/hilited.bits.db",
+ "/appearance/button/default/hilited/visible", "yes",
+ "/appearance/button/default/selected",
+ "/appearance/button/default/selected.bits.db",
+ "/appearance/button/default/selected/visible", "yes",
+
+ "/appearance/button/check/base-checked0",
+ "/appearance/button/check/base-checked0.bits.db",
+ "/appearance/button/check/base-checked0/visible", "yes",
+ "/appearance/button/check/base-checked1",
+ "/appearance/button/check/base-checked1.bits.db",
+ "/appearance/button/check/base-checked1/visible", "yes",
+ "/appearance/button/check/clicked-checked0",
+ "/appearance/button/check/clicked-checked0.bits.db",
+ "/appearance/button/check/clicked-checked0/visible", "yes",
+ "/appearance/button/check/clicked-checked1",
+ "/appearance/button/check/clicked-checked1.bits.db",
+ "/appearance/button/check/clicked-checked1/visible", "yes",
+ "/appearance/button/check/hilited-checked0",
+ "/appearance/button/check/hilited-checked0.bits.db",
+ "/appearance/button/check/hilited-checked0/visible", "yes",
+ "/appearance/button/check/hilited-checked1",
+ "/appearance/button/check/hilited-checked1.bits.db",
+ "/appearance/button/check/hilited-checked1/visible", "yes",
+ "/appearance/button/check/selected-checked0",
+ "/appearance/button/check/selected-checked0.bits.db",
+ "/appearance/button/check/selected-checked0/visible", "yes",
+ "/appearance/button/check/selected-checked1",
+ "/appearance/button/check/selected-checked1.bits.db",
+ "/appearance/button/check/selected-checked1/visible", "yes",
+
+ "/appearance/button/radio/base-checked0",
+ "/appearance/button/radio/base-checked0.bits.db",
+ "/appearance/button/radio/base-checked0/visible", "yes",
+ "/appearance/button/radio/base-checked1",
+ "/appearance/button/radio/base-checked1.bits.db",
+ "/appearance/button/radio/base-checked1/visible", "yes",
+ "/appearance/button/radio/clicked-checked0",
+ "/appearance/button/radio/clicked-checked0.bits.db",
+ "/appearance/button/radio/clicked-checked0/visible", "yes",
+ "/appearance/button/radio/clicked-checked1",
+ "/appearance/button/radio/clicked-checked1.bits.db",
+ "/appearance/button/radio/clicked-checked1/visible", "yes",
+ "/appearance/button/radio/hilited-checked0",
+ "/appearance/button/radio/hilited-checked0.bits.db",
+ "/appearance/button/radio/hilited-checked0/visible", "yes",
+ "/appearance/button/radio/hilited-checked1",
+ "/appearance/button/radio/hilited-checked1.bits.db",
+ "/appearance/button/radio/hilited-checked1/visible", "yes",
+ "/appearance/button/radio/selected-checked0",
+ "/appearance/button/radio/selected-checked0.bits.db",
+ "/appearance/button/radio/selected-checked0/visible", "yes",
+ "/appearance/button/radio/selected-checked1",
+ "/appearance/button/radio/selected-checked1.bits.db",
+ "/appearance/button/radio/selected-checked1/visible", "yes",
+
+ "/appearance/entry/default/base",
+ "/appearance/entry/default/base.bits.db",
+ "/appearance/entry/default/base/visible", "yes",
+ "/appearance/entry/cursor/base",
+ "/appearance/entry/cursor/base.bits.db",
+ "/appearance/entry/cursor/base/visible", "yes",
+
+ "/appearance/list/default/base",
+ "/appearance/list/default/base.bits.db",
+ "/appearance/list/default/base/visible", "yes",
+ "/appearance/list/marker/base",
+ "/appearance/list/marker/base.bits.db",
+ "/appearance/list/marker/base/visible", "yes",
+
+ "/appearance/seeker/horizontal/base",
+ "/appearance/seeker/horizontal/base.bits.db",
+ "/appearance/seeker/horizontal/base/visible", "yes",
+ "/appearance/seeker/horizontal/dragbar",
+ "/appearance/seeker/horizontal/dragbar.bits.db",
+ "/appearance/seeker/horizontal/dragbar/visible", "yes",
+
+ "/appearance/seeker/vertical/base",
+ "/appearance/seeker/vertical/base.bits.db",
+ "/appearance/seeker/vertical/base/visible", "yes",
+ "/appearance/seeker/vertical/dragbar",
+ "/appearance/seeker/vertical/dragbar.bits.db",
+ "/appearance/seeker/vertical/dragbar/visible", "yes",
+
+ "/appearance/table/default/base",
+ "/appearance/table/default/base.bits.db",
+ "/appearance/table/default/base/visible", "yes",
+
+ "/appearance/window/default/base",
+ "/appearance/window/default/base.bits.db",
+ "/appearance/window/default/base/visible", "yes",
+
+ NULL, NULL
+};
+
+
+/* Initialize the data structures involved with theme handling. This involves
+ * finding the specified theme file. */
void
ewl_theme_init(void)
{
- char *theme_name = NULL;
- char theme_file[PATH_LEN];
+ struct stat st;
+ char *str;
+ char *home;
- theme_name = ewl_prefs_theme_name_get();
+ /*
+ * Alloacte and clear the default theme
+ */
+ def_theme_data = ewd_hash_new(ewd_str_hash, ewd_str_compare);
+
+ /*
+ * Setup a string with the path to the users theme dir
+ */
+ str = ewl_prefs_str_get("/theme/name");
+ if (!str)
+ DERROR("No theme name... unable to proceed.\n");
+
+ home = getenv("HOME");
+ if (!home)
+ DERROR("Environment variable HOME not defined\n"
+ "Try export HOME=/home/user in a bash like environemnt or\n"
+ "setenv HOME=/home/user in a sh like environment.\n");
+
+ snprintf(theme_path, PATH_LEN, "%s/" EWL_USER_THEMES "/%s", home,
+ str);
+
+ /*
+ * Check the users theme dir to make sure it exists and is a dir
+ */
+ stat(theme_path, &st);
+ if (!S_ISDIR(st.st_mode))
+ {
+ /*
+ * Theme dir is ok, now get the specified theme's path
+ */
+ snprintf(theme_path, PATH_LEN, EWL_GLOBAL_THEMES "/%s",
+ str);
+ stat(theme_path, &st);
- if (!theme && theme_name[0])
- {
- snprintf(theme_path, PATH_LEN, "%s/%s", EWL_GLOBAL_THEMES,
- theme_name);
- snprintf(theme_file, PATH_LEN, "%s/theme.db", theme_path);
- theme = e_db_open_read(theme_file);
- }
-
- /* Got a theme name so lets try to open the theme */
- if (!theme && theme_name)
- {
- /* Absolute path given, so open it there */
- if (theme_name[0] == '/')
- snprintf(theme_path, PATH_LEN, "%s",
- theme_name);
- /* Relative path given so look in user's directory */
- else
- snprintf(theme_path, PATH_LEN, "%s/%s/%s",
- getenv("HOME"), EWL_USER_THEMES,
- theme_name);
-
- snprintf(theme_file, PATH_LEN, "%s/theme.db", theme_path);
- theme = e_db_open_read(theme_file);
- }
-
- /* Ok, stupid user specified a non-existant theme or no theme,
- * so open the default */
- if (!theme)
- {
- snprintf(theme_path, PATH_LEN, "%s/default", EWL_GLOBAL_THEMES);
- snprintf(theme_file, PATH_LEN, "%s/theme.db", theme_path);
- theme = e_db_open_read(theme_file);
- }
+ if (!S_ISDIR(st.st_mode))
+ DERROR("No theme dir =( exiting....");
+ }
+
+ ewl_theme_data_set_defaults();
+}
+
+/* Initialize the widget's theme */
+void
+ewl_theme_init_widget(Ewl_Widget * w)
+{
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
+
+ w->theme = def_theme_data;
+
+ DLEAVE_FUNCTION;
+}
+
+void
+ewl_theme_deinit_widget(Ewl_Widget * w)
+{
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
- snprintf(font_path, PATH_LEN, "%s/appearance/fonts", theme_path);
- snprintf(style_path, PATH_LEN, "%s/appearance/font_styles", theme_path);
+ /*
+ * We only want to destroy the hash if its not def_theme_data
+ * * We destroy def_theme_data from else where..
+ */
+ if (w->theme && w->theme != def_theme_data)
+ ewd_hash_destroy(w->theme);
+
+ else
+ w->theme = NULL;
- etox_style_add_path(style_path);
+ DLEAVE_FUNCTION;
}
+/* Return the path of the current theme */
char *
ewl_theme_path()
{
return strdup(theme_path);
}
+/* Return the path of the current theme's fonts */
char *
ewl_theme_font_path()
{
- return strdup(font_path);
-}
+ static char *font_path = NULL;
-char *
-ewl_theme_font_style_path()
-{
- return strdup(style_path);
+ DENTER_FUNCTION;
+
+ /*
+ * No font path specified yet, so build it up
+ */
+ if (!font_path)
+ {
+ font_path = NEW(char, PATH_LEN);
+
+ snprintf(font_path, PATH_LEN, "%s/appearance/fonts",
+ theme_path);
+ }
+
+ return font_path;
}
+/* Return a string with the path to the specified image */
char *
-ewl_theme_ebit_get(char * widget, char * type, char * state)
+ewl_theme_image_get(Ewl_Widget * w, char *k)
{
- char temp[PATH_LEN];
- char * value = NULL;
- struct stat st;
+ char *path;
+ char *data;
- snprintf(temp, PATH_LEN, "%s/appearance/%s/%s/%s.bits.db",
- theme_path, widget, type, state);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR_RET("w", w, NULL);
+ DCHECK_PARAM_PTR_RET("k", k, NULL);
- value = strdup(temp);
+ data = ewl_theme_data_get(w, k);
- stat(value, &st);
+ if (!data)
+ DRETURN_PTR(NULL);
- if (S_ISREG(st.st_mode))
- return value;
- else
+
+ if (!strncmp(data, "/appearance", 11))
{
- DERROR("File\n%s\ndoes not exist, exiting...\n", value);
- ewl_main_quit();
+ path = NEW(char, PATH_LEN);
+ snprintf(path, PATH_LEN, "%s%s", theme_path, data);
+ FREE(data);
}
+ else /* Absolute path given, so return it */
+ path = data;;
- return NULL;
+ DRETURN_PTR(path);
}
-int
-ewl_theme_int_get(char * key)
+/* Retrieve data from the theme */
+char *
+ewl_theme_data_get(Ewl_Widget * w, char *k)
{
- int value;
+ char *ret = NULL;
+ char *v = NULL;
- e_db_int_get(theme, key, &value);
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR_RET("k", k, NULL);
- return value;
+ if (w)
+ {
+ if (strlen(k) && w->theme)
+ {
+ v = ewd_hash_get(w->theme, k);
+
+ if (v)
+ ret = strdup(v);
+ }
+
+ if (!ret && strlen(k))
+ {
+ if (w->parent)
+ {
+ v = ewl_theme_data_get(w->parent, k);
+ if (v)
+ ret = v;
+ }
+ else
+ {
+ v = ewd_hash_get(def_theme_data, k);
+
+ if (v)
+ ret = strdup(v);
+ }
+ }
+ }
+ else
+ {
+
+ v = ewd_hash_get(def_theme_data, k);
+
+ if (v)
+ ret = strdup(v);
+
+ }
+
+ DRETURN_PTR(ret);
}
+/* Store data into the theme */
void
-ewl_theme_int_set(char * key, int value)
+ewl_theme_data_set(Ewl_Widget * w, char *k, char *v)
{
- e_db_int_set(theme, key, value);
-}
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_PARAM_PTR("k", k);
+ if (w->theme == def_theme_data)
+ w->theme = ewd_hash_new(ewd_str_hash, ewd_str_compare);
-float
-ewl_theme_float_get(char * key)
-{
- float value;
+ ewd_hash_set(w->theme, k, v);
- e_db_float_get(theme, key, &value);
+ ewl_widget_theme_update(w);
- return value;
+ DLEAVE_FUNCTION;
}
void
-ewl_theme_float_set(char * key, float value)
+ewl_theme_data_set_default(char *k, char *v)
{
- e_db_float_set(theme, key, value);
+ DENTER_FUNCTION;
+
+ ewd_hash_set(def_theme_data, k, v);
+
+ DLEAVE_FUNCTION;
}
-char *
-ewl_theme_str_get(char * key)
+void
+ewl_theme_data_gen_default_theme_db(char *f)
{
- return e_db_str_get(theme, key);
+ E_DB_File *db;
+ char str[7], key[512], val[512];
+ int i = -1, j, jj, l;
+
+ db = e_db_open(f);
+
+ while (theme_keys[++i])
+ {
+ snprintf(key, 512, "%s", theme_keys[i]);
+
+ l = strlen(key);
+
+ jj = 0;
+
+ for (j = l - 7; j < l; j++)
+ str[jj++] = key[j];
+
+ if (!strncasecmp(str, "visible", 7))
+ snprintf(val, 512, "yes");
+ else
+ snprintf(val, 512, "%s.bits.db", theme_keys[i]);
+
+ e_db_str_set(db, key, val);
+
+ ++i;
+ }
+
+ e_db_flush();
+
+ e_db_close(db);
}
void
-ewl_theme_str_set(char * key, char * value)
+ewl_theme_data_set_defaults(void)
{
- e_db_str_set(theme, key, value);
+ char *str, *str2;
+ int i;
+
+ for (i = 0; theme_keys[i]; i++)
+ {
+ str = strdup(theme_keys[i]);
+ str2 = strdup(theme_keys[++i]);
+
+ ewd_hash_set(def_theme_data, str, str2);
+ }
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_theme.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -3 -r1.1.1.1 -r1.2
--- ewl_theme.h 2001/04/14 01:16:37 1.1.1.1
+++ ewl_theme.h 2001/07/20 07:31:54 1.2
@@ -2,15 +2,15 @@
#ifndef __EWL_THEME_H__
#define __EWL_THEME_H__
-void ewl_theme_init(void);
-char * ewl_theme_path();
-char * ewl_theme_font_path();
-char * ewl_theme_ebit_get(char * widget, char * type, char * state);
-int ewl_theme_int_get(char * key);
-void ewl_theme_int_set(char * key, int value);
-float ewl_theme_float_get(char * key);
-void ewl_theme_float_set(char * key, float value);
-char * ewl_theme_str_get(char * key);
-void ewl_theme_str_set(char * key, char * value);
+void ewl_theme_init(void);
+void ewl_theme_init_widget(Ewl_Widget * w);
+void ewl_theme_deinit_widget(Ewl_Widget * w);
+char *ewl_theme_path();
+char *ewl_theme_font_path();
+char *ewl_theme_image_get(Ewl_Widget * w, char *k);
+char *ewl_theme_data_get(Ewl_Widget * w, char *k);
+void ewl_theme_data_set(Ewl_Widget * w, char *k, char *v);
+void ewl_theme_data_set_default(char *k, char *v);
+void ewl_theme_data_set_defaults(void);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_widget.c 2001/05/01 04:00:38 1.3
+++ ewl_widget.c 2001/07/20 07:31:54 1.4
@@ -1,92 +1,125 @@
#include <Ewl.h>
-Ewl_Widget *
-ewl_widget_new()
+
+extern Ewl_Widget *last_selected;
+extern Ewl_Widget *last_key;
+extern Ewl_Widget *last_focused;
+extern Ewl_Widget *dnd_widget;
+
+
+void
+ewl_widget_init(Ewl_Widget * w, int type, int req_w, int req_h,
+ int max_w, int max_h)
{
- Ewl_Widget * widget = NULL;
+ CHECK_PARAM_POINTER("w", w);
- widget = NEW(Ewl_Widget, 1);
+ /*
+ * Set up the necessary theme structures
+ */
+ ewl_theme_init_widget(EWL_WIDGET(w));
+ w->type = type;
- ewl_widget_init(widget);
+ /*
+ * Set size fields on the object
+ */
+ MAX_W(w) = max_w;
+ MAX_H(w) = max_h;
- return widget;
+ MIN_W(w) = CURRENT_W(w) = REQUEST_W(w) = req_w;
+ MIN_H(w) = CURRENT_H(w) = REQUEST_H(w) = req_h;
}
void
-ewl_widget_init(Ewl_Widget * widget)
+ewl_widget_realize(Ewl_Widget * w)
{
- CHECK_PARAM_POINTER("widget", widget);
+ int realized = 0;
+
+ CHECK_PARAM_POINTER("w", w);
- memset(widget, 0, sizeof(Ewl_Widget));
+ ewl_object_get_realized(EWL_OBJECT(w), &realized);
+
+ if (realized)
+ return;
+
+ ewl_object_set_realized(EWL_OBJECT(w), TRUE);
+
+ ewl_callback_call(w, EWL_CALLBACK_REALIZE);
}
void
-ewl_widget_reparent(Ewl_Widget * widget, Ewl_Widget * parent)
+ewl_widget_show(Ewl_Widget * w)
{
- CHECK_PARAM_POINTER("widget", widget);
- CHECK_PARAM_POINTER("parent", parent);
+ int visible = 0;
+ int realized = 0;
+
+ CHECK_PARAM_POINTER("w", w);
- widget->evas = parent->evas;
- widget->evas_window = parent->evas_window;
- widget->parent = parent;
+ ewl_object_get_visible(EWL_OBJECT(w), &visible);
+ ewl_object_get_realized(EWL_OBJECT(w), &realized);
+
+ if (visible)
+ return;
+
+ if (!realized)
+ ewl_widget_realize(w);
+
+ ewl_object_set_visible(EWL_OBJECT(w), TRUE);
+
+ ewl_callback_call(w, EWL_CALLBACK_SHOW);
}
void
-ewl_widget_realize(Ewl_Widget * widget)
+ewl_widget_hide(Ewl_Widget * w)
{
- CHECK_PARAM_POINTER("widget", widget);
+ CHECK_PARAM_POINTER("w", w);
- if (EWL_OBJECT(widget)->realized)
- return;
-
- if (!widget->evas && widget->parent && widget->parent->evas)
- {
- EWL_OBJECT(widget)->layer = widget->parent->object.layer + 1;
- widget->evas = widget->parent->evas;
- }
+ ewl_callback_call(w, EWL_CALLBACK_HIDE);
- EWL_OBJECT(widget)->realized = TRUE;
- ewl_callback_call(widget, EWL_CALLBACK_REALIZE);
+ ewl_object_set_visible(EWL_OBJECT(w), FALSE);
}
void
-ewl_widget_show(Ewl_Widget * widget)
+ewl_widget_destroy(Ewl_Widget * w)
{
- CHECK_PARAM_POINTER("widget", widget);
+ CHECK_PARAM_POINTER("w", w);
- if (EWL_OBJECT(widget)->visible)
- return;
+ if (last_selected == w)
+ last_selected = NULL;
+
+ if (last_key == w)
+ last_key = NULL;
+
+ if (last_focused == w)
+ last_focused = NULL;
- if (!EWL_OBJECT(widget)->realized)
- ewl_widget_realize(widget);
+ if (dnd_widget == w)
+ dnd_widget = NULL;
- EWL_OBJECT(widget)->visible = TRUE;
- ewl_callback_call(widget, EWL_CALLBACK_SHOW);
+ ewl_callback_call(w, EWL_CALLBACK_DESTROY);
}
void
-ewl_widget_hide(Ewl_Widget * widget)
+ewl_widget_destroy_recursive(Ewl_Widget * w)
{
- CHECK_PARAM_POINTER("widget", widget);
+ CHECK_PARAM_POINTER("w", w);
- ewl_callback_call(widget, EWL_CALLBACK_HIDE);
- EWL_OBJECT(widget)->visible = FALSE;
+ ewl_callback_call(w, EWL_CALLBACK_DESTROY_RECURSIVE);
+ ewl_widget_destroy(w);
}
void
-ewl_widget_destroy(Ewl_Widget * widget)
+ewl_widget_configure(Ewl_Widget * w)
{
- CHECK_PARAM_POINTER("widget", widget);
+ CHECK_PARAM_POINTER("w", w);
- ewl_callback_call(widget, EWL_CALLBACK_DESTROY);
- EWL_OBJECT(widget)->realized = FALSE;
+ ewl_callback_call(w, EWL_CALLBACK_CONFIGURE);
}
void
-ewl_widget_configure(Ewl_Widget * widget)
+ewl_widget_theme_update(Ewl_Widget * w)
{
- CHECK_PARAM_POINTER("widget", widget);
+ CHECK_PARAM_POINTER("w", w);
- ewl_callback_call(widget, EWL_CALLBACK_CONFIGURE);
+ ewl_callback_call(w, EWL_CALLBACK_THEME_UPDATE);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_widget.h 2001/05/01 04:00:38 1.4
+++ ewl_widget.h 2001/07/20 07:31:54 1.5
@@ -5,48 +5,69 @@
typedef struct _ewl_widget Ewl_Widget;
typedef enum _ewl_widget_type Ewl_Widget_Type;
-#include <ewl_container.h>
-
-enum _ewl_widget_type {
- EWL_WIDGET_WINDOW,
- EWL_WIDGET_BOX,
- EWL_WIDGET_BUTTON,
- EWL_WIDGET_ENTRY,
- EWL_WIDGET_TABLE,
+enum _ewl_widget_type
+{
+ EWL_WIDGET_WINDOW,
+ EWL_WIDGET_BOX,
+ EWL_WIDGET_BUTTON,
+ EWL_WIDGET_LABEL_BUTTON,
+ EWL_WIDGET_CHECK_BUTTON,
+ EWL_WIDGET_RADIO_BUTTON,
+ EWL_WIDGET_ENTRY,
+ EWL_WIDGET_TABLE,
EWL_WIDGET_SEEKER,
- EWL_WIDGET_SPINNER
+ EWL_WIDGET_SPINNER,
+ EWL_WIDGET_LIST,
+ EWL_WIDGET_TEXT,
+ EWL_WIDGET_IMAGE
};
-struct _ewl_widget {
+struct _ewl_widget
+{
+ /*
+ * These fields are the basic information about how this widget
+ * relates to others.
+ */
Ewl_Object object;
-
- Ewl_Widget * parent;
-
+ Ewl_Widget *parent;
Ewl_Widget_Type type;
- Ewl_Container container;
-
- /* List of callbacks for this widget */
- Ewd_List * callbacks[EWL_CALLBACK_MAX];
-
+ /*
+ * List of callbacks for this widget
+ */
+ Ewd_List *callbacks[EWL_CALLBACK_MAX];
+
+ /*
+ * The following fields allow for drawing the widget and its children
+ */
Evas evas;
- Evas_Object fx_clip_box; /* use to cover up whole widget for FX */
Window evas_window;
-
+ Evas_Object fx_clip_box;
+ Ebits_Object *ebits_object;
+ int recursive;
+
+ /*
+ * And these are for keeping track of the appearance and behavior
+ * states of the widget.
+ */
Ewl_State state;
+ Ewd_Hash *theme;
};
#define EWL_WIDGET(widget) ((Ewl_Widget *) widget)
/* Returns a allocated widget structure */
-Ewl_Widget * ewl_widget_new();
-void ewl_widget_init(Ewl_Widget * _ewl_widget);
+Ewl_Widget *ewl_widget_new();
+void
+ewl_widget_init(Ewl_Widget * w, int type, int req_w, int req_h,
+ int max_w, int max_h);
void ewl_widget_reparent(Ewl_Widget * parent, Ewl_Widget * widget);
-void ewl_widget_init(Ewl_Widget * _ewl_widget);
void ewl_widget_realize(Ewl_Widget * widget);
void ewl_widget_show(Ewl_Widget * widget);
void ewl_widget_hide(Ewl_Widget * widget);
void ewl_widget_destroy(Ewl_Widget * widget);
+void ewl_widget_destroy_recursive(Ewl_Widget * widget);
void ewl_widget_configure(Ewl_Widget * widget);
+void ewl_widget_theme_update(Ewl_Widget * w);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_window.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_window.c 2001/05/02 23:12:42 1.6
+++ ewl_window.c 2001/07/20 07:31:54 1.7
@@ -1,224 +1,338 @@
#include <Ewl.h>
-Ewd_List * ewl_window_list = NULL;
+Ewd_List *ewl_window_list = NULL;
-static void ewl_window_init(Ewl_Widget * widget);
-static void ewl_window_realize(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_window_show(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_window_hide(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_window_destroy(Ewl_Widget * widget, Ewl_Callback * cb);
-static void ewl_window_configure(Ewl_Widget * widget, Ewl_Callback * cb);
+static void __ewl_window_init(Ewl_Window * w);
+static void __ewl_window_realize(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_window_show(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_window_hide(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_window_destroy(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_window_destroy_recursive(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_window_configure(Ewl_Widget * w, void *event_data,
+ void *user_data);
+static void __ewl_window_theme_update(Ewl_Widget * w, void *event_data,
+ void *user_data);
Ewl_Widget *
ewl_window_new()
{
- Ewl_Window * window = NULL;
+ Ewl_Window *w;
- window = NEW(Ewl_Window, 1);
+ DENTER_FUNCTION;
- ewl_window_init(EWL_WIDGET(window));
+ w = NEW(Ewl_Window, 1);
- return EWL_WIDGET(window);
+ __ewl_window_init(w);
+
+ DRETURN_PTR(EWL_WIDGET(w));
}
static void
-ewl_window_init(Ewl_Widget * widget)
+__ewl_window_init(Ewl_Window * w)
{
- CHECK_PARAM_POINTER("widget", widget);
-
- memset(EWL_WINDOW(widget), 0, sizeof(Ewl_Window));
-
- EWL_WINDOW(widget)->title = strdup("EWL!");
- widget->type = EWL_WIDGET_WINDOW;
+ DCHECK_PARAM_PTR("w", w);
- ewl_callback_append(widget, EWL_CALLBACK_REALIZE,
- ewl_window_realize, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_SHOW,
- ewl_window_show, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_HIDE,
- ewl_window_hide, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_DESTROY,
- ewl_window_destroy, NULL);
- ewl_callback_append(widget, EWL_CALLBACK_CONFIGURE,
- ewl_window_configure, NULL);
-
- widget->container.recursive = TRUE;
-
- EWL_OBJECT(widget)->current.w = 256;
- EWL_OBJECT(widget)->current.h = 256;
- EWL_OBJECT(widget)->minimum.w = 1;
- EWL_OBJECT(widget)->minimum.h = 1;
- EWL_OBJECT(widget)->maximum.w = 2024;
- EWL_OBJECT(widget)->maximum.h = 2024;
- EWL_OBJECT(widget)->request.w = 256;
- EWL_OBJECT(widget)->request.h = 256;
+ /*
+ * Initialize the fields of the inherited container class
+ */
+ memset(w, 0, sizeof(Ewl_Window));
+ ewl_container_init(EWL_CONTAINER(w), EWL_WIDGET_WINDOW, 256, 256,
+ 2048, 2048);
+
+ w->title = strdup("EWL!");
+
+ ewl_theme_init_widget(EWL_WIDGET(w));
+
+ ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_REALIZE,
+ __ewl_window_realize, NULL);
+ ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_SHOW,
+ __ewl_window_show, NULL);
+ ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_HIDE,
+ __ewl_window_hide, NULL);
+ ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_DESTROY,
+ __ewl_window_destroy, NULL);
+ ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_DESTROY_RECURSIVE,
+ __ewl_window_destroy_recursive, NULL);
+ ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_CONFIGURE,
+ __ewl_window_configure, NULL);
- EWL_OBJECT(widget)->layer = -999;
+ EWL_OBJECT(w)->layer = -999;
if (!ewl_window_list)
ewl_window_list = ewd_list_new();
- ewd_list_append(ewl_window_list, widget);
+ ewd_list_append(ewl_window_list, w);
}
static void
-ewl_window_realize(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_window_realize(Ewl_Widget * w, void *event_data, void *user_data)
{
- Ewl_Window * window = NULL;
- char * image = NULL;
+ Ewl_Window *window;
+ char *font_path;
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("w", w);
- window = EWL_WINDOW(widget);
+ window = EWL_WINDOW(w);
- window->window = e_window_new(0, 0, 0, EWL_OBJECT(widget)->current.w,
- EWL_OBJECT(widget)->current.h);
+ window->window =
+ e_window_new(0, 0, 0, EWL_OBJECT(w)->current.w,
+ EWL_OBJECT(w)->current.h);
e_window_set_events(window->window, XEV_CONFIGURE);
e_window_set_name_class(window->window, "EWL", "EWL!");
- e_window_set_min_size(window->window, EWL_OBJECT(widget)->minimum.w,
- EWL_OBJECT(widget)->minimum.h);
- e_window_set_max_size(window->window, EWL_OBJECT(widget)->maximum.w,
- EWL_OBJECT(widget)->maximum.h);
+ e_window_set_min_size(window->window,
+ EWL_OBJECT(w)->minimum.w,
+ EWL_OBJECT(w)->minimum.h);
+ e_window_set_max_size(window->window,
+ EWL_OBJECT(w)->maximum.w,
+ EWL_OBJECT(w)->maximum.h);
e_window_set_title(window->window, window->title);
e_window_set_delete_inform(window->window);
+
+ font_path = ewl_theme_font_path();
+
+ w->evas = evas_new_all(e_display_get(),
+ window->window, 0, 0,
+ EWL_OBJECT(w)->
+ current.w,
+ EWL_OBJECT(w)->
+ current.h,
+ ewl_prefs_render_method_get
+ (), 216, 1024 * 1024 * 2,
+ 1024 * 1024 * 5, font_path);
+
+ IF_FREE(font_path);
+
+ w->evas_window = evas_get_window(w->evas);
+ e_window_set_events(w->evas_window, XEV_KEY | XEV_BUTTON |
+ XEV_IN_OUT | XEV_EXPOSE | XEV_VISIBILITY |
+ XEV_MOUSE_MOVE);
- EWL_WIDGET(window)->evas = evas_new_all(e_display_get(),
- window->window, 0, 0,
- EWL_OBJECT(widget)->current.w, EWL_OBJECT(widget)->current.h,
- ewl_prefs_render_method_get(),
- 216,
- 1024 * 1024 * 2,
- 1024 * 1024 * 5,
- ewl_theme_font_path());
-
- widget->evas_window = evas_get_window(widget->evas);
- e_window_set_events(widget->evas_window, XEV_KEY | XEV_BUTTON |
- XEV_IN_OUT | XEV_EXPOSE | XEV_VISIBILITY | XEV_MOUSE_MOVE);
-
-
- image = ewl_theme_ebit_get("window", "default", "base");
- EWL_WINDOW(widget)->ebits_object = ebits_load(image);
- IF_FREE(image);
- ebits_add_to_evas(EWL_WINDOW(widget)->ebits_object, widget->evas);
- ebits_set_layer(EWL_BUTTON(widget)->ebits_object, -1000);
+ ewl_widget_theme_update(w);
}
static void
-ewl_window_show(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_window_show(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("w", w);
- e_window_show(EWL_WINDOW(widget)->window);
- e_window_show(widget->evas_window);
- ebits_show(EWL_WINDOW(widget)->ebits_object);
+ e_window_show(EWL_WINDOW(w)->window);
+ e_window_show(w->evas_window);
- ewl_widget_configure(widget);
+ ewl_widget_configure(w);
}
static void
-ewl_window_hide(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_window_hide(Ewl_Widget * widget, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("widget", widget);
e_window_hide(widget->evas_window);
e_window_hide(EWL_WINDOW(widget)->window);
}
static void
-ewl_window_destroy(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_window_destroy(Ewl_Widget * w, void *event_data, void *user_data)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("w", w);
- IF_FREE(EWL_WINDOW(widget)->title);
+ IF_FREE(EWL_WINDOW(w)->title);
- ebits_hide(EWL_WINDOW(widget)->ebits_object);
- ebits_free(EWL_WINDOW(widget)->ebits_object);
+ if (w->ebits_object)
+ {
+ ebits_hide(w->ebits_object);
+ ebits_free(w->ebits_object);
+ }
- evas_free(widget->evas);
+ if (w->evas)
+ evas_free(w->evas);
- e_window_hide(widget->evas_window);
- e_window_hide(EWL_WINDOW(widget)->window);
+ e_window_hide(w->evas_window);
+ e_window_hide(EWL_WINDOW(w)->window);
- e_window_destroy(widget->evas_window);
- e_window_destroy(EWL_WINDOW(widget)->window);
+ e_window_destroy(w->evas_window);
+ e_window_destroy(EWL_WINDOW(w)->window);
- if (ewd_list_goto(ewl_window_list, widget))
+ IF_FREE(EWL_WINDOW(w)->title);
+
+ if (ewd_list_goto(ewl_window_list, w))
ewd_list_remove(ewl_window_list);
+
+ ewl_callback_del_all(w);
- FREE(widget);
+ ewl_theme_deinit_widget(w);
+
+ FREE(w);
}
static void
-ewl_window_configure(Ewl_Widget * widget, Ewl_Callback * cb)
+__ewl_window_destroy_recursive(Ewl_Widget * widget, void *event_data,
+ void *user_data)
{
- Ewl_Widget * child;
- int x, y, l = 0, r = 0, t = 0, b = 0;
+ Ewl_Widget *child;
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("widget", widget);
+
+ while ((child =
+ ewd_list_remove_last(EWL_CONTAINER(widget)->children)) !=
+ NULL)
+ ewl_widget_destroy_recursive(child);
+}
+
+static void
+__ewl_window_configure(Ewl_Widget * widget, void *event_data, void *user_data)
+{
+ Ewl_Widget *child;
+ int x, y, l = 0, r = 0, t = 0, b = 0;
- if (EWL_WINDOW(widget)->ebits_object)
- ebits_resize(EWL_WINDOW(widget)->ebits_object,
- EWL_OBJECT(widget)->request.w, EWL_OBJECT(widget)->request.h);
+ DCHECK_PARAM_PTR("widget", widget);
EWL_OBJECT(widget)->request.x = 0;
EWL_OBJECT(widget)->request.y = 0;
-
- ebits_get_insets(EWL_WINDOW(widget)->ebits_object, &l, &r, &t, &b);
- if (widget->container.clip_box)
+ if (widget->ebits_object)
{
- evas_move(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->request.x + l,
- EWL_OBJECT(widget)->request.y + t);
- evas_resize(widget->evas, widget->container.clip_box,
- EWL_OBJECT(widget)->request.w - (l+r),
- EWL_OBJECT(widget)->request.h - (t+b));
+ ebits_resize(widget->ebits_object,
+ EWL_OBJECT(widget)->request.w,
+ EWL_OBJECT(widget)->request.h);
+ ebits_get_insets(widget->ebits_object, &l, &r, &t, &b);
+
+ if (EWL_CONTAINER(widget)->clip_box)
+ {
+ evas_move(widget->evas,
+ EWL_CONTAINER(widget)->clip_box,
+ REQUEST_X(widget) + l,
+ REQUEST_Y(widget) + t);
+ evas_resize(widget->evas,
+ EWL_CONTAINER(widget)->clip_box,
+ REQUEST_W(widget) - (l + r),
+ REQUEST_H(widget) - (t + b));
+ }
+
+ e_window_resize(widget->evas_window, REQUEST_W(widget),
+ REQUEST_H(widget));
+ evas_set_output_size(widget->evas, REQUEST_W(widget),
+ REQUEST_H(widget));
+ evas_set_output_viewport(widget->evas, 0, 0,
+ REQUEST_W(widget),
+ REQUEST_H(widget));
}
- e_window_resize(widget->evas_window,
- EWL_OBJECT(widget)->request.w, EWL_OBJECT(widget)->request.h);
- evas_set_output_size(widget->evas,
- EWL_OBJECT(widget)->request.w, EWL_OBJECT(widget)->request.h);
- evas_set_output_viewport(widget->evas, 0, 0,
- EWL_OBJECT(widget)->request.w, EWL_OBJECT(widget)->request.h);
+ CURRENT_W(widget) = REQUEST_W(widget);
+ CURRENT_H(widget) = REQUEST_H(widget);
- EWL_OBJECT(widget)->current.w = EWL_OBJECT(widget)->request.w;
- EWL_OBJECT(widget)->current.h = EWL_OBJECT(widget)->request.h;
+ if (EWL_CONTAINER(widget)->children)
+ ewd_list_goto_first(EWL_CONTAINER(widget)->children);
- if (widget->container.children)
- ewd_list_goto_first(widget->container.children);
-
x = l;
y = t;
+
+ if (EWL_CONTAINER(widget)->children)
+ while ((child =
+ ewd_list_next(EWL_CONTAINER(widget)->children)) !=
+ NULL)
+ {
+ REQUEST_X(child) = x;
+ REQUEST_Y(child) = y;
+ REQUEST_W(child) = CURRENT_W(widget) - l - r;
+ REQUEST_H(child) = (CURRENT_H(widget) /
+ ewd_list_nodes(EWL_CONTAINER
+ (widget)->
+ children)) - b -
+ t;
+ y += CURRENT_H(child) + t;
+ ewl_widget_configure(child);
+ }
+}
+
+static void
+__ewl_window_theme_update(Ewl_Widget * w, void *event_data, void *user_data)
+{
+ Ewl_Window *win;
+ char *v;
- if (widget->container.children)
- while ((child = ewd_list_next(widget->container.children)) != NULL)
+ DENTER_FUNCTION;
+ DCHECK_PARAM_PTR("w", w);
+
+ /*
+ * Shouldn't do anything if the widget isn't realized yet
+ */
+ if (!w->object.realized)
+ DRETURN;
+
+ win = EWL_WINDOW(w);
+
+ /*
+ * Check if GFX should be visible or not
+ */
+ v = ewl_theme_data_get(w, "/appearance/window/default/base/visible");
+
+ /*
+ * Destroy old image (if any)
+ */
+ if (w->ebits_object)
+ {
+ ebits_hide(w->ebits_object);
+ ebits_unset_clip(w->ebits_object);
+ ebits_free(w->ebits_object);
+ }
+
+ /*
+ * If we want to show the new GFX show it :-)
+ */
+ if (v && !strncasecmp(v, "yes", 3))
{
- EWL_OBJECT(child)->request.x = x;
- EWL_OBJECT(child)->request.y = y;
- EWL_OBJECT(child)->request.w = EWL_OBJECT(widget)->current.w - l - r;
- EWL_OBJECT(child)->request.h = (EWL_OBJECT(widget)->current.h /
- widget->container.children->nodes) - b - t;
- y += EWL_OBJECT(child)->current.h + t;
- ewl_widget_configure(child);
+ char *i;
+
+ i = ewl_theme_image_get(w,
+ "/appearance/window/default/base");
+
+ if (i)
+ {
+ w->ebits_object = ebits_load(i);
+ FREE(i);
+
+ if (w->ebits_object)
+ {
+ ebits_add_to_evas(w->ebits_object,
+ w->evas);
+ ebits_set_layer(w->ebits_object,
+ w->object.layer);
+ ebits_set_clip(w->ebits_object,
+ w->fx_clip_box);
+
+ ebits_show(w->ebits_object);
+ }
+ }
}
+
+ IF_FREE(v);
+
+ /*
+ * Finally configure the widget to update changes
+ */
+ ewl_widget_configure(w);
}
Ewl_Window *
ewl_window_find_window(Window window)
{
- Ewl_Window * retwin;
+ Ewl_Window *retwin;
- CHECK_PARAM_POINTER_RETURN("window", window, NULL);
+ DCHECK_PARAM_PTR_RET("window", window, NULL);
ewd_list_goto_first(ewl_window_list);
- while ((retwin = EWL_WINDOW(ewd_list_next(ewl_window_list))) != NULL)
+ while ((retwin = ewd_list_next(ewl_window_list)) != NULL)
{
- if (retwin->window == window)
- return retwin;
+ if (retwin->window == window)
+ return retwin;
}
return NULL;
@@ -227,16 +341,16 @@
Ewl_Window *
ewl_window_find_window_by_evas_window(Window window)
{
- Ewl_Window * retwin;
+ Ewl_Window *retwin;
- CHECK_PARAM_POINTER_RETURN("window", window, NULL);
+ DCHECK_PARAM_PTR_RET("window", window, NULL);
ewd_list_goto_first(ewl_window_list);
- while ((retwin = EWL_WINDOW(ewd_list_next(ewl_window_list))) != NULL)
+ while ((retwin = ewd_list_next(ewl_window_list)) != NULL)
{
- if (EWL_WIDGET(retwin)->evas_window == window)
- return retwin;
+ if (EWL_WIDGET(retwin)->evas_window == window)
+ return retwin;
}
return NULL;
@@ -245,7 +359,7 @@
void
ewl_window_resize(Ewl_Widget * widget, int w, int h)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("widget", widget);
EWL_OBJECT(widget)->current.w = w;
EWL_OBJECT(widget)->current.h = h;
@@ -256,7 +370,7 @@
void
ewl_window_set_min_size(Ewl_Widget * widget, int w, int h)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("widget", widget);
EWL_OBJECT(widget)->minimum.w = w;
EWL_OBJECT(widget)->minimum.h = h;
@@ -270,7 +384,7 @@
void
ewl_window_set_max_size(Ewl_Widget * widget, int w, int h)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("widget", widget);
EWL_OBJECT(widget)->maximum.w = w;
EWL_OBJECT(widget)->maximum.h = h;
@@ -282,14 +396,14 @@
}
void
-ewl_window_set_title(Ewl_Widget * widget, char * title)
+ewl_window_set_title(Ewl_Widget * widget, char *title)
{
- CHECK_PARAM_POINTER("widget", widget);
+ DCHECK_PARAM_PTR("widget", widget);
if (strcmp(EWL_WINDOW(widget)->title, title))
{
- IF_FREE(EWL_WINDOW(widget)->title);
- EWL_WINDOW(widget)->title = strdup(title);
+ IF_FREE(EWL_WINDOW(widget)->title);
+ EWL_WINDOW(widget)->title = strdup(title);
}
if (!EWL_OBJECT(widget)->realized)
@@ -301,7 +415,7 @@
char *
ewl_window_get_title(Ewl_Widget * widget)
{
- CHECK_PARAM_POINTER_RETURN("widget", widget, NULL);
+ DCHECK_PARAM_PTR_RET("widget", widget, NULL);
return strdup(EWL_WINDOW(widget)->title);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_window.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_window.h 2001/05/01 04:00:38 1.2
+++ ewl_window.h 2001/07/20 07:31:54 1.3
@@ -2,24 +2,41 @@
#ifndef __EWL_WINDOW_H__
#define __EWL_WINDOW_H__
+/*
+ * We want to support a variety of window types, including normal windows,
+ * dialog boxes, and MacOS X style drop down dialogs.
+ */
+typedef enum _ewl_window_type Ewl_Window_Type;
+
+enum _ewl_window_type
+{
+ EWL_WINDOW_NORMAL,
+ EWL_WINDOW_DIALOG,
+ EWL_WINDOW_DROPDOWN
+};
+
+/*
+ * The window structure is mostly a container for holding widgets and a
+ * wrapper around the xlib window.
+ */
typedef struct _ewl_window Ewl_Window;
-struct _ewl_window {
- Ewl_Widget widget;
- Ebits_Object ebits_object;
- Window window;
- char * title;
+struct _ewl_window
+{
+ Ewl_Container widget;
+ Window window;
+ char *title;
};
#define EWL_WINDOW(widget) ((Ewl_Window *) widget)
-Ewl_Widget * ewl_window_new();
-Ewl_Window * ewl_window_find_window(Window window);
-Ewl_Window * ewl_window_find_window_by_evas_window(Window window);
+Ewl_Widget *ewl_window_new();
+Ewl_Window *ewl_window_find_window(Window window);
+Ewl_Window *ewl_window_find_window_by_evas_window(Window window);
void ewl_window_resize(Ewl_Widget * widget, int w, int h);
void ewl_window_set_min_size(Ewl_Widget * widget, int w, int h);
void ewl_window_set_max_size(Ewl_Widget * widget, int w, int h);
-void ewl_window_set_title(Ewl_Widget * widget, char * title);
-char * ewl_window_get_title(Ewl_Widget * widget);
+void ewl_window_set_title(Ewl_Widget * widget, char *title);
+char *ewl_window_get_title(Ewl_Widget * widget);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/getopt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- getopt.c 2001/04/16 11:59:23 1.1
+++ getopt.c 2001/07/20 07:31:54 1.2
@@ -1,3 +1,4 @@
+
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to roland@...
@@ -32,6 +33,7 @@
#endif
#if !defined (__STDC__) || !__STDC__
+
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
@@ -63,6 +65,7 @@
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
+
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
#include <stdlib.h>
@@ -77,6 +80,7 @@
#endif
#ifndef _
+
/* This is for other GNU distributions with internationalized messages.
When compiling libc, the _ macro is predefined. */
#ifdef HAVE_LIBINTL_H
@@ -183,7 +187,7 @@
static enum
{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
}
ordering;
@@ -191,6 +195,7 @@
static char *posixly_correct;
#ifdef __GNU_LIBRARY__
+
/* We want to avoid inclusion of string.h with non-GNU libraries
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
@@ -206,24 +211,26 @@
static char *
my_index(str, chr)
- const char *str;
- int chr;
+ const char *str;
+ int chr;
{
- while (*str)
- {
- if (*str == chr)
- return (char *) str;
- str++;
- }
- return 0;
+ while (*str)
+ {
+ if (*str == chr)
+ return (char *) str;
+ str++;
+ }
+ return 0;
}
/* If using GCC, we can safely declare strlen this way.
If not using GCC, it is ok not to declare it. */
#ifdef __GNUC__
+
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
That was relevant to code that was here before. */
#if !defined (__STDC__) || !__STDC__
+
/* gcc with -traditional declares the built-in strlen to return int,
and has done so at least since version 2.4.5. -- rms. */
extern int strlen(const char *);
@@ -242,6 +249,7 @@
static int last_nonopt;
#ifdef _LIBC
+
/* Bash 2.0 gives us an environment variable containing flags
indicating ARGV elements that should not be considered arguments. */
@@ -258,17 +266,19 @@
is valid for the getopt call we must make sure that the ARGV passed
to getopt is that one passed to the process. */
static void __attribute__ ((unused)) store_args_and_env(int argc,
- char *const *argv)
+ char *const *argv)
{
- /* XXX This is no good solution. We should rather copy the args so that
- we can compare them later. But we must not use malloc(3). */
- original_argc = argc;
- original_argv = argv;
+ /*
+ * XXX This is no good solution. We should rather copy the args so that
+ * * we can compare them later. But we must not use malloc(3).
+ */
+ original_argc = argc;
+ original_argv = argv;
}
# ifdef text_set_element
text_set_element(__libc_subinit, store_args_and_env);
-# endif /* text_set_element */
+# endif /* text_set_element */
# define SWAP_FLAGS(ch1, ch2) \
if (nonoption_flags_len > 0) \
@@ -296,83 +306,107 @@
static void
exchange(argv)
- char **argv;
+ char **argv;
{
- int bottom = first_nonopt;
- int middle = last_nonopt;
- int top = optind;
- char *tem;
-
- /* Exchange the shorter segment with the far end of the longer segment.
- That puts the shorter segment into the right place. It leaves the
- longer segment in the right place overall, but it consists of two parts
- that need to be swapped next. */
+ int bottom = first_nonopt;
+ int middle = last_nonopt;
+ int top = optind;
+ char *tem;
+
+ /*
+ * Exchange the shorter segment with the far end of the longer segment.
+ * * That puts the shorter segment into the right place. It leaves the
+ * * longer segment in the right place overall, but it consists of two parts
+ * * that need to be swapped next.
+ */
#ifdef _LIBC
- /* First make sure the handling of the `__getopt_nonoption_flags' string
- can work normally. Our top argument must be in the range of the
- string. */
- if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
- {
- /* We must extend the array. The user plays games with us and presents
- new arguments. */
- char *new_str = malloc(top + 1);
-
- if (new_str == NULL)
- nonoption_flags_len = nonoption_flags_max_len = 0;
- else
- {
- memset(__mempcpy
- (new_str, __getopt_nonoption_flags, nonoption_flags_max_len),
- '\0', top + 1 - nonoption_flags_max_len);
- nonoption_flags_max_len = top + 1;
- __getopt_nonoption_flags = new_str;
- }
- }
+ /*
+ * First make sure the handling of the `__getopt_nonoption_flags' string
+ * * can work normally. Our top argument must be in the range of the
+ * * string.
+ */
+ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
+ {
+ /*
+ * We must extend the array. The user plays games with us and presents
+ * * new arguments.
+ */
+ char *new_str = malloc(top + 1);
+
+ if (new_str == NULL)
+ nonoption_flags_len = nonoption_flags_max_len = 0;
+ else
+ {
+ memset(__mempcpy
+ (new_str, __getopt_nonoption_flags,
+ nonoption_flags_max_len), '\0',
+ top + 1 - nonoption_flags_max_len);
+ nonoption_flags_max_len = top + 1;
+ __getopt_nonoption_flags = new_str;
+ }
+ }
#endif
-
- while (top > middle && middle > bottom)
- {
- if (top - middle > middle - bottom)
- {
- /* Bottom segment is the short one. */
- int len = middle - bottom;
- register int i;
-
- /* Swap it with the top part of the top segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[top - (middle - bottom) + i];
- argv[top - (middle - bottom) + i] = tem;
- SWAP_FLAGS(bottom + i, top - (middle - bottom) + i);
- }
- /* Exclude the moved bottom segment from further swapping. */
- top -= len;
- }
- else
- {
- /* Top segment is the short one. */
- int len = top - middle;
- register int i;
-
- /* Swap it with the bottom part of the bottom segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[middle + i];
- argv[middle + i] = tem;
- SWAP_FLAGS(bottom + i, middle + i);
- }
- /* Exclude the moved top segment from further swapping. */
- bottom += len;
- }
- }
- /* Update records for the slots the non-options now occupy. */
+ while (top > middle && middle > bottom)
+ {
+ if (top - middle > middle - bottom)
+ {
+ /*
+ * Bottom segment is the short one.
+ */
+ int len = middle - bottom;
+ register int i;
+
+ /*
+ * Swap it with the top part of the top segment.
+ */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] =
+ argv[top - (middle - bottom) +
+ i];
+ argv[top - (middle - bottom) + i] = tem;
+ SWAP_FLAGS(bottom + i,
+ top - (middle - bottom) + i);
+ }
+ /*
+ * Exclude the moved bottom segment from further swapping.
+ */
+ top -= len;
+ }
+ else
+ {
+ /*
+ * Top segment is the short one.
+ */
+ int len = top - middle;
+ register int i;
+
+ /*
+ * Swap it with the bottom part of the bottom segment.
+ */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ SWAP_FLAGS(bottom + i, middle + i);
+ }
+ /*
+ * Exclude the moved top segment from further swapping.
+ */
+ bottom += len;
+ }
+ }
+
+ /*
+ * Update records for the slots the non-options now occupy.
+ */
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
+ first_nonopt += (optind - last_nonopt);
+ last_nonopt = optind;
}
/* Initialize the internal data when the first call is made. */
@@ -382,69 +416,78 @@
#endif
static const char *
_getopt_initialize(argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
+ int argc;
+ char *const *argv;
+ const char *optstring;
{
- /* Start processing options with ARGV-element 1 (since ARGV-element 0 is
- the program name); the sequence of previously skipped non-option
- ARGV-elements is empty. */
-
- first_nonopt = last_nonopt = optind;
-
- nextchar = NULL;
-
- posixly_correct = getenv("POSIXLY_CORRECT");
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
- else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
- else if (posixly_correct != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
+ /*
+ * Start processing options with ARGV-element 1 (since ARGV-element 0 is
+ * * the program name); the sequence of previously skipped non-option
+ * * ARGV-elements is empty.
+ */
+
+ first_nonopt = last_nonopt = optind;
+
+ nextchar = NULL;
+
+ posixly_correct = getenv("POSIXLY_CORRECT");
+
+ /*
+ * Determine how to handle the ordering of options and nonoptions.
+ */
+
+ if (optstring[0] == '-')
+ {
+ ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
+ else if (optstring[0] == '+')
+ {
+ ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
+ else if (posixly_correct != NULL)
+ ordering = REQUIRE_ORDER;
+ else
+ ordering = PERMUTE;
#ifdef _LIBC
- if (posixly_correct == NULL && argc == original_argc
- && argv == original_argv)
- {
- if (nonoption_flags_max_len == 0)
- {
- if (__getopt_nonoption_flags == NULL
- || __getopt_nonoption_flags[0] == '\0')
- nonoption_flags_max_len = -1;
- else
- {
- const char *orig_str = __getopt_nonoption_flags;
- int len = nonoption_flags_max_len = strlen(orig_str);
-
- if (nonoption_flags_max_len < argc)
- nonoption_flags_max_len = argc;
- __getopt_nonoption_flags =
- (char *) malloc(nonoption_flags_max_len);
- if (__getopt_nonoption_flags == NULL)
- nonoption_flags_max_len = -1;
- else
- memset(__mempcpy(__getopt_nonoption_flags, orig_str, len),
- '\0', nonoption_flags_max_len - len);
- }
- }
- nonoption_flags_len = nonoption_flags_max_len;
- }
- else
- nonoption_flags_len = 0;
+ if (posixly_correct == NULL && argc == original_argc
+ && argv == original_argv)
+ {
+ if (nonoption_flags_max_len == 0)
+ {
+ if (__getopt_nonoption_flags == NULL
+ || __getopt_nonoption_flags[0] == '\0')
+ nonoption_flags_max_len = -1;
+ else
+ {
+ const char *orig_str =
+ __getopt_nonoption_flags;
+ int len = nonoption_flags_max_len =
+ strlen(orig_str);
+
+ if (nonoption_flags_max_len < argc)
+ nonoption_flags_max_len = argc;
+ __getopt_nonoption_flags = (char *)
+ malloc(nonoption_flags_max_len);
+ if (__getopt_nonoption_flags == NULL)
+ nonoption_flags_max_len = -1;
+ else
+ memset(__mempcpy
+ (__getopt_nonoption_flags,
+ orig_str, len), '\0',
+ nonoption_flags_max_len -
+ len);
+ }
+ }
+ nonoption_flags_len = nonoption_flags_max_len;
+ }
+ else
+ nonoption_flags_len = 0;
#endif
- return optstring;
+ return optstring;
}
/* Scan elements of ARGV (whose length is ARGC) for option characters
@@ -505,28 +548,30 @@
int
_getopt_internal(argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
+ int argc;
+ char *const *argv;
+ const char *optstring;
+ const struct option *longopts;
+ int *longind;
+ int long_only;
{
- optarg = NULL;
+ optarg = NULL;
- if (optind == 0 || !__getopt_initialized)
- {
- if (optind == 0)
- optind = 1; /* Don't scan ARGV[0], the
- program name. */
- optstring = _getopt_initialize(argc, argv, optstring);
- __getopt_initialized = 1;
- }
-
- /* Test whether ARGV[optind] points to a non-option argument. Either it
- does not have option syntax, or there is an environment flag from the
- shell indicating it is not an option. The later information is only
- used when the used in the GNU libc. */
+ if (optind == 0 || !__getopt_initialized)
+ {
+ if (optind == 0)
+ optind = 1; /* Don't scan ARGV[0], the
+ * program name. */
+ optstring = _getopt_initialize(argc, argv, optstring);
+ __getopt_initialized = 1;
+ }
+
+ /*
+ * Test whether ARGV[optind] points to a non-option argument. Either it
+ * * does not have option syntax, or there is an environment flag from the
+ * * shell indicating it is not an option. The later information is only
+ * * used when the used in the GNU libc.
+ */
#ifdef _LIBC
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|| (optind < nonoption_flags_len \
@@ -535,437 +580,552 @@
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
#endif
- if (nextchar == NULL || *nextchar == '\0')
- {
- /* Advance to the next ARGV-element. */
-
- /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
- moved back by the user (who may also have changed the arguments). */
- if (last_nonopt > optind)
- last_nonopt = optind;
- if (first_nonopt > optind)
- first_nonopt = optind;
-
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some
- non-options, exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Skip any additional non-options and extend the range of
- non-options previously skipped. */
-
- while (optind < argc && NONOPTION_P)
- optind++;
- last_nonopt = optind;
- }
-
- /* The special ARGV-element `--' means premature end of options. Skip
- it like a null option, then exchange with previous non-options as if
- it were an option, then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp(argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan and back over
- any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options that we
- previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return -1;
- }
-
- /* If we have come to a non-option and did not permute it, either stop
- the scan or describe it to the caller and pass it by. */
-
- if (NONOPTION_P)
- {
- if (ordering == REQUIRE_ORDER)
- return -1;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element. Skip the initial
- punctuation. */
-
- nextchar =
- (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-'));
- }
-
- /* Decode the current option-ARGV-element. */
-
- /* Check whether the ARGV-element is a long option.
-
- If long_only and the ARGV-element has the form "-f", where f is a valid
- short option, don't consider it an abbreviated form of a long option
- that starts with f. Otherwise there would be no way to give the -f
- short option.
-
- On the other hand, if there's a long option "fubar" and the
- ARGV-element is "-fu", do consider that an abbreviation of the long
- option, just like "--fu", and not "-f" with arg "u".
-
- This distinction seems to be the most useful approach. */
-
- if (longopts != NULL
- && (argv[optind][1] == '-'
- || (long_only
- && (argv[optind][2]
- || !my_index(optstring, argv[optind][1])))))
- {
- char *nameend;
- const struct option *p;
- const struct option *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound = -1;
- int option_index;
-
- for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
- /* Do nothing. */ ;
-
- /* Test all long options for either exact match or abbreviated matches.
- */
- for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp(p->name, nextchar, nameend - nextchar))
- {
- if ((unsigned int) (nameend - nextchar) ==
- (unsigned int) strlen(p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf(stderr, _("%s: option `%s' is ambiguous\n"), argv[0],
- argv[optind]);
- nextchar += strlen(nextchar);
- optind++;
- optopt = 0;
- return '?';
- }
-
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*nameend)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = nameend + 1;
- else
- {
- if (opterr)
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf(stderr,
- _
- ("%s: option `--%s' doesn't allow an argument\n"),
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf(stderr,
- _
- ("%s: option `%c%s' doesn't allow an argument\n"),
- argv[0], argv[optind - 1][0], pfound->name);
-
- nextchar += strlen(nextchar);
-
- optopt = pfound->val;
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf(stderr, _("%s: option `%s' requires an argument\n"),
- argv[0], argv[optind - 1]);
- nextchar += strlen(nextchar);
- optopt = pfound->val;
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen(nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
-
- /* Can't find it as a long option. If this is not getopt_long_only, or
- the option starts with '--' or is not a valid short option, then
- it's an error. Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
- || my_index(optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf(stderr, _("%s: unrecognized option `--%s'\n"), argv[0],
- nextchar);
- else
- /* +option or -option */
- fprintf(stderr, _("%s: unrecognized option `%c%s'\n"), argv[0],
- argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- optopt = 0;
- return '?';
- }
- }
-
- /* Look at and handle the next short option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index(optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':')
- {
- if (opterr)
- {
- if (posixly_correct)
- /* 1003.2 specifies the format of this message. */
- fprintf(stderr, _("%s: illegal option -- %c\n"), argv[0], c);
- else
- fprintf(stderr, _("%s: invalid option -- %c\n"), argv[0], c);
- }
- optopt = c;
- return '?';
- }
- /* Convenience. Treat POSIX -W foo same as long option --foo */
- if (temp[0] == 'W' && temp[1] == ';')
- {
- char *nameend;
- const struct option *p;
- const struct option *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound = 0;
- int option_index;
-
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg, we
- must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
- /* 1003.2 specifies the format of this message. */
- fprintf(stderr, _("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- return c;
- }
- else
- /* We already incremented `optind' once; increment it again when
- taking next ARGV-elt as argument. */
- optarg = argv[optind++];
-
- /* optarg is now the argument, see if it's in the table of longopts.
- */
-
- for (nextchar = nameend = optarg; *nameend && *nameend != '=';
- nameend++)
- /* Do nothing. */ ;
-
- /* Test all long options for either exact match or abbreviated
- matches. */
- for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp(p->name, nextchar, nameend - nextchar))
- {
- if ((unsigned int) (nameend - nextchar) == strlen(p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
- if (ambig && !exact)
- {
- if (opterr)
- fprintf(stderr, _("%s: option `-W %s' is ambiguous\n"),
- argv[0], argv[optind]);
- nextchar += strlen(nextchar);
- optind++;
- return '?';
- }
- if (pfound != NULL)
- {
- option_index = indfound;
- if (*nameend)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = nameend + 1;
- else
- {
- if (opterr)
- fprintf(stderr, _("\
+ if (nextchar == NULL || *nextchar == '\0')
+ {
+ /*
+ * Advance to the next ARGV-element.
+ */
+
+ /*
+ * Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+ * * moved back by the user (who may also have changed the arguments).
+ */
+ if (last_nonopt > optind)
+ last_nonopt = optind;
+ if (first_nonopt > optind)
+ first_nonopt = optind;
+
+ if (ordering == PERMUTE)
+ {
+ /*
+ * If we have just processed some options following some
+ * * non-options, exchange them so that the options come first.
+ */
+
+ if (first_nonopt != last_nonopt &&
+ last_nonopt != optind)
+ exchange((char **) argv);
+ else if (last_nonopt != optind)
+ first_nonopt = optind;
+
+ /*
+ * Skip any additional non-options and extend the range of
+ * * non-options previously skipped.
+ */
+
+ while (optind < argc && NONOPTION_P)
+ optind++;
+ last_nonopt = optind;
+ }
+
+ /*
+ * The special ARGV-element `--' means premature end of options. Skip
+ * * it like a null option, then exchange with previous non-options as if
+ * * it were an option, then skip everything else like a non-option.
+ */
+
+ if (optind != argc && !strcmp(argv[optind], "--"))
+ {
+ optind++;
+
+ if (first_nonopt != last_nonopt &&
+ last_nonopt != optind)
+ exchange((char **) argv);
+ else if (first_nonopt == last_nonopt)
+ first_nonopt = optind;
+ last_nonopt = argc;
+
+ optind = argc;
+ }
+
+ /*
+ * If we have done all the ARGV-elements, stop the scan and back over
+ * * any non-options that we skipped and permuted.
+ */
+
+ if (optind == argc)
+ {
+ /*
+ * Set the next-arg-index to point at the non-options that we
+ * * previously skipped, so the caller will digest them.
+ */
+ if (first_nonopt != last_nonopt)
+ optind = first_nonopt;
+ return -1;
+ }
+
+ /*
+ * If we have come to a non-option and did not permute it, either stop
+ * * the scan or describe it to the caller and pass it by.
+ */
+
+ if (NONOPTION_P)
+ {
+ if (ordering == REQUIRE_ORDER)
+ return -1;
+ optarg = argv[optind++];
+ return 1;
+ }
+
+ /*
+ * We have found another option-ARGV-element. Skip the initial
+ * * punctuation.
+ */
+
+ nextchar =
+ (argv[optind] + 1 +
+ (longopts != NULL && argv[optind][1] == '-'));
+ }
+
+ /*
+ * Decode the current option-ARGV-element.
+ */
+
+ /*
+ * Check whether the ARGV-element is a long option.
+ * *
+ * * If long_only and the ARGV-element has the form "-f", where f is a valid
+ * * short option, don't consider it an abbreviated form of a long option
+ * * that starts with f. Otherwise there would be no way to give the -f
+ * * short option.
+ * *
+ * * On the other hand, if there's a long option "fubar" and the
+ * * ARGV-element is "-fu", do consider that an abbreviation of the long
+ * * option, just like "--fu", and not "-f" with arg "u".
+ * *
+ * * This distinction seems to be the most useful approach.
+ */
+
+ if (longopts != NULL
+ && (argv[optind][1] == '-' || (long_only && (argv[optind][2]
+ ||
+ !my_index
+ (optstring,
+ argv[optind][1])))))
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = -1;
+ int option_index;
+
+ for (nameend = nextchar; *nameend && *nameend != '=';
+ nameend++)
+ /*
+ * Do nothing.
+ */ ;
+
+ /*
+ * Test all long options for either exact match or abbreviated matches.
+ */
+ for (p = longopts, option_index = 0; p->name;
+ p++, option_index++)
+ if (!strncmp(p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend - nextchar) ==
+ (unsigned int) strlen(p->name))
+ {
+ /*
+ * Exact match found.
+ */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /*
+ * First nonexact match found.
+ */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /*
+ * Second or later nonexact match found.
+ */
+ ambig = 1;
+ }
+
+ if (ambig && !exact)
+ {
+ if (opterr)
+ fprintf(stderr,
+ _
+ ("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[optind]);
+ nextchar += strlen(nextchar);
+ optind++;
+ optopt = 0;
+ return '?';
+ }
+
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ optind++;
+ if (*nameend)
+ {
+ /*
+ * Don't test has_arg with >, because some C compilers don't
+ * * allow it to be used on enums.
+ */
+ if (pfound->has_arg)
+ optarg = nameend + 1;
+ else
+ {
+ if (opterr)
+ if (argv[optind - 1]
+ [1] == '-')
+ /*
+ * --option
+ */
+ fprintf(stderr, _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name);
+ else
+ /*
+ * +option or -option
+ */
+ fprintf(stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name);
+
+ nextchar += strlen(nextchar);
+
+ optopt = pfound->val;
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf(stderr,
+ _
+ ("%s: option `%s' requires an argument\n"),
+ argv[0],
+ argv[optind -
+ 1]);
+ nextchar += strlen(nextchar);
+ optopt = pfound->val;
+ return optstring[0] ==
+ ':' ? ':' : '?';
+ }
+ }
+ nextchar += strlen(nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+
+ /*
+ * Can't find it as a long option. If this is not getopt_long_only, or
+ * * the option starts with '--' or is not a valid short option, then
+ * * it's an error. Otherwise interpret it as a short option.
+ */
+ if (!long_only || argv[optind][1] == '-'
+ || my_index(optstring, *nextchar) == NULL)
+ {
+ if (opterr)
+ {
+ if (argv[optind][1] == '-')
+ /*
+ * --option
+ */
+ fprintf(stderr,
+ _
+ ("%s: unrecognized option `--%s'\n"),
+ argv[0], nextchar);
+ else
+ /*
+ * +option or -option
+ */
+ fprintf(stderr,
+ _
+ ("%s: unrecognized option `%c%s'\n"),
+ argv[0],
+ argv[optind][0],
+ nextchar);
+ }
+ nextchar = (char *) "";
+ optind++;
+ optopt = 0;
+ return '?';
+ }
+ }
+
+ /*
+ * Look at and handle the next short option-character.
+ */
+
+ {
+ char c = *nextchar++;
+ char *temp = my_index(optstring, c);
+
+ /*
+ * Increment `optind' when we start to process its last character.
+ */
+ if (*nextchar == '\0')
+ ++optind;
+
+ if (temp == NULL || c == ':')
+ {
+ if (opterr)
+ {
+ if (posixly_correct)
+ /*
+ * 1003.2 specifies the format of this message.
+ */
+ fprintf(stderr,
+ _
+ ("%s: illegal option -- %c\n"),
+ argv[0], c);
+ else
+ fprintf(stderr,
+ _
+ ("%s: invalid option -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ return '?';
+ }
+ /*
+ * Convenience. Treat POSIX -W foo same as long option --foo
+ */
+ if (temp[0] == 'W' && temp[1] == ';')
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = 0;
+ int option_index;
+
+ /*
+ * This is an option that requires an argument.
+ */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /*
+ * If we end this ARGV-element by taking the rest as an arg, we
+ * * must advance to the next element now.
+ */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ {
+ /*
+ * 1003.2 specifies the format of this message.
+ */
+ fprintf(stderr,
+ _
+ ("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ return c;
+ }
+ else
+ /*
+ * We already incremented `optind' once; increment it again when
+ * * taking next ARGV-elt as argument.
+ */
+ optarg = argv[optind++];
+
+ /*
+ * optarg is now the argument, see if it's in the table of longopts.
+ */
+
+ for (nextchar = nameend = optarg;
+ *nameend && *nameend != '='; nameend++)
+ /*
+ * Do nothing.
+ */ ;
+
+ /*
+ * Test all long options for either exact match or abbreviated
+ * * matches.
+ */
+ for (p = longopts, option_index = 0; p->name;
+ p++, option_index++)
+ if (!strncmp
+ (p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend -
+ nextchar) ==
+ strlen(p->name))
+ {
+ /*
+ * Exact match found.
+ */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /*
+ * First nonexact match found.
+ */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /*
+ * Second or later nonexact match found.
+ */
+ ambig = 1;
+ }
+ if (ambig && !exact)
+ {
+ if (opterr)
+ fprintf(stderr,
+ _
+ ("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[optind]);
+ nextchar += strlen(nextchar);
+ optind++;
+ return '?';
+ }
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ if (*nameend)
+ {
+ /*
+ * Don't test has_arg with >, because some C compilers don't
+ * * allow it to be used on enums.
+ */
+ if (pfound->has_arg)
+ optarg = nameend + 1;
+ else
+ {
+ if (opterr)
+ fprintf(stderr, _("\
%s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name);
- nextchar += strlen(nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf(stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[optind - 1]);
- nextchar += strlen(nextchar);
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen(nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- nextchar = NULL;
- return 'W'; /* Let the application handle it.
- */
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = NULL;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
- /* 1003.2 specifies the format of this message. */
- fprintf(stderr,
- _("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- }
- else
- /* We already incremented `optind' once; increment it again
- when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
+ nextchar +=
+ strlen
+ (nextchar);
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf(stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]);
+ nextchar +=
+ strlen
+ (nextchar);
+ return optstring[0] ==
+ ':' ? ':' :
+ '?';
+ }
+ }
+ nextchar += strlen(nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+ nextchar = NULL;
+ return 'W'; /* Let the application handle it.
+ */
+ }
+ if (temp[1] == ':')
+ {
+ if (temp[2] == ':')
+ {
+ /*
+ * This is an option that accepts an argument optionally.
+ */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ optind++;
+ }
+ else
+ optarg = NULL;
+ nextchar = NULL;
+ }
+ else
+ {
+ /*
+ * This is an option that requires an argument.
+ */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /*
+ * If we end this ARGV-element by taking the rest as an arg,
+ * * we must advance to the next element now.
+ */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ {
+ /*
+ * 1003.2 specifies the format of this message.
+ */
+ fprintf(stderr,
+ _
+ ("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ }
+ else
+ /*
+ * We already incremented `optind' once; increment it again
+ * * when taking next ARGV-elt as argument.
+ */
+ optarg = argv[optind++];
+ nextchar = NULL;
+ }
+ }
+ return c;
+ }
}
int
getopt(argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
+ int argc;
+ char *const *argv;
+ const char *optstring;
{
- return _getopt_internal(argc, argv, optstring, (const struct option *) 0,
- (int *) 0, 0);
+ return _getopt_internal(argc, argv, optstring,
+ (const struct option *) 0, (int *) 0, 0);
}
#endif /* Not ELIDE_CODE. */
@@ -977,67 +1137,68 @@
int
main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
- int c;
- int digit_optind = 0;
+ int c;
+ int digit_optind = 0;
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt(argc, argv, "abc:d:0123456789");
- if (c == -1)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf("option %c\n", c);
- break;
-
- case 'a':
- printf("option a\n");
- break;
-
- case 'b':
- printf("option b\n");
- break;
-
- case 'c':
- printf("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf("non-option ARGV-elements: ");
- while (optind < argc)
- printf("%s ", argv[optind++]);
- printf("\n");
- }
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt(argc, argv, "abc:d:0123456789");
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 &&
+ digit_optind != this_option_optind)
+ printf("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf("option %c\n", c);
+ break;
+
+ case 'a':
+ printf("option a\n");
+ break;
+
+ case 'b':
+ printf("option b\n");
+ break;
+
+ case 'c':
+ printf("option c with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf("%s ", argv[optind++]);
+ printf("\n");
+ }
- exit(0);
+ exit(0);
}
#endif /* TEST */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/getopt.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- getopt.h 2001/04/16 11:59:23 1.1
+++ getopt.h 2001/07/20 07:31:54 1.2
@@ -1,3 +1,4 @@
+
/* Declarations for getopt.
Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -31,7 +32,7 @@
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
- extern char *optarg;
+ extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
@@ -45,16 +46,16 @@
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
- extern int optind;
+ extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
- extern int opterr;
+ extern int opterr;
/* Set to an option character which was unrecognized. */
- extern int optopt;
+ extern int optopt;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
@@ -77,19 +78,21 @@
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
- struct option
- {
+ struct option
+ {
#if defined (__STDC__) && __STDC__
- const char *name;
+ const char *name;
#else
- char *name;
+ char *name;
#endif
- /* has_arg can't be an enum because some compilers complain about type
- mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
- };
+ /*
+ * has_arg can't be an enum because some compilers complain about type
+ * * mismatches in all the code that assumes it is an int.
+ */
+ int has_arg;
+ int *flag;
+ int val;
+ };
/* Names for the values of the `has_arg' field of `struct option'. */
@@ -99,38 +102,43 @@
#if defined (__STDC__) && __STDC__
#ifdef __GNU_LIBRARY__
+
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
- extern int getopt(int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
+ extern int getopt(int argc, char *const *argv, const char *shortopts);
+#else /* not __GNU_LIBRARY__ */
#ifndef __cplusplus
+
/* C++ is more pedantic, and demands a full prototype, not this.
Hope that stdlib.h has a prototype for `getopt'. */
- extern int getopt();
-#endif /* __cplusplus */
-#endif /* __GNU_LIBRARY__ */
- extern int getopt_long(int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
- extern int getopt_long_only(int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
+ extern int getopt();
+#endif /* __cplusplus */
+#endif /* __GNU_LIBRARY__ */
+ extern int getopt_long(int argc,
+ char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind);
+ extern int getopt_long_only(int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts,
+ int *longind);
/* Internal only. Users should not call this directly. */
- extern int _getopt_internal(int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
- extern int getopt();
- extern int getopt_long();
- extern int getopt_long_only();
+ extern int _getopt_internal(int argc,
+ char *const *argv,
+ const char *shortopts,
+ const struct option *longopts,
+ int *longind, int long_only);
+#else /* not __STDC__ */
+ extern int getopt();
+ extern int getopt_long();
+ extern int getopt_long_only();
- extern int _getopt_internal();
-#endif /* __STDC__ */
+ extern int _getopt_internal();
+#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
-
-#endif /* getopt.h */
+#endif /* getopt.h */
|