demo_view_radiobox.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "demo_view.h"
  2. #include <rtgui/widgets/radiobox.h>
  3. static char* radio_item[5] =
  4. {
  5. "one",
  6. "two",
  7. "three",
  8. "item 1",
  9. "item 2"
  10. };
  11. static char* radio_item_h[3] =
  12. {
  13. "one", "two", "three"
  14. };
  15. rtgui_view_t* demo_view_radiobox(rtgui_workbench_t* workbench)
  16. {
  17. rtgui_rect_t rect;
  18. rtgui_view_t* view;
  19. rtgui_radiobox_t* radiobox;
  20. view = demo_view(workbench, "RadioBox View");
  21. demo_view_get_rect(view, &rect);
  22. rect.x1 += 5; rect.x2 -= 5;
  23. rect.y1 += 5; rect.y2 = rect.y1 + 5 * 25;
  24. radiobox = rtgui_radiobox_create("Radio Box", RTGUI_VERTICAL, radio_item, 5);
  25. rtgui_radiobox_set_selection(radiobox, 0);
  26. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(radiobox));
  27. rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect);
  28. demo_view_get_rect(view, &rect);
  29. rect.x1 += 5; rect.x2 -= 5;
  30. rect.y1 += 5 + 5 * 25; rect.y2 = rect.y1 + 60;
  31. radiobox = rtgui_radiobox_create("Radio Box", RTGUI_HORIZONTAL, radio_item_h, 3);
  32. rtgui_radiobox_set_selection(radiobox, 0);
  33. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(radiobox));
  34. rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect);
  35. return view;
  36. }