list_view.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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/view.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_view 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_int16_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_type_t *rtgui_list_view_type_get(void);
  57. rtgui_list_view_t* rtgui_list_view_create(const struct rtgui_list_item* items, rt_uint16_t count,
  58. rtgui_rect_t *rect, rt_uint16_t flag);
  59. void rtgui_list_view_destroy(rtgui_list_view_t* view);
  60. rt_bool_t rtgui_list_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
  61. #endif