demo_fnview.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "demo_view.h"
  2. #include <rtgui/widgets/label.h>
  3. #include <rtgui/widgets/button.h>
  4. // #include <rtgui/widgets/fn_view.h>
  5. static rtgui_label_t* label;
  6. void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
  7. {
  8. /* create a fn view */
  9. }
  10. rtgui_view_t* demo_fn_view(rtgui_workbench_t* workbench)
  11. {
  12. rtgui_rect_t rect;
  13. rtgui_view_t* view;
  14. rtgui_button_t* open_btn;
  15. rtgui_font_t* font;
  16. view = demo_view(workbench);
  17. rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
  18. font = rtgui_font_refer("asc", 12);
  19. rect.x1 += 5; rect.x2 -= 5;
  20. rect.y1 += 5; rect.y2 = rect.y1 + 20;
  21. label = rtgui_label_create("fn: ");
  22. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  23. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  24. RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font;
  25. rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
  26. rect.x1 += 5; rect.x2 = rect.x1 + 80;
  27. rect.y1 += 30; rect.y2 = rect.y1 + 20;
  28. open_btn = rtgui_button_create("Open File");
  29. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn));
  30. rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
  31. RTGUI_WIDGET_FONT(RTGUI_WIDGET(open_btn)) = font;
  32. rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
  33. return view;
  34. }