Enlightenment CVS committal
Author : rbdpngn
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src
Modified Files:
ewl_progressbar.c ewl_progressbar.h ewl_scrollpane.c
ewl_scrollpane.h
Log Message:
More progressbar work from balony. Slight modifications to the theme for it
too.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_progressbar.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_progressbar.c 12 Nov 2003 20:07:17 -0000 1.2
+++ ewl_progressbar.c 12 Nov 2003 23:18:00 -0000 1.3
@@ -47,13 +47,14 @@
ewl_container_append_child(EWL_CONTAINER(p), p->bar);
ewl_widget_show(p->bar);
- p->text = ewl_text_new("test");
- ewl_object_set_alignment(EWL_OBJECT(p->text),
+ p->label = ewl_text_new(NULL);
+ ewl_object_set_alignment(EWL_OBJECT(p->label),
EWL_FLAG_ALIGN_CENTER);
- ewl_container_append_child(EWL_CONTAINER(p), p->text);
- ewl_widget_show(p->text);
+ ewl_container_append_child(EWL_CONTAINER(p), p->label);
+ ewl_widget_show(p->label);
p->value = 0.0;
+ p->range = 100.0;
ewl_callback_append(w, EWL_CALLBACK_CONFIGURE,
__ewl_progressbar_configure, NULL);
@@ -64,23 +65,33 @@
/**
* @param p: the progressbar whose value will be changed
- * @param v: the new value the statusbar
+ * @param v: the new value of the statusbar
* @return Returns no value.
* @brief Set the value of the progressbars location
*/
void ewl_progressbar_set_value(Ewl_Progressbar * p, double v)
{
+ char c[10];
+
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("p", p);
if (v == p->value)
DRETURN(DLEVEL_STABLE);
+ if (p->value >= p->range)
+ DRETURN(DLEVEL_STABLE);
+
if (v < 0)
v = 0;
p->value = v;
+ if (!p->auto_label) {
+ snprintf (c, sizeof (c), "%.0lf", p->value);
+ ewl_text_set_text(EWL_TEXT(p->label), c);
+ }
+
ewl_widget_configure(EWL_WIDGET(p));
ewl_callback_call(EWL_WIDGET(p), EWL_CALLBACK_VALUE_CHANGED);
@@ -101,22 +112,114 @@
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_set_range (Ewl_Progressbar * p, double r)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("p", p);
+
+ 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_get_range (Ewl_Progressbar * p)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR_RET("p", p, -1);
+
+ DRETURN_FLOAT(p->range, DLEVEL_STABLE);
+}
+
/**
* @param p: the progressbars whose text will be changed
- * @param text: the new text
+ * @param label: the new label
* @return Returns no value
* @brief Sets the given text on the progressbar
*/
-void ewl_progressbar_set_text (Ewl_Progressbar * p, char *text)
+void ewl_progressbar_set_label (Ewl_Progressbar * p, char *label)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("p", p);
+
+ p->auto_label = TRUE;
+
+ if (label)
+ ewl_text_set_text(EWL_TEXT(p->label), label);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param p: the progressbars whose label will be changed
+ * @param format_string: format string for the new label
+ * @return Returns no value
+ * @brief Sets the given format string on the progressbar (%lf of %lf beers)
+ */
+void ewl_progressbar_set_custom_label (Ewl_Progressbar * p, char *format_string)
{
+ char label[PATH_MAX];
+
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("p", p);
- if (text)
- ewl_text_set_text(EWL_TEXT(p->text), text);
+ p->auto_label = TRUE;
- DLEAVE_FUNCTION(DLEVEL_STABLE)
+ if (format_string) {
+ snprintf (label, PATH_MAX, format_string, p->value, p->range);
+ ewl_text_set_text(EWL_TEXT(p->label), label);
+ }
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param p: the progressbars whose label will be hidden
+ * @return Returns no value
+ * @brief Hides the given progressbars label
+ */
+void ewl_progressbar_label_hide (Ewl_Progressbar * p) {
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("p", p);
+
+ p->auto_label = TRUE;
+ ewl_text_set_text(EWL_TEXT(p->label), "");
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param p: the progressbars whose label will be shown
+ * @return Returns no value
+ * @brief Shows the given progressbars label
+ */
+void ewl_progressbar_label_show (Ewl_Progressbar * p) {
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("p", p);
+
+ p->auto_label = FALSE;
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -141,7 +244,10 @@
dw = CURRENT_W(p);
dh = CURRENT_H(p);
- ewl_object_request_geometry(EWL_OBJECT(p->bar), dx, dy, dw * p->value, dh);
+ ewl_object_request_geometry (EWL_OBJECT(p->bar), dx, dy,
+ dw * (p->value / p->range), dh);
+
+ ewl_object_place (EWL_OBJECT(p->label), dx, dy, dw, dh);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_progressbar.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_progressbar.h 12 Nov 2003 20:07:17 -0000 1.2
+++ ewl_progressbar.h 12 Nov 2003 23:18:00 -0000 1.3
@@ -33,10 +33,12 @@
*/
struct Ewl_Progressbar
{
- Ewl_Container container; /**< Inherit from Ewl_Container */
- Ewl_Widget *bar; /**< The moving bar on top */
- Ewl_Widget *text; /**< text label on the bar */
- double value; /**< current value of the progressbar */
+ Ewl_Container container; /**< Inherit from Ewl_Container */
+ 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 */
};
@@ -44,8 +46,15 @@
void ewl_progressbar_init (Ewl_Progressbar * p);
void ewl_progressbar_set_value (Ewl_Progressbar * p, double v);
-double ewl_progressbar_get_value(Ewl_Progressbar * p);
+double ewl_progressbar_get_value (Ewl_Progressbar * p);
-void ewl_progressbar_set_text (Ewl_Progressbar * p, char *text);
+void ewl_progressbar_set_range (Ewl_Progressbar * p, double r);
+double ewl_progressbar_get_range (Ewl_Progressbar * p);
+
+void ewl_progressbar_set_label (Ewl_Progressbar * p, char *label);
+void ewl_progressbar_set_custom_label (Ewl_Progressbar * p, char *format_string);
+
+void ewl_progressbar_label_show (Ewl_Progressbar * p);
+void ewl_progressbar_label_hide (Ewl_Progressbar * p);
#endif /* __EWL_PROGRESSBAR_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollpane.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- ewl_scrollpane.c 12 Nov 2003 20:07:17 -0000 1.27
+++ ewl_scrollpane.c 12 Nov 2003 23:18:00 -0000 1.28
@@ -1,4 +1,3 @@
-
#include <Ewl.h>
void __ewl_scrollpane_configure(Ewl_Widget * w, void *ev_data,
@@ -170,6 +169,34 @@
f = ewl_scrollbar_get_flag(EWL_SCROLLBAR(s->vscrollbar));
DRETURN_INT(f, DLEVEL_STABLE);
+}
+
+/**
+ * @param s: the scrollpane to retrieve it's horizontal scrollbar value
+ * @return Returns the value of the horizontal scrollbar in @a s on success.
+ * @brief Retrieves the value of the horizontal scrollbar in @a s.
+ */
+double ewl_scrollpane_get_hscrollbar_value(Ewl_ScrollPane *s)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR_RET("s", s, 0.0);
+
+ DRETURN_FLOAT(ewl_scrollbar_get_value(EWL_SCROLLBAR(s->hscrollbar)),
+ DLEVEL_STABLE);
+}
+
+/**
+ * @param s: the scrollpane to retrieve it's vertical scrollbar value
+ * @return Returns the value of the vertical scrollbar in @a s on success.
+ * @brief Retrieves the value of the vertical scrollbar in @a s.
+ */
+double ewl_scrollpane_get_vscrollbar_value(Ewl_ScrollPane *s)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR_RET("s", s, 0.0);
+
+ DRETURN_FLOAT(ewl_scrollbar_get_value(EWL_SCROLLBAR(s->vscrollbar)),
+ DLEVEL_STABLE);
}
/*
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollpane.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_scrollpane.h 16 Oct 2003 20:54:25 -0000 1.7
+++ ewl_scrollpane.h 12 Nov 2003 23:18:00 -0000 1.8
@@ -51,6 +51,9 @@
Ewl_ScrollBar_Flags ewl_scrollpane_get_hscrollbar_flag(Ewl_ScrollPane * s);
Ewl_ScrollBar_Flags ewl_scrollpane_get_vscrollbar_flag(Ewl_ScrollPane * s);
+double ewl_scrollpane_get_hscrollbar_value(Ewl_ScrollPane *s);
+double ewl_scrollpane_get_vscrollbar_value(Ewl_ScrollPane *s);
+
/**
* @}
*/
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs