demo_view_notebook.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * 程序清单:notebook控件演示
  3. *
  4. * 这个例子会在创建出的view上演示notebook控件
  5. */
  6. #include "demo_view.h"
  7. #include <rtgui/widgets/notebook.h>
  8. #include <rtgui/widgets/listbox.h>
  9. const static struct rtgui_listbox_item items[] =
  10. {
  11. {"list #0", RT_NULL},
  12. {"list #1", RT_NULL},
  13. {"list #2", RT_NULL},
  14. {"list #3", RT_NULL},
  15. };
  16. /* 创建用于演示notebook控件的视图 */
  17. rtgui_view_t* demo_view_notebook(rtgui_workbench_t* workbench)
  18. {
  19. rtgui_rect_t rect;
  20. rtgui_view_t* view;
  21. rtgui_notebook_t* notebook;
  22. rtgui_listbox_t* box;
  23. /* 先创建一个演示用的视图 */
  24. view = demo_view(workbench, "Notebook View");
  25. /* 获得视图的位置信息 */
  26. demo_view_get_rect(view, &rect);
  27. notebook = rtgui_notebook_create(&rect);
  28. /* view是一个container控件,调用add_child方法添加这个notebook控件 */
  29. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(notebook));
  30. box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &rect);
  31. rtgui_notebook_add(notebook, "Tab 1", RTGUI_WIDGET(box));
  32. return view;
  33. }