rt-thread/examples/gui/demo_view_checkbox.c

81 lines
2.4 KiB
C
Raw Normal View History

/*
2013-02-01 10:27:10 +08:00
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>checkbox<EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD>ʾ
*
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>checkbox<EFBFBD>ؼ<EFBFBD>
*/
#include "demo_view.h"
#include <rtgui/widgets/checkbox.h>
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾcheckbox<6F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ */
rtgui_container_t *demo_view_checkbox(void)
{
rtgui_rect_t rect;
rtgui_container_t *container;
rtgui_checkbox_t *checkbox;
rtgui_font_t *font;
2013-02-01 10:27:10 +08:00
/* <20>ȴ<EFBFBD><C8B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ */
container = demo_view("CheckBox View");
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
demo_view_get_rect(container, &rect);
rect.x1 += 5;
rect.x2 = rect.x1 + 100;
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>checkbox<6F>ؼ<EFBFBD> */
checkbox = rtgui_checkbox_create("Red", RT_TRUE);
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>ɫΪ<C9AB><CEAA>ɫ */
RTGUI_WIDGET_FOREGROUND(checkbox) = red;
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>checkbox<6F><78>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
rtgui_container_add_child(container, RTGUI_WIDGET(checkbox));
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
demo_view_get_rect(container, &rect);
rect.x1 += 5;
rect.x2 = rect.x1 + 100;
rect.y1 += 5 + 25;
rect.y2 = rect.y1 + 20;
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>checkbox<6F>ؼ<EFBFBD> */
checkbox = rtgui_checkbox_create("Blue", RT_TRUE);
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>ɫΪ<C9AB><CEAA>ɫ */
RTGUI_WIDGET_FOREGROUND(checkbox) = blue;
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>checkbox<6F><78>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
rtgui_container_add_child(container, RTGUI_WIDGET(checkbox));
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
demo_view_get_rect(container, &rect);
rect.x1 += 5;
rect.x2 = rect.x1 + 100;
rect.y1 += 5 + 25 + 25;
rect.y2 = rect.y1 + 20;
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>checkbox<6F>ؼ<EFBFBD> */
checkbox = rtgui_checkbox_create("12 font", RT_TRUE);
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ12<31><32><EFBFBD><EFBFBD> */
font = rtgui_font_refer("asc", 12);
RTGUI_WIDGET_FONT(checkbox) = font;
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>checkbox<6F><78>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
rtgui_container_add_child(container, RTGUI_WIDGET(checkbox));
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
demo_view_get_rect(container, &rect);
rect.x1 += 5;
rect.x2 = rect.x1 + 100;
rect.y1 += 5 + 25 + 25 + 25;
rect.y2 = rect.y1 + 20;
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>checkbox<6F>ؼ<EFBFBD> */
checkbox = rtgui_checkbox_create("16 font", RT_TRUE);
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ16<31><36><EFBFBD><EFBFBD> */
font = rtgui_font_refer("asc", 16);
RTGUI_WIDGET_FONT(checkbox) = font;
2013-02-01 10:27:10 +08:00
/* <20><><EFBFBD><EFBFBD>checkbox<6F><78>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
rtgui_container_add_child(container, RTGUI_WIDGET(checkbox));
return container;
}