summaryrefslogtreecommitdiff
path: root/components/rtgui/widgets/plot_curve.c
diff options
context:
space:
mode:
author[email protected] <[email protected]>2012-11-26 02:42:52 +0000
committer[email protected] <[email protected]>2012-11-26 02:42:52 +0000
commit62447b2cd84b529f7dbf6712c29d7ac4ff0c1e12 (patch)
tree399aa1bbc0d4c632d7dc2804ed76e5c62b5cec27 /components/rtgui/widgets/plot_curve.c
parent9789907ca1b4c43ee34fac6e94e5a48f76aaca3c (diff)
sync RTGUI with github(https://github.com/RT-Thread/RTGUI) 9ae08379da5b698d6facc40bd0415de2e254ae9c
As always, full log is in GitHub. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2449 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/rtgui/widgets/plot_curve.c')
-rw-r--r--components/rtgui/widgets/plot_curve.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/components/rtgui/widgets/plot_curve.c b/components/rtgui/widgets/plot_curve.c
index 4eccbd5209..11b620da65 100644
--- a/components/rtgui/widgets/plot_curve.c
+++ b/components/rtgui/widgets/plot_curve.c
@@ -13,14 +13,14 @@
*/
#include <rtgui/color.h>
+#include <rtgui/rtgui_mv_model.h>
#include <rtgui/widgets/widget.h>
#include <rtgui/widgets/plot_curve.h>
static void _rtgui_plot_curve_constructor(struct rtgui_plot_curve *curve)
{
- curve->length = 0;
- curve->x_data = curve->y_data = RT_NULL;
curve->color = red;
+ curve->max_x = curve->min_x = curve->max_y = curve->min_y = 0;
/* init widget and set event handler */
rtgui_object_set_event_handler(RTGUI_OBJECT(curve), RT_NULL);
@@ -32,20 +32,56 @@ static void _rtgui_plot_curve_destructor(struct rtgui_plot_curve *curve)
}
DEFINE_CLASS_TYPE(plot_curve, "plot_curve",
- RTGUI_OBJECT_TYPE,
+ RTGUI_MV_MODEL_TYPE,
_rtgui_plot_curve_constructor,
_rtgui_plot_curve_destructor,
sizeof(struct rtgui_plot_curve));
struct rtgui_plot_curve *rtgui_plot_curve_create(void)
{
- return (struct rtgui_plot_curve*)rtgui_object_create(RTGUI_PLOT_CURVE_TYPE);
+ struct rtgui_plot_curve *curve;
+
+ curve = RTGUI_PLOT_CURVE(rtgui_object_create(RTGUI_PLOT_CURVE_TYPE));
+ if (curve == RT_NULL)
+ return RT_NULL;
+
+ if (rtgui_mv_model_set_dimension(RTGUI_MV_MODEL(curve), 2) != RT_EOK)
+ {
+ rtgui_object_destroy(RTGUI_OBJECT(curve));
+ return RT_NULL;
+ }
+
+ return curve;
}
RTM_EXPORT(rtgui_plot_curve_create);
void rtgui_plot_curve_destroy(struct rtgui_plot_curve *curve)
{
- rtgui_object_destroy(RTGUI_OBJECT(curve));
+ rtgui_mv_model_destroy(RTGUI_MV_MODEL(curve));
}
RTM_EXPORT(rtgui_plot_curve_destroy);
+void rtgui_plot_curve_set_x(struct rtgui_plot_curve *curve, void *p)
+{
+ rtgui_mv_model_set_data(RTGUI_MV_MODEL(curve), 0, p);
+}
+RTM_EXPORT(rtgui_plot_curve_set_x);
+
+void *rtgui_plot_curve_get_x(struct rtgui_plot_curve *curve)
+{
+ return rtgui_mv_model_get_data(RTGUI_MV_MODEL(curve), 0);
+}
+RTM_EXPORT(rtgui_plot_curve_get_x);
+
+void rtgui_plot_curve_set_y(struct rtgui_plot_curve *curve, void *p)
+{
+ rtgui_mv_model_set_data(RTGUI_MV_MODEL(curve), 1, p);
+}
+RTM_EXPORT(rtgui_plot_curve_set_y);
+
+void *rtgui_plot_curve_get_y(struct rtgui_plot_curve *curve)
+{
+ return rtgui_mv_model_get_data(RTGUI_MV_MODEL(curve), 1);
+}
+RTM_EXPORT(rtgui_plot_curve_get_y);
+