From c6a2715902a92e799942396b34e7785a8f53c371 Mon Sep 17 00:00:00 2001 From: "bernard.xiong" Date: Mon, 29 Nov 2010 09:19:46 +0000 Subject: [PATCH] fix compile error in Preprocessor setting. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1136 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/rtgui/common/font_bmp.c | 24 +++++++++++++++++++++++- examples/gui/demo_fnview.c | 2 +- examples/gui/demo_view_image.c | 2 +- examples/gui/demo_view_module.c | 3 +++ examples/gui/demo_workbench.c | 6 ++++-- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/components/rtgui/common/font_bmp.c b/components/rtgui/common/font_bmp.c index 9887c6ad5d..36192c6244 100644 --- a/components/rtgui/common/font_bmp.c +++ b/components/rtgui/common/font_bmp.c @@ -71,8 +71,9 @@ void rtgui_bitmap_font_draw_char(struct rtgui_font_bitmap* font, struct rtgui_dc static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect) { rt_uint32_t length; - struct rtgui_font* hz_font; struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data); +#ifdef RTGUI_USING_FONTHZ + struct rtgui_font* hz_font; RT_ASSERT(bmp_font != RT_NULL); @@ -109,6 +110,27 @@ static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc } rtgui_font_derefer(hz_font); +#else + while ((rect->x1 < rect->x2) && len) + { + while (((rt_uint8_t)*(text + length) < 0x80) && *(text + length)) length ++; + if (length > 0) + { + len -= length; + while (length-- && rect->x1 < rect->x2) + { + rtgui_bitmap_font_draw_char(bmp_font, dc, *text, rect); + + /* move x to next character */ + if (bmp_font->char_width == RT_NULL) + rect->x1 += bmp_font->width; + else + rect->x1 += bmp_font->char_width[*text - bmp_font->first_char]; + text ++; + } + } + } +#endif } static void rtgui_bitmap_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect) diff --git a/examples/gui/demo_fnview.c b/examples/gui/demo_fnview.c index cac944f8a4..d20fc99ee4 100644 --- a/examples/gui/demo_fnview.c +++ b/examples/gui/demo_fnview.c @@ -9,7 +9,7 @@ #include #include -#ifdef RT_USING_DFS +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) /* 用于显示选择文件名的文本标签 */ static rtgui_label_t* label; /* 触发文件列表视图的按钮回调函数 */ diff --git a/examples/gui/demo_view_image.c b/examples/gui/demo_view_image.c index 55310ce02d..b7cc9ab624 100644 --- a/examples/gui/demo_view_image.c +++ b/examples/gui/demo_view_image.c @@ -12,7 +12,7 @@ static rtgui_image_t* image = RT_NULL; static rtgui_view_t* _view = RT_NULL; -#ifdef RT_USING_DFS +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) /* 打开按钮的回调函数 */ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event) { diff --git a/examples/gui/demo_view_module.c b/examples/gui/demo_view_module.c index 56544bdc25..c1ce83b6f3 100644 --- a/examples/gui/demo_view_module.c +++ b/examples/gui/demo_view_module.c @@ -10,6 +10,7 @@ #include #ifdef RT_USING_MODULE +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) static rtgui_view_t* _view = RT_NULL; /* 打开按钮的回调函数 */ @@ -72,3 +73,5 @@ rtgui_view_t* demo_view_module(rtgui_workbench_t* workbench) return _view; } #endif +#endif + diff --git a/examples/gui/demo_workbench.c b/examples/gui/demo_workbench.c index f0718481a9..35333264b9 100644 --- a/examples/gui/demo_workbench.c +++ b/examples/gui/demo_workbench.c @@ -81,15 +81,17 @@ static void workbench_entry(void* parameter) demo_view_listbox(workbench); demo_view_slider(workbench); demo_view_mywidget(workbench); -#ifdef RT_USING_DFS +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) demo_view_image(workbench); #endif #ifdef RT_USING_MODULE +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) demo_view_module(workbench); +#endif #endif demo_listview_view(workbench); demo_listview_icon_view(workbench); -#ifdef RT_USING_DFS +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) demo_fn_view(workbench); #endif