checkbox.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __RTGUI_CHECKBOX_H__
  2. #define __RTGUI_CHECKBOX_H__
  3. #include <rtgui/rtgui.h>
  4. #include <rtgui/widgets/widget.h>
  5. #include <rtgui/widgets/label.h>
  6. DECLARE_CLASS_TYPE(checkbox);
  7. /** Gets the type of a checkbox */
  8. #define RTGUI_CHECKBOX_TYPE (RTGUI_TYPE(checkbox))
  9. /** Casts the object to an rtgui_button */
  10. #define RTGUI_CHECKBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CHECKBOX_TYPE, struct rtgui_checkbox))
  11. /** Checks if the object is an rtgui_button */
  12. #define RTGUI_IS_CHECKBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CHECKBOX_TYPE))
  13. #define RTGUI_CHECKBOX_STATUS_CHECKED 0
  14. #define RTGUI_CHECKBOX_STATUS_UNCHECKED 1
  15. struct rtgui_checkbox
  16. {
  17. /* inherit from label */
  18. struct rtgui_label parent;
  19. /* check box status */
  20. rt_uint8_t status_down;
  21. /* click button event handler */
  22. void (*on_button)(struct rtgui_widget* widget, rtgui_event_t *event);
  23. };
  24. typedef struct rtgui_checkbox rtgui_checkbox_t;
  25. rtgui_checkbox_t* rtgui_checkbox_create(const char* text, rt_bool_t checked);
  26. void rtgui_checkbox_destroy(rtgui_checkbox_t* checkbox);
  27. void rtgui_checkbox_set_checked(rtgui_checkbox_t* checkbox, rt_bool_t checked);
  28. rt_bool_t rtgui_checkbox_get_checked(rtgui_checkbox_t* checkbox);
  29. void rtgui_checkbox_set_onbutton(rtgui_checkbox_t* checkbox, rtgui_onbutton_func_t func);
  30. rt_bool_t rtgui_checkbox_event_handler(struct rtgui_object* object, struct rtgui_event* event);
  31. #endif