groupbox.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * File : groupbox.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. * 2012-07-29 Bernard first version
  13. */
  14. #ifndef __RTGUI_GROUPBOX_H__
  15. #define __RTGUI_GROUPBOX_H__
  16. #include <rtgui/rtgui.h>
  17. #include <rtgui/event.h>
  18. #include <rtgui/widgets/panel.h>
  19. #include <rtgui/widgets/box.h>
  20. DECLARE_CLASS_TYPE(groupbox);
  21. /** Gets the type of a groupbox */
  22. #define RTGUI_GROUPBOX_TYPE (RTGUI_TYPE(groupbox))
  23. /** Casts the object to an groupbox */
  24. #define RTGUI_GROUPBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_GROUPBOX_TYPE, rtgui_groupbox_t))
  25. /** Checks if the object is an rtgui_groupbox */
  26. #define RTGUI_IS_GROUPBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_GROUPBOX_TYPE))
  27. typedef void (*widget_select_t)(struct rtgui_widget *widget, rt_bool_t selected);
  28. /*
  29. * the groupbox widget
  30. *
  31. * The Group Box is a container widget, in which user can place some other widget into it.
  32. * However, the current selected in group box must be notified by user:
  33. * - invoke rtgui_groupbox_select_widget to notify group box the current selected widget;
  34. * - when a widget has been selected, group box invokes groupbox->select_func to change
  35. * the status of widget, for example un-select this widget.
  36. */
  37. struct rtgui_groupbox
  38. {
  39. struct rtgui_panel parent;
  40. char *label;
  41. struct rtgui_box *box;
  42. struct rtgui_widget *selected;
  43. widget_select_t select_func;
  44. rtgui_event_handler_ptr on_selected;
  45. };
  46. typedef struct rtgui_groupbox rtgui_groupbox_t;
  47. rtgui_groupbox_t *rtgui_groupbox_create(const char *label, struct rtgui_rect *rect, int style, widget_select_t select_func);
  48. void rtgui_groupbox_destroy(rtgui_groupbox_t *groupbox);
  49. void rtgui_groupbox_layout(struct rtgui_groupbox *box);
  50. void rtgui_groupbox_add_widget(struct rtgui_groupbox *box, struct rtgui_widget *widget);
  51. void rtgui_groupbox_select_widget(struct rtgui_groupbox *box, struct rtgui_widget *widget);
  52. struct rtgui_widget *rtgui_groupbox_get_selected(struct rtgui_groupbox *box);
  53. rt_bool_t rtgui_groupbox_event_handler(struct rtgui_object *object, struct rtgui_event *event);
  54. rt_inline void rtgui_groupbox_set_onselected(struct rtgui_groupbox *box, rtgui_event_handler_ptr on_selected)
  55. {
  56. RT_ASSERT(box != RT_NULL);
  57. box->on_selected = on_selected;
  58. }
  59. #endif