[Kst] extragear/graphics/kst/kst/extensions/js
George Staikos
staikos at kde.org
Sun May 29 18:08:03 CEST 2005
SVN commit 419510 by staikos:
more properties and methods for view object
M +2 -0 TODO
M +53 -0 bind_viewobject.cpp
M +18 -0 bind_viewobject.h
--- trunk/extragear/graphics/kst/kst/extensions/js/TODO #419509:419510
@@ -4,6 +4,8 @@
- "delete" support - in order drop references?
- Possible to create duplicate tagnames with current script code
- use inheritence to make it less tedious to implement bindings
+ - .dynamicCast() and .asViewObject() for instance?
+ - C++ inheritence?
- Plots are flattened from inside windows - will be a problem when plot groups
are accessible - what to do?
- Constructors should not return KJS::Object() if there is a type error - or
--- trunk/extragear/graphics/kst/kst/extensions/js/bind_viewobject.cpp #419509:419510
@@ -73,6 +73,7 @@
static ViewObjectBindings viewObjectBindings[] = {
+ { "findChild", &KstBindViewObject::findChild },
{ 0L, 0L }
};
@@ -86,6 +87,8 @@
{ "color", &KstBindViewObject::setColor, &KstBindViewObject::color },
{ "backgroundColor", &KstBindViewObject::setBackgroundColor, &KstBindViewObject::backgroundColor },
{ "children", 0L, &KstBindViewObject::children },
+ { "minimumSize", 0L, &KstBindViewObject::minimumSize },
+ { "type", 0L, &KstBindViewObject::type },
{ 0L, 0L, 0L }
};
@@ -351,4 +354,54 @@
}
+KJS::Value KstBindViewObject::findChild(KJS::ExecState *exec, const KJS::List& args) {
+ if (!_d) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+
+ if (args.size() != 1) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly two arguments.");
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+
+ if (args[0].type() != KJS::ObjectType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+
+ KstBindPoint *imp = dynamic_cast<KstBindPoint*>(args[0].toObject(exec).imp());
+ if (!imp) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+
+ KstViewObjectPtr vop = _d->findChild(QPoint(int(imp->_x), int(imp->_y))); // FIXME
+
+ if (vop) {
+ KJS::Object(new KstBindViewObject(exec, vop));
+ }
+
+ return KJS::Null();
+}
+
+
+KJS::Value KstBindViewObject::minimumSize(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+ KstReadLocker rl(_d);
+ return KJS::Object(new KstBindSize(exec, _d->minimumSize()));
+}
+
+
+KJS::Value KstBindViewObject::type(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+ KstReadLocker rl(_d);
+ return KJS::String(_d->type());
+}
+
+
// vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/extensions/js/bind_viewobject.h #419509:419510
@@ -45,6 +45,14 @@
KJS::ReferenceList propList(KJS::ExecState *exec, bool recursive = true);
bool hasProperty(KJS::ExecState *exec, const KJS::Identifier& propertyName) const;
+ /* @method findChild
+ @returns ViewObject
+ @arg Point pos The relative position to search.
+ @description Finds the topmost child of this view object at the given
+ point. Returns null if there is no child there.
+ */
+ KJS::Value findChild(KJS::ExecState *exec, const KJS::List& args);
+
/* @property Point position
@description The location of the object relative to its parent.
*/
@@ -89,6 +97,16 @@
*/
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
More information about the Kst
mailing list