[Kst] branches/work/kst/1.6/kst/src/extensions/js
Andrew Walker
arwalker at sumusltd.com
Fri Nov 23 22:59:57 CET 2007
SVN commit 740696 by arwalker:
add layout functionality to window in javaScript
M +7 -6 README
M +49 -0 bind_window.cpp
M +9 -0 bind_window.h
--- branches/work/kst/1.6/kst/src/extensions/js/README #740695:740696
@@ -19,11 +19,11 @@
Fit
Filter
Plugin
-Histogram DONE
-Curve DONE
-Image
-Plot needs many more functions/properties
-Window needs many more functions/properties
+Histogram DONE
+Curve DONE
+Image DONE
+Plot
+Window DONE
PlotLabel DONE
PlotLegend DONE
@@ -37,6 +37,8 @@
Arrow DONE
Group
+ELOG DONE
+
KstUIMerge
- Global object used to load XMLUI files for merging.
KstJSUIBuilder loadGUI(string filename);
@@ -88,6 +90,5 @@
1.2.0 issues:
- Curves are stale in concept - split them?
-- No image binding
- "delete" support - in order drop references?
- Make .position and .size directly manipulated?
--- branches/work/kst/1.6/kst/src/extensions/js/bind_window.cpp #740695:740696
@@ -105,6 +105,7 @@
{ "name", &KstBindWindow::setWindowName, &KstBindWindow::windowName },
{ "plots", 0L, &KstBindWindow::plots },
{ "view", 0L, &KstBindWindow::view },
+ { "columns", &KstBindWindow::setColumns, &KstBindWindow::columns },
{ 0L, 0L, 0L }
};
@@ -240,6 +241,54 @@
}
+void KstBindWindow::setColumns(KJS::ExecState *exec, const KJS::Value& value) {
+ unsigned cols = 1;
+ if (value.type() != KJS::NumberType || !value.toUInt32(cols)) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+
+ if (!_d) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return;
+ }
+
+ KstTopLevelViewPtr tlv = _d->view();
+ if( !tlv) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return;
+ }
+
+ KstWriteLocker wl(tlv);
+ tlv->setOnGrid(true);
+ tlv->setColumns(cols);
+ tlv->cleanup(cols);
+ tlv->paint(KstPainter::P_PAINT);
+}
+
+
+KJS::Value KstBindWindow::columns(KJS::ExecState *exec) const {
+ if (!_d) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+
+ KstTopLevelViewPtr tlv = _d->view();
+ if( !tlv) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+
+ KstReadLocker rl(tlv);
+ return KJS::Number(tlv->columns());
+}
+
+
KJS::Value KstBindWindow::plots(KJS::ExecState *exec) const {
return KJS::Object(new KstBindPlotCollection(exec, _d));
}
--- branches/work/kst/1.6/kst/src/extensions/js/bind_window.h #740695:740696
@@ -61,17 +61,26 @@
*/
void setWindowName(KJS::ExecState *exec, const KJS::Value& value);
KJS::Value windowName(KJS::ExecState *exec) const;
+
/* @property PlotCollection plots
@description The list of plots contained in this window, flattened.
This property is subject to change! Do not rely on it for
production code yet!
*/
KJS::Value plots(KJS::ExecState *exec) const;
+
/* @property ViewObject view
@description The view object for this window.
*/
KJS::Value view(KJS::ExecState *exec) const;
+ /* @property number columns
+ @description The number of columns the children are organized into. If
+ this value is modified, <i>onGrid</i> is set to true.
+ */
+ void setColumns(KJS::ExecState *exec, const KJS::Value& value);
+ KJS::Value columns(KJS::ExecState *exec) const;
+
protected:
KstBindWindow(int id);
void addBindings(KJS::ExecState *exec, KJS::Object& obj);
More information about the Kst
mailing list