aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/e_widget_label.c
diff options
context:
space:
mode:
authorcodewarrior <codewarrior>2005-10-12 22:21:50 +0000
committercodewarrior <codewarrior@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2005-10-12 22:21:50 +0000
commitc73c78469864af0cc20f0c154797a37370fe95ad (patch)
treee96083d205641baf46297a2cd4f7127c2696edc9 /src/bin/e_widget_label.c
parent- remove image thats not used (diff)
downloadenlightenment-c73c78469864af0cc20f0c154797a37370fe95ad.tar.gz
- Add label widget (futur work: ability to tie its focus to another widget)
- Redo properties dialog in EFM to show more info and file permissions. (needs more work so it can do and apply things, and load permissions) SVN revision: 17468
Diffstat (limited to 'src/bin/e_widget_label.c')
-rw-r--r--src/bin/e_widget_label.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/bin/e_widget_label.c b/src/bin/e_widget_label.c
new file mode 100644
index 000000000..11ed9bb46
--- /dev/null
+++ b/src/bin/e_widget_label.c
@@ -0,0 +1,119 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+#include "e.h"
+
+typedef struct _E_Widget_Data E_Widget_Data;
+struct _E_Widget_Data
+{
+ Evas_Object *o_label;
+ int *valptr;
+};
+
+static void _e_wid_del_hook(Evas_Object *obj);
+static void _e_wid_focus_hook(Evas_Object *obj);
+static void _e_wid_do(Evas_Object *obj);
+static void _e_wid_activate_hook(Evas_Object *obj);
+static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source);
+static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info);
+
+/* local subsystem functions */
+
+/* externally accessible functions */
+Evas_Object *
+e_widget_label_add(Evas *evas, char *label, int *val)
+{
+ Evas_Object *obj, *o;
+ E_Widget_Data *wd;
+ Evas_Coord mw, mh;
+
+ obj = e_widget_add(evas);
+
+ e_widget_del_hook_set(obj, _e_wid_del_hook);
+ e_widget_focus_hook_set(obj, _e_wid_focus_hook);
+ e_widget_activate_hook_set(obj, _e_wid_activate_hook);
+ wd = calloc(1, sizeof(E_Widget_Data));
+ wd->valptr = val;
+ e_widget_data_set(obj, wd);
+
+ o = edje_object_add(evas);
+ wd->o_label = o;
+ e_theme_edje_object_set(o, "base/theme/widgets",
+ "widgets/label");
+ edje_object_signal_callback_add(o, "toggled", "*", _e_wid_signal_cb1, obj);
+ edje_object_part_text_set(o, "label", label);
+ evas_object_show(o);
+ edje_object_size_min_calc(o, &mw, &mh);
+ e_widget_min_size_set(obj, mw, mh);
+
+ if (wd->valptr)
+ {
+ if (*(wd->valptr)) edje_object_signal_emit(o, "toggle_on", "");
+ }
+
+ e_widget_sub_object_add(obj, o);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj);
+ e_widget_resize_object_set(obj, o);
+
+ return obj;
+}
+
+static void
+_e_wid_del_hook(Evas_Object *obj)
+{
+ E_Widget_Data *wd;
+
+ wd = e_widget_data_get(obj);
+ free(wd);
+}
+
+static void
+_e_wid_focus_hook(Evas_Object *obj)
+{
+ E_Widget_Data *wd;
+
+ wd = e_widget_data_get(obj);
+ if (e_widget_focus_get(obj))
+ edje_object_signal_emit(wd->o_label, "focus_in", "");
+ else
+ edje_object_signal_emit(wd->o_label, "focus_out", "");
+}
+
+static void
+_e_wid_do(Evas_Object *obj)
+{
+ E_Widget_Data *wd;
+
+ wd = e_widget_data_get(obj);
+ if (wd->valptr)
+ {
+ if (*(wd->valptr) == 0) *(wd->valptr) = 1;
+ else *(wd->valptr) = 0;
+ }
+}
+
+static void
+_e_wid_activate_hook(Evas_Object *obj)
+{
+ E_Widget_Data *wd;
+
+ wd = e_widget_data_get(obj);
+ _e_wid_do(obj);
+ if (wd->valptr)
+ {
+ if (*(wd->valptr)) edje_object_signal_emit(wd->o_label, "toggle_on", "");
+ else edje_object_signal_emit(wd->o_label, "toggle_off", "");
+ }
+}
+
+static void
+_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ _e_wid_do(data);
+}
+
+static void
+_e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ e_widget_focus_steal(data);
+}