demo_view_checkbox.c 1.8 KB
Newer Older
B
bernard.xiong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#include "demo_view.h"
#include <rtgui/widgets/checkbox.h>

rtgui_view_t* demo_view_checkbox(rtgui_workbench_t* workbench)
{
	rtgui_rect_t rect;
	rtgui_view_t* view;
	rtgui_checkbox_t* checkbox;
	rtgui_font_t* font;

	/* create a demo view */
	view = demo_view(workbench);

	demo_view_get_rect(view, &rect);
	rect.x1 += 5; rect.x2 = rect.x1 + 100;
	rect.y1 += 5; rect.y2 = rect.y1 + 20;
	checkbox = rtgui_checkbox_create("Red");
	RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = red;
	rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(checkbox));

	demo_view_get_rect(view, &rect);
	rect.x1 += 5; rect.x2 = rect.x1 + 100;
	rect.y1 += 5 + 25; rect.y2 = rect.y1 + 20;
	checkbox = rtgui_checkbox_create("Blue");
	RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = blue;
	rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(checkbox));

	demo_view_get_rect(view, &rect);
	rect.x1 += 5; rect.x2 = rect.x1 + 100;
	rect.y1 += 5 + 25 + 25; rect.y2 = rect.y1 + 20;
	checkbox = rtgui_checkbox_create("12 font");
	font = rtgui_font_refer("asc", 12);
	RTGUI_WIDGET_FONT(RTGUI_WIDGET(checkbox)) = font;
	rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(checkbox));

	demo_view_get_rect(view, &rect);
	rect.x1 += 5; rect.x2 = rect.x1 + 100;
	rect.y1 += 5 + 25 + 25 + 25; rect.y2 = rect.y1 + 20;
	checkbox = rtgui_checkbox_create("16 font");
	font = rtgui_font_refer("asc", 16);
	RTGUI_WIDGET_FONT(RTGUI_WIDGET(checkbox)) = font;
	rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(checkbox));

	return view;
}