diff --git a/examples/gui/demo_view_scrollbar.c b/examples/gui/demo_view_scrollbar.c new file mode 100644 index 000000000..2db27119d --- /dev/null +++ b/examples/gui/demo_view_scrollbar.c @@ -0,0 +1,42 @@ +#include "demo_view.h" +#include +#include +#include + +static rtgui_scrollbar_t* hbar; +static rtgui_scrollbar_t* vbar; + +rtgui_view_t *demo_view_scrollbar(rtgui_workbench_t* workbench) +{ + rtgui_view_t *view; + rtgui_rect_t rect; + rtgui_label_t *label; + + /* create a demo view */ + view = demo_view(workbench, "ScrollBar View"); + + /* get demo view rect */ + demo_view_get_rect(view, &rect); + label = rtgui_label_create("horizontal bar:"); + rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); + rect.x1 += 5; rect.x2 -= 5; + rect.y1 += 5; rect.y2 = rect.y1 + 18; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rect.y1 += 20; rect.y2 = rect.y1 + 18; + hbar = rtgui_scrollbar_create(RTGUI_HORIZONTAL, &rect); + rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(hbar)); + + /* get demo view rect */ + demo_view_get_rect(view, &rect); + label = rtgui_label_create("vertical bar:"); + rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); + rect.x1 += 5; rect.x2 -= 5; + rect.y1 += 45; rect.y2 = rect.y1 + 18; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rect.x1 += 110; rect.x2 = rect.x1 + 20; + rect.y1 += 18 + 5; rect.y2 = rect.y1 + 150; + vbar = rtgui_scrollbar_create(RTGUI_VERTICAL, &rect); + rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(vbar)); + + return view; +} diff --git a/examples/gui/demo_workbench.c b/examples/gui/demo_workbench.c index 9782efb98..241939cd8 100644 --- a/examples/gui/demo_workbench.c +++ b/examples/gui/demo_workbench.c @@ -63,6 +63,7 @@ static void workbench_entry(void* parameter) demo_view_button(workbench); demo_view_checkbox(workbench); demo_view_progressbar(workbench); + demo_view_scrollbar(workbench); demo_view_radiobox(workbench); demo_view_textbox(workbench); demo_view_listbox(workbench);