changeset 442:76b61d447225

merge upstream
author john.cylee@gmail.com
date Thu, 30 Jul 2009 17:14:18 +0800
parents 94477e7d981e (current diff) 254854ed479c (diff)
children 1f900a67bd38
files
diffstat 2 files changed, 37 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/event.c	Thu Jul 30 12:21:34 2009 +0800
+++ b/src/event.c	Thu Jul 30 17:14:18 2009 +0800
@@ -9,6 +9,7 @@
 #include "mb_redraw_man.h"
 #include "mb_shapes.h"
 #endif
+#include "../config.h"
 
 #define OK 0
 #define ERR -1
@@ -156,7 +157,8 @@
        MBO_PATH,
        MBO_TEXT,
        MBO_RECT,
-       MBO_IMAGE
+       MBO_IMAGE,
+       MBO_STEXT
 };
 #define MBO_TYPE(x) (((mb_obj_t *)(x))->obj_type)
 #define IS_MBO_SHAPES(x) (((mb_obj_t *)(x))->obj_type & MBO_SHAPES)
@@ -527,23 +529,39 @@
     return OK;
 }
 
+/*! \brief Draw path of a shape.
+ *
+ * \note This function should be merged with what is in redraw_man.c.
+ */
 static void draw_shape_path(shape_t *shape, cairo_t *cr) {
     switch(MBO_TYPE(shape)) {
     case MBO_PATH:
 	sh_path_draw(shape, cr);
 	break;
+#ifdef SH_TEXT
     case MBO_TEXT:
 	sh_text_draw(shape, cr);
 	break;
+#endif
     case MBO_RECT:
 	sh_rect_draw(shape, cr);
 	break;
     case MBO_IMAGE:
 	sh_image_draw(shape, cr);
 	break;
+#ifdef SH_STEXT
+    case MBO_STEXT:
+	sh_stext_draw(shape, cr);
+	break;
+#endif
     }
 }
 
+/*! \brief Implement exactly point testing with Cairo.
+ *
+ * \note This function should not be called directly. Call
+ *  _shape_pos_is_in() insteaded.
+ */
 static int _shape_pos_is_in_cairo(shape_t *shape, co_aix x, co_aix y,
 				  int *in_stroke, cairo_t *cr) {
     draw_shape_path(shape, cr);
@@ -562,6 +580,8 @@
     return FALSE;
 }
 
+/*! \brief Find all shapes whose bounding box include a specified position.
+ */
 static
 int _shape_pos_is_in(shape_t *shape, co_aix x, co_aix y,
 		     int *in_stroke, cairo_t *cr) {
@@ -579,6 +599,8 @@
     return TRUE;
 }
 
+/*! \brief Find first shape that is draw at a specified position.
+ */
 static shape_t *_find_shape_in_pos(redraw_man_t *rdman,
 				   co_aix x, co_aix y, int *in_stroke) {
     shape_t *shape;
@@ -590,7 +612,7 @@
 	shape = rdman_get_shape_gl(rdman, i);
 	if(sh_get_flags(shape, GEF_HIDDEN))
 	    continue;
-	r = _shape_pos_is_in_cairo(shape, x, y, in_stroke, cr);
+	r = _shape_pos_is_in(shape, x, y, in_stroke, cr);
 	if(r)
 	    return shape;
     }
--- a/src/shape_stext.c	Thu Jul 30 12:21:34 2009 +0800
+++ b/src/shape_stext.c	Thu Jul 30 17:14:18 2009 +0800
@@ -314,7 +314,7 @@
     cairo_set_scaled_font(cr, (cairo_scaled_font_t *)scaled);
     
     cairo_move_to(cr, x, y);
-    cairo_show_text(cr, buf);
+    cairo_text_path(cr, buf);
     
     cairo_set_scaled_font(cr, saved_scaled);
     cairo_scaled_font_destroy(saved_scaled);
@@ -478,7 +478,7 @@
  */
 static
 void extent_extents(mb_text_extents_t *full, mb_text_extents_t *sub) {
-    co_aix f_rbx, f_rby;	/* rb stands for right button */
+    co_aix f_rbx, f_rby;	/* rb stands for right bottom */
     co_aix s_rbx, s_rby;
     co_aix s_xbr, s_ybr;
     co_aix new_x_adv, new_y_adv;
@@ -541,8 +541,6 @@
     char *txt, saved;
     int i, nscaled;
     
-    memset(&txt_o->extents, sizeof(mb_text_extents_t), 0);
-    
     scaled_fonts = &txt_o->scaled_fonts;
     for(i = 0; i < scaled_fonts->num; i++)
 	scaled_font_free(scaled_fonts->ds[i]);
@@ -571,11 +569,19 @@
 	compute_text_extents(scaled, txt, sub);
 	txt[blk_txt_len] = saved;
 
-	extent_extents(&txt_o->extents, sub);
-
 	blk++;
 	txt += blk_txt_len;
-    }    
+    }
+    
+    if(style_blks->num > 0) {
+	sub = sub_exts->ds;
+	memcpy(&txt_o->extents, sub, sizeof(mb_text_extents_t));
+	for(i = 1; i < style_blks->num; i++) {
+	    sub = sub_exts->ds + i;
+	    extent_extents(&txt_o->extents, sub);
+	}
+    } else
+	memset(&txt_o->extents, sizeof(mb_text_extents_t), 0);    
 }
 
 /*