listview.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef __RTGUI_LIST_VIEW_H__
  2. #define __RTGUI_LIST_VIEW_H__
  3. #include <rtgui/rtgui.h>
  4. #include <rtgui/image.h>
  5. #include <rtgui/rtgui_system.h>
  6. #include <rtgui/widgets/view.h>
  7. typedef void (*item_action)(void* parameter);
  8. struct list_item
  9. {
  10. char* name;
  11. rtgui_image_t *image;
  12. item_action action;
  13. void *parameter;
  14. };
  15. /** Gets the type of a list view */
  16. #define LIST_VIEW_TYPE (list_view_type_get())
  17. /** Casts the object to a filelist */
  18. #define LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), LIST_VIEW_TYPE, list_view_t))
  19. /** Checks if the object is a filelist view */
  20. #define IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), LIST_VIEW_TYPE))
  21. struct list_view
  22. {
  23. struct rtgui_view parent;
  24. /* widget private data */
  25. /* list item */
  26. struct list_item* items;
  27. /* total number of items */
  28. rt_uint16_t items_count;
  29. /* the number of item in a page */
  30. rt_uint16_t page_items;
  31. /* current item */
  32. rt_uint16_t current_item;
  33. };
  34. typedef struct list_view list_view_t;
  35. rtgui_type_t *list_view_type_get(void);
  36. list_view_t* list_view_create(struct list_item* items, rt_uint16_t count,
  37. rtgui_rect_t *rect);
  38. void list_view_clear(list_view_t* view);
  39. rt_bool_t list_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
  40. #endif