2012-04-18 23:06:12 +08:00
|
|
|
#include "demo_view.h"
|
|
|
|
#include <rtgui/rtgui_system.h>
|
|
|
|
#include <rtgui/widgets/label.h>
|
|
|
|
#include <rtgui/widgets/scrollbar.h>
|
|
|
|
|
|
|
|
rtgui_container_t *demo_view_scrollbar(void)
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
rtgui_container_t *container;
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
rtgui_label_t *label;
|
|
|
|
rtgui_scrollbar_t *hbar;
|
|
|
|
rtgui_scrollbar_t *vbar;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
/* create a demo container */
|
|
|
|
container = demo_view("ScrollBar View");
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
/* get demo container rect */
|
|
|
|
demo_view_get_rect(container, &rect);
|
2012-11-26 10:42:52 +08:00
|
|
|
rect.x1 += 5;
|
|
|
|
rect.x2 -= 5;
|
|
|
|
rect.y1 += 5;
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2012-08-13 16:32:01 +08:00
|
|
|
label = rtgui_label_create("horizontal bar:");
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
2012-08-13 16:32:01 +08:00
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(label));
|
2012-11-26 10:42:52 +08:00
|
|
|
|
|
|
|
hbar = rtgui_scrollbar_create(container, 5, 70, 20, 200, RTGUI_HORIZONTAL);
|
|
|
|
rtgui_scrollbar_set_line_step(hbar, 1);
|
|
|
|
rtgui_scrollbar_set_page_step(hbar, 3);
|
|
|
|
rtgui_scrollbar_set_range(hbar, 20);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
/* get demo container rect */
|
|
|
|
demo_view_get_rect(container, &rect);
|
2012-11-26 10:42:52 +08:00
|
|
|
rect.x1 += 5;
|
|
|
|
rect.x2 -= 5;
|
|
|
|
rect.y1 += 5+40;
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2012-08-13 16:32:01 +08:00
|
|
|
label = rtgui_label_create("vertical bar:");
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
2012-08-13 16:32:01 +08:00
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(label));
|
2012-11-26 10:42:52 +08:00
|
|
|
|
|
|
|
vbar = rtgui_scrollbar_create(container, 10, 110, 20, 200, RTGUI_VERTICAL);
|
|
|
|
rtgui_scrollbar_set_line_step(vbar, 1);
|
|
|
|
rtgui_scrollbar_set_page_step(vbar, 5);
|
|
|
|
rtgui_scrollbar_set_range(vbar, 20);
|
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
|
|
|
}
|