plot_curve.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * File : plot.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2012, 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-09-03 Grissiom first version
  13. */
  14. #include <rtgui/color.h>
  15. #include <rtgui/widgets/widget.h>
  16. #include <rtgui/widgets/plot_curve.h>
  17. static void _rtgui_plot_curve_constructor(struct rtgui_plot_curve *curve)
  18. {
  19. curve->length = 0;
  20. curve->x_data = curve->y_data = RT_NULL;
  21. curve->color = red;
  22. /* init widget and set event handler */
  23. rtgui_object_set_event_handler(RTGUI_OBJECT(curve), RT_NULL);
  24. }
  25. static void _rtgui_plot_curve_destructor(struct rtgui_plot_curve *curve)
  26. {
  27. /* nothing to do so far. */
  28. }
  29. DEFINE_CLASS_TYPE(plot_curve, "plot_curve",
  30. RTGUI_OBJECT_TYPE,
  31. _rtgui_plot_curve_constructor,
  32. _rtgui_plot_curve_destructor,
  33. sizeof(struct rtgui_plot_curve));
  34. struct rtgui_plot_curve *rtgui_plot_curve_create(void)
  35. {
  36. return (struct rtgui_plot_curve*)rtgui_object_create(RTGUI_PLOT_CURVE_TYPE);
  37. }
  38. RTM_EXPORT(rtgui_plot_curve_create);
  39. void rtgui_plot_curve_destroy(struct rtgui_plot_curve *curve)
  40. {
  41. rtgui_object_destroy(RTGUI_OBJECT(curve));
  42. }
  43. RTM_EXPORT(rtgui_plot_curve_destroy);