Handle<Value> TiUIScrollableView::_scrollToView(void* userContext, TiObject*, const Arguments& args)
{
    TiUIScrollableView* self = static_cast<TiUIScrollableView*>(userContext);
    NativeScrollableViewObject* scrollableView = static_cast<NativeScrollableViewObject*>(self->getNativeObject());

    bool animated = true;
    if(args.Length() > 1) {
        Local<Boolean> _animated = args[1]->ToBoolean();
        animated = _animated->Value();
    }

    if (args[0]->IsNumber())
    {
        Local<Integer> index = args[0]->ToInteger();
        scrollableView->scrollToIndex(index->Value(), animated);
    }
    else
    {
        TiObject* tiObj = TiObject::getTiObjectFromJsObject(args[0]);
        scrollableView->scrollToView(tiObj->getNativeObject(), animated);
    }


    return Undefined();
}
Handle<Value> TiUIScrollableView::_addView(void* userContext, TiObject*, const Arguments& args)
{
    TiUIScrollableView* self = static_cast<TiUIScrollableView*>(userContext);
    NativeScrollableViewObject* scrollableView = static_cast<NativeScrollableViewObject*>(self->getNativeObject());

    TiObject* tiObj = TiObject::getTiObjectFromJsObject(args[0]);
    NativeObject* view = (NativeObject*)tiObj->getNativeObject();
    scrollableView->addChildNativeObject(view);
    return Undefined();
}
Exemplo n.º 3
0
Handle<Value> TiObject::_getValue(int propertyNumber, void* context)
{
    TiObject* self = static_cast<TiObject*>(context);
    NativeObject* object = self->getNativeObject();
    TiObject value;
    if (object != NULL)
    {
        object->getPropertyValue(propertyNumber, &value);
    }
    return value.getValue();
}
Handle<Value> TiMapView::_addAnnotation(void* userContext, TiObject*, const Arguments& args) {
	HandleScope handleScope;
	TiMapView* obj = (TiMapView*) userContext;
	NativeMapViewObject* nativeMapViewObject = (NativeMapViewObject*) obj->getNativeObject();

	TiObject* tiObj = TiObject::getTiObjectFromJsObject(args[0]);
	NativeObject* annotation = (NativeObject*)tiObj->getNativeObject();

	nativeMapViewObject->addAnnotation(annotation);

	return Undefined();
}
Exemplo n.º 5
0
VALUE_MODIFY TiObject::_valueModify(int propertyNumber, TiObject* value, void* context)
{
    TiObject* self = static_cast<TiObject*>(context);
    NativeObject* object = self->getNativeObject();
    if (object == NULL)
    {
        return VALUE_MODIFY_NOT_SUPPORTED;
    }
    VALUE_MODIFY modify = VALUE_MODIFY_ALLOW;
    switch (object->setPropertyValue(propertyNumber, value))
    {
    case NATIVE_ERROR_OK:
        modify = VALUE_MODIFY_ALLOW;
        break;
    case NATIVE_ERROR_NOTSUPPORTED:
        modify = VALUE_MODIFY_ALLOW; //VALUE_MODIFY_NOT_SUPPORTED;
        break;
    default:
        modify = VALUE_MODIFY_INVALID;
        break;
    }
    object->release();
    return modify;
}
Handle<Value> TiUIBase::_animate(void* userContext, TiObject*, const Arguments& args)
{
    HandleScope handleScope;

    TiUIBase* self = static_cast<TiUIBase*>(userContext);
    NativeControlObject *native = static_cast<NativeControlObject*>(self->getNativeObject());
    TiObject* tiObject = TiObject::getTiObjectFromJsObject(args[0]);

    if(!tiObject) {
        Local<Object> jsObject = Local<Object>::Cast(args[0]);
        if(args.Length() > 1 && args[1]->IsFunction()) {
        	Handle<Function> callback = Handle<Function>::Cast(args[1]);
        	Handle<Object> source = Handle<Object>::Cast(self->getValue());
            TiV8Event* event = TiV8Event::createEvent("complete", callback, source);
        	native->animate(jsObject, event);
        } else {
            native->animate(jsObject);
        }
    } else {
        native->animate(tiObject->getNativeObject());
    }

    return Undefined();
}