Index: sccursor.cpp
===================================================================
--- sccursor.cpp	(revision 2887)
+++ sccursor.cpp	(working copy)
@@ -77,9 +77,9 @@
 //   rewind
 //---------------------------------------------------------
 
-void SCursor::rewind(int type)
+void SCursor::rewind(RewindType type)
       {
-      if (type == 0) {
+      if (type == SCORE_START) {
             _segment   = 0;
             Measure* m = _score->firstMeasure();
             if (_expandRepeat && !_score->repeatList()->isEmpty()){
@@ -95,12 +95,12 @@
                         }
                   }
             }
-      else if (type == 1) {
+      else if (type == SELECTION_START) {
             _segment  = _score->selection().startSegment();
             _staffIdx = _score->selection().staffStart();
             _voice    = 0;
             }
-      else if (type == 2) {
+      else if (type == SELECTION_END) {
             _segment  = _score->selection().endSegment();
             _staffIdx = _score->selection().staffEnd();
             _voice    = 0;
@@ -114,7 +114,95 @@
 Q_DECLARE_METATYPE(Score*);
 Q_DECLARE_METATYPE(Measure*);
 Q_DECLARE_METATYPE(Text*);
+Q_DECLARE_METATYPE(RewindType);
 
+//
+// RewindType
+//
+
+static QScriptValue create_enum_class_helper(
+    QScriptEngine *engine,
+    QScriptEngine::FunctionSignature construct,
+    QScriptEngine::FunctionSignature valueOf,
+    QScriptEngine::FunctionSignature toString)
+{
+    QScriptValue proto = engine->newObject();
+    proto.setProperty(QString::fromLatin1("valueOf"),
+        engine->newFunction(valueOf), QScriptValue::SkipInEnumeration);
+    proto.setProperty(QString::fromLatin1("toString"),
+        engine->newFunction(toString), QScriptValue::SkipInEnumeration);
+    return engine->newFunction(construct, proto, 1);
+}
+
+static const RewindType cursor_RewindType_values[] = {
+    SCORE_START
+    , SELECTION_START
+    , SELECTION_END
+};
+
+static const char * const cursor_RewindType_keys[] = {
+    "scoreStart"
+    , "selectionStart"
+    , "selectionEnd"
+};
+
+static QString cursor_RewindType_toStringHelper(RewindType value)
+{
+    for (int i = 0; i < 3; ++i) {
+        if (cursor_RewindType_values[i] == value)
+            return QString::fromLatin1(cursor_RewindType_keys[i]);
+    }
+    return QString();
+}
+
+static QScriptValue cursor_RewindType_toScriptValue(QScriptEngine *engine, const RewindType &value)
+{
+    QScriptValue clazz = engine->globalObject().property(QString::fromLatin1("Cursor"));
+    return clazz.property(cursor_RewindType_toStringHelper(value));
+}
+
+static void cursor_RewindType_fromScriptValue(const QScriptValue &value, RewindType &out)
+{
+    out = qvariant_cast<RewindType>(value.toVariant());
+}
+
+static QScriptValue construct_Cursor_RewindType(QScriptContext *context, QScriptEngine *engine)
+{
+    int arg = context->argument(0).toInt32();
+    for (int i = 0; i < 3; ++i) {
+        if (cursor_RewindType_values[i] == arg)
+            return qScriptValueFromValue(engine,  static_cast<RewindType>(arg));
+    }
+    return context->throwError(QString::fromLatin1("RewindType(): invalid enum value (%0)").arg(arg));
+}
+
+static QScriptValue cursor_RewindType_valueOf(QScriptContext *context, QScriptEngine *engine)
+{
+    RewindType value = qscriptvalue_cast<RewindType>(context->thisObject());
+    return QScriptValue(engine, static_cast<int>(value));
+}
+
+static QScriptValue cursor_RewindType_toString(QScriptContext *context, QScriptEngine *engine)
+{
+    RewindType value = qscriptvalue_cast<RewindType>(context->thisObject());
+    return QScriptValue(engine, cursor_RewindType_toStringHelper(value));
+}
+
+static QScriptValue create_Cursor_RewindType_class(QScriptEngine *engine, QScriptValue &clazz)
+{
+    QScriptValue ctor = create_enum_class_helper(
+        engine, construct_Cursor_RewindType,
+        cursor_RewindType_valueOf, cursor_RewindType_toString);
+    qScriptRegisterMetaType<RewindType>(engine, cursor_RewindType_toScriptValue,
+        cursor_RewindType_fromScriptValue, ctor.property(QString::fromLatin1("prototype")));
+    for (int i = 0; i < 3; ++i) {
+        clazz.setProperty(QString::fromLatin1(cursor_RewindType_keys[i]),
+            engine->newVariant(qVariantFromValue(cursor_RewindType_values[i])),
+            QScriptValue::ReadOnly | QScriptValue::Undeletable);
+    }
+    return ctor;
+}
+
 static const char* const function_names_cursor[] = {
       "rewind", "eos", "chord", "rest", "measure", "next", "nextMeasure", "putStaffText",  "isChord", "isRest",
       "add", "tick", "time", "staff", "voice", "pageNumber", "pos"
@@ -169,11 +257,11 @@
       switch(_id) {
             case 0:     // "rewind",
                   if (context->argumentCount() == 0) {
-                        cursor->rewind(0);
+                        cursor->rewind(SCORE_START);
                         return context->engine()->undefinedValue();
                         }
                   if (context->argumentCount() == 1) {
-                        int val = context->argument(0).toInteger();
+                        RewindType val = qscriptvalue_cast<RewindType>(context->argument(0));
                         cursor->rewind(val);
                         return context->engine()->undefinedValue();
                         }
@@ -345,7 +433,16 @@
             }
 
       engine->setDefaultPrototype(qMetaTypeId<SCursor*>(), proto);
-      return engine->newFunction(static_Cursor_call, proto, 1);
+       
+      
+      
+      QScriptValue ctor = engine->newFunction(static_Cursor_call, proto, 1);
+      ctor.setData(QScriptValue(engine, uint(0xBABF0000 + 0)));
+
+      ctor.setProperty(QString::fromLatin1("RewindType"),
+          create_Cursor_RewindType_class(engine, ctor));
+      
+      return ctor;
       }
 
 //---------------------------------------------------------
Index: sccursor.h
===================================================================
--- sccursor.h	(revision 2885)
+++ sccursor.h	(working copy)
@@ -37,10 +37,15 @@
 class Measure;
 typedef Measure* MeasurePtr;
 
+enum RewindType {
+  SCORE_START,
+  SELECTION_START,
+  SELECTION_END
+};
+
 //---------------------------------------------------------
 //   SCursor
 //---------------------------------------------------------
-
 class SCursor {
       Score* _score;
       int _staffIdx;
@@ -69,7 +74,7 @@
       bool expandRepeat()                     { return _expandRepeat; }
       Score* score() const                    { return _score;    }
       ChordRest* cr() const;
-      void rewind(int);
+      void rewind(RewindType);
       bool next();
       bool nextMeasure();
       void putStaffText(Text* s);
