ok- fangie.. THIS Is what i meant! this! put a textblock in a scrollframe.
authorCarsten Haitzler <raster@rasterman.com>
Wed, 25 Jan 2006 09:28:12 +0000 (09:28 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Wed, 25 Jan 2006 09:28:12 +0000 (09:28 +0000)
textblock comes from an edje so it can be styled by the theme!

SVN revision: 20027

data/themes/Makefile.am
data/themes/default.edc
data/themes/default_textblock.edc [new file with mode: 0644]
src/bin/Makefile.am
src/bin/e_configure.c
src/bin/e_includes.h
src/bin/e_test.c
src/bin/e_widget_textblock.c [new file with mode: 0644]
src/bin/e_widget_textblock.h [new file with mode: 0644]

index 2a75673..84c3409 100644 (file)
@@ -51,7 +51,8 @@ default_scrollframe.edc \
 default_ilist.edc \
 default_tlist.edc \
 default_slider.edc \
-default_exebuf.edc
+default_exebuf.edc \
+default_textblock.edc
 
 default.edj: Makefile $(EXTRA_DIST)
        $(EDJE_CC) $(EDJE_FLAGS) \
index 140f87d..c26be7e 100644 (file)
@@ -60,5 +60,6 @@ collections {
 #include "default_tlist.edc"
 #include "default_slider.edc"
 #include "default_exebuf.edc"
+#include "default_textblock.edc"
 }
 
diff --git a/data/themes/default_textblock.edc b/data/themes/default_textblock.edc
new file mode 100644 (file)
index 0000000..d2c1a1a
--- /dev/null
@@ -0,0 +1,36 @@
+styles
+{
+   style {
+      name: "textblock_style";
+      base: "font=Edje-Vera font_size=10 align=left color=#000 style=shadow shadow_color=#ffffff80 wrap=word";
+      
+      tag:  "br" "\n";
+      tag:  "hilight" "+ font=Edje-Vera-Bold style=glow color=#fff glow2_color=#fe87 glow_color=#fa14";
+      tag:  "title" "+ font_size=12 font=Edje-Vera-Bold style=soft_shadow color=#fff shadow_color=#00000020";
+      tag:  "/title" "- \n \n";
+   }
+}
+
+group {
+   name: "widgets/textblock";
+   parts {
+      part {
+        name:          "text";
+        type:          TEXTBLOCK;
+        mouse_events:  0;
+        description {
+           state:    "default" 0.0;
+           rel1 {
+              offset: 4 4;
+           }
+           rel2 {
+              offset: -5 -5;
+           }
+           text {
+              style:    "textblock_style";
+              min:      1 1;
+           }
+        }
+      }
+   }
+}
index 610b256..dd985e3 100644 (file)
@@ -134,7 +134,8 @@ e_deskpreview.h \
 e_exebuf.h \
 e_int_config_modules.h \
 e_exehist.h \
-e_color_class.h
+e_color_class.h \
+e_widget_textblock.h
 
 enlightenment_src = \
 e_user.c \
@@ -251,6 +252,7 @@ e_exebuf.c \
 e_int_config_modules.c \
 e_exehist.c \
 e_color_class.c \
+e_widget_textblock.c \
 $(ENLIGHTENMENTHEADERS)
 
 enlightenment_SOURCES = \
index 595c3d3..07fb8af 100644 (file)
@@ -54,7 +54,7 @@ e_configure_show(E_Container *con)
    e_theme_edje_object_set(eco->edje, "base/theme/configure",
                           "widgets/configure/main");
    
-   eco->ilist = e_widget_ilist_add(eco->evas, 48, 48, NULL);
+   eco->ilist = e_widget_ilist_add(eco->evas, 24, 24, NULL);
    e_widget_ilist_selector_set(eco->ilist, 1);
    e_widget_min_size_get(eco->ilist, &mw, &mh);
    edje_extern_object_min_size_set(eco->ilist, mw, mh);
index 798cd54..90659f6 100644 (file)
 #include "e_int_config_modules.h"
 #include "e_exehist.h"
 #include "e_color_class.h"
+#include "e_widget_textblock.h"
index bcef3a5..0bfadcb 100644 (file)
@@ -534,6 +534,42 @@ _e_test_internal(E_Container *con)
    
    evas_object_focus_set(o, 1);
 }
