demo_view_scrollbar.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_container_t *demo_view_scrollbar(void)
  6. {
  7. rtgui_container_t *container;
  8. rtgui_rect_t rect;
  9. rtgui_label_t *label;
  10. rtgui_scrollbar_t *hbar;
  11. rtgui_scrollbar_t *vbar;
  12. /* create a demo container */
  13. container = demo_view("ScrollBar View");
  14. /* get demo container rect */
  15. demo_view_get_rect(container, &rect);
  16. label = rtgui_label_create("horizontal bar:");
  17. rtgui_container_add_child(container, RTGUI_WIDGET(label));
  18. rect.x1 += 5;
  19. rect.x2 -= 5;
  20. rect.y1 += 5;
  21. rect.y2 = rect.y1 + 18;
  22. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  23. rect.y1 += 20;
  24. rect.y2 = rect.y1 + 18;
  25. hbar = rtgui_scrollbar_create(RTGUI_HORIZONTAL, &rect);
  26. rtgui_container_add_child(container, RTGUI_WIDGET(hbar));
  27. /* get demo container rect */
  28. demo_view_get_rect(container, &rect);
  29. label = rtgui_label_create("vertical bar:");
  30. rtgui_container_add_child(container, RTGUI_WIDGET(label));
  31. rect.x1 += 5;
  32. rect.x2 -= 5;
  33. rect.y1 += 45;
  34. rect.y2 = rect.y1 + 18;
  35. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  36. rect.x1 += 110;
  37. rect.x2 = rect.x1 + 20;
  38. rect.y1 += 18 + 5;
  39. rect.y2 = rect.y1 + 150;
  40. vbar = rtgui_scrollbar_create(RTGUI_VERTICAL, &rect);
  41. rtgui_container_add_child(container, RTGUI_WIDGET(vbar));
  42. rtgui_scrollbar_set_line_step(vbar, 1);
  43. // RTGUI_WIDGET_DISABLE(vbar);
  44. return container;
  45. }