rtt-f030/examples/gui/demo_view_radiobox.c

70 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 程序清单radiobox控件演示
*
* 这个例子会在创建出的container上添加两个不同方向的radiobox控件
*/
#include "demo_view.h"
#include <rtgui/widgets/radiobox.h>
/* 用于显示垂直方向的radio文本项数组 */
static char* radio_item_v[5] =
{
"one",
"two",
"three",
"item 1",
"item 2"
};
/* 用于显示水平方向的radio文本项数组 */
static char* radio_item_h[3] =
{
"one", "two", "three"
};
/* 创建用于演示radiobox控件的视图 */
rtgui_container_t* demo_view_radiobox(void)
{
rtgui_rect_t rect;
rtgui_container_t* container;
rtgui_radiobox_t* radiobox;
/* 先创建一个演示用的视图 */
container = demo_view("RadioBox View");
/* 获得视图的位置信息 */
demo_view_get_rect(container, &rect);
rect.x1 += 5;
rect.x2 -= 5;
rect.y1 += 5;
rect.y2 = rect.y1 + 5 * 25;
/* 创建一个垂直方向显示的radiobox控件文本项是radio_item_v数组共5个项 */
radiobox = rtgui_radiobox_create("Radio Box", RTGUI_VERTICAL, radio_item_v, 5);
/* 设置当前选择的数组是第0项 */
rtgui_radiobox_set_selection(radiobox, 0);
/* 添加radiobox控件到视图中 */
rtgui_container_add_child(container, RTGUI_WIDGET(radiobox));
/* 设置radiobox控件的位置信息 */
rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect);
/* 获得视图的位置信息 */
demo_view_get_rect(container, &rect);
rect.x1 += 5;
rect.x2 -= 5;
rect.y1 += 5 + 5 * 25;
rect.y2 = rect.y1 + 60;
/* 创建一个水平方向显示的radiobox控件文本项是radio_item_h数组共3个项 */
radiobox = rtgui_radiobox_create("Radio Box", RTGUI_HORIZONTAL, radio_item_h, 3);
/* 设置当前选择的数组是第0项 */
rtgui_radiobox_set_selection(radiobox, 0);
/* 添加radiobox控件到视图中 */
rtgui_container_add_child(container, RTGUI_WIDGET(radiobox));
/* 设置radiobox控件的位置信息 */
rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect);
return container;
}