+#elif 0
+static void
+_e_test_internal(E_Container *con)
+{
+   E_Dialog *dia;
+   Evas_Object *o;
+   Evas_Coord mw, mh;
+   
+   dia = e_dialog_new(con);
+   e_dialog_title_set(dia, "A Test Dialog");
+   
+   o = e_widget_textblock_add(dia->win->evas);
+   e_widget_textblock_markup_set(o,
+                                "<title>A title</title>"
+                                "This is some text<br>"
+                                "Blah blah<br>"
+                                "<hilight>hilighted text</hilight><br>"
+                                "<br>"
+                                "More lines of text<br>"
+                                "And yet more lines of text<br>"
+                                "A very very long line of text that SHOULD be getting word wrapped because it is so long.<br>"
+                                "And another line<br>"
+                                "Some more<br>"
+                                "Smelly fish on a stick<br>"
+                                "Whatever."
+                                );
+   evas_object_show(o);
+   
+   e_dialog_content_set(dia, o, 160, 160);
+   
+   e_dialog_button_add(dia, "OK", NULL, NULL, NULL);
+   e_win_centered_set(dia->win, 1);
+   e_dialog_show(dia);
+   
+   evas_object_focus_set(o, 1);
+}
 #else
 static void
 _e_test_internal(E_Container *con)
diff --git a/src/bin/e_widget_textblock.c b/src/bin/e_widget_textblock.c
new file mode 100644 (file)
index 0000000..35ee766
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * 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_widget, *o_scrollframe, *o_textblock;
+};
+
+static void _e_wid_del_hook(Evas_Object *obj);
+static void _e_wid_focus_hook(Evas_Object *obj);
+static void _e_wid_cb_scrollframe_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info);
+
+/* externally accessible functions */
+EAPI Evas_Object *
+e_widget_textblock_add(Evas *evas)
+{
+   Evas_Object *obj, *o;
+   E_Widget_Data *wd;
+   
+   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);
+   wd = calloc(1, sizeof(E_Widget_Data));
+   e_widget_data_set(obj, wd);
+
+   o = e_scrollframe_add(evas);
+   wd->o_scrollframe = o;
+   evas_object_show(o);
+   e_widget_sub_object_add(obj, o);
+   e_widget_resize_object_set(obj, o);
+   evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj);
+
+   o = edje_object_add(evas);
+   e_theme_edje_object_set(o, "base/theme/widgets",
+                          "widgets/textblock");
+   wd->o_textblock = o;
+   evas_object_event_callback_add(wd->o_scrollframe, EVAS_CALLBACK_RESIZE, _e_wid_cb_scrollframe_resize, wd);
+   e_scrollframe_child_set(wd->o_scrollframe, o);
+   e_widget_sub_object_add(obj, o);
+   evas_object_show(o);
+                      
+   evas_object_resize(obj, 32, 32);
+   e_widget_min_size_set(obj, 32, 32);
+   return obj;
+}
+
+EAPI void
+e_widget_textblock_markup_set(Evas_Object *obj, const char *text)
+{
+   E_Widget_Data *wd;
+   Evas_Coord mw, mh, vw, vh;
+
+   wd = e_widget_data_get(obj);
+   edje_object_part_text_set(wd->o_textblock, "text", text);
+   edje_object_size_min_calc(wd->o_textblock, &mw, &mh);
+   e_scrollframe_child_viewport_size_get(wd->o_scrollframe, &vw, &vh);
+   if (vw > mw) mw = vw;
+   if (vh > mh) mh = vh;
+   evas_object_resize(wd->o_textblock, mw, mh);
+}
+
+EAPI void
+e_widget_textblock_plain_set(Evas_Object *obj, const char *text)
+{
+   /* FIXME: parse text escape anything htmlish, - generate new text, set
+    * as markup
+    */
+   e_widget_textblock_markup_set(obj, text);
+}
+
+
+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(e_scrollframe_edje_object_get(wd->o_scrollframe), "focus_in", "");
+       evas_object_focus_set(wd->o_scrollframe, 1);
+     }
+   else
+     {
+       edje_object_signal_emit(e_scrollframe_edje_object_get(wd->o_scrollframe), "focus_out", "");
+       evas_object_focus_set(wd->o_scrollframe, 0);
+     }
+}
+
+static void
+_e_wid_cb_scrollframe_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   E_Widget_Data *wd;
+   Evas_Coord mw, mh, vw, vh;
+   
+   wd = data;
+   e_scrollframe_child_viewport_size_get(obj, &vw, &vh);
+   edje_object_size_min_calc(wd->o_textblock, &mw, &mh);
+   e_scrollframe_child_viewport_size_get(wd->o_scrollframe, &vw, &vh);
+   if (vw > mw) mw = vw;
+   if (vh > mh) mh = vh;
+   evas_object_resize(wd->o_textblock, mw, mh);
+}
+   
+static void
+_e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   e_widget_focus_steal(data);
+}
diff --git a/src/bin/e_widget_textblock.h b/src/bin/e_widget_textblock.h
new file mode 100644 (file)
index 0000000..9a0eedd
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+#ifdef E_TYPEDEFS
+#else
+#ifndef E_WIDGET_TEXTBLOCK_H
+#define E_WIDGET_TEXTBLOCK_H
+
+EAPI Evas_Object *e_widget_textblock_add(Evas *evas);
+EAPI void e_widget_textblock_markup_set(Evas_Object *obj, const char *text);
+EAPI void e_widget_textblock_plain_set(Evas_Object *obj, const char *text);
+    
+#endif
+#endif