[Kst] extragear/graphics/kst/kst/extensions/js
George Staikos
staikos at kde.org
Sun Jan 15 00:16:28 CET 2006
SVN commit 498207 by staikos:
add minorTickCount and majorTickDensity
M +112 -0 bind_axis.cpp
M +18 -0 bind_axis.h
--- trunk/extragear/graphics/kst/kst/extensions/js/bind_axis.cpp #498206:498207
@@ -70,6 +70,8 @@
{ "outerTicks", &KstBindAxis::setOuterTicks, &KstBindAxis::outerTicks },
{ "majorGridColor", &KstBindAxis::setMajorGridColor, &KstBindAxis::majorGridColor },
{ "minorGridColor", &KstBindAxis::setMinorGridColor, &KstBindAxis::minorGridColor },
+ { "minorTickCount", &KstBindAxis::setMinorTickCount, &KstBindAxis::minorTickCount },
+ { "majorTickDensity", &KstBindAxis::setMajorTickDensity, &KstBindAxis::majorTickDensity },
{ "label", &KstBindAxis::setLabel, &KstBindAxis::label },
{ "type", 0L, &KstBindAxis::type },
{ 0L, 0L, 0L }
@@ -604,4 +606,114 @@
}
+KJS::Value KstBindAxis::minorTickCount(KJS::ExecState *exec) const {
+ if (!_d) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+ KstReadLocker rl(_d);
+ if (_xAxis) {
+ return KJS::Number(_d->xMinorTicks());
+ } else {
+ return KJS::Number(_d->yMinorTicks());
+ }
+}
+
+
+void KstBindAxis::setMinorTickCount(KJS::ExecState *exec, const KJS::Value& value) {
+ if (!_d) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return;
+ }
+ if (value.type() != KJS::NumberType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+
+ KstWriteLocker rl(_d);
+ if (_xAxis) {
+ _d->setXMinorTicks(value.toInt32(exec));
+ } else {
+ _d->setYMinorTicks(value.toInt32(exec));
+ }
+}
+
+
+KJS::Value KstBindAxis::majorTickDensity(KJS::ExecState *exec) const {
+ if (!_d) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+ KstReadLocker rl(_d);
+ int i = 0;
+ if (_xAxis) {
+ i = _d->xMajorTicks();
+ } else {
+ i = _d->yMajorTicks();
+ }
+ switch (i) {
+ case 2:
+ i = 0;
+ break;
+ case 10:
+ i = 2;
+ break;
+ case 15:
+ i = 3;
+ break;
+ case 5:
+ default:
+ i = 1;
+ break;
+ }
+
+ return KJS::Number(i);
+}
+
+
+void KstBindAxis::setMajorTickDensity(KJS::ExecState *exec, const KJS::Value& value) {
+ if (!_d) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return;
+ }
+ if (value.type() != KJS::NumberType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+
+ int i = value.toInt32(exec);
+ switch (i) {
+ case 0:
+ i = 2;
+ break;
+ case 1:
+ i = 5;
+ break;
+ case 2:
+ i = 10;
+ break;
+ case 3:
+ i = 15;
+ break;
+ default:
+ KJS::Object eobj = KJS::Error::create(exec, KJS::RangeError);
+ exec->setException(eobj);
+ return;
+ }
+
+ KstWriteLocker rl(_d);
+ if (_xAxis) {
+ _d->setXMajorTicks(value.toInt32(exec));
+ } else {
+ _d->setYMajorTicks(value.toInt32(exec));
+ }
+}
+
+
// vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/extensions/js/bind_axis.h #498206:498207
@@ -114,6 +114,24 @@
*/
void setMinorGridColor(KJS::ExecState *exec, const KJS::Value& value);
KJS::Value minorGridColor(KJS::ExecState *exec) const;
+ /* @property number minorTickCount
+ @description The number of minor ticks between two major ticks. The
+ special value -1 forces Kst to determine this automatically.
+ */
+ void setMinorTickCount(KJS::ExecState *exec, const KJS::Value& value);
+ KJS::Value minorTickCount(KJS::ExecState *exec) const;
+ /* @property number majorTickDensity
+ @description The density of major tick markers along this axis. Value
+ must be one of:
+ <ul>
+ <li>0 - Coarse</li>
+ <li>1 - Default</li>
+ <li>2 - Fine</li>
+ <li>3 - Very Fine</li>
+ </ul>
+ */
+ void setMajorTickDensity(KJS::ExecState *exec, const KJS::Value& value);
+ KJS::Value majorTickDensity(KJS::ExecState *exec) const;
protected:
KstBindAxis(int id);
More information about the Kst
mailing list