コード例 #1
0
void TiUIScrollViewProxy::setContentOffset(Ti::TiValue arg)
{
	if(!arg.isList()) return;
	QList<Ti::TiValue> args = arg.toList();

	// Thanks for this ssaracut
	// https://github.com/appcelerator/titanium_mobile_blackberry/pull/217

	Ti::TiValue position = args.at(0);
	if(!position.isMap()) return;

	QMap<QString, Ti::TiValue> positionMap = position.toMap();
	Ti::TiValue xPos = positionMap.value(QString("x"));
	Ti::TiValue yPos = positionMap.value(QString("y"));
	float x = xPos.toNumber();
	float y = yPos.toNumber();
	bool isAnimated = true;

	if(args.size() > 1)
	{
		Ti::TiValue animated = args.at(1);
		if(animated.isMap())
		{
			QMap<QString, Ti::TiValue> animatedMap = animated.toMap();
			Ti::TiValue animatedValue = animatedMap.value(QString("animated"));
			isAnimated = animatedValue.toBool();
		}
	}



	_nativeScrollView->scrollToPoint((float)x, (float)y, isAnimated ? bb::cascades::ScrollAnimation::Default : bb::cascades::ScrollAnimation::None);
}
コード例 #2
0
Ti::TiValue TiUITabProxy::open(Ti::TiValue value)
{
	Ti::TiValue val;
	val.setUndefined();

	Ti::TiWindowProxy* windowProxy;
	if(value.isList())
	{
		QList<Ti::TiValue> vs = value.toList();
		Ti::TiValue v = vs.at(0);
		windowProxy = static_cast<TiUIWindowProxy*>(v.toProxy());
	}
	else if(value.isProxy())
	{
		windowProxy = static_cast<TiUIWindowProxy*>(value.toProxy());
	}
	else
	{
		return val;
	}

	windowProxy->clearWeak();
	windowProxy->getPane()->setParent(NULL);
	_windows.append(windowProxy);

	Ti::TiEventParameters _params;
	windowProxy->fireEvent(Ti::TiConstants::EventOpen, _params);

	_navigationPane->push(static_cast<bb::cascades::Page*>(windowProxy->getPane()));
	return val;
}
コード例 #3
0
Ti::TiValue Ti::TiViewProxy::animate(Ti::TiValue val)
{
	Ti::TiCallback* callback = NULL;

	if(val.isList()) {
		QList<Ti::TiValue> array = val.toList();
		callback = new Ti::TiCallback(this, array.at(1));
		val = Ti::TiValue(array.at(0));
	}

	if(val.isProxy())
	{
		Ti::TiAnimationProxy *proxy = static_cast<Ti::TiAnimationProxy*>(val.toProxy());
		proxy->animate(this, callback);
	}
	else if(val.isMap())
	{
		TiUI::TiUIAnimationProxy *proxy = TiUI::TiUIAnimationProxy::CreateProxy();
		proxy->applyProperties(val);
		proxy->animate(this, callback);
	}
	Ti::TiValue result;
	result.setUndefined();
	return result;
}
コード例 #4
0
Ti::TiValue TiUIScrollViewProxy::scrollTo(Ti::TiValue arg)
{
	if(!arg.isList()) return Ti::TiValue();
	QList<Ti::TiValue> array = arg.toList();
	if(array.size() < 2)  return Ti::TiValue();
	Ti::TiValue x = array.at(0);
	Ti::TiValue y = array.at(1);
	_nativeScrollView->scrollToPoint((float)x.toNumber(), (float)y.toNumber());
	return Ti::TiValue();
}
コード例 #5
0
void Ti::TiViewProxy::setContextMenus(Ti::TiValue value)
{
	if(!value.isList()) return;
	QList<Ti::TiValue> allValues = value.toList();
	foreach(Ti::TiValue current, allValues)
	{
		if(!current.isProxy()) continue;
		Ti::TiProxy* menuProxy = current.toProxy();
		if(menuProxy->__data__ == NULL) return;

		bb::cascades::ActionSet *menu = (bb::cascades::ActionSet*)menuProxy->__data__;
		getChildControl()->addActionSet(menu);
	}
}
コード例 #6
0
Ti::TiValue TiUIWebViewProxy::evalJS(Ti::TiValue val)
{
	if(val.isList())
	{
		QList<Ti::TiValue> array = val.toList();
		Ti::TiValue str = array.at(0);
		Ti::TiValue callback = array.at(1);
		_tiWebView->evalJS(str.toString(), callback);
	}
	else
	{
		_tiWebView->evalJS(val.toString());
	}
	return Ti::TiValue();
}
コード例 #7
0
Ti::TiValue TiUITabProxy::close(Ti::TiValue value)
{
	Ti::TiValue val;
	val.setUndefined();
	Ti::TiWindowProxy* windowProxy;
	bool animated = true;
	if(value.isList())
	{
		QList<Ti::TiValue> vs = value.toList();
		Ti::TiValue v = vs.at(0);
		windowProxy = static_cast<TiUIWindowProxy*>(v.toProxy());
		Ti::TiValue optionsValue = vs.at(1);
		if(optionsValue.isMap())
		{
			QMap<QString, Ti::TiValue> options = optionsValue.toMap();
			if(options.contains("animated"))
			{
				animated = options["animated"].toBool();
			}
		}
	}
	else if(value.isProxy())
	{
		windowProxy = static_cast<TiUIWindowProxy*>(value.toProxy());
	}
	else
	{
		return val;
	}
	if(_windows.last() == windowProxy && animated == true)
	{
		_navigationPane->pop();
	}
	else
	{
		_navigationPane->remove(static_cast<bb::cascades::Page*>(windowProxy->getPane()));
		Ti::TiEventParameters _params;
		windowProxy->fireEvent(Ti::TiConstants::EventClose, _params);
		windowProxy->makeWeak();
	}
	_windows.removeOne(windowProxy);

	return val;
}
コード例 #8
0
// TODO: Finish this
Ti::TiValue Ti::TiProxy::fireEvent(Ti::TiValue value)
{
	QString eventName;
	Ti::TiEventParameters eventParams;
	if(value.isList()) {

		Ti::TiValue eName = value.toList().at(0);
		Ti::TiValue eParams = value.toList().at(1);
		eventName = eName.toString();

		if(eParams.isMap())
		{
			QMap<QString, Ti::TiValue> map = eParams.toMap();
			QList<QString> keys = map.keys();
			int len = keys.size();
			while(len--)
			{
				QString 	name 	= keys.at(len);
				Ti::TiValue val 	= map[name];

				if(val.isNumber())
				{
					eventParams.addParam(name, val.toNumber());
				}
				else if (val.isProxy())
				{
					eventParams.addParam(name, val.toProxy());
				}
				else // if(val.isString())
				{
					eventParams.addParam(name, val.toString());
				}
			}
		}
	}
	else
	{
		eventName = value.toString();
	}

	fireEvent(eventName, eventParams);

	return Ti::TiValue(Undefined());
}