listbox.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * File : listbox.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_LISTBOX_H__
  15. #define __RTGUI_LISTBOX_H__
  16. #include <rtgui/rtgui.h>
  17. #include <rtgui/kbddef.h>
  18. #include <rtgui/color.h>
  19. #include <rtgui/image.h>
  20. struct rtgui_listbox_item
  21. {
  22. char *name;
  23. rtgui_image_t *image;
  24. };
  25. typedef struct rtgui_listbox_item rtgui_listbox_item_t;
  26. /** Gets the type of a list box */
  27. #define RTGUI_LISTBOX_TYPE (rtgui_listbox_type_get())
  28. /** Casts the object to a filelist */
  29. #define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t))
  30. /** Checks if the object is a filelist box */
  31. #define RTGUI_IS_LISTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTBOX_TYPE))
  32. typedef struct rtgui_listbox rtgui_listbox_t;
  33. struct rtgui_listbox
  34. {
  35. rtgui_container_t parent;
  36. /* widget private data */
  37. rt_int16_t item_per_page; /* the number of item in a page */
  38. rt_int16_t item_count; /* total number of items */
  39. rt_int16_t item_size; /* item size */
  40. rt_int16_t frist_aloc; /* frist item */
  41. rt_int16_t now_aloc; /* now item */
  42. rt_int16_t old_aloc; /* old item */
  43. rt_bool_t ispopup; /* 是弹出类型列表 */
  44. PVOID widgetlnk; /* 链接的控件 */
  45. rtgui_scrollbar_t *sbar;
  46. rtgui_listbox_item_t *items; /* items array */
  47. /* item event handler */
  48. rt_bool_t (*on_item)(PVOID wdt, rtgui_event_t* event);
  49. rt_uint32_t (*get_count)(rtgui_listbox_t* box);
  50. void (*add_item)(rtgui_listbox_t* box, rtgui_listbox_item_t* item);
  51. };
  52. rtgui_type_t *rtgui_listbox_type_get(void);
  53. rtgui_listbox_t* rtgui_listbox_create(PVOID wdt, int left,int top,int w,int h,rt_uint32_t style);
  54. void rtgui_listbox_destroy(rtgui_listbox_t* box);
  55. void rtgui_listbox_update(rtgui_listbox_t* box);
  56. rt_bool_t rtgui_listbox_event_handler(PVOID wdt, rtgui_event_t* event);
  57. void rtgui_listbox_set_onitem(rtgui_listbox_t* box, rtgui_event_handler_ptr func);
  58. void rtgui_listbox_set_items(rtgui_listbox_t* box, rtgui_listbox_item_t* items, rt_uint32_t count);
  59. void rtgui_listbox_delete_item(rtgui_listbox_t* box, rt_uint32_t item_num);
  60. #endif