Enlightenment CVS committal
Author : dj2
Project : e17
Module : docs
Dir : e17/docs/ewlbook/xml
Modified Files:
appendix-ewl_media_example.xml object_hierarchy.xml
widgets.xml
Log Message:
- add some more images
- fill in password widget
- add ewl_media_test code to the appendix
===================================================================
RCS file: /cvsroot/enlightenment/e17/docs/ewlbook/xml/appendix-ewl_media_example.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- appendix-ewl_media_example.xml 16 Jul 2004 04:11:17 -0000 1.1
+++ appendix-ewl_media_example.xml 23 Jul 2004 03:51:53 -0000 1.2
@@ -1,6 +1,214 @@
<appendix id="apx-ewl_media_player_example">
<title>EWL Media Player Example</title>
<para>
+<example>
+<title>Ewl Media Player</title>
+<programlisting role="C">
+#include <Ewl.h>
+
+static Ewl_Widget *video;
+static Ewl_Widget *fd_win;
+static Ewl_Widget *seeker;
+
+typedef struct {
+ char *name;
+ Ewl_Callback_Function func;
+} Control;
+
+void del_cb(Ewl_Widget *w, void *event, void *data) {
+ ewl_widget_hide(w);
+ ewl_widget_destroy(w);
+ ewl_main_quit();
+}
+
+void play_cb(Ewl_Widget *w, void *event, void *data ) {
+ ewl_media_play_set(EWL_MEDIA(video), 1);
+}
+
+void stop_cb(Ewl_Widget *w, void *event, void *data ) {
+ ewl_media_play_set(EWL_MEDIA(video), 0);
+}
+
+void ff_cb(Ewl_Widget *w, void *event, void *data ) {
+ double p = ewl_media_position_get(EWL_MEDIA(video));
+ ewl_media_position_set(EWL_MEDIA(video), p + 10.0);
+}
+
+void rew_cb(Ewl_Widget *w, void *event, void *data ) {
+ double p = ewl_media_position_get(EWL_MEDIA(video));
+ ewl_media_position_set(EWL_MEDIA(video), p - 10.0);
+}
+
+void video_realize_cb(Ewl_Widget *w, void *event, void *data) {
+ double len = ewl_media_length_get(EWL_MEDIA(video));
+ ewl_seeker_set_range(EWL_SEEKER(seeker), len);
+}
+
+void video_change_cb(Ewl_Widget *w, void *event, void *data) {
+ char buf[512];
+ int h, m;
+ double s;
+ Ewl_Text *t = (Ewl_Text *)data;
+ double pos = ewl_media_position_get(EWL_MEDIA(video));
+
+ ewl_seeker_set_value(EWL_SEEKER(seeker), pos);
+ ewl_media_position_time_get(EWL_MEDIA(video), &h, &m, &s);
+ snprintf(buf, sizeof(buf), "%02i:%02i:%02.0f", h, m, s);
+ ewl_text_text_set(t, buf);
+}
+
+void seeker_move_cb(Ewl_Widget *w, void *event, void *data) {
+ double val = ewl_seeker_get_value(EWL_SEEKER(seeker));
+ ewl_media_position_set(EWL_MEDIA(video), val);
+}
+
+void fd_win_del_cb(Ewl_Widget *w, void *event, void *data) {
+ ewl_widget_hide(w);
+ ewl_widget_destroy(w);
+}
+
+void open_file_cb(Ewl_Widget *w, void *event, void *data) {
+ char *file = NULL;
+
+ ewl_widget_hide(fd_win);
+ file = (char *)event;
+ if (file)
+ ewl_media_media_set(EWL_MEDIA(video), file);
+}
+
+void open_cb(Ewl_Widget *w, void *event, void *data ) {
+ Ewl_Widget *fd = NULL;
+
+ if (fd_win) {
+ ewl_widget_show(fd_win);
+ return;
+ }
+
+ fd_win = ewl_window_new();
+ ewl_window_set_title(EWL_WINDOW(fd_win), "EWL Media Open");
+ ewl_window_set_class(EWL_WINDOW(fd_win), "EWL_Media_Open");
+ ewl_window_set_name(EWL_WINDOW(fd_win), "EWL_Media_Open");
+ ewl_callback_append(fd_win, EWL_CALLBACK_DELETE_WINDOW,
+ fd_win_del_cb, NULL);
+ ewl_widget_show(fd_win);
+
+ fd = ewl_filedialog_new(EWL_FILEDIALOG_TYPE_OPEN);
+ ewl_container_append_child(EWL_CONTAINER(fd_win), fd);
+ ewl_callback_append(fd, EWL_CALLBACK_VALUE_CHANGED, open_file_cb, NULL);
+ ewl_widget_show(fd);
+}
+
+void key_up_cb(Ewl_Widget *w, void *event, void *data) {
+ Ewl_Event_Key_Up *e = (Ewl_Event_Key_Up *)event;
+
+ if (!strcmp(e->keyname, "p"))
+ ewl_media_play_set(EWL_MEDIA(video), 1);
+
+ else if (!strcmp(e->keyname, "s"))
+ ewl_media_play_set(EWL_MEDIA(video), 0);
+
+ else if (!strcmp(e->keyname, "q"))
+ del_cb(w, event, data);
+}
+
+int main(int argc, char ** argv) {
+ Ewl_Widget *win = NULL, *o = NULL, *b = NULL;
+ Ewl_Widget *controls = NULL, *time = NULL;
+ char * file = NULL;
+
+ if (!ewl_init(&argc, argv)) {
+ printf("Can't init ewl");
+ return 1;
+ }
+
+ if (argc > 1)
+ file = argv[1];
+
+ win = ewl_window_new();
+ ewl_window_set_title(EWL_WINDOW(win), "EWL Media test");
+ ewl_window_set_name(EWL_WINDOW(win), "EWL_Media_test");
+ ewl_window_set_class(EWL_WINDOW(win), "EWL_Media_test");
+ ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, del_cb, NULL);
+ ewl_callback_append(win, EWL_CALLBACK_KEY_UP, key_up_cb, NULL);
+ ewl_object_request_size(EWL_OBJECT(win), 320, 280);
+ ewl_object_set_fill_policy(EWL_OBJECT(win), EWL_FLAG_FILL_ALL);
+ ewl_widget_show(win);
+
+ /* box to contain everything */
+ b = ewl_vbox_new();
+ ewl_container_append_child(EWL_CONTAINER(win), b);
+ ewl_object_set_fill_policy(EWL_OBJECT(b), EWL_FLAG_FILL_ALL);
+ ewl_widget_show(b);
+
+ /* create the time widget now so we can pass it to the video as data */
+ time = ewl_text_new("00:00:00");
+
+ /* the video */
+ video = ewl_media_new(file);
+ ewl_container_append_child(EWL_CONTAINER(b), video);
+ ewl_object_set_fill_policy(EWL_OBJECT(video), EWL_FLAG_FILL_ALL);
+ ewl_callback_append(video, EWL_CALLBACK_REALIZE, video_realize_cb, NULL);
+ ewl_callback_append(video, EWL_CALLBACK_VALUE_CHANGED, video_change_cb, time);
+ ewl_widget_show(video);
+
+ /* box to contain contols and scrollers */
+ controls = ewl_vbox_new();
+ ewl_object_set_fill_policy(EWL_OBJECT(controls),
+ EWL_FLAG_FILL_VSHRINK | EWL_FLAG_FILL_HFILL);
+ ewl_container_append_child(EWL_CONTAINER(b), controls);
+ ewl_widget_show(controls);
+
+ /* hold he controls */
+ b = ewl_hbox_new();
+ ewl_container_append_child(EWL_CONTAINER(controls), b);
+ ewl_widget_show(b);
+
+ {
+ Control controls [] = {
+ { "play", play_cb },
+ { "stop", stop_cb },
+ { "rewind", rew_cb },
+ { "fast forward", ff_cb },
+ { "open", open_cb },
+ { NULL, NULL }
+ };
+ int i;
+
+ for(i = 0; controls[i].name != NULL; i++) {
+ o = ewl_button_with_stock_new(controls[i].name);
+ ewl_container_append_child(EWL_CONTAINER(b), o);
+ ewl_callback_append(o, EWL_CALLBACK_CLICKED,
+ controls[i].func, NULL);
+ ewl_widget_show(o);
+ }
+ }
+
+ b = ewl_hbox_new();
+ ewl_container_append_child(EWL_CONTAINER(controls), b);
+ ewl_widget_show(b);
+
+ /* the video seeker */
+ seeker = ewl_seeker_new(EWL_ORIENTATION_HORIZONTAL);
+ ewl_container_append_child(EWL_CONTAINER(b), seeker);
+ ewl_object_set_fill_policy(EWL_OBJECT(seeker),
+ EWL_FLAG_FILL_VSHRINK | EWL_FLAG_FILL_HFILL);
+ ewl_seeker_set_value(EWL_SEEKER(seeker), 0.0);
+ ewl_seeker_set_range(EWL_SEEKER(seeker), 0.0);
+ ewl_seeker_set_step(EWL_SEEKER(seeker), 1.0);
+ ewl_callback_append(seeker, EWL_CALLBACK_VALUE_CHANGED, seeker_move_cb, NULL);
+ ewl_widget_show(seeker);
+
+ /* the time text spot */
+ ewl_container_append_child(EWL_CONTAINER(b), time);
+ ewl_object_set_insets(EWL_OBJECT(time), 0, 3, 0, 0);
+ ewl_object_set_fill_policy(EWL_OBJECT(time), EWL_FLAG_FILL_SHRINK);
+ ewl_widget_show(time);
+
+ ewl_main();
+ return 0;
+}
+</programlisting>
+</example>
</para>
</appendix>
===================================================================
RCS file: /cvsroot/enlightenment/e17/docs/ewlbook/xml/object_hierarchy.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- object_hierarchy.xml 16 Jul 2004 04:11:17 -0000 1.2
+++ object_hierarchy.xml 23 Jul 2004 03:51:53 -0000 1.3
@@ -1,6 +1,8 @@
<chapter id="ch-OjbectHierarchy">
<title>Object Hierarchy</title>
+<sect1 id="sec-ObjHierIntro">
+<title>Introduction</title>
<para>
The EWL widgets are setup in a hierarcy. The base widget that everything
extends from is the <literal>Ewl_Object</literal>. The
@@ -45,7 +47,25 @@
widgets that are to hold other widgets. This includes anything from the main
window, to boxes, to scrollpanes.
</para>
+</sect1>
+<sect1 id="sec-ObjHierCasting">
+<title>Object Casting</title>
+<para>
+As you progress into EWL you will notice that there is a lot of casting
+between different types. To make this easier, each cast to a particular type
+has a EWL_TYPE() macro defined. So for example there is are EWL_OBJECT(o) and
+EWL_WIDGET(o) defined to make life easier.
+</para>
+
+<para>
+These macros should always be used when converting between EWL widgets so
+that you know that the right thing is being done.
+</para>
+</sect1>
+
+<sect1 id="sec-ObjHierNewWidget">
+<title>Adding new widgets</title>
<para>
To add new widgets into EWL you just need to create a new struct that has
the appropriate type of subclass as the first element. This subclass object
@@ -66,6 +86,7 @@
<literal>Ewl_Container</literal> so you would be able to pack other widgets
into this new widget type.
</para>
+</sect1>
</chapter>
===================================================================
RCS file: /cvsroot/enlightenment/e17/docs/ewlbook/xml/widgets.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- widgets.xml 18 Jul 2004 20:45:02 -0000 1.6
+++ widgets.xml 23 Jul 2004 03:51:53 -0000 1.7
@@ -123,6 +123,27 @@
</sect1>
<!-- ################################### -->
+<!-- EWL CHECKBUTTON -->
+<sect1 id="sec-EwlCheckButton">
+<title>ewl_checkbutton</title>
+<para>
+ <figure>
+ <title>An Ewl Checkbutton</title>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="img/checkbutton.png" format="png" />
+ </imageobject>
+ <textobject>
+ <phrase>Example of an EWL checkbutton</phrase>
+ </textobject>
+ </inlinemediaobject>
+ </figure>
+</para>
+<para>
+</para>
+</sect1>
+
+<!-- ################################### -->
<!-- EWL COMBO -->
<sect1 id="sec-EwlCombo">
<title>ewl_combo</title>
@@ -401,7 +422,8 @@
<title>Creating an EWL filedialog</title>
<programlisting role="C">
Ewl_Widget *filedialog = ewl_filedialog_new(EWL_FILEDIALOG_TYPE_OPEN);
- ewl_callback_append(filedialog, EWL_CALLBACK_VALUE_CHANGED, open_file_cb, NULL);
+ ewl_callback_append(filedialog, EWL_CALLBACK_VALUE_CHANGED,
+ open_file_cb, NULL);
ewl_widget_show(filedialog);
</programlisting>
</example>
@@ -484,6 +506,13 @@
<sect1 id="sec-EwlPassword">
<title>ewl_password</title>
<para>
+The <literal>ewl_password</literal> widget provides similar functionality to
+the <literal>ewl_text</literal> widget, except that any text entered will
+not be displayed, instead a configurable obscuring character will be
+displayed.
+</para>
+
+<para>
<figure>
<title>An EWL password dialog</title>
<inlinemediaobject>
@@ -496,7 +525,41 @@
</inlinemediaobject>
</figure>
</para>
+
+<para>
+<example>
+<title>Creating an EWL password</title>
+<programlisting role="C">
+ Ewl_Widget *p = ewl_password_new("default");
+ ewl_password_set_obscure(EWL_PASSWORD(p), "-");
+ ewl_callback_append(p, EWL_CALLBACK_VALUE_CHANGED, passwd_cb, NULL);
+ ewl_widget_show(p);
+</programlisting>
+</example>
+The default obscuring character used is a '*' character. This can be easily
+changed by calling
+<function>ewl_password_set_obscure(Ewl_Password *, char)</function>.
+There is also a corresponding
+<function>char ewl_password_get_obscure(Ewl_Password *)</function> to
+retrieve the current obscuring character. As with the
+<literal>ewl_text</literal> widget there are two functions to get and set
+the text of the widget:
+<function>ewl_password_set_text(Ewl_Password *, char *)</function> and
+<function>char *ewl_password_get_text(Ewl_Password *)</function>.
+</para>
+
<para>
+When the user presses the enter key in the password box a
+<literal>EWL_CALLBACK_VALUE_CHANGED</literal> will be triggered.
+<example>
+<title>Ewl_Password value changed callback</title>
+<programlisting role="C">
+void passwd_cb(Ewl_Widget *, void *event, void *data) {
+ char *text = ewl_password_get_text(EWL_PASSWORD(w));
+ printf("text: %s\n", text);
+}
+</programlisting>
+</example>
</para>
</sect1>
@@ -526,6 +589,19 @@
<sect1 id="sec-Ewl-RadioButton">
<title>ewl_radiobutton</title>
<para>
+ <figure>
+ <title>An EWL radiobutton</title>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="img/radiobutton.png" format="png" />
+ </imageobject>
+ <textobject>
+ <phrase>Example of an EWL radiobutton</phrase>
+ </textobject>
+ </inlinemediaobject>
+ </figure>
+</para>
+<para>
</para>
</sect1>
@@ -542,7 +618,44 @@
<sect1 id="sec-EwlSeeker">
<title>ewl_seeker</title>
<para>
+ <figure>
+ <title>An EWL seeker</title>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="img/seeker.png" format="png" />
+ </imageobject>
+ <textobject>
+ <phrase>Example of an EWL seeker</phrase>
+ </textobject>
+ </inlinemediaobject>
+ </figure>
+</para>
+<para>
+<example>
+<title>Creating an EWL seeker</title>
+<programlisting role="C">
+ Ewl_Widget *s = ewl_seeker_new(EWL_ORIENTATION_HORIZONTAL);
+ ewl_seeker_set_value(EWL_SEEKER(s), 5.0);
+ ewl_seeker_set_range(EWL_SEEKER(s), 10.0);
+ ewl_seeker_set_step(EWL_SEEKER(s), 1);
+ ewl_callback_append(s, EWL_CALLBACK_VALUE_CHANGED, seeker_cb, NULL);
+ ewl_widget_show(s);
+</programlisting>
+</example>
+</para>
+
+<para>
+<example>
+<title>Ewl_Seeker callback</title>
+<programlisting role="C">
+void seeker_cb(Ewl_Widget *w, void *event, void *data) {
+ double val = ewl_seeker_get_value(EWL_SEEKER(w));
+ printf("%f\n", val);
+}
+</programlisting>
+</example>
</para>
+
</sect1>
<!-- ################################### -->
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs