2012-04-18 23:06:12 +08:00
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>嵥<EFBFBD><EFBFBD>TTF<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ʾ
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>container<EFBFBD>Ͻ<EFBFBD><EFBFBD><EFBFBD>TTF<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "demo_view.h"
|
|
|
|
|
#include <rtgui/dc.h>
|
|
|
|
|
#include <rtgui/font.h>
|
|
|
|
|
#include <rtgui/rtgui_system.h>
|
|
|
|
|
|
|
|
|
|
#ifdef RTGUI_USING_TTF
|
|
|
|
|
static rtgui_font_t *font_16, *font_24, *font_36, *font_48;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* container<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rt_bool_t ttf_event_handler(struct rtgui_object *object, rtgui_event_t *event)
|
2012-04-18 23:06:12 +08:00
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>PAINT<4E>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD> */
|
|
|
|
|
if (event->type == RTGUI_EVENT_PAINT)
|
|
|
|
|
{
|
|
|
|
|
struct rtgui_dc *dc;
|
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
rtgui_font_t *saved;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD>Ϊ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>demo container<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֿؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD>ͼʱ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>demo container
|
|
|
|
|
* <EFBFBD>Ȼ<EFBFBD>ͼ
|
|
|
|
|
*/
|
|
|
|
|
rtgui_container_event_handler(widget, event);
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC<44>IJ<EFBFBD><C4B2><EFBFBD> */
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC */
|
|
|
|
|
dc = rtgui_dc_begin_drawing(widget);
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC<44><43><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC>ؼ<F2B8B8BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>DC<44>ǻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ɹ<EFBFBD><C9B9>ģ<EFBFBD> */
|
|
|
|
|
if (dc == RT_NULL)
|
|
|
|
|
return RT_FALSE;
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>demo container<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
demo_view_get_rect(RTGUI_CONTAINER(widget), &rect);
|
|
|
|
|
|
|
|
|
|
saved = RTGUI_WIDGET_FONT(widget);
|
|
|
|
|
|
|
|
|
|
RTGUI_WIDGET_FONT(widget) = font_16;
|
|
|
|
|
rtgui_dc_draw_text(dc, "ABCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", &rect);
|
|
|
|
|
rect.y1 += 18;
|
|
|
|
|
|
|
|
|
|
RTGUI_WIDGET_FONT(widget) = font_24;
|
|
|
|
|
rtgui_dc_draw_text(dc, "ABCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", &rect);
|
|
|
|
|
rect.y1 += 26;
|
|
|
|
|
|
|
|
|
|
RTGUI_WIDGET_FONT(widget) = font_36;
|
|
|
|
|
rtgui_dc_draw_text(dc, "ABCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", &rect);
|
|
|
|
|
rect.y1 += 38;
|
|
|
|
|
|
|
|
|
|
RTGUI_WIDGET_FONT(widget) = font_48;
|
|
|
|
|
rtgui_dc_draw_text(dc, "ABCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", &rect);
|
|
|
|
|
|
|
|
|
|
RTGUI_WIDGET_FONT(widget) = saved;
|
|
|
|
|
/* <20><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD> */
|
|
|
|
|
rtgui_dc_end_drawing(dc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϵ<EFBFBD><CFB5>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
return rtgui_container_event_handler(widget, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return RT_FALSE;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TTF<54><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʾ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ */
|
|
|
|
|
rtgui_container_t *demo_view_ttf()
|
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_t *container;
|
|
|
|
|
|
|
|
|
|
font_16 = rtgui_freetype_font_create("d:/simsun.ttf", 0, 0, 16);
|
|
|
|
|
font_24 = rtgui_freetype_font_create("d:/simsun.ttf", 0, 0, 24);
|
|
|
|
|
font_36 = rtgui_freetype_font_create("d:/simsun.ttf", 0, 0, 36);
|
|
|
|
|
font_48 = rtgui_freetype_font_create("d:/simsun.TTF", 0, 0, 72);
|
|
|
|
|
|
|
|
|
|
container = demo_view("TTF <20><>ʾ");
|
|
|
|
|
if (container != RT_NULL)
|
|
|
|
|
{
|
|
|
|
|
RTGUI_WIDGET_BACKGROUND(container) = white;
|
|
|
|
|
/* <20><><EFBFBD>ó<EFBFBD><C3B3>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
rtgui_object_set_event_handler(RTGUI_OBJECT(container), ttf_event_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return container;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
}
|
|
|
|
|
#endif
|