combobox.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef __RTGUI_COMBOBOX_H__
  2. #define __RTGUI_COMBOBOX_H__
  3. #include <rtgui/rtgui.h>
  4. #include <rtgui/image.h>
  5. #include <rtgui/widgets/window.h>
  6. #include <rtgui/widgets/listbox.h>
  7. DECLARE_CLASS_TYPE(combobox);
  8. /** Gets the type of a combobox */
  9. #define RTGUI_COMBOBOX_TYPE (RTGUI_TYPE(combobox))
  10. /** Casts the object to a rtgui_combobox */
  11. #define RTGUI_COMBOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_COMBOBOX_TYPE, rtgui_combobox_t))
  12. /** Checks if the object is a rtgui_combobox */
  13. #define RTGUI_IS_COMBOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_COMBOBOX_TYPE))
  14. #define RTGUI_COMBOBOX_WIDTH 75
  15. #define RTGUI_COMBOBOX_HEIGHT 20
  16. #define RTGUI_COMBOBOX_BUTTON_WIDTH 18
  17. struct rtgui_combobox
  18. {
  19. struct rtgui_widget parent;
  20. /* widget private data */
  21. /* pull down window */
  22. struct rtgui_win *pd_win;
  23. rt_bool_t pd_pressed;
  24. /* combobox items */
  25. struct rtgui_listbox_item *items;
  26. rt_uint16_t items_count;
  27. rt_uint16_t current_item;
  28. /* call back */
  29. rtgui_event_handler_ptr on_selected;
  30. };
  31. typedef struct rtgui_combobox rtgui_combobox_t;
  32. rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item *items, rt_uint16_t counter, struct rtgui_rect *rect);
  33. void rtgui_combobox_destroy(rtgui_combobox_t *box);
  34. rt_bool_t rtgui_combobox_event_handler(struct rtgui_object *object, struct rtgui_event *event);
  35. struct rtgui_listbox_item *rtgui_combox_get_select(struct rtgui_combobox *box);
  36. void rtgui_combobox_set_onselected(struct rtgui_combobox *box, rtgui_event_handler_ptr func);
  37. #endif