[Kst] extragear/graphics/kst/kst/extensions/js

George Staikos staikos at kde.org
Sat Jan 14 19:38:22 CET 2006


SVN commit 498117 by staikos:

add axis binding


 M  +1 -0      Makefile.am  
 A             bind_axis.cpp   [License: GPL (v2+)]
 A             bind_axis.h   [License: GPL (v2+)]
 M  +9 -36     bind_plot.cpp  
 M  +8 -8      bind_plot.h  


--- trunk/extragear/graphics/kst/kst/extensions/js/Makefile.am #498116:498117
@@ -45,6 +45,7 @@
 			    bind_point.cpp \
 			    bind_window.cpp \
 			    bind_plot.cpp \
+			    bind_axis.cpp \
 			    bind_collection.cpp \
 			    bind_plotcollection.cpp \
 			    bind_curvecollection.cpp \
--- trunk/extragear/graphics/kst/kst/extensions/js/bind_plot.cpp #498116:498117
@@ -16,6 +16,7 @@
  ***************************************************************************/
 
 #include "bind_plot.h"
+#include "bind_axis.h"
 #include "bind_curvecollection.h"
 #include "bind_legend.h"
 
@@ -114,8 +115,8 @@
   { "curves", 0L, &KstBindPlot::curves },
   { "legend", 0L, &KstBindPlot::legend },
   { "topLabel", &KstBindPlot::setTopLabel, &KstBindPlot::topLabel },
-  { "xLabel", &KstBindPlot::setXLabel, &KstBindPlot::xLabel },
-  { "yLabel", &KstBindPlot::setYLabel, &KstBindPlot::yLabel },
+  { "xAxis", 0L, &KstBindPlot::xAxis },
+  { "yAxis", 0L, &KstBindPlot::yAxis },
   { "tied", &KstBindPlot::setTied, &KstBindPlot::tied },
   { 0L, 0L, 0L }
 };
@@ -275,53 +276,25 @@
 }
 
 
-void KstBindPlot::setXLabel(KJS::ExecState *exec, const KJS::Value& value) {
-  if (value.type() != KJS::StringType) {
-    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
-    exec->setException(eobj);
-    return;
-  }
-  Kst2DPlotPtr d = makePlot(_d);
-  if (d) {
-    KstWriteLocker wl(d);
-    d->xLabel()->setText(value.toString(exec).qstring());
-  }
-}
-
-
-KJS::Value KstBindPlot::xLabel(KJS::ExecState *exec) const {
+KJS::Value KstBindPlot::xAxis(KJS::ExecState *exec) const {
   Q_UNUSED(exec)
   Kst2DPlotPtr d = makePlot(_d);
   if (d) {
     KstReadLocker rl(d);
-    return KJS::String(d->xLabel()->text());
+    return KJS::Object(new KstBindAxis(exec, d, true));
   }
-  return KJS::String();
+  return KJS::Object();
 }
 
 
-void KstBindPlot::setYLabel(KJS::ExecState *exec, const KJS::Value& value) {
-  if (value.type() != KJS::StringType) {
-    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
-    exec->setException(eobj);
-    return;
-  }
-  Kst2DPlotPtr d = makePlot(_d);
-  if (d) {
-    KstWriteLocker wl(d);
-    d->yLabel()->setText(value.toString(exec).qstring());
-  }
-}
-
-
-KJS::Value KstBindPlot::yLabel(KJS::ExecState *exec) const {
+KJS::Value KstBindPlot::yAxis(KJS::ExecState *exec) const {
   Q_UNUSED(exec)
   Kst2DPlotPtr d = makePlot(_d);
   if (d) {
     KstReadLocker rl(d);
-    return KJS::String(d->yLabel()->text());
+    return KJS::Object(new KstBindAxis(exec, d, false));
   }
-  return KJS::String();
+  return KJS::Object();
 }
 
 
--- trunk/extragear/graphics/kst/kst/extensions/js/bind_plot.h #498116:498117
@@ -73,16 +73,16 @@
     */
     void setTopLabel(KJS::ExecState *exec, const KJS::Value& value);
     KJS::Value topLabel(KJS::ExecState *exec) const;
-    /* @property string xLabel
-       @description The X-axis label for this plot.
+    /* @property Axis xAxis
+       @readonly
+       @description The X-axis for this plot.
     */
-    void setXLabel(KJS::ExecState *exec, const KJS::Value& value);
-    KJS::Value xLabel(KJS::ExecState *exec) const;
-    /* @property string yLabel
-       @description The Y-axis label for this plot.
+    KJS::Value xAxis(KJS::ExecState *exec) const;
+    /* @property Axis yAxis
+       @readonly
+       @description The Y-axis for this plot.
     */
-    void setYLabel(KJS::ExecState *exec, const KJS::Value& value);
-    KJS::Value yLabel(KJS::ExecState *exec) const;
+    KJS::Value yAxis(KJS::ExecState *exec) const;
     /* @property boolean tied
        @description True if the plot zoom state is tied.
     */


More information about the Kst mailing list