list_view.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * File : list_view.h
  3. * This file is part of RTGUI in RT-Thread RTOS
  4. * COPYRIGHT (C) 2010, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2010-01-06 Bernard first version
  13. */
  14. #ifndef __RTGUI_LIST_VIEW_H__
  15. #define __RTGUI_LIST_VIEW_H__
  16. #include <rtgui/rtgui.h>
  17. #include <rtgui/image.h>
  18. #include <rtgui/rtgui_system.h>
  19. #include <rtgui/widgets/container.h>
  20. typedef void (*item_action)(struct rtgui_widget* widget, void* parameter);
  21. struct rtgui_list_item
  22. {
  23. char* name;
  24. rtgui_image_t *image;
  25. item_action action;
  26. void *parameter;
  27. };
  28. DECLARE_CLASS_TYPE(listview);
  29. /** Gets the type of a list view */
  30. #define RTGUI_LIST_VIEW_TYPE (RTGUI_TYPE(listview))
  31. /** Casts the object to a filelist */
  32. #define RTGUI_LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LIST_VIEW_TYPE, rtgui_list_view_t))
  33. /** Checks if the object is a filelist view */
  34. #define RTGUI_IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LIST_VIEW_TYPE))
  35. #define RTGUI_LIST_VIEW_LIST 0x00
  36. #define RTGUI_LIST_VIEW_ICON 0x01
  37. #define RTGUI_LIST_VIEW_REPORT 0x02
  38. struct rtgui_list_view
  39. {
  40. struct rtgui_container parent;
  41. /* widget private data */
  42. /* list item */
  43. const struct rtgui_list_item* items;
  44. /* layout flag */
  45. rt_uint16_t flag;
  46. /* total number of items */
  47. rt_uint16_t items_count;
  48. /* the number of item in a page */
  49. rt_uint16_t page_items;
  50. /* current item */
  51. rt_uint16_t current_item;
  52. /* icon layout */
  53. rt_uint8_t row_items, col_items;
  54. };
  55. typedef struct rtgui_list_view rtgui_list_view_t;
  56. rtgui_list_view_t* rtgui_list_view_create(const struct rtgui_list_item* items, rt_uint16_t count,
  57. rtgui_rect_t *rect, rt_uint16_t flag);
  58. void rtgui_list_view_destroy(rtgui_list_view_t* view);
  59. rt_bool_t rtgui_list_view_event_handler(struct rtgui_object* widget, struct rtgui_event* event);
  60. #endif