listbox.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * File : listbox.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009, 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. * 2009-10-16 Bernard first version
  13. */
  14. #ifndef __RTGUI_LISTBOX_H__
  15. #define __RTGUI_LISTBOX_H__
  16. #include <rtgui/widgets/item.h>
  17. #include <rtgui/widgets/scrollview.h>
  18. #define RTGUI_LISTBOX_WIDTH 150
  19. #define RTGUI_LISTBOX_HEIGHT 200
  20. /** Gets the type of a listbox */
  21. #define RTGUI_LISTBOX_TYPE (rtgui_listbox_type_get())
  22. /** Casts the object to a rtgui_listbox */
  23. #define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t))
  24. /** Checks if the object is a rtgui_listbox */
  25. #define RTGUI_IS_LISTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTBOX_TYPE))
  26. /*
  27. * the listbox widget
  28. */
  29. struct rtgui_listbox
  30. {
  31. struct rtgui_scrollview parent;
  32. /* widget private data */
  33. int flag;
  34. /* total number of items */
  35. rt_uint32_t count;
  36. /* the selected item */
  37. struct rtgui_item* selected;
  38. /* call back */
  39. rt_bool_t (*on_selected) (struct rtgui_widget* widget, struct rtgui_event* event);
  40. rt_bool_t (*on_activated) (struct rtgui_widget* widget, struct rtgui_event* event);
  41. };
  42. typedef struct rtgui_listbox rtgui_listbox_t;
  43. rtgui_type_t *rtgui_listbox_type_get(void);
  44. rtgui_listbox_t* rtgui_listbox_create(void);
  45. void rtgui_listbox_destroy(rtgui_listbox_t* listbox);
  46. rt_bool_t rtgui_listbox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
  47. struct rtgui_item* rtgui_listbox_get_select(struct rtgui_listbox* box);
  48. void rtgui_listbox_set_select(struct rtgui_listbox* box, rt_uint32_t index);
  49. void rtgui_listbox_set_select_item(struct rtgui_listbox* box, struct rtgui_item* item);
  50. struct rtgui_item* rtgui_listbox_add_item_string(struct rtgui_listbox* box, const unsigned char* text);
  51. void rtgui_listbox_add_item(struct rtgui_listbox* list, struct rtgui_item* item);
  52. #endif