diff examples/svg2code_ex/main.c @ 108:565b55508c8d

More dox
author Thinker K.F. Li <thinker@branda.to>
date Fri, 12 Sep 2008 13:58:30 +0800
parents 42698de1f653
children c14cb6d12030
line wrap: on
line diff
--- a/examples/svg2code_ex/main.c	Fri Sep 12 12:55:13 2008 +0800
+++ b/examples/svg2code_ex/main.c	Fri Sep 12 13:58:30 2008 +0800
@@ -1,6 +1,5 @@
 #include <stdio.h>
-#include <mb_types.h>
-#include <X_supp.h>
+#include <mb/mb.h>
 #include "svg2code_ex.h"
 
 typedef struct _ex_rt ex_rt_t;
@@ -15,7 +14,9 @@
     switch(evt->type) {
     case EVT_MOUSE_BUT_PRESS:
 	coord_show(ex_rt->code->file_menu);
+	/* Tell redraw manager that a coord (group) is chagned. */
 	rdman_coord_changed(ex_rt->rt->rdman, ex_rt->code->file_menu);
+	/* Update changed part to UI. */
 	rdman_redraw_changed(ex_rt->rt->rdman);
 	break;
     }
@@ -27,7 +28,9 @@
     switch(evt->type) {
     case EVT_MOUSE_BUT_PRESS:
 	coord_hide(ex_rt->code->file_menu);
+	/* Tell redraw manager that a coord (group) is chagned. */
 	rdman_coord_changed(ex_rt->rt->rdman, ex_rt->code->file_menu);
+	/* Update changed part to UI. */
 	rdman_redraw_changed(ex_rt->rt->rdman);
 	break;
     }
@@ -41,11 +44,23 @@
     ex_rt_t ex_rt;
     int r;
 
+    /*
+     * Initialize a runtime with XLib as backend.
+     */
     r = X_MB_init(":0.0", 800, 600, &rt);
 
+    /*
+     * Instantiate objects from a SVG file.
+     */
     svg2code = svg2code_ex_new(rt.rdman);
 
+    /*
+     * Get observer factory
+     */
     factory = rdman_get_ob_factory(rt.rdman);
+    /*
+     * Register observers to subjects of events for objects.
+     */
     subject = coord_get_mouse_event(svg2code->file_button);
     ex_rt.rt = &rt;
     ex_rt.code = svg2code;
@@ -53,8 +68,15 @@
     subject = coord_get_mouse_event(svg2code->file_menu);
     subject_add_observer(factory, subject, file_menu_handler, &ex_rt);
 
+    /*
+     * Start handle connections, includes one to X server.
+     * User start to interact with the application.
+     */
     X_MB_handle_connection(&rt);
 
+    /*
+     * Clean
+     */
     svg2code_ex_free(svg2code);
     X_MB_destroy(&rt);