list_view.h 2.1 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/kbddef.h>
  18. #include <rtgui/color.h>
  19. #include <rtgui/event.h>
  20. #include <rtgui/widgets/view.h>
  21. typedef void (*item_action)(void* parameter);
  22. typedef struct rtgui_list_item rtgui_list_view_item_t;
  23. struct rtgui_list_item
  24. {
  25. char* name;
  26. rtgui_image_t *image;
  27. item_action action;
  28. void *parameter;
  29. };
  30. /** Gets the type of a list view */
  31. #define RTGUI_LIST_VIEW_TYPE (rtgui_list_view_type_get())
  32. /** Casts the object to a rtgui_list_view_t */
  33. #define RTGUI_LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LIST_VIEW_TYPE, rtgui_list_view_t))
  34. /** Checks if the object is a rtgui_list_view_t */
  35. #define RTGUI_IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LIST_VIEW_TYPE))
  36. #define RTGUI_LIST_VIEW_LIST 0x00
  37. #define RTGUI_LIST_VIEW_ICON 0x01
  38. #define RTGUI_LIST_VIEW_REPORT 0x02
  39. struct rtgui_list_view
  40. {
  41. rtgui_view_t parent;
  42. /* widget private data */
  43. /* list item */
  44. const rtgui_list_view_item_t* items;
  45. /* layout flag */
  46. rt_uint16_t flag;
  47. /* total number of items */
  48. rt_uint16_t item_count;
  49. /* the number of item in a page */
  50. rt_uint16_t page;
  51. /* current item */
  52. rt_int16_t item_current;
  53. /* icon layout */
  54. rt_uint32_t row_items, col_items;
  55. };
  56. typedef struct rtgui_list_view rtgui_list_view_t;
  57. rtgui_type_t *rtgui_list_view_type_get(void);
  58. rtgui_list_view_t* rtgui_list_view_create(PVOID parent,const rtgui_list_view_item_t* items, rt_uint16_t count, int left,int top,int w,int h, rt_uint16_t flag);
  59. void rtgui_list_view_destroy(rtgui_list_view_t* view);
  60. rt_bool_t rtgui_list_view_event_handler(PVOID wdt, rtgui_event_t* event);
  61. #endif