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

George Staikos staikos at kde.org
Sun May 29 14:56:58 CEST 2005


SVN commit 419435 by staikos:

Added more methods (colors, maximized)


 M  +56 -0     bind_viewobject.cpp  
 M  +18 -0     bind_viewobject.h  


--- trunk/extragear/graphics/kst/kst/extensions/js/bind_viewobject.cpp #419434:419435
@@ -83,6 +83,8 @@
   { "position", &KstBindViewObject::setPosition, &KstBindViewObject::position },
   { "onGrid", &KstBindViewObject::setOnGrid, &KstBindViewObject::onGrid },
   { "columns", &KstBindViewObject::setColumns, &KstBindViewObject::columns },
+  { "color", &KstBindViewObject::setColor, &KstBindViewObject::color },
+  { "backgroundColor", &KstBindViewObject::setBackgroundColor, &KstBindViewObject::backgroundColor },
   { "children", 0L, &KstBindViewObject::children },
   { 0L, 0L, 0L }
 };
@@ -196,6 +198,60 @@
 }
 
 
+void KstBindViewObject::setColor(KJS::ExecState *exec, const KJS::Value& value) {
+  QVariant cv = KJSEmbed::convertToVariant(exec, value);
+  if (!cv.canCast(QVariant::Color)) {
+    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+    exec->setException(eobj);
+    return;
+  }
+  KstWriteLocker rl(_d);
+  _d->setForegroundColor(cv.toColor());
+}
+
+
+KJS::Value KstBindViewObject::color(KJS::ExecState *exec) const {
+  KstReadLocker rl(_d);
+  return KJSEmbed::convertToValue(exec, _d->foregroundColor());
+}
+
+
+void KstBindViewObject::setBackgroundColor(KJS::ExecState *exec, const KJS::Value& value) {
+  QVariant cv = KJSEmbed::convertToVariant(exec, value);
+  if (!cv.canCast(QVariant::Color)) {
+    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+    exec->setException(eobj);
+    return;
+  }
+  KstWriteLocker rl(_d);
+  _d->setBackgroundColor(cv.toColor());
+}
+
+
+KJS::Value KstBindViewObject::backgroundColor(KJS::ExecState *exec) const {
+  KstReadLocker rl(_d);
+  return KJSEmbed::convertToValue(exec, _d->backgroundColor());
+}
+
+
+void KstBindViewObject::setMaximized(KJS::ExecState *exec, const KJS::Value& value) {
+  if (value.type() != KJS::BooleanType) {
+    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+    exec->setException(eobj);
+    return;
+  }
+  KstWriteLocker wl(_d);
+  _d->setMaximized(value.toBoolean(exec));
+}
+
+
+KJS::Value KstBindViewObject::maximized(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+  KstReadLocker rl(_d);
+  return KJS::Boolean(_d->maximized());
+}
+
+
 void KstBindViewObject::setSize(KJS::ExecState *exec, const KJS::Value& value) {
   if (value.type() != KJS::ObjectType) {
     KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
--- trunk/extragear/graphics/kst/kst/extensions/js/bind_viewobject.h #419434:419435
@@ -71,6 +71,24 @@
      */
     void setColumns(KJS::ExecState *exec, const KJS::Value& value);
     KJS::Value columns(KJS::ExecState *exec) const;
+    /* @property string color
+       @description The foreground color for this object.
+     */
+    void setColor(KJS::ExecState *exec, const KJS::Value& value);
+    KJS::Value color(KJS::ExecState *exec) const;
+    /* @property string backgroundColor
+       @description The background color for this object.
+     */
+    void setBackgroundColor(KJS::ExecState *exec, const KJS::Value& value);
+    KJS::Value backgroundColor(KJS::ExecState *exec) const;
+    /* @property boolean maximized
+       @description If true, this object is maximized relative to its parent.
+                    This is a temporary state whereby the plot uses all the
+                    space available in the parent but can be restored to
+                    <i>normal</i> size again.
+     */
+    void setMaximized(KJS::ExecState *exec, const KJS::Value& value);
+    KJS::Value maximized(KJS::ExecState *exec) const;
     /* @property ViewObjectCollection children
        @description The list of all children of this view object in z-order
                     from the furthest back to the closest to the top.  This


More information about the Kst mailing list