notebook.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef __RTGUI_NOTEBOOK_H__
  2. #define __RTGUI_NOTEBOOK_H__
  3. #include <rtgui/rtgui.h>
  4. #include <rtgui/image.h>
  5. #include <rtgui/widgets/widget.h>
  6. DECLARE_CLASS_TYPE(notebook);
  7. /** Gets the type of a notebook */
  8. #define RTGUI_NOTEBOOK_TYPE (RTGUI_TYPE(notebook))
  9. /** Casts the object to a notebook control */
  10. #define RTGUI_NOTEBOOK(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_NOTEBOOK_TYPE, struct rtgui_notebook))
  11. /** Checks if the object is a notebook control */
  12. #define RTGUI_IS_NOTEBOOK(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_NOTEBOOK_TYPE))
  13. #define RTGUI_NOTEBOOK_TOP 0x00
  14. #define RTGUI_NOTEBOOK_BOTTOM 0x01
  15. #define RTGUI_NOTEBOOK_NOTAB 0x02
  16. #define RTGUI_NOTEBOOK_LEFT 0x03
  17. #define RTGUI_NOTEBOOK_RIGHT 0x04
  18. struct rtgui_notebook_tab;
  19. struct rtgui_notebook
  20. {
  21. struct rtgui_widget parent;
  22. rt_uint8_t flag;
  23. /* widget private data */
  24. struct rtgui_notebook_tab *childs;
  25. rt_uint16_t count;
  26. rt_int16_t current;
  27. rt_uint16_t tab_w, tab_h;
  28. };
  29. struct rtgui_notebook* rtgui_notebook_create(const rtgui_rect_t* rect, rt_uint8_t style);
  30. void rtgui_notebook_destroy(struct rtgui_notebook* notebook);
  31. rt_inline void rtgui_notebook_set_tab_height(struct rtgui_notebook *notebook, rt_uint16_t height)
  32. {
  33. RT_ASSERT(notebook != RT_NULL);
  34. notebook->tab_h = height;
  35. }
  36. rt_inline void rtgui_notebook_set_tab_width(struct rtgui_notebook *notebook, rt_uint16_t width)
  37. {
  38. RT_ASSERT(notebook != RT_NULL);
  39. notebook->tab_w = width;
  40. }
  41. void rtgui_notebook_add(struct rtgui_notebook* notebook, const char* label, struct rtgui_widget* child);
  42. #ifdef RTGUI_USING_NOTEBOOK_IMAGE
  43. void rtgui_notebook_add_image(struct rtgui_notebook* notebook, const char* label, struct rtgui_widget* child,
  44. struct rtgui_image *pressed_image, struct rtgui_image *unpressed_image);
  45. #endif
  46. void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index);
  47. struct rtgui_widget* rtgui_notebook_get_current(struct rtgui_notebook* notebook);
  48. rt_int16_t rtgui_notebook_get_current_index(struct rtgui_notebook* notebook);
  49. int rtgui_notebook_get_count(struct rtgui_notebook* notebook);
  50. void rtgui_notebook_get_client_rect(struct rtgui_notebook* notebook, struct rtgui_rect *rect);
  51. void rtgui_notebook_set_current(struct rtgui_notebook* notebook, struct rtgui_widget* child);
  52. void rtgui_notebook_set_current_by_index(struct rtgui_notebook* notebook, rt_uint16_t index);
  53. struct rtgui_widget* rtgui_notebook_get_widget_at(struct rtgui_notebook* notebook, rt_uint16_t index);
  54. rt_bool_t rtgui_notebook_event_handler(struct rtgui_object* widget, struct rtgui_event* event);
  55. #endif