combobox.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef __RTGUI_COMBO_H__
  2. #define __RTGUI_COMBO_H__
  3. #include <rtgui/rtgui.h>
  4. #include <rtgui/rtgui_system.h>
  5. #include <rtgui/widgets/widget.h>
  6. #include <rtgui/widgets/textbox.h>
  7. #include <rtgui/widgets/button.h>
  8. #include <rtgui/widgets/view.h>
  9. #include <rtgui/widgets/listbox.h>
  10. #define RTGUI_COMBOBOX_HEIGHT 24
  11. #define RTGUI_COMBOBOX_BUTTON_WIDTH 16
  12. #define RTGUI_COMBO_STYLE_DOWNARROW_UP 0x01
  13. #define RTGUI_COMBO_STYLE_DOWNARROW_DOWN 0x02
  14. typedef struct rtgui_combo rtgui_combo_t;
  15. /** Gets the type of a textbox */
  16. #define RTGUI_COMBOBOX_TYPE (rtgui_combo_type_get())
  17. /** Casts the object to a rtgui_textbox_t */
  18. #define RTGUI_COMBOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_COMBOBOX_TYPE, rtgui_combo_t))
  19. /** Checks if the object is a rtgui_textbox_t */
  20. #define RTGUI_IS_COMBOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_COMBOBOX_TYPE))
  21. typedef struct rtgui_combo_item
  22. {
  23. char *name;
  24. }rtgui_combo_item_t;
  25. struct rtgui_combo
  26. {
  27. rtgui_container_t parent;
  28. /* widget private data */
  29. rt_uint32_t style;
  30. rtgui_textbox_t *tbox;
  31. rtgui_listbox_t *lbox;
  32. /* call back */
  33. void (*on_selected) (PVOID wdt, rtgui_event_t* event);
  34. rt_uint32_t (*get_count)(rtgui_combo_t* box);
  35. void (*add_string)(rtgui_combo_t* box,char* string);
  36. };
  37. rtgui_type_t *rtgui_combo_type_get(void);
  38. rtgui_combo_t* rtgui_combo_create(PVOID parent,const char* text,int left,int top,int w,int h);
  39. void rtgui_combo_destroy(rtgui_combo_t* cbo);
  40. void rtgui_combo_set_onitem(rtgui_combo_t* cbo, rtgui_event_handler_ptr func);
  41. rt_bool_t rtgui_combo_event_handler(PVOID wdt, rtgui_event_t* event);
  42. rt_bool_t rtgui_combo_onitem(PVOID wdt, rtgui_event_t* event);
  43. void rtgui_combo_set_items(rtgui_combo_t* cbo, rtgui_listbox_item_t* items, rt_uint32_t count);
  44. rt_uint32_t rtgui_combo_get_select(rtgui_combo_t* cbo);
  45. char* rtgui_combo_get_string(rtgui_combo_t* cbo);
  46. #endif