2012-04-18 23:06:12 +08:00
|
|
|
|
/*
|
2013-02-01 10:27:10 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>嵥<EFBFBD><EFBFBD>label<EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD>ʾ
|
2012-04-18 23:06:12 +08:00
|
|
|
|
*
|
2013-02-01 10:27:10 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>container<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>label<EFBFBD>ؼ<EFBFBD>
|
2012-04-18 23:06:12 +08:00
|
|
|
|
*/
|
|
|
|
|
#include "demo_view.h"
|
|
|
|
|
#include <rtgui/widgets/label.h>
|
|
|
|
|
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾlabel<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_t *demo_view_label(void)
|
2012-04-18 23:06:12 +08:00
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
rtgui_container_t *container;
|
|
|
|
|
rtgui_label_t *label;
|
|
|
|
|
rtgui_font_t *font;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20>ȴ<EFBFBD><C8B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
container = demo_view("Label View");
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
demo_view_get_rect(container, &rect);
|
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y1 += 5;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
label = rtgui_label_create("Red Left");
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD><D8BC>ϵ<EFBFBD><CFB5>ı<EFBFBD><C4B1><EFBFBD><EFBFBD>뷽ʽΪ<CABD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
RTGUI_WIDGET_TEXTALIGN(label) = RTGUI_ALIGN_LEFT;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD><D8BC><EFBFBD>ǰ<EFBFBD><C7B0>ɫΪ<C9AB><CEAA>ɫ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
RTGUI_WIDGET_FOREGROUND(label) = red;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* container<65><72>һ<EFBFBD><D2BB>container<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>add_child<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(label));
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
demo_view_get_rect(container, &rect);
|
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y1 += 5 + 25;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
label = rtgui_label_create("Blue Right");
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD><D8BC>ϵ<EFBFBD><CFB5>ı<EFBFBD><C4B1><EFBFBD><EFBFBD>뷽ʽΪ<CABD><CEAA><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
RTGUI_WIDGET_TEXTALIGN(label) = RTGUI_ALIGN_RIGHT;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD><D8BC><EFBFBD>ǰ<EFBFBD><C7B0>ɫΪ<C9AB><CEAA>ɫ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
RTGUI_WIDGET_FOREGROUND(label) = blue;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* container<65><72>һ<EFBFBD><D2BB>container<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>add_child<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(label));
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
demo_view_get_rect(container, &rect);
|
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y1 += 5 + 25 + 25;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
label = rtgui_label_create("Green Center");
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD><D8BC><EFBFBD>ǰ<EFBFBD><C7B0>ɫΪ<C9AB><CEAA>ɫ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
RTGUI_WIDGET_FOREGROUND(label) = green;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD><D8BC>ϵ<EFBFBD><CFB5>ı<EFBFBD><C4B1><EFBFBD><EFBFBD>뷽ʽΪ<CABD><CEAA><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
RTGUI_WIDGET_TEXTALIGN(label) = RTGUI_ALIGN_CENTER_HORIZONTAL;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* container<65><72>һ<EFBFBD><D2BB>container<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>add_child<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(label));
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
demo_view_get_rect(container, &rect);
|
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y1 += 5 + 25 + 25 + 25;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
label = rtgui_label_create("12 font");
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ12<31><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>asc<73><63><EFBFBD><EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
font = rtgui_font_refer("asc", 12);
|
|
|
|
|
RTGUI_WIDGET_FONT(label) = font;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* container<65><72>һ<EFBFBD><D2BB>container<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>add_child<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(label));
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
demo_view_get_rect(container, &rect);
|
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.y1 += 5 + 25 + 25 + 25 + 25;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
label = rtgui_label_create("16 font");
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD>asc<73><63><EFBFBD><EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
font = rtgui_font_refer("asc", 16);
|
|
|
|
|
RTGUI_WIDGET_FONT(label) = font;
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
2013-02-01 10:27:10 +08:00
|
|
|
|
/* container<65><72>һ<EFBFBD><D2BB>container<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>add_child<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(label));
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
return container;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
}
|
|
|
|
|
|