combobox.h 1.6 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. /** Gets the type of a combobox */
  8. #define RTGUI_COMBOBOX_TYPE (rtgui_combobox_type_get())
  9. /** Casts the object to a rtgui_combobox */
  10. #define RTGUI_COMBOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_COMBOBOX_TYPE, rtgui_combobox_t))
  11. /** Checks if the object is a rtgui_combobox */
  12. #define RTGUI_IS_COMBOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_COMBOBOX_TYPE))
  13. #define RTGUI_COMBOBOX_WIDTH 75
  14. #define RTGUI_COMBOBOX_HEIGHT 20
  15. #define RTGUI_COMBOBOX_BUTTON_WIDTH 18
  16. struct rtgui_combobox
  17. {
  18. struct rtgui_widget parent;
  19. /* widget private data */
  20. /* pull down window */
  21. struct rtgui_win* pd_win;
  22. rt_bool_t pd_pressed;
  23. /* combobox items */
  24. struct rtgui_listbox_item* items;
  25. rt_uint16_t items_count;
  26. rt_uint16_t current_item;
  27. /* call back */
  28. void (*on_selected) (struct rtgui_widget* widget, struct rtgui_event* event);
  29. };
  30. typedef struct rtgui_combobox rtgui_combobox_t;
  31. rtgui_type_t *rtgui_combobox_type_get(void);
  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_widget* widget, 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_onitem_func_t func);
  37. #endif