diff options
| author | bernard.xiong <[email protected]> | 2011-01-20 09:59:45 +0000 |
|---|---|---|
| committer | bernard.xiong <[email protected]> | 2011-01-20 09:59:45 +0000 |
| commit | 66037b4de6baded89f0bb072cd9f33c103f45dd1 (patch) | |
| tree | c902df0ec8cdeb03d7af281d882f44260f399644 /components/rtgui/common | |
| parent | 17b7ae81e247f3b7c82dc6fbcb294583eeee3cfd (diff) | |
add textstyle in gc; fix hz_cache memory leak issue; fix selection issue in radiobox.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1250 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/rtgui/common')
| -rw-r--r-- | components/rtgui/common/font_bmp.c | 11 | ||||
| -rw-r--r-- | components/rtgui/common/font_hz_bmp.c | 12 | ||||
| -rw-r--r-- | components/rtgui/common/font_hz_file.c | 40 |
3 files changed, 55 insertions, 8 deletions
diff --git a/components/rtgui/common/font_bmp.c b/components/rtgui/common/font_bmp.c index 1e6bbeba01..96b4609b9a 100644 --- a/components/rtgui/common/font_bmp.c +++ b/components/rtgui/common/font_bmp.c @@ -29,13 +29,18 @@ const struct rtgui_font_engine bmp_font_engine = void rtgui_bitmap_font_draw_char(struct rtgui_font_bitmap* font, struct rtgui_dc* dc, const char ch, rtgui_rect_t* rect) { + rtgui_color_t bc; const rt_uint8_t* font_ptr; - rt_uint16_t x, y, h; + rt_uint16_t x, y, h, style; register rt_base_t i, j, k, word_bytes; /* check first and last char */ if (ch < font->first_char || ch > font->last_char) return; + /* get text style */ + style = rtgui_dc_get_gc(dc)->textstyle; + bc = rtgui_dc_get_gc(dc)->background; + x = rect->x1; y = rect->y1; /* get width */ @@ -63,6 +68,10 @@ void rtgui_bitmap_font_draw_char(struct rtgui_font_bitmap* font, struct rtgui_dc /* draw a pixel */ rtgui_dc_draw_point(dc, k + 8 * j + x, i + y); } + else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND) + { + rtgui_dc_draw_color_point(dc, k + 8 * j + x, i + y, bc); + } } } } diff --git a/components/rtgui/common/font_hz_bmp.c b/components/rtgui/common/font_hz_bmp.c index 7c0d125de7..c35f70bfc9 100644 --- a/components/rtgui/common/font_hz_bmp.c +++ b/components/rtgui/common/font_hz_bmp.c @@ -16,11 +16,17 @@ const struct rtgui_font_engine hz_bmp_font_engine = static void _rtgui_hz_bitmap_font_draw_text(struct rtgui_font_bitmap* bmp_font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect) { - register rt_base_t h, word_bytes; rt_uint8_t* str; + rtgui_color_t bc; + rt_uint16_t style; + register rt_base_t h, word_bytes; RT_ASSERT(bmp_font != RT_NULL); + /* get text style */ + style = rtgui_dc_get_gc(dc)->textstyle; + bc = rtgui_dc_get_gc(dc)->background; + /* drawing height */ h = (bmp_font->height + rect->y1 > rect->y2)? rect->y2 - rect->y1 : bmp_font->height; word_bytes = (bmp_font->width + 7)/8; @@ -51,6 +57,10 @@ static void _rtgui_hz_bitmap_font_draw_text(struct rtgui_font_bitmap* bmp_font, { rtgui_dc_draw_point(dc, rect->x1 + 8*j + k, rect->y1 + i); } + else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND) + { + rtgui_dc_draw_color_point(dc, rect->x1 + 8*j + k, rect->y1 + i, bc); + } } } diff --git a/components/rtgui/common/font_hz_file.c b/components/rtgui/common/font_hz_file.c index dce99e1213..9cfa92fc50 100644 --- a/components/rtgui/common/font_hz_file.c +++ b/components/rtgui/common/font_hz_file.c @@ -41,16 +41,27 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t struct hz_cache *cache, search; search.hz_id = hz_id; - cache = SPLAY_FIND(cache_tree, &(font->cache_root), &search); + + /* enter critical */ + rtgui_enter_critical(); + + cache = SPLAY_FIND(cache_tree, &(font->cache_root), &search); if (cache != RT_NULL) { - /* find it */ + /* exit critical */ + rtgui_exit_critical(); + + /* found it */ return (rt_uint8_t*)(cache + 1); } - /* can not find it, load to cache */ + /* exit critical */ + rtgui_exit_critical(); + + /* can not find it, load to cache */ cache = (struct hz_cache*) rtgui_malloc(sizeof(struct hz_cache) + font->font_data_size); - if (cache == RT_NULL) return RT_NULL; /* no memory yet */ + if (cache == RT_NULL) + return RT_NULL; /* no memory yet */ cache->hz_id = hz_id; seek = 94 * (((hz_id & 0xff) - 0xA0) - 1) + ((hz_id >> 8) - 0xA0) - 1; @@ -65,7 +76,10 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t return RT_NULL; } - /* insert to cache */ + /* enter critical */ + rtgui_enter_critical(); + + /* insert to cache */ SPLAY_INSERT(cache_tree, &(font->cache_root), cache); font->cache_size ++; @@ -78,9 +92,13 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t /* remove the left node */ SPLAY_REMOVE(cache_tree, &(font->cache_root), left); + rtgui_free(left); font->cache_size --; } + /* exit critical */ + rtgui_exit_critical(); + return (rt_uint8_t*)(cache + 1); } @@ -94,8 +112,14 @@ static void rtgui_hz_file_font_load(struct rtgui_font* font) static void _rtgui_hz_file_font_draw_text(struct rtgui_hz_file_font* hz_file_font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect) { - register rt_base_t h, word_bytes; rt_uint8_t* str; + rtgui_color_t bc; + rt_uint16_t style; + register rt_base_t h, word_bytes; + + /* get text style */ + style = rtgui_dc_get_gc(dc)->textstyle; + bc = rtgui_dc_get_gc(dc)->background; /* drawing height */ h = (hz_file_font->font_size + rect->y1 > rect->y2)? @@ -123,6 +147,10 @@ static void _rtgui_hz_file_font_draw_text(struct rtgui_hz_file_font* hz_file_fon { rtgui_dc_draw_point(dc, rect->x1 + 8*j + k, rect->y1 + i); } + else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND) + { + rtgui_dc_draw_color_point(dc, rect->x1 + 8*j + k, rect->y1 + i, bc); + } } } |
