filelist.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __FILE_LIST_VIEW_H__
  2. #define __FILE_LIST_VIEW_H__
  3. #include <rtgui/widgets/view.h>
  4. #define FITEM_FILE 0x0
  5. #define FITEM_DIR 0x1
  6. struct file_item
  7. {
  8. rt_uint8_t* name;
  9. rt_uint32_t type;
  10. rt_uint32_t size;
  11. };
  12. /** Gets the type of a filelist view */
  13. #define FILELIST_VIEW_TYPE (filelist_view_type_get())
  14. /** Casts the object to a filelist */
  15. #define FILELIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), FILELIST_VIEW_TYPE, filelist_view_t))
  16. /** Checks if the object is a filelist view */
  17. #define IS_FILELIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), FILELIST_VIEW_TYPE))
  18. struct filelist_view
  19. {
  20. struct rtgui_view parent;
  21. /* widget private data */
  22. /* current directory */
  23. rt_uint8_t* current_directory;
  24. rt_uint8_t* pattern;
  25. /* the number of item in a page */
  26. rt_uint16_t page_items;
  27. rt_uint16_t items_count;
  28. /* the selected item */
  29. rt_uint16_t current_item;
  30. /* items array */
  31. struct file_item *items;
  32. };
  33. typedef struct filelist_view filelist_view_t;
  34. rtgui_type_t *filelist_view_type_get(void);
  35. filelist_view_t* filelist_view_create(rtgui_workbench_t* workbench, const char* directory, const char* pattern, const rtgui_rect_t* rect);
  36. void filelist_view_destroy(filelist_view_t* view);
  37. void filelist_view_clear(filelist_view_t* view);
  38. rt_bool_t filelist_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
  39. void filelist_view_set_directory(filelist_view_t* view, const char* directory);
  40. #endif