demo_view_button.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "demo_view.h"
  2. #include <rtgui/widgets/button.h>
  3. rtgui_view_t* demo_view_button(rtgui_workbench_t* workbench)
  4. {
  5. rtgui_rect_t rect;
  6. rtgui_view_t* view;
  7. rtgui_button_t* button;
  8. rtgui_font_t* font;
  9. /* create a demo view */
  10. view = demo_view(workbench, "Button View");
  11. demo_view_get_rect(view, &rect);
  12. rect.x1 += 5; rect.x2 = rect.x1 + 100;
  13. rect.y1 += 5; rect.y2 = rect.y1 + 20;
  14. button = rtgui_button_create("Red");
  15. RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(button)) = red;
  16. rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
  17. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
  18. demo_view_get_rect(view, &rect);
  19. rect.x1 += 5; rect.x2 = rect.x1 + 100;
  20. rect.y1 += 5 + 25; rect.y2 = rect.y1 + 20;
  21. button = rtgui_button_create("Blue");
  22. RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(button)) = blue;
  23. rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
  24. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
  25. demo_view_get_rect(view, &rect);
  26. rect.x1 += 5; rect.x2 = rect.x1 + 100;
  27. rect.y1 += 5 + 25 + 25; rect.y2 = rect.y1 + 20;
  28. button = rtgui_button_create("12 font");
  29. font = rtgui_font_refer("asc", 12);
  30. RTGUI_WIDGET_FONT(RTGUI_WIDGET(button)) = font;
  31. rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
  32. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
  33. demo_view_get_rect(view, &rect);
  34. rect.x1 += 5; rect.x2 = rect.x1 + 100;
  35. rect.y1 += 5 + 25 + 25 + 25; rect.y2 = rect.y1 + 20;
  36. button = rtgui_button_create("16 font");
  37. font = rtgui_font_refer("asc", 16);
  38. RTGUI_WIDGET_FONT(RTGUI_WIDGET(button)) = font;
  39. rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
  40. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
  41. return view;
  42. }