scrollbar.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * File : scrollbar.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2010, 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. * 2010-08-09 Bernard first version
  13. */
  14. #ifndef __RTGUI_SCROLLBAR_H__
  15. #define __RTGUI_SCROLLBAR_H__
  16. #include <rtgui/rtgui.h>
  17. #include <rtgui/widgets/widget.h>
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /** Gets the type of a scrollbar */
  22. #define RTGUI_SCROLLBAR_TYPE (rtgui_scrollbar_type_get())
  23. /** Casts the object to an rtgui_scrollbar */
  24. #define RTGUI_SCROLLBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SCROLLBAR_TYPE, rtgui_scrollbar_t))
  25. /** Checks if the object is an rtgui_scrollbar */
  26. #define RTGUI_IS_SCROLLBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SCROLLBAR_TYPE))
  27. #define RTGUI_DEFAULT_SB_WIDTH 16
  28. /* scrollbar status/positions*/
  29. #define SBAR_UNKNOWN 0x0000
  30. #define SBAR_LEFTARROW 0x0001 //在向左按钮上
  31. #define SBAR_RIGHTARROW 0x0002 //在向右按钮上
  32. #define SBAR_LEFTSPACE 0x0004 //在活动块左侧空白处
  33. #define SBAR_RIGHTSPACE 0x0008 //在活动块右侧空白处
  34. #define SBAR_HORZTHUMB 0x0010 //活动块水平滑动
  35. #define SBAR_UPARROW 0x0020 //状态向上
  36. #define SBAR_DOWNARROW 0x0040 //状态向下
  37. #define SBAR_UPSPACE 0x0080 //在活动块上侧空白处
  38. #define SBAR_DOWNSPACE 0x0100 //在活动块下侧空白处
  39. #define SBAR_VERTTHUMB 0x0200 //活动块垂直滑动
  40. #define SBAR_UPTHUMB 0x0400 //活动块向上滑动
  41. #define SBAR_DOWNTHUMB 0x0800 //活动块向下滑动
  42. #define SBAR_LEFTTHUMB 0x1000 //活动块向左滑动
  43. #define SBAR_RIGHTTHUMB 0x2000 //活动块向右滑动
  44. struct rtgui_scrollbar
  45. {
  46. /* inherit from widget */
  47. rtgui_widget_t parent;
  48. rt_uint32_t orient;
  49. rt_uint32_t status;
  50. /* page_step = display lines of scrollbar */
  51. /* thumb_len = line_step * page_step / (page_step - (button width * 2)) */
  52. rt_int16_t line_step, page_step;
  53. rt_int16_t value, thumb_len,thumb_w;
  54. /* position 1:1 width of scrollbar */
  55. rt_int16_t count;
  56. PVOID widgetlnk;//链接的控件
  57. rt_bool_t (*on_scroll) (PVOID wdt, rtgui_event_t* event);
  58. };
  59. typedef struct rtgui_scrollbar rtgui_scrollbar_t;
  60. rtgui_type_t *rtgui_scrollbar_type_get(void);
  61. rtgui_scrollbar_t* rtgui_scrollbar_create(PVOID wdt,int left,int top,int w,int len,int orient);
  62. void rtgui_scrollbar_destroy(rtgui_scrollbar_t* bar);
  63. void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *erect);
  64. void rtgui_scrollbar_set_range(rtgui_scrollbar_t* bar, int count);
  65. void rtgui_scrollbar_set_value(rtgui_scrollbar_t* bar, rt_int16_t value);
  66. void rtgui_scrollbar_set_onscroll(rtgui_scrollbar_t* bar, rtgui_event_handler_ptr handler);
  67. void rtgui_scrollbar_set_orientation(rtgui_scrollbar_t* bar, int orient);
  68. void rtgui_scrollbar_set_page_step(rtgui_scrollbar_t* bar, int step);
  69. void rtgui_scrollbar_set_line_step(rtgui_scrollbar_t* bar, int step);
  70. rt_bool_t rtgui_scrollbar_event_handler(PVOID wdt, rtgui_event_t* event);
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif