Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/bin/tests/widget Modified Files: ewl_widget_test.c Log Message: - Pull the tutorials out of the src/bin/tests/*/*.c files and move them to doc/tutorials. This way we don't end up with any test structures showing up in the Ewl docs. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/widget/ewl_widget_test.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_widget_test.c 12 Jan 2008 21:55:20 -0000 1.6 +++ ewl_widget_test.c 26 Feb 2008 04:24:12 -0000 1.7 @@ -7,104 +7,6 @@ #include <string.h> #include <stdlib.h> -/** - * @addtogroup Ewl_Widget - * @section widget_tut Tutorial - * - * Small as small can be - * (originally at http://everburning.com/news/small-as-small-can-be) - * - * Whats the minimum amount of work you need to do to create your own EWL - * widget? Just want something you can build on but dont know where to start? - * - * Well, hopefully this should give you the base for starting your widget. - * Assuming you're creating a widget called My_Widget, the EWL convention is to - * have a my_widget.c and my_widget.h files. There are only a couple things you - * need to implement to get a working widget. - * - * First, my_widget.h. - * - * @code - * #ifndef MY_WIDGET_H - * #define MY_WIDGET_H - * - * #include <Ewl.h> - * - * #define MY_WIDGET(w) ((My_Widget *)w) - * #define MY_WIDGET_TYPE "my_widget" - * - * typedef struct My_Widget My_Widget; - * struct My_Widget - * { - * Ewl_Widget widget; - * }; - * - * Ewl_Widget *my_widget_new(void); - * int my_widget_init(My_Widget *w); - * - * #endif - * @endcode - * - * That wasn't so bad. What have we got? Well, the MY_WIDGET(w) define gives us - * a simple macro to cast other widgets to our widget. The second define, - * MY_WIDGET_TYPE, is a simple macro containing the type name of the widget. - * Well use that a bit later (and in any type checking we add to our widget.) - * - * We then create the widget structure. In this case were inheriting from - * Ewl_Widget so its the first item in our struct (and not a pointer, thats - * important). This is how EWLs inhertiance works. The widget you're inheriting - * from is the first item in the struct and not a pointer. You will now be able - * to call any of the methods of the inherited class on the new class. - * - * We then declare two methods. The convention in EWL is that the _new() - * function always takes no parameters (void). There is also always a _init() - * function that takes the widget as its only parameter and returns an int, if - * the initialization succeeded or failed. - * - * With that out of the way, lets take a look at my_widget.c. - * - * @code - * #include "my_widget.h" - * - * Ewl_Widget * - * my_widget_new(void) - * { - * Ewl_Widget *w; - * - * w = calloc(1, sizeof(My_Widget))); - * if (!w) return NULL; - * - * if (!my_widget_init(MY_WIDGET(w))) - * { - * free(w); - * return NULL; - * } - * return w; - * } - * - * int - * my_widget_init(My_Widget *w) - * { - * if (!ewl_widget_init(EWL_WIDGET(w))) - * return 0; - * - * ewl_widget_appearance_set(EWL_WIDGET(w), MY_WIDGET_TYPE); - * ewl_widget_inherit(EWL_WIDGET(w), MY_WIDGET_TYPE); - * - * return 1; - * } - * @endcode - * - * Thats pretty simple. We create a new widget, initialize it and thats about - * it. In my_widget_init() we make sure we call ewl_widget_init() as thats the - * widget we are inheriting from and we then set our inheritance and appearance - * strings (notice the use of our type define from earlier). - * - * With that you've got a simple widget. It doesn't do much, but it exists. - * Build on as you will. - * - */ - static int create_test(Ewl_Container *box); static void ewl_widget_cb_toggle(Ewl_Widget *w, void *ev, void *data); static void ewl_widget_cb_first_click(Ewl_Widget *w, void *ev, void *data); ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs