demo_view_scrollbar.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "demo_view.h"
  2. #include <rtgui/rtgui_system.h>
  3. #include <rtgui/widgets/label.h>
  4. #include <rtgui/widgets/scrollbar.h>
  5. rtgui_view_t *demo_view_scrollbar(rtgui_workbench_t* workbench)
  6. {
  7. rtgui_view_t *view;
  8. rtgui_rect_t rect;
  9. rtgui_label_t *label;
  10. rtgui_scrollbar_t* hbar;
  11. rtgui_scrollbar_t* vbar;
  12. /* create a demo view */
  13. view = demo_view(workbench, "ScrollBar View");
  14. /* get demo view rect */
  15. demo_view_get_rect(view, &rect);
  16. label = rtgui_label_create("horizontal bar:");
  17. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  18. rect.x1 += 5; rect.x2 -= 5;
  19. rect.y1 += 5; rect.y2 = rect.y1 + 18;
  20. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  21. rect.y1 += 20; rect.y2 = rect.y1 + 18;
  22. hbar = rtgui_scrollbar_create(RTGUI_HORIZONTAL, &rect);
  23. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(hbar));
  24. /* get demo view rect */
  25. demo_view_get_rect(view, &rect);
  26. label = rtgui_label_create("vertical bar:");
  27. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  28. rect.x1 += 5; rect.x2 -= 5;
  29. rect.y1 += 45; rect.y2 = rect.y1 + 18;
  30. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  31. rect.x1 += 110; rect.x2 = rect.x1 + 20;
  32. rect.y1 += 18 + 5; rect.y2 = rect.y1 + 150;
  33. vbar = rtgui_scrollbar_create(RTGUI_VERTICAL, &rect);
  34. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(vbar));
  35. rtgui_scrollbar_set_line_step(vbar, 1);
  36. // RTGUI_WIDGET_DISABLE(RTGUI_WIDGET(vbar));
  37. return view;
  38. }