Mercurial > MadButterfly
comparison src/shape_text.c @ 73:9ab15ebc9061
Observer for mouse events
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 18 Aug 2008 01:59:26 +0800 |
parents | 1ca417f741f1 |
children | dd813dcc232c |
comparison
equal
deleted
inserted
replaced
72:171a8cb7e4b5 | 73:9ab15ebc9061 |
---|---|
21 int flags; | 21 int flags; |
22 } sh_text_t; | 22 } sh_text_t; |
23 | 23 |
24 #define TXF_SCALE_DIRTY 0x1 | 24 #define TXF_SCALE_DIRTY 0x1 |
25 | 25 |
26 static void sh_text_free(shape_t *shape) { | |
27 sh_text_t *text = (sh_text_t *)shape; | |
28 | |
29 if(text->scaled_font) | |
30 cairo_scaled_font_destroy(text->scaled_font); | |
31 cairo_font_face_destroy(text->face); | |
32 } | |
33 | |
26 shape_t *sh_text_new(const char *txt, co_aix x, co_aix y, | 34 shape_t *sh_text_new(const char *txt, co_aix x, co_aix y, |
27 co_aix font_size, cairo_font_face_t *face) { | 35 co_aix font_size, cairo_font_face_t *face) { |
28 sh_text_t *text; | 36 sh_text_t *text; |
29 | 37 |
30 text = (sh_text_t *)malloc(sizeof(sh_text_t)); | 38 text = (sh_text_t *)malloc(sizeof(sh_text_t)); |
43 text->font_size = font_size; | 51 text->font_size = font_size; |
44 cairo_font_face_reference(face); | 52 cairo_font_face_reference(face); |
45 text->face = face; | 53 text->face = face; |
46 text->flags |= TXF_SCALE_DIRTY; | 54 text->flags |= TXF_SCALE_DIRTY; |
47 | 55 |
56 text->shape.free = sh_text_free; | |
57 | |
48 return (shape_t *)text; | 58 return (shape_t *)text; |
49 } | |
50 | |
51 void sh_text_free(shape_t *shape) { | |
52 sh_text_t *text = (sh_text_t *)shape; | |
53 | |
54 if(text->scaled_font) | |
55 cairo_scaled_font_destroy(text->scaled_font); | |
56 cairo_font_face_destroy(text->face); | |
57 } | 59 } |
58 | 60 |
59 static int get_extents(sh_text_t *text, cairo_text_extents_t *extents) { | 61 static int get_extents(sh_text_t *text, cairo_text_extents_t *extents) { |
60 cairo_matrix_t fmatrix; | 62 cairo_matrix_t fmatrix; |
61 cairo_matrix_t ctm; | 63 cairo_matrix_t ctm; |