demo_fnview.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. rtgui_view_t *view;
  10. view = rtgui_filelist_view_create(workbench, "/", "*.*");
  11. }
  12. rtgui_view_t* demo_fn_view(rtgui_workbench_t* workbench)
  13. {
  14. rtgui_rect_t rect;
  15. rtgui_view_t* view;
  16. rtgui_button_t* open_btn;
  17. rtgui_font_t* font;
  18. font = rtgui_font_refer("asc", 12);
  19. view = demo_view(workbench, "FileList View");
  20. demo_view_get_rect(view, &rect);
  21. rect.x1 += 5; rect.x2 -= 5;
  22. rect.y1 += 5; rect.y2 = rect.y1 + 20;
  23. label = rtgui_label_create("fn: ");
  24. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  25. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  26. RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font;
  27. demo_view_get_rect(view, &rect);
  28. rect.x1 += 5; rect.x2 = rect.x1 + 80;
  29. rect.y1 += 30; rect.y2 = rect.y1 + 20;
  30. open_btn = rtgui_button_create("Open File");
  31. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn));
  32. rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
  33. RTGUI_WIDGET_FONT(RTGUI_WIDGET(open_btn)) = font;
  34. rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
  35. return view;
  36. }