list_view.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /** Gets the type of a list view */
  29. #define RTGUI_LIST_VIEW_TYPE (rtgui_list_view_type_get())
  30. /** Casts the object to a filelist */
  31. #define RTGUI_LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LIST_VIEW_TYPE, rtgui_list_view_t))
  32. /** Checks if the object is a filelist view */
  33. #define RTGUI_IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LIST_VIEW_TYPE))
  34. #define RTGUI_LIST_VIEW_LIST 0x00
  35. #define RTGUI_LIST_VIEW_ICON 0x01
  36. #define RTGUI_LIST_VIEW_REPORT 0x02
  37. struct rtgui_list_view
  38. {
  39. struct rtgui_view parent;
  40. /* widget private data */
  41. /* list item */
  42. const struct rtgui_list_item* items;
  43. /* layout flag */
  44. rt_uint16_t flag;
  45. /* total number of items */
  46. rt_uint16_t items_count;
  47. /* the number of item in a page */
  48. rt_uint16_t page_items;
  49. /* current item */
  50. rt_uint16_t current_item;
  51. /* icon layout */
  52. rt_uint8_t row_items, col_items;
  53. };
  54. typedef struct rtgui_list_view rtgui_list_view_t;
  55. rtgui_type_t *rtgui_list_view_type_get(void);
  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_widget* widget, struct rtgui_event* event);
  60. #endif