[Kst] branches/work/kst/viewpaint/kst/kst/extensions/js
George Staikos
staikos at kde.org
Sun Jan 29 20:09:55 CET 2006
SVN commit 503635 by staikos:
update the bindings to add the methods that were lost in the base class change
M +55 -0 bind_box.cpp
M +10 -0 bind_box.h
--- branches/work/kst/viewpaint/kst/kst/extensions/js/bind_box.cpp #503634:503635
@@ -105,6 +105,8 @@
static BoxProperties boxProperties[] = {
{ "xRound", &KstBindBox::setXRound, &KstBindBox::xRound },
{ "yRound", &KstBindBox::setYRound, &KstBindBox::yRound },
+ { "borderWidth", &KstBindBox::setBorderWidth, &KstBindBox::borderWidth },
+ { "borderColor", &KstBindBox::setBorderColor, &KstBindBox::borderColor },
{ 0L, 0L, 0L }
};
@@ -319,6 +321,59 @@
}
+void KstBindBox::setBorderWidth(KJS::ExecState *exec, const KJS::Value& value) {
+ unsigned borderWidth = 0;
+ if (value.type() != KJS::NumberType || !value.toUInt32(borderWidth)) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+ KstViewBoxPtr d = makeBox(_d);
+ if (d) {
+ KstWriteLocker wl(d);
+ d->setBorderWidth(borderWidth);
+ KstApp::inst()->paintAll(KstPainter::P_PAINT);
+ }
+}
+
+
+KJS::Value KstBindBox::borderWidth(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+ KstViewBoxPtr d = makeBox(_d);
+ if (d) {
+ KstReadLocker rl(d);
+ return KJS::Number(d->borderWidth());
+ }
+ return KJS::Number(0);
+}
+
+
+void KstBindBox::setBorderColor(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;
+ }
+ KstViewBoxPtr d = makeBox(_d);
+ if (d) {
+ KstWriteLocker rl(d);
+ d->setBorderColor(cv.toColor());
+ KstApp::inst()->paintAll(KstPainter::P_PAINT);
+ }
+}
+
+
+KJS::Value KstBindBox::borderColor(KJS::ExecState *exec) const {
+ KstViewBoxPtr d = makeBox(_d);
+ if (d) {
+ KstReadLocker rl(d);
+ return KJSEmbed::convertToValue(exec, d->borderColor());
+ }
+ return KJSEmbed::convertToValue(exec, QColor());
+}
+
+
#undef makeBox
// vim: ts=2 sw=2 et
--- branches/work/kst/viewpaint/kst/kst/extensions/js/bind_box.h #503634:503635
@@ -79,6 +79,16 @@
*/
void setCornerStyle(KJS::ExecState *exec, const KJS::Value& value);
KJS::Value cornerStyle(KJS::ExecState *exec) const;
+ /* @property int borderWidth
+ @description The width in pixels of the border.
+ */
+ void setBorderWidth(KJS::ExecState *exec, const KJS::Value& value);
+ KJS::Value borderWidth(KJS::ExecState *exec) const;
+ /* @property string borderColor
+ @description The border color for this object.
+ */
+ void setBorderColor(KJS::ExecState *exec, const KJS::Value& value);
+ KJS::Value borderColor(KJS::ExecState *exec) const;
protected:
KstBindBox(int id, const char *name = 0L);
More information about the Kst
mailing list