Enlightenment CVS committal
Author : pfritz
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/lib
Modified Files:
Ewl.h Makefile.am ewl_colorpicker.c ewl_progressbar.c
ewl_progressbar.h ewl_scrollbar.c ewl_seeker.c ewl_seeker.h
ewl_spinner.c ewl_spinner.h
Log Message:
**API-BREAK**
- add ewl_range a new abstract widget to unify the api of seeker, spinner and
progressbar
- NOTE this breaks colorpicker hopefully for a short time
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Ewl.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- Ewl.h 14 Jul 2006 02:53:34 -0000 1.6
+++ Ewl.h 11 Aug 2006 04:00:57 -0000 1.7
@@ -304,6 +304,7 @@
#include <ewl_colorpicker.h>
#include <ewl_colordialog.h>
#include <ewl_password.h>
+#include <ewl_range.h>
#include <ewl_seeker.h>
#include <ewl_scrollbar.h>
#include <ewl_spacer.h>
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Makefile.am,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- Makefile.am 14 Jul 2006 02:53:34 -0000 1.29
+++ Makefile.am 11 Aug 2006 04:00:57 -0000 1.30
@@ -64,6 +64,7 @@
ewl_password.h \
ewl_progressbar.h \
ewl_radiobutton.h \
+ ewl_range.h \
ewl_row.h \
ewl_scrollbar.h \
ewl_scrollpane.h \
@@ -133,6 +134,7 @@
ewl_password.c \
ewl_progressbar.c \
ewl_radiobutton.c \
+ ewl_range.c \
ewl_row.c \
ewl_scrollbar.c \
ewl_scrollpane.c \
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_colorpicker.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- ewl_colorpicker.c 12 Jul 2006 03:44:19 -0000 1.24
+++ ewl_colorpicker.c 11 Aug 2006 04:00:57 -0000 1.25
@@ -234,38 +234,38 @@
o = ewl_colorpicker_spinner_new();
ewl_widget_internal_set(o, TRUE);
ewl_container_child_append(EWL_CONTAINER(hbox), o);
- ewl_spinner_min_val_set(EWL_SPINNER(o), 0);
- ewl_spinner_max_val_set(EWL_SPINNER(o), modes[i].max);
+ ewl_range_min_val_set(EWL_RANGE(o), 0);
+ ewl_range_max_val_set(EWL_RANGE(o), modes[i].max);
switch(modes[i].mode)
{
case EWL_COLOR_MODE_HSV_HUE:
- ewl_spinner_value_set(EWL_SPINNER(o), h);
+ ewl_range_value_set(EWL_RANGE(o), h);
cp->spinners.hsv.h = o;
break;
case EWL_COLOR_MODE_HSV_SATURATION:
- ewl_spinner_value_set(EWL_SPINNER(o), s * 100);
+ ewl_range_value_set(EWL_RANGE(o), s * 100);
cp->spinners.hsv.s = o;
break;
case EWL_COLOR_MODE_HSV_VALUE:
- ewl_spinner_value_set(EWL_SPINNER(o), v * 100);
+ ewl_range_value_set(EWL_RANGE(o), v * 100);
cp->spinners.hsv.v = o;
break;
case EWL_COLOR_MODE_RGB_RED:
- ewl_spinner_value_set(EWL_SPINNER(o), r);
+ ewl_range_value_set(EWL_RANGE(o), r);
cp->spinners.rgb.r = o;
break;
case EWL_COLOR_MODE_RGB_GREEN:
- ewl_spinner_value_set(EWL_SPINNER(o), g);
+ ewl_range_value_set(EWL_RANGE(o), g);
cp->spinners.rgb.g = o;
break;
case EWL_COLOR_MODE_RGB_BLUE:
- ewl_spinner_value_set(EWL_SPINNER(o), b);
+ ewl_range_value_set(EWL_RANGE(o), b);
cp->spinners.rgb.b = o;
break;
}
- ewl_spinner_step_set(EWL_SPINNER(o), 1);
+ ewl_range_step_set(EWL_RANGE(o), 1);
ewl_spinner_digits_set(EWL_SPINNER(o), 0);
ewl_colorpicker_spinner_mode_set(EWL_COLORPICKER_SPINNER(o),
modes[i].mode);
@@ -278,9 +278,9 @@
o = ewl_spinner_new();
ewl_widget_internal_set(o, TRUE);
ewl_container_child_append(EWL_CONTAINER(vbox), o);
- ewl_spinner_min_val_set(EWL_SPINNER(o), 0);
- ewl_spinner_max_val_set(EWL_SPINNER(o), 255);
- ewl_spinner_value_set(EWL_SPINNER(o), 0);
+ ewl_range_min_val_set(EWL_RANGE(o), 0);
+ ewl_range_max_val_set(EWL_RANGE(o), 255);
+ ewl_range_value_set(EWL_RANGE(o), 0);
ewl_spinner_digits_set(EWL_SPINNER(o), 0);
cp->spinners.alpha = o;
@@ -335,7 +335,7 @@
DCHECK_TYPE("cp", cp, EWL_COLORPICKER_TYPE);
if (alpha > 255) alpha = 255;
- ewl_spinner_value_set(EWL_SPINNER(cp->spinners.alpha), alpha);
+ ewl_range_value_set(EWL_RANGE(cp->spinners.alpha), alpha);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -354,7 +354,7 @@
DCHECK_PARAM_PTR_RET("cp", cp, 255);
DCHECK_TYPE_RET("cp", cp, EWL_COLORPICKER_TYPE, 255);
- alpha = ewl_spinner_value_get(EWL_SPINNER(cp->spinners.alpha));
+ alpha = ewl_range_value_get(EWL_RANGE(cp->spinners.alpha));
DRETURN_INT(alpha, DLEVEL_STABLE);
}
@@ -625,29 +625,29 @@
switch ((int)mode)
{
case EWL_COLOR_MODE_RGB_RED:
- r =
ewl_spinner_value_get(EWL_SPINNER(cp->spinners.rgb.r));
+ r = ewl_range_value_get(EWL_RANGE(cp->spinners.rgb.r));
break;
case EWL_COLOR_MODE_RGB_GREEN:
- g =
ewl_spinner_value_get(EWL_SPINNER(cp->spinners.rgb.g));
+ g = ewl_range_value_get(EWL_RANGE(cp->spinners.rgb.g));
break;
case EWL_COLOR_MODE_RGB_BLUE:
- b =
ewl_spinner_value_get(EWL_SPINNER(cp->spinners.rgb.b));
+ b = ewl_range_value_get(EWL_RANGE(cp->spinners.rgb.b));
break;
case EWL_COLOR_MODE_HSV_HUE:
- h =
ewl_spinner_value_get(EWL_SPINNER(cp->spinners.hsv.h));
+ h = ewl_range_value_get(EWL_RANGE(cp->spinners.hsv.h));
set_hsv = TRUE;
break;
case EWL_COLOR_MODE_HSV_SATURATION:
- s =
ewl_spinner_value_get(EWL_SPINNER(cp->spinners.hsv.s)) / 100.0;
+ s = ewl_range_value_get(EWL_RANGE(cp->spinners.hsv.s))
/ 100.0;
set_hsv = TRUE;
break;
case EWL_COLOR_MODE_HSV_VALUE:
- v =
ewl_spinner_value_get(EWL_SPINNER(cp->spinners.hsv.v)) / 100.0;
+ v = ewl_range_value_get(EWL_RANGE(cp->spinners.hsv.v))
/ 100.0;
set_hsv = TRUE;
break;
@@ -734,13 +734,13 @@
DCHECK_PARAM_PTR("cp", cp);
DCHECK_TYPE("cp", cp, EWL_COLORPICKER_TYPE);
- ewl_spinner_value_set(EWL_SPINNER(cp->spinners.rgb.r), r);
- ewl_spinner_value_set(EWL_SPINNER(cp->spinners.rgb.g), g);
- ewl_spinner_value_set(EWL_SPINNER(cp->spinners.rgb.b), b);
-
- ewl_spinner_value_set(EWL_SPINNER(cp->spinners.hsv.h), h);
- ewl_spinner_value_set(EWL_SPINNER(cp->spinners.hsv.s), s * 100);
- ewl_spinner_value_set(EWL_SPINNER(cp->spinners.hsv.v), v * 100);
+ ewl_range_value_set(EWL_RANGE(cp->spinners.rgb.r), r);
+ ewl_range_value_set(EWL_RANGE(cp->spinners.rgb.g), g);
+ ewl_range_value_set(EWL_RANGE(cp->spinners.rgb.b), b);
+
+ ewl_range_value_set(EWL_RANGE(cp->spinners.hsv.h), h);
+ ewl_range_value_set(EWL_RANGE(cp->spinners.hsv.s), s * 100);
+ ewl_range_value_set(EWL_RANGE(cp->spinners.hsv.v), v * 100);
ewl_widget_color_set(cp->preview.current, r, g, b, 255);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_progressbar.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_progressbar.c 26 May 2006 18:17:19 -0000 1.9
+++ ewl_progressbar.c 11 Aug 2006 04:00:57 -0000 1.10
@@ -43,7 +43,7 @@
w = EWL_WIDGET(p);
- if (!ewl_container_init(EWL_CONTAINER(w)))
+ if (!ewl_range_init(EWL_RANGE(w)))
DRETURN_INT(FALSE, DLEVEL_STABLE);
ewl_widget_appearance_set(w, EWL_PROGRESSBAR_TYPE);
@@ -67,114 +67,21 @@
p->label = ewl_text_new();
ewl_text_text_set(EWL_TEXT(p->label), NULL);
+ ewl_widget_layer_priority_set(p->label, 1);
ewl_object_alignment_set(EWL_OBJECT(p->label), EWL_FLAG_ALIGN_CENTER);
ewl_container_child_append(EWL_CONTAINER(p), p->label);
ewl_widget_show(p->label);
- p->value = 0.0;
- p->range = 100.0;
p->auto_label = TRUE;
ewl_callback_append(w, EWL_CALLBACK_CONFIGURE,
ewl_progressbar_configure_cb, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_VALUE_CHANGED,
+ ewl_progressbar_value_changed_cb, NULL);
DRETURN_INT(TRUE, DLEVEL_STABLE);
}
-
-/**
- * @param p: the progressbar whose value will be changed
- * @param v: the new value of the statusbar
- * @return Returns no value.
- * @brief Set the value of the progressbars location
- */
-void
-ewl_progressbar_value_set(Ewl_Progressbar *p, double v)
-{
- char c[10];
-
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("p", p);
- DCHECK_TYPE("p", p, EWL_PROGRESSBAR_TYPE);
-
- if (v == p->value)
- DRETURN(DLEVEL_STABLE);
-
- if (v < 0) v = 0;
-
- p->value = v;
- if (p->auto_label) {
- /*
- * Do a precentage calculation as a default label.
- */
- snprintf (c, sizeof (c), "%.0lf%%", (p->value / p->range) *
100);
- ewl_text_text_set(EWL_TEXT(p->label), c);
- }
-
- ewl_widget_configure(EWL_WIDGET(p));
- ewl_callback_call(EWL_WIDGET(p), EWL_CALLBACK_VALUE_CHANGED);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-
-/**
- * @param p: the progressbars to retrieve the value
- * @return Returns 0 on failure, the value of the progressbars location on
success.
- * @brief Retrieve the current value of the progressbars
- */
-double
-ewl_progressbar_value_get(Ewl_Progressbar *p)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("p", p, -1);
- DCHECK_TYPE_RET("p", p, EWL_PROGRESSBAR_TYPE, -1);
-
- DRETURN_FLOAT(p->value, DLEVEL_STABLE);
-}
-
-/**
- * @param p: the progressbar whose range will be changed
- * @param r: the new range of the statusbar
- * @return Returns no value.
- * @brief Set the range of the progressbar. Cannot be less then 1.
- */
-void
-ewl_progressbar_range_set(Ewl_Progressbar *p, double r)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("p", p);
- DCHECK_TYPE("p", p, EWL_PROGRESSBAR_TYPE);
-
- if (r == p->range)
- DRETURN(DLEVEL_STABLE);
-
- if (r < 1)
- DRETURN(DLEVEL_STABLE);
-
- p->range = r;
-
- ewl_widget_configure(EWL_WIDGET(p));
- ewl_callback_call(EWL_WIDGET(p), EWL_CALLBACK_VALUE_CHANGED);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @param p: the progressbars to retrieve the range
- * @return Returns 0 on failure, the value of the progressbars location on
success.
- * @brief Retrieve the current range of the progressbars (default 100)
- */
-double
-ewl_progressbar_range_get(Ewl_Progressbar *p)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("p", p, -1);
- DCHECK_TYPE_RET("p", p, EWL_PROGRESSBAR_TYPE, -1);
-
- DRETURN_FLOAT(p->range, DLEVEL_STABLE);
-}
-
/**
* @param p: the progressbars whose text will be changed
* @param label: the new label
@@ -205,6 +112,7 @@
void
ewl_progressbar_custom_label_set(Ewl_Progressbar *p, char *format_string)
{
+ Ewl_Range *r;
char label[PATH_MAX];
DENTER_FUNCTION(DLEVEL_STABLE);
@@ -212,9 +120,10 @@
DCHECK_TYPE("p", p, EWL_PROGRESSBAR_TYPE);
p->auto_label = FALSE;
+ r = EWL_RANGE(p);
if (format_string) {
- snprintf (label, PATH_MAX, format_string, p->value, p->range);
+ snprintf (label, PATH_MAX, format_string, r->value, r->max_val);
ewl_text_text_set(EWL_TEXT(p->label), label);
}
@@ -271,25 +180,67 @@
void *user_data __UNUSED__)
{
Ewl_Progressbar *p;
+ Ewl_Range *r;
int dx, dy;
- int dw, dh;
+ int dw;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
p = EWL_PROGRESSBAR(w);
+ r = EWL_RANGE(p);
dx = CURRENT_X(p);
dy = CURRENT_Y(p);
dw = CURRENT_W(p);
- dh = CURRENT_H(p);
-
- ewl_object_geometry_request(EWL_OBJECT(p->bar), dx, dy,
- dw * (p->value / p->range), dh);
+
+ dw = dw * (r->value - r->min_val) / (r->max_val - r->min_val);
+
+ if (r->invert){
+ dx += CURRENT_W(p) - dw;
+ }
+
+ ewl_object_geometry_request(EWL_OBJECT(p->bar), dx, CURRENT_Y(p),
+ dw, CURRENT_H(p));
+ ewl_object_place (EWL_OBJECT(p->label), CURRENT_X(p),CURRENT_Y(p),
+ CURRENT_W(p), CURRENT_H(p));
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
- ewl_object_place (EWL_OBJECT(p->label), dx, dy, dw, dh);
+/**
+ * @internal
+ * @param w: The widget to work with
+ * @param ev_data: UNUSED
+ * @param user_data: UNUSED
+ * @return Returns no value
+ * @brief the value changed callback
+ */
+void
+ewl_progressbar_value_changed_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
+ void *user_data __UNUSED__)
+{
+ Ewl_Progressbar *p;
+ Ewl_Range *r;
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
+
+ p = EWL_PROGRESSBAR(w);
+ r = EWL_RANGE(p);
+
+ if (p->auto_label) {
+ char c[10];
+ /*
+ * Do a precentage calculation as a default label.
+ */
+ snprintf (c, sizeof (c), "%.0lf%%", (r->value /
+ (r->max_val - r->min_val)) * 100);
+ ewl_text_text_set(EWL_TEXT(p->label), c);
+ }
+
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -297,23 +248,24 @@
ewl_progressbar_child_handle(Ewl_Container *c,
Ewl_Widget *w __UNUSED__)
{
- Ewl_Progressbar *p;
+ Ewl_Range *r;
double value;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("c", c);
DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE);
- p = EWL_PROGRESSBAR(c);
- value = p->value / p->range;
+ r = EWL_RANGE(c);
+ value = r->value / (r->max_val - r->min_val);
if (value < 0.01)
value = 0.01;
- ewl_object_preferred_inner_w_set (EWL_OBJECT(p),
- ewl_object_preferred_w_get (EWL_OBJECT(p->bar)) /
value);
+ ewl_object_preferred_inner_w_set (EWL_OBJECT(c),
+ ewl_object_preferred_w_get(
+ EWL_OBJECT(EWL_PROGRESSBAR(c)->bar)) / value);
- ewl_container_largest_prefer (EWL_CONTAINER (c),
+ ewl_container_largest_prefer(EWL_CONTAINER(c),
EWL_ORIENTATION_VERTICAL);
DLEAVE_FUNCTION(DLEVEL_STABLE);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_progressbar.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_progressbar.h 15 Mar 2006 04:03:48 -0000 1.9
+++ ewl_progressbar.h 11 Aug 2006 04:00:57 -0000 1.10
@@ -33,16 +33,14 @@
#define EWL_PROGRESSBAR(progressbar) ((Ewl_Progressbar *) progressbar)
/**
- * Inherits from Ewl_Container and creates an internal Ewl_Widget, the
+ * Inherits from Ewl_Range and creates an internal Ewl_Widget, the
* statusbar itself.
*/
struct Ewl_Progressbar
{
- Ewl_Container container; /**< Inherit from Ewl_Container */
+ Ewl_Range range; /**< Inherit from Ewl_Range */
Ewl_Widget *bar; /**< The moving bar on top */
Ewl_Widget *label; /**< text label on the bar */
- double value; /**< current value of the progressbar */
- double range; /**< the maximum range of the progressbar
*/
int auto_label; /**< flag if user is setting label or not
*/
};
@@ -50,12 +48,6 @@
Ewl_Widget *ewl_progressbar_new(void);
int ewl_progressbar_init(Ewl_Progressbar *p);
-void ewl_progressbar_value_set(Ewl_Progressbar *p, double v);
-double ewl_progressbar_value_get(Ewl_Progressbar *p);
-
-void ewl_progressbar_range_set(Ewl_Progressbar *p, double r);
-double ewl_progressbar_range_get(Ewl_Progressbar *p);
-
void ewl_progressbar_label_set(Ewl_Progressbar *p, char *label);
void ewl_progressbar_custom_label_set(Ewl_Progressbar *p,
char *format_string);
@@ -67,6 +59,8 @@
* Internally used callbacks, override at your own risk.
*/
void ewl_progressbar_configure_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
+void ewl_progressbar_value_changed_cb(Ewl_Widget *w, void *ev_data,
void *user_data);
void ewl_progressbar_child_show_cb(Ewl_Container *c, Ewl_Widget *w);
void ewl_progressbar_child_resize_cb(Ewl_Container *c, Ewl_Widget *w, int size,
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_scrollbar.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- ewl_scrollbar.c 26 May 2006 18:17:19 -0000 1.12
+++ ewl_scrollbar.c 11 Aug 2006 04:00:57 -0000 1.13
@@ -173,8 +173,8 @@
* Define the maximum value that the seeker can reach, and the
* default increments it takes to get there.
*/
- ewl_seeker_range_set(EWL_SEEKER(s->seeker), 1.0);
- ewl_seeker_step_set(EWL_SEEKER(s->seeker), 0.05);
+ ewl_range_max_val_set(EWL_RANGE(s->seeker), 1.0);
+ ewl_range_step_set(EWL_RANGE(s->seeker), 0.05);
/*
* Set the appearance strings for the parts of the scrollbar
@@ -210,7 +210,7 @@
/*
* Set the default value to the beginning of the seeker.
*/
- ewl_seeker_value_set(EWL_SEEKER(s->seeker), 0);
+ ewl_range_value_set(EWL_RANGE(s->seeker), 0.0);
DRETURN_INT(TRUE, DLEVEL_STABLE);
}
@@ -402,7 +402,7 @@
DCHECK_PARAM_PTR_RET("s", s, -1);
DCHECK_TYPE_RET("s", s, EWL_SCROLLBAR_TYPE, -1);
- v = ewl_seeker_value_get(EWL_SEEKER(s->seeker));
+ v = ewl_range_value_get(EWL_RANGE(s->seeker));
/*
if (EWL_BOX(s)->orientation == EWL_ORIENTATION_VERTICAL)
@@ -427,7 +427,7 @@
DCHECK_PARAM_PTR("s", s);
DCHECK_TYPE("s", s, EWL_SCROLLBAR_TYPE);
- ewl_seeker_value_set(EWL_SEEKER(s->seeker), v);
+ ewl_range_value_set(EWL_RANGE(s->seeker), v);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -444,7 +444,7 @@
DCHECK_PARAM_PTR_RET("s", s, 0);
DCHECK_TYPE_RET("s", s, EWL_SCROLLBAR_TYPE, 0);
- DRETURN_INT(ewl_seeker_step_get(EWL_SEEKER(s->seeker)), DLEVEL_STABLE);
+ DRETURN_INT(ewl_range_step_get(EWL_RANGE(s->seeker)), DLEVEL_STABLE);
}
/**
@@ -462,7 +462,7 @@
DCHECK_PARAM_PTR("s", s);
DCHECK_TYPE("s", s, EWL_SCROLLBAR_TYPE);
- ewl_seeker_step_set(EWL_SEEKER(s->seeker), v);
+ ewl_range_step_set(EWL_RANGE(s->seeker), v);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -548,7 +548,7 @@
s = EWL_SCROLLBAR(data);
dt = ecore_time_get() - s->start_time;
- value = ewl_seeker_value_get(EWL_SEEKER(s->seeker));
+ value = ewl_range_value_get(EWL_RANGE(s->seeker));
/*
* Check the theme for a velocity setting and bring it within normal
@@ -567,7 +567,7 @@
value += (double)(s->direction) * 10 * (1 - exp(-dt)) *
((double)(velocity) / 100.0);
- ewl_seeker_value_set(EWL_SEEKER(s->seeker), value);
+ ewl_range_value_set(EWL_RANGE(s->seeker), value);
DRETURN_INT(TRUE, DLEVEL_STABLE);
}
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_seeker.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- ewl_seeker.c 3 Jun 2006 16:18:11 -0000 1.18
+++ ewl_seeker.c 11 Aug 2006 04:00:57 -0000 1.19
@@ -87,7 +87,7 @@
w = EWL_WIDGET(s);
- if (!ewl_container_init(EWL_CONTAINER(w)))
+ if (!ewl_range_init(EWL_RANGE(w)))
DRETURN_INT(FALSE, DLEVEL_STABLE);
/*
@@ -111,12 +111,9 @@
ewl_widget_appearance_set(s->button, "hbutton");
/*
- * Set the starting orientation, range and values
+ * Set the starting orientation
*/
s->orientation = EWL_ORIENTATION_HORIZONTAL;
- s->range = 100.0;
- s->value = 0.0;
- s->step = 10.0;
/*
* Add necessary configuration callbacks
@@ -201,130 +198,6 @@
}
/**
- *
- * @param s: the seeker whose value will be changed
- * @param v: the new value of the locator, checked against the valid range
- * @return Returns no value.
- * @brief Set the value of pointer of the seekers locator
- */
-void
-ewl_seeker_value_set(Ewl_Seeker *s, double v)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SEEKER_TYPE);
-
- if (v == s->value)
- DRETURN(DLEVEL_STABLE);
-
- if (v < 0) v = 0;
- if (v > s->range) v = s->range;
-
- s->value = v;
-
- ewl_widget_configure(EWL_WIDGET(s));
- ewl_callback_call(EWL_WIDGET(s), EWL_CALLBACK_VALUE_CHANGED);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-
-/**
- * @param s: the seekers to retrieve the value
- * @return Returns 0 on failure, the value of the seekers locator on success.
- * @brief Retrieve the current value of the seekers locator
- */
-double
-ewl_seeker_value_get(Ewl_Seeker *s)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("s", s, -1);
- DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, -1);
-
- DRETURN_FLOAT(s->value, DLEVEL_STABLE);
-}
-
-/**
- * @param s: the seeker to change the range
- * @param r: the largest bound on the range of the seekers value
- * @return Returns no value.
- * @brief specify the range of values represented by the seeker
- */
-void
-ewl_seeker_range_set(Ewl_Seeker *s, double r)
-{
- int new_val;
-
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SEEKER_TYPE);
-
- new_val = r * (s->value / s->range);
-
- s->range = r;
- s->value = new_val;
-
- ewl_widget_configure(EWL_WIDGET(s));
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @param s: the seeker to return the range of values
- * @return Returns 0 on failure, or the upper bound on the seeker on success.
- * @brief Retrieve the range of values represented by the seeker
- */
-double
-ewl_seeker_range_get(Ewl_Seeker *s)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("s", s, -1);
- DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, -1);
-
- DRETURN_FLOAT(s->range, DLEVEL_STABLE);
-}
-
-/**
- * @param s: the seeker to change step
- * @param step: the new step value for the seeker
- * @return Returns no value.
- * @brief Set the steps between increments
- *
- * Changes the amount that each increment or decrement changes the value of the
- * seeker @a s.
- */
-void
-ewl_seeker_step_set(Ewl_Seeker *s, double step)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SEEKER_TYPE);
-
- if (step > s->range)
- step = s->range;
-
- s->step = step;
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @param s: the seeker to retrieve step size
- * @return Returns the step size of the seeker @a s.
- * @brief Retrieve the step size of the seeker
- */
-double
-ewl_seeker_step_get(Ewl_Seeker *s)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("s", s, -1);
- DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, -1);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
- DRETURN_FLOAT(s->step, DLEVEL_STABLE);
-}
-
-/**
* @param s: the seeker to change autohide
* @param v: the new boolean value for autohiding
* @return Returns no value.
@@ -371,99 +244,7 @@
DRETURN_INT(abs(s->autohide), DLEVEL_STABLE);
}
-
-/**
- * @param s: the seeker to set invert property
- * @param invert: the new value for the seekers invert property
- * @return Returns no value.
- * @brief Changes the invert property on the seeker for inverting it's scale.
- */
-void
-ewl_seeker_invert_set(Ewl_Seeker *s, int invert)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SEEKER_TYPE);
-
- if (s->invert != invert) {
- s->invert = invert;
- ewl_widget_configure(EWL_WIDGET(s));
- }
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @param s: the seeker to retrieve invert property value
- * @return Returns the current value of the invert property in the seeker.
- * @brief Retrieve the current invert value from a seeker.
- */
-int
-ewl_seeker_invert_get(Ewl_Seeker *s)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("s", s, FALSE);
- DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, FALSE);
-
- DRETURN_INT(s->invert, DLEVEL_STABLE);
-}
-
-/**
- * @param s: the seeker to increase
- * @return Returns no value.
- * @brief Increase the value of a seeker by it's step size
- *
- * Increases the value of the seeker @a s by one increment of it's step size.
- */
-void
-ewl_seeker_increase(Ewl_Seeker *s)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SEEKER_TYPE);
-
- s->value += s->step;
-
- if (s->value > s->range)
- s->value = s->range;
- else if (s->value < 0.0)
- s->value = 0.0;
-
- ewl_widget_configure(EWL_WIDGET(s));
-
- ewl_callback_call(EWL_WIDGET(s), EWL_CALLBACK_VALUE_CHANGED);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @param s: the seeker to decrease
- * @return Returns no value.
- * @brief Decrease the value of a seeker by it's step size
- *
- * Decreases the value of the seeker @a s by one increment of it's step size.
- */
-void
-ewl_seeker_decrease(Ewl_Seeker *s)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SEEKER_TYPE);
-
- s->value -= s->step;
-
- if (s->value > s->range)
- s->value = s->range;
- else if (s->value < 0.0)
- s->value = 0.0;
-
- ewl_widget_configure(EWL_WIDGET(s));
-
- ewl_callback_call(EWL_WIDGET(s), EWL_CALLBACK_VALUE_CHANGED);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
+
/**
* @internal
* @param w: The widget to work with
@@ -479,7 +260,9 @@
void *user_data __UNUSED__)
{
Ewl_Seeker *s;
+ Ewl_Range *r;
double s1, s2;
+ double range;
int dx, dy;
int dw, dh;
int nw, nh;
@@ -489,6 +272,8 @@
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
s = EWL_SEEKER(w);
+ r = EWL_RANGE(w);
+
if (!s->button)
DRETURN(DLEVEL_STABLE);
@@ -496,22 +281,23 @@
dy = CURRENT_Y(s);
dw = CURRENT_W(s);
dh = CURRENT_H(s);
-
+
+ range = r->max_val - r->min_val;
/*
* First determine the size based on the number of steps to span from
* min to max values. Then reduce the total scale to keep the button on
* the seeker, then position the button.
*/
- s1 = s->step / s->range;
+ s1 = r->step / range;
if (s->autohide && s1 >= 1.0) {
ewl_widget_hide(w);
s->autohide = -abs(s->autohide);
}
- if (s->invert)
- s2 = (s->range - s->value) / s->range;
+ if (r->invert)
+ s2 = (r->max_val - r->value) / range;
else
- s2 = s->value / s->range;
+ s2 = (r->value - r->min_val) / range;
if (s->orientation == EWL_ORIENTATION_VERTICAL) {
dh *= s1;
@@ -609,6 +395,7 @@
{
Ewl_Event_Mouse_Move *ev;
Ewl_Seeker *s;
+ Ewl_Range *r;
double scale;
DENTER_FUNCTION(DLEVEL_STABLE);
@@ -617,8 +404,9 @@
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
s = EWL_SEEKER(w);
+ r = EWL_RANGE(w);
- if (s->step == s->range)
+ if (r->step == r->max_val - r->min_val)
DRETURN(DLEVEL_STABLE);
ev = ev_data;
@@ -645,7 +433,7 @@
scale = ewl_seeker_mouse_value_map(s, ev->x, ev->y);
- ewl_seeker_value_set(s, scale);
+ ewl_range_value_set(r, scale);
DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -664,6 +452,7 @@
void *user_data __UNUSED__)
{
Ewl_Seeker *s;
+ Ewl_Range *r;
Ewl_Event_Mouse_Down *ev;
double value, step = 0;
int xx, yy, ww, hh;
@@ -675,6 +464,7 @@
ev = ev_data;
s = EWL_SEEKER(w);
+ r = EWL_RANGE(w);
if (ewl_object_state_has(EWL_OBJECT(s->button), EWL_FLAG_STATE_PRESSED))
DRETURN(DLEVEL_STABLE);
@@ -682,7 +472,7 @@
ewl_object_current_geometry_get(EWL_OBJECT(s->button),
&xx, &yy, &ww, &hh);
- value = s->value;
+ value = r->value;
/*
* Increment or decrement the value based on the position of the click
@@ -691,25 +481,25 @@
if (s->orientation == EWL_ORIENTATION_HORIZONTAL) {
s->dragstart = ev->x;
if (ev->x < xx) {
- step = -s->step;
+ step = -r->step;
}
else if (ev->x > xx + ww) {
- step = s->step;
+ step = r->step;
}
}
else {
s->dragstart = ev->y;
if (ev->y < yy)
- step = -s->step;
+ step = -r->step;
else if (ev->y > yy + hh)
- step = s->step;
+ step = r->step;
}
- if (s->invert)
+ if (r->invert)
step = -step;
value += step;
- ewl_seeker_value_set(s, value);
+ ewl_range_value_set(r, value);
s->start_time = ecore_time_get();
s->timer = ecore_timer_add(0.5, ewl_seeker_timer, s);
@@ -757,12 +547,12 @@
ewl_seeker_key_down_cb(Ewl_Widget *w, void *ev_data,
void *user_data __UNUSED__)
{
- Ewl_Seeker *s;
+ Ewl_Range *r;
Ewl_Event_Key_Down *ev;
double start, end;
- void (*increase)(Ewl_Seeker *s);
- void (*decrease)(Ewl_Seeker *s);
+ void (*increase)(Ewl_Range *r);
+ void (*decrease)(Ewl_Range *r);
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
@@ -770,35 +560,35 @@
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
ev = ev_data;
- s = EWL_SEEKER(w);
+ r = EWL_RANGE(w);
- if (!s->invert) {
- increase = ewl_seeker_increase;
- decrease = ewl_seeker_decrease;
- start = 0.0;
- end = s->range;
+ if (!r->invert) {
+ increase = ewl_range_increase;
+ decrease = ewl_range_decrease;
+ start = r->min_val;
+ end = r->max_val;
}
else {
- increase = ewl_seeker_decrease;
- decrease = ewl_seeker_increase;
- start = s->range;
- end = 0.0;
+ increase = ewl_range_decrease;
+ decrease = ewl_range_increase;
+ start = r->max_val;
+ end = r->min_val;
}
if (!strcmp(ev->keyname, "Home"))
- ewl_seeker_value_set(s, start);
+ ewl_range_value_set(r, start);
else if (!strcmp(ev->keyname, "End"))
- ewl_seeker_value_set(s, end);
+ ewl_range_value_set(r, end);
else if (!strcmp(ev->keyname, "Left")
|| !strcmp(ev->keyname, "KP_Left")
|| !strcmp(ev->keyname, "Up")
|| !strcmp(ev->keyname, "KP_Up"))
- decrease(s);
+ decrease(r);
else if (!strcmp(ev->keyname, "Right")
|| !strcmp(ev->keyname, "KP_Right")
|| !strcmp(ev->keyname, "Down")
|| !strcmp(ev->keyname, "KP_Down"))
- increase(s);
+ increase(r);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -814,7 +604,7 @@
ewl_seeker_child_show_cb(Ewl_Container *p, Ewl_Widget *w)
{
int pw, ph;
- Ewl_Seeker *s;
+ Ewl_Range *r;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("p", p);
@@ -822,15 +612,15 @@
DCHECK_TYPE("p", p, EWL_CONTAINER_TYPE);
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
- s = EWL_SEEKER(p);
+ r = EWL_RANGE(p);
pw = ewl_object_preferred_w_get(EWL_OBJECT(w));
ph = ewl_object_preferred_h_get(EWL_OBJECT(w));
- if (s->orientation == EWL_ORIENTATION_HORIZONTAL)
- pw *= s->range / s->step;
+ if (EWL_SEEKER(r)->orientation == EWL_ORIENTATION_HORIZONTAL)
+ pw *= (r->max_val - r->min_val) / r->step;
else
- ph *= s->range / s->step;
+ ph *= (r->max_val - r->min_val) / r->step;
ewl_object_preferred_inner_size_set(EWL_OBJECT(p), pw, ph);
@@ -840,6 +630,7 @@
static double
ewl_seeker_mouse_value_map(Ewl_Seeker *s, int mx, int my)
{
+ Ewl_Range *r;
int m;
int dc, dg;
int adjust;
@@ -849,6 +640,8 @@
DCHECK_PARAM_PTR_RET("s", s, 0.0);
DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, 0.0);
+ r = EWL_RANGE(s);
+
if (s->orientation == EWL_ORIENTATION_HORIZONTAL) {
m = mx;
@@ -888,9 +681,12 @@
/*
* Calculate the new value based on the range, sizes and new position.
*/
- scale = s->range * (double)(m - dc) / (double)dg;
- if (s->invert)
- scale = s->range - scale;
+ scale = (r->max_val - r->min_val) * (double)(m - dc) / (double)dg;
+
+ if (!r->invert)
+ scale = r->min_val + scale;
+ else
+ scale = r->max_val - scale;
DRETURN_FLOAT(scale, DLEVEL_STABLE);
}
@@ -899,41 +695,43 @@
ewl_seeker_timer(void *data)
{
Ewl_Seeker *s;
- double value, posval;
+ double value, posval, step;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR_RET("data", data, FALSE);
DCHECK_TYPE_RET("data", data, EWL_SEEKER_TYPE, FALSE);
s = EWL_SEEKER(data);
- value = ewl_seeker_value_get(s);
+ value = ewl_range_value_get(EWL_RANGE(s));
+ step = ewl_range_step_get(EWL_RANGE(s));
/*
* Find the value based on mouse position
*/
- posval = ewl_seeker_mouse_value_map(s, s->dragstart, s->dragstart);
+ posval = ewl_seeker_mouse_value_map(s, s->dragstart * 2,
+ s->dragstart * 2);
/*
* Limit the value to the intersection with the mouse.
*/
if (posval > value) {
- if (value + s->step > posval) {
+ if (value + step > posval) {
value = posval;
}
else {
- value += s->step;
+ value += step;
}
}
else {
- if (value - s->step < posval) {
+ if (value - step < posval) {
value = posval;
}
else {
- value -= s->step;
+ value -= step;
}
}
- ewl_seeker_value_set(EWL_SEEKER(s), value);
+ ewl_range_value_set(EWL_RANGE(s), value);
DRETURN_INT(TRUE, DLEVEL_STABLE);
}
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_seeker.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- ewl_seeker.h 3 Jun 2006 16:18:11 -0000 1.12
+++ ewl_seeker.h 11 Aug 2006 04:00:57 -0000 1.13
@@ -40,13 +40,9 @@
*/
struct Ewl_Seeker
{
- Ewl_Container container; /**< Inherit from Ewl_Container */
+ Ewl_Range range; /**< Inherit from Ewl_Range */
Ewl_Orientation orientation; /**< Indicates layout direction */
Ewl_Widget *button; /**< Draggable widget for selecting value */
- double value; /**< Currently chosen value */
- double range; /**< Total selectable range */
- double step; /**< Size of increments in the range */
- int invert; /**< Invert the axis */
int dragstart; /**< The coordinate where the drag starts */
int autohide; /**< Indicator to hide when not scrollable */
Ecore_Timer *timer; /**< Timer for scroll repeating */
@@ -61,23 +57,8 @@
void ewl_seeker_orientation_set(Ewl_Seeker *s, Ewl_Orientation o);
Ewl_Orientation ewl_seeker_orientation_get(Ewl_Seeker *s);
-void ewl_seeker_value_set(Ewl_Seeker *s, double v);
-double ewl_seeker_value_get(Ewl_Seeker *s);
-
-void ewl_seeker_range_set(Ewl_Seeker *s, double r);
-double ewl_seeker_range_get(Ewl_Seeker *s);
-
-void ewl_seeker_step_set(Ewl_Seeker *s, double step);
-double ewl_seeker_step_get(Ewl_Seeker *s);
-
void ewl_seeker_autohide_set(Ewl_Seeker *s, int v);
int ewl_seeker_autohide_get(Ewl_Seeker *s);
-
-void ewl_seeker_invert_set(Ewl_Seeker *s, int invert);
-int ewl_seeker_invert_get(Ewl_Seeker *s);
-
-void ewl_seeker_decrease(Ewl_Seeker *s);
-void ewl_seeker_increase(Ewl_Seeker *s);
/*
* Internally used callbacks, override at your own risk.
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- ewl_spinner.c 10 Jul 2006 21:13:33 -0000 1.18
+++ ewl_spinner.c 11 Aug 2006 04:00:57 -0000 1.19
@@ -3,7 +3,7 @@
#include "ewl_debug.h"
#include "ewl_macros.h"
-static void ewl_spinner_calc_value(Ewl_Spinner *s, double val, unsigned int
call);
+static void ewl_spinner_entry_update(Ewl_Spinner *s);
static int ewl_spinner_timer(void *data);
/**
@@ -39,19 +39,18 @@
int
ewl_spinner_init(Ewl_Spinner *s)
{
- Ewl_Widget *w, *vbox;
+ Ewl_Widget *w;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR_RET("s", s, FALSE);
w = EWL_WIDGET(s);
- if (!ewl_box_init(EWL_BOX(w)))
+ if (!ewl_range_init(EWL_RANGE(w)))
{
DRETURN_INT(FALSE, DLEVEL_STABLE);
}
- ewl_box_orientation_set(EWL_BOX(w), EWL_ORIENTATION_HORIZONTAL);
ewl_widget_appearance_set(w, EWL_SPINNER_TYPE);
ewl_widget_inherit(w, EWL_SPINNER_TYPE);
@@ -60,9 +59,17 @@
ewl_callback_append(w, EWL_CALLBACK_REALIZE,
ewl_spinner_realize_cb, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_CONFIGURE,
+ ewl_spinner_configure_cb, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_VALUE_CHANGED,
+ ewl_spinner_value_changed_cb, NULL);
ewl_callback_prepend(w, EWL_CALLBACK_DESTROY,
ewl_spinner_destroy_cb, NULL);
-
+ ewl_container_show_notify_set(EWL_CONTAINER(w),
+ ewl_spinner_child_show_cb);
+ ewl_container_resize_notify_set(EWL_CONTAINER(w),
+ ewl_spinner_child_resize_cb);
+
s->entry = ewl_entry_new();
ewl_text_text_set(EWL_TEXT(s->entry), "0");
ewl_container_child_append(EWL_CONTAINER(s), s->entry);
@@ -83,15 +90,15 @@
ewl_widget_show(s->entry);
- vbox = ewl_vbox_new();
- ewl_container_child_append(EWL_CONTAINER(s), vbox);
- ewl_widget_appearance_set(vbox, "controls");
- ewl_widget_internal_set(vbox, TRUE);
- ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_NONE);
- ewl_widget_show(vbox);
+ s->vbox = ewl_vbox_new();
+ ewl_container_child_append(EWL_CONTAINER(s), s->vbox);
+ ewl_widget_appearance_set(s->vbox, "controls");
+ ewl_widget_internal_set(s->vbox, TRUE);
+ ewl_object_fill_policy_set(EWL_OBJECT(s->vbox), EWL_FLAG_FILL_NONE);
+ ewl_widget_show(s->vbox);
s->increment = ewl_button_new();
- ewl_container_child_append(EWL_CONTAINER(vbox), s->increment);
+ ewl_container_child_append(EWL_CONTAINER(s->vbox), s->increment);
ewl_object_alignment_set(EWL_OBJECT(s->increment),
EWL_FLAG_ALIGN_CENTER);
ewl_widget_appearance_set(s->increment, "increment");
@@ -107,7 +114,7 @@
ewl_widget_show(s->increment);
s->decrement = ewl_button_new();
- ewl_container_child_append(EWL_CONTAINER(vbox), s->decrement);
+ ewl_container_child_append(EWL_CONTAINER(s->vbox), s->decrement);
ewl_object_alignment_set(EWL_OBJECT(s->decrement),
EWL_FLAG_ALIGN_CENTER);
ewl_widget_appearance_set(s->decrement, "decrement");
@@ -122,51 +129,12 @@
ewl_spinner_key_down_cb, s);
ewl_widget_show(s->decrement);
- s->min_val = INT_MIN;
- s->max_val = INT_MAX;
- s->value = 0.0;
- s->step = 0.1;
s->digits = 2;
DRETURN_INT(TRUE, DLEVEL_STABLE);
}
/**
- * @param s: the spinner widget to set the current value
- * @param value: the value to set for the spinner @a s
- * @return Returns no value.
- * @brief Set the current value of a spinner widget
- *
- * Sets the current value of the spinner @a s to @a value.
- */
-void
-ewl_spinner_value_set(Ewl_Spinner *s, double value)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SPINNER_TYPE);
-
- ewl_spinner_calc_value(s, value, FALSE);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @param s: the spinner widget to retrieve the value
- * @return Returns the current value in @a s on success, 0.0 on failure.
- * @brief Get the current value of a spinner widget
- */
-double
-ewl_spinner_value_get(Ewl_Spinner *s)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("s", s, 0.00);
- DCHECK_TYPE_RET("s", s, EWL_SPINNER_TYPE, 0.00);
-
- DRETURN_FLOAT(s->value, DLEVEL_STABLE);
-}
-
-/**
* @param s: the widget to change the number of digits displayed
* @param digits: the number of digits to display for the spinner @a s
* @return Returns no value.
@@ -182,100 +150,55 @@
DCHECK_TYPE("s", s, EWL_SPINNER_TYPE);
s->digits = digits;
- ewl_spinner_calc_value(s, s->value, FALSE);
+ ewl_spinner_entry_update(s);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
/**
- * @param s: the spinner to retrieve minimum value
- * @brief Retrieves the minimum value for the spinner.
- * @return Returns the currently set minimum value for the specified spinner.
- */
-double
-ewl_spinner_min_val_get(Ewl_Spinner *s)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("s", s, 0.0);
- DCHECK_TYPE_RET("s", s, EWL_SPINNER_TYPE, 0.0);
-
- DRETURN_FLOAT(s->min_val, DLEVEL_STABLE);
-}
-
-/**
- * @param s: the spinner to change the minimum possible value
- * @param val: the new minimum possible value for @a s
- * @return Returns no value.
- * @brief Set the minimum value possible for a spinner
- *
- * Sets the smallest value that @a s can obtain to @a val.
+ * @internal
+ * @param w: The widget to work with
+ * @param ev_data: UNUSED
+ * @param user_data: UNUSED
+ * @return Returns no value
+ * @brief The realize callback
*/
void
-ewl_spinner_min_val_set(Ewl_Spinner *s, double val)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SPINNER_TYPE);
-
- s->min_val = val;
- ewl_spinner_calc_value(s, s->value, FALSE);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @param s: the spinner to retrieve maximum value
- * @brief Retrieves the maximum value for the spinner.
- * @return Returns the currently set maximum value for the specified spinner.
- */
-double
-ewl_spinner_max_val_get(Ewl_Spinner *s)
+ewl_spinner_realize_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
+ void *user_data __UNUSED__)
{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("s", s, 100.0);
- DCHECK_TYPE_RET("s", s, EWL_SPINNER_TYPE, 100.0);
-
- DRETURN_FLOAT(s->max_val, DLEVEL_STABLE);
-}
+ Ewl_Spinner *s;
-/**
- * @param s: the spinner to change the maximum possible value
- * @param val: the new maximum possible value for @a s
- * @return Returns no value.
- * @brief Set the maximum value possible for a spinner
- *
- * Sets the largest value that @a s can obtain to @a val.
- */
-void
-ewl_spinner_max_val_set(Ewl_Spinner *s, double val)
-{
DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SPINNER_TYPE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
- s->max_val = val;
- ewl_spinner_calc_value(s, s->value, FALSE);
+ s = EWL_SPINNER(w);
+ ewl_spinner_entry_update(s);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
/**
- * @param s: the spinner to change increment step
- * @param step: the new increment between clicks of the spinner @a s
- * @brief Returns no value.
- * @brief Set the increment between each click of the spinner
- *
- * Changes the increment that @a s changes by with each click of it's spinner
- * buttons to @a step.
+ * @internal
+ * @param w: The widget to work with
+ * @param ev_data: UNUSED
+ * @param user_data: UNUSED
+ * @return Returns no value
+ * @brief The value changed callback
*/
void
-ewl_spinner_step_set(Ewl_Spinner *s, double step)
+ewl_spinner_value_changed_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
+ void *user_data __UNUSED__)
{
+ Ewl_Spinner *s;
+
DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("s", s);
- DCHECK_TYPE("s", s, EWL_SPINNER_TYPE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
- s->step = step;
+ s = EWL_SPINNER(w);
+ ewl_spinner_entry_update(s);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -286,21 +209,34 @@
* @param ev_data: UNUSED
* @param user_data: UNUSED
* @return Returns no value
- * @brief The realize callback
+ * @brief The configure callback
*/
void
-ewl_spinner_realize_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
+ewl_spinner_configure_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
void *user_data __UNUSED__)
{
Ewl_Spinner *s;
+ int cx, cy, cw, ch;
+ int pvw; /* the preferred w of the vbox */
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
s = EWL_SPINNER(w);
- ewl_spinner_calc_value(s, s->value, FALSE);
+ cx = CURRENT_X(w);
+ cy = CURRENT_Y(w);
+ cw = CURRENT_W(w);
+ ch = CURRENT_H(w);
+
+ pvw = ewl_object_preferred_w_get(EWL_OBJECT(s->vbox));
+
+ ewl_object_place(EWL_OBJECT(s->vbox), cx + cw - pvw, cy, pvw,
+ ch);
+ ewl_object_place(EWL_OBJECT(s->entry), cx, cy, cw - pvw,
+ ch);
+
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -392,7 +328,7 @@
if (str && strlen(str)) {
val = atof(str);
- ewl_spinner_calc_value(s, (double) (val), TRUE);
+ ewl_range_value_set(EWL_RANGE(s), (double) (val));
} else if (str)
FREE(str);
@@ -411,7 +347,7 @@
ewl_spinner_wheel_cb(Ewl_Widget *w, void *ev_data,
void *user_data __UNUSED__)
{
- Ewl_Spinner *s;
+ Ewl_Range *r;
Ewl_Event_Mouse_Wheel *wheel;
DENTER_FUNCTION(DLEVEL_STABLE);
@@ -419,45 +355,32 @@
DCHECK_PARAM_PTR("ev_data", ev_data);
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
- s = EWL_SPINNER(w);
+ r = EWL_RANGE(w);
wheel = (Ewl_Event_Mouse_Wheel *)ev_data;
- ewl_spinner_calc_value(s, s->value - (wheel->z * s->step), TRUE);
+ ewl_range_value_set(r, r->value - (wheel->z * r->step));
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
static void
-ewl_spinner_calc_value(Ewl_Spinner *s, double value, unsigned int call)
+ewl_spinner_entry_update(Ewl_Spinner *s)
{
+ Ewl_Range *r;
char format[64];
char str[64];
- double oval;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("s", s);
DCHECK_TYPE("s", s, EWL_SPINNER_TYPE);
- oval = s->value;
-
- if (value < s->min_val)
- s->value = s->min_val;
- else if (value > s->max_val)
- s->value = s->max_val;
- else
- s->value = value;
+ r = EWL_RANGE(s);
snprintf(format, 64, "%%.%df", s->digits);
- snprintf(str, 64, format, s->value);
+ snprintf(str, 64, format, r->value);
ewl_text_text_set(EWL_TEXT(s->entry), str);
- if ((call == TRUE) && (oval != s->value)) {
- oval = s->value;
- ewl_callback_call_with_event_data(EWL_WIDGET(s),
- EWL_CALLBACK_VALUE_CHANGED, &oval);
- }
-
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -474,6 +397,7 @@
void *user_data)
{
Ewl_Spinner *s;
+ Ewl_Range *r;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
@@ -481,12 +405,16 @@
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
s = EWL_SPINNER(user_data);
+ r = EWL_RANGE(s);
ewl_spinner_focus_out_cb(EWL_WIDGET(s), NULL, NULL);
-
- ewl_spinner_calc_value(s, s->value + s->step, TRUE);
+
+ if (!r->invert)
+ ewl_range_increase(r);
+ else
+ ewl_range_decrease(r);
if (ev_data) {
- s->direction = 1;
+ s->direction = (!r->invert) ? 1 : -1;
s->start_time = ecore_time_get();
s->timer = ecore_timer_add(0.02, ewl_spinner_timer, s);
}
@@ -506,7 +434,6 @@
ewl_spinner_value_stop_cb(Ewl_Widget *w __UNUSED__,
void *ev_data __UNUSED__, void *user_data)
{
- double oval;
Ewl_Spinner *s;
DENTER_FUNCTION(DLEVEL_STABLE);
@@ -521,10 +448,6 @@
s->start_time = 0;
}
- oval = s->value;
- ewl_callback_call_with_event_data(EWL_WIDGET(s),
- EWL_CALLBACK_VALUE_CHANGED, &oval);
-
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -541,6 +464,7 @@
void *user_data)
{
Ewl_Spinner *s;
+ Ewl_Range *r;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
@@ -548,11 +472,17 @@
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
s = EWL_SPINNER(user_data);
+ r = EWL_RANGE(s);
+
ewl_spinner_focus_out_cb(EWL_WIDGET(s), NULL, NULL);
- ewl_spinner_calc_value(s, s->value - s->step, TRUE);
+ if (!r->invert)
+ ewl_range_decrease(r);
+ else
+ ewl_range_increase(r);
+
if (ev_data) {
- s->direction = -1;
+ s->direction = (!r->invert) ? -1 : 1;
s->start_time = ecore_time_get();
s->timer = ecore_timer_add(0.02, ewl_spinner_timer, s);
}
@@ -591,6 +521,7 @@
ewl_spinner_timer(void *data)
{
Ewl_Spinner *s;
+ Ewl_Range *r;
double dt;
double value, range, tmpt;
int velocity, delay;
@@ -599,10 +530,11 @@
DCHECK_PARAM_PTR_RET("data", data, FALSE);
s = EWL_SPINNER(data);
+ r = EWL_RANGE(s);
dt = ecore_time_get() - s->start_time;
- value = ewl_spinner_value_get(s);
- range = s->max_val - s->min_val;
+ value = r->value;
+ range = r->max_val - r->min_val;
/*
* Check the theme for a velocity setting and bring it within normal
@@ -632,8 +564,79 @@
tmpt = ((1 - exp(-tmpt)) * ((double)(velocity) / 100.0)) * range;
value += (double)(s->direction) * ((1 - exp(-dt)) + tmpt);
- ewl_spinner_value_set(s, value);
+ ewl_range_value_set(r, value);
DRETURN_INT(TRUE, DLEVEL_STABLE);
+}
+
+static void
+ewl_spinner_child_handle(Ewl_Container *c,
+ Ewl_Widget *w __UNUSED__)
+{
+ Ewl_Spinner *s;
+ int pvw, pvh, pew, peh;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("c", c);
+ DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE);
+
+ s = EWL_SPINNER(c);
+
+ pvw = ewl_object_preferred_w_get(EWL_OBJECT(s->vbox));
+ pvh = ewl_object_preferred_h_get(EWL_OBJECT(s->vbox));
+
+ pew = ewl_object_preferred_w_get(EWL_OBJECT(s->entry));
+ peh = ewl_object_preferred_h_get(EWL_OBJECT(s->entry));
+
+ ewl_object_preferred_inner_size_set(EWL_OBJECT(c), pvw + pew,
+ MAX(peh, pvh));
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @internal
+ * @param c: The container to work with
+ * @param w: The widget to work with
+ * @return Returns no value
+ * @brief The child show callback
+ */
+void
+ewl_spinner_child_show_cb(Ewl_Container *c, Ewl_Widget *w)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("c", c);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE);
+ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
+
+ ewl_spinner_child_handle(c, w);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @internal
+ * @param c: The container to work with
+ * @param w: The widget to work with
+ * @param size: UNUSED
+ * @param o: UNUSED
+ * @return Returns no value
+ * @brief The child resize callback
+ */
+void
+ewl_spinner_child_resize_cb(Ewl_Container *c, Ewl_Widget *w,
+ int size __UNUSED__,
+ Ewl_Orientation o __UNUSED__)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("c", c);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE);
+ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
+
+ ewl_spinner_child_handle(c, w);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
}
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- ewl_spinner.h 15 Mar 2006 04:03:48 -0000 1.10
+++ ewl_spinner.h 11 Aug 2006 04:00:57 -0000 1.11
@@ -33,18 +33,15 @@
#define EWL_SPINNER(spinner) ((Ewl_Spinner *) spinner)
/**
- * Inherits from Ewl_Box and adds an entry box that can only contain
+ * Inherits from Ewl_Range and adds an entry box that can only contain
* numerical values as well as buttons for manipulating that value.
*/
struct Ewl_Spinner
{
- Ewl_Box box; /**< Inherit from Ewl_Box */
- double min_val; /**< Minimum numerical value displayed */
- double max_val; /**< Maximum numerical value displayed */
- double value; /**< Current value displayed */
- double step; /**< Amount to add or subtract at a time */
+ Ewl_Range range; /**< Inherit from Ewl_Range */
int digits; /**< Number of digits displayed after decimal */
Ewl_Widget *entry; /**< The Ewl_Entry displaying value */
+ Ewl_Widget *vbox; /**< Ewl_Box to hold the buttons */
Ewl_Widget *increment; /**< Ewl_Button to add value */
Ewl_Widget *decrement; /**< Ewl_Button to subtract value */
double start_time; /**< Time the spinner was pressed */
@@ -54,20 +51,17 @@
Ewl_Widget *ewl_spinner_new(void);
int ewl_spinner_init(Ewl_Spinner *s);
-void ewl_spinner_value_set(Ewl_Spinner *s, double value);
-double ewl_spinner_value_get(Ewl_Spinner *s);
void ewl_spinner_digits_set(Ewl_Spinner *s, unsigned char digits);
-double ewl_spinner_min_val_get(Ewl_Spinner *s);
-void ewl_spinner_min_val_set(Ewl_Spinner *s, double val);
-double ewl_spinner_max_val_get(Ewl_Spinner *s);
-void ewl_spinner_max_val_set(Ewl_Spinner *s, double val);
-void ewl_spinner_step_set(Ewl_Spinner *s, double step);
/*
* Internally used callbacks, override at your own risk.
*/
void ewl_spinner_realize_cb(Ewl_Widget *widget, void *ev_data,
void *user_data);
+void ewl_spinner_value_changed_cb(Ewl_Widget *widget, void *ev_data,
+ void *user_data);
+void ewl_spinner_configure_cb(Ewl_Widget *widget, void *ev_data,
+ void *user_data);
void ewl_spinner_key_down_cb(Ewl_Widget *widget, void *ev_data,
void *user_data);
void ewl_spinner_focus_out_cb(Ewl_Widget *w, void *ev_data,
@@ -81,7 +75,9 @@
void *user_data);
void ewl_spinner_value_stop_cb(Ewl_Widget *w, void *ev_data, void *user_data);
void ewl_spinner_destroy_cb(Ewl_Widget *w, void *ev_data, void *user_data);
-
+void ewl_spinner_child_show_cb(Ewl_Container *c, Ewl_Widget *w);
+void ewl_spinner_child_resize_cb(Ewl_Container *c, Ewl_Widget *w, int size,
+ Ewl_Orientation o);
/**
* @}
*/
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs