[Kst] branches/work/kst/1.6/kst/src

Andrew Walker arwalker at sumusltd.com
Wed Nov 14 23:46:45 CET 2007


SVN commit 736825 by arwalker:

allow user to raise/lower objects in the z-order from javaScript

 M  +107 -3    extensions/js/bind_viewobject.cpp  
 M  +41 -0     extensions/js/bind_viewobject.h  
 M  +3 -1      libkstapp/ksteditviewobjectdialog_i.cpp  
 M  +4 -4      libkstapp/kstviewobject.h  


--- branches/work/kst/1.6/kst/src/extensions/js/bind_viewobject.cpp #736824:736825
@@ -73,6 +73,10 @@
   { "resize", &KstBindViewObject::resize },
   { "move", &KstBindViewObject::move },
   { "convertTo", &KstBindViewObject::convertTo },
+  { "raiseToTop", &KstBindViewObject::raiseToTop },
+  { "lowerToBottom", &KstBindViewObject::lowerToBottom },
+  { "raise", &KstBindViewObject::raise },
+  { "lower", &KstBindViewObject::lower },
   { 0L, 0L }
 };
 
@@ -522,7 +526,7 @@
   if (type == "ViewObject") {
     return KJS::Object(new KstBindViewObject(exec, kst_cast<KstViewObject>(_d)));
   }
-  
+
   if (_factoryMap.contains(type)) {
     KstBindViewObject *o = (_factoryMap[type])(exec, kst_cast<KstViewObject>(_d));
     if (o) {
@@ -534,6 +538,106 @@
 }
 
 
+KJS::Value KstBindViewObject::raiseToTop(KJS::ExecState *exec, const KJS::List& args) {
+  if (args.size() != 0) {
+    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires no arguments.");
+    exec->setException(eobj);
+    return KJS::Null();
+  }
+
+  KstViewObjectPtr d = makeViewObject(_d);
+  if (d) {
+    KstReadLocker rl(d);
+
+    d->raiseToTop();
+    KstViewObjectPtr vo = d->topLevelParent();
+    if (vo) {
+      KstTopLevelViewPtr tlv =  kst_cast<KstTopLevelView>(vo);
+      if (tlv) {
+        tlv->paint(KstPainter::P_PAINT);
+      }
+    }
+  }
+
+  return KJS::Undefined();
+}
+
+
+KJS::Value KstBindViewObject::lowerToBottom(KJS::ExecState *exec, const KJS::List& args) {
+  if (args.size() != 0) {
+    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires no arguments.");
+    exec->setException(eobj);
+    return KJS::Null();
+  }
+
+  KstViewObjectPtr d = makeViewObject(_d);
+  if (d) {
+    KstReadLocker rl(d);
+
+    d->lowerToBottom();
+    KstViewObjectPtr vo = d->topLevelParent();
+    if (vo) {
+      KstTopLevelViewPtr tlv =  kst_cast<KstTopLevelView>(vo);
+      if (tlv) {
+        tlv->paint(KstPainter::P_PAINT);
+      }
+    }
+  }
+
+  return KJS::Undefined();
+}
+
+
+KJS::Value KstBindViewObject::raise(KJS::ExecState *exec, const KJS::List& args) {
+  if (args.size() != 0) {
+    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires no arguments.");
+    exec->setException(eobj);
+    return KJS::Null();
+  }
+
+  KstViewObjectPtr d = makeViewObject(_d);
+  if (d) {
+    KstReadLocker rl(d);
+
+    d->raise();
+    KstViewObjectPtr vo = d->topLevelParent();
+    if (vo) {
+      KstTopLevelViewPtr tlv =  kst_cast<KstTopLevelView>(vo);
+      if (tlv) {
+        tlv->paint(KstPainter::P_PAINT);
+      }
+    }
+  }
+
+  return KJS::Undefined();
+}
+
+
+KJS::Value KstBindViewObject::lower(KJS::ExecState *exec, const KJS::List& args) {
+  if (args.size() != 0) {
+    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires no arguments.");
+    exec->setException(eobj);
+    return KJS::Null();
+  }
+
+  KstViewObjectPtr d = makeViewObject(_d);
+  if (d) {
+    KstReadLocker rl(d);
+
+    d->lower();
+    KstViewObjectPtr vo = d->topLevelParent();
+    if (vo) {
+      KstTopLevelViewPtr tlv =  kst_cast<KstTopLevelView>(vo);
+      if (tlv) {
+        tlv->paint(KstPainter::P_PAINT);
+      }
+    }
+  }
+
+  return KJS::Undefined();
+}
+
+
 KJS::Value KstBindViewObject::findChild(KJS::ExecState *exec, const KJS::List& args) {
   if (args.size() != 1) {
     KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly one argument.");
@@ -556,7 +660,7 @@
       return KJS::Object(KstBindViewObject::bind(exec, vop));
     }
   }
-  
+
   return KJS::Null();
 }
 
@@ -586,7 +690,7 @@
   if (!obj) {
     return 0L;
   }
-  
+
   if (_factoryMap.contains(obj->type())) {
     KstBindViewObject *o = (_factoryMap[obj->type()])(exec, obj);
     if (o) {
--- branches/work/kst/1.6/kst/src/extensions/js/bind_viewobject.h #736824:736825
@@ -53,12 +53,14 @@
        @description Resizes the object to the given size, if possible.
     */
     KJS::Value resize(KJS::ExecState *exec, const KJS::List& args);
+
     /* @method move
        @returns ViewObject
        @arg Point pos The position to move the object to.
        @description Moves the object to a new position, if possible.
     */
     KJS::Value move(KJS::ExecState *exec, const KJS::List& args);
+
     /* @method findChild
        @returns ViewObject
        @arg Point pos The relative position to search.
@@ -66,6 +68,7 @@
                     point.  Returns null if there is no child there.
     */
     KJS::Value findChild(KJS::ExecState *exec, const KJS::List& args);
+
     /* @method convertTo
        @returns ViewObject
        @arg string type The type to attempt to convert this object to.
@@ -76,43 +79,78 @@
     */
     KJS::Value convertTo(KJS::ExecState *exec, const KJS::List& args);
 
+    /* @method raiseToTop
+       @returns ViewObject
+       @arg
+       @description Raises the object to the top of the z-order.
+    */
+    KJS::Value raiseToTop(KJS::ExecState *exec, const KJS::List& args);
+
+    /* @method lowerToBottom
+       @returns ViewObject
+       @arg
+       @description Lowers the object to the bottom of the z-order.
+    */
+    KJS::Value lowerToBottom(KJS::ExecState *exec, const KJS::List& args);
+
+    /* @method raise
+       @returns ViewObject
+       @arg
+       @description Raises the object one place in the z-order.
+    */
+    KJS::Value raise(KJS::ExecState *exec, const KJS::List& args);
+
+    /* @method lower
+       @returns ViewObject
+       @arg
+       @description Lowers the object one place in the z-order.
+    */
+    KJS::Value lower(KJS::ExecState *exec, const KJS::List& args);
+
     /* @property Point position
        @description The location of the object relative to its parent.
     */
     void setPosition(KJS::ExecState *exec, const KJS::Value& value);
     KJS::Value position(KJS::ExecState *exec) const;
+
     /* @property Size size
        @description The size of the object in pixels.
     */
     void setSize(KJS::ExecState *exec, const KJS::Value& value);
     KJS::Value size(KJS::ExecState *exec) const;
+
     /* @property boolean transparent
        @description True if this object is transparent.  Not all objects
                     support transparency.
      */
     void setTransparent(KJS::ExecState *exec, const KJS::Value& value);
     KJS::Value transparent(KJS::ExecState *exec) const;
+
     /* @property boolean onGrid
        @description True if the children of this object are on a grid.
      */
     void setOnGrid(KJS::ExecState *exec, const KJS::Value& value);
     KJS::Value onGrid(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;
+
     /* @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
@@ -121,16 +159,19 @@
      */
     void setMaximized(KJS::ExecState *exec, const KJS::Value& value);
     KJS::Value maximized(KJS::ExecState *exec) const;
+
     /* @property Size minimumSize
        @readonly
        @description The minimum size of the view object.
      */
     KJS::Value minimumSize(KJS::ExecState *exec) const;
+
     /* @property string type
        @readonly
        @description A string containing the type of this view object.
      */
     KJS::Value type(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
--- branches/work/kst/1.6/kst/src/libkstapp/ksteditviewobjectdialog_i.cpp #736824:736825
@@ -591,6 +591,9 @@
         if (combo != 0L) {
           int currentItem = combo->currentItem();
           fillPenStyleWidget(combo);
+          if (_editMultipleMode) {
+            combo->insertItem(QString(" "));
+          }
           combo->setCurrentItem(currentItem);
         }
       }
@@ -599,4 +602,3 @@
 }
 
 #include "ksteditviewobjectdialog_i.moc"
-
--- branches/work/kst/1.6/kst/src/libkstapp/kstviewobject.h #736824:736825
@@ -272,6 +272,10 @@
     virtual KstViewObject* copyObjectQuietly(KstViewObject& parent, const QString& name = QString::null) const;
     virtual KstViewObject* copyObjectQuietly() const;
     virtual bool showDialog(KstTopLevelViewPtr invoker, bool isNew);
+    virtual void raiseToTop();
+    virtual void lowerToBottom();
+    virtual void raise();
+    virtual void lower();
 
   protected slots:
     virtual void parentResized();
@@ -281,10 +285,6 @@
 
     /***********  Actions ************/
     virtual void deleteObject();
-    virtual void raiseToTop();
-    virtual void lowerToBottom();
-    virtual void raise();
-    virtual void lower();
     virtual void moveTo(int);
     virtual void copyTo(int);
     virtual void rename();


More information about the Kst mailing list