Skip to content

Commit

Permalink
Merge pull request #60 from dcampbell-macadamian/TIMOB-8996
Browse files Browse the repository at this point in the history
TIMOB-8996: Complete remaining issues from code review
  • Loading branch information
dcampbell-macadamian committed Jun 8, 2012
2 parents 0432ebf + 65d8826 commit b733e5c
Show file tree
Hide file tree
Showing 29 changed files with 179 additions and 169 deletions.
1 change: 1 addition & 0 deletions blackberry/tibb/NativeButtonObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ NAHANDLE NativeButtonObject::getNativeHandle() const
int NativeButtonObject::setTitle(TiObject* obj)
{
QString str;

int error = NativeControlObject::getString(obj, str);
if (!N_SUCCEEDED(error))
{
Expand Down
4 changes: 4 additions & 0 deletions blackberry/tibb/NativeContainerObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ NAHANDLE NativeContainerObject::getNativeHandle() const

int NativeContainerObject::initialize(TiEventContainerFactory* containerFactory)
{
if (container_ != NULL)
{
return NATIVE_ERROR_OK;
}
container_ = Container::create();
if (container_ == NULL)
{
Expand Down
47 changes: 40 additions & 7 deletions blackberry/tibb/NativeControlObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ int NativeControlObject::setBackgroundColor(TiObject* obj)
return NATIVE_ERROR_NOTSUPPORTED;
}

PROP_SETTER(setBottom)
int NativeControlObject::setBottom(TiObject* obj)
{
float bottom;
int error = getFloat(obj, &bottom);
if (error != NATIVE_ERROR_OK)
{
return error;
}
((bb::cascades::Control*)getNativeHandle())->setBottomMargin(bottom);
return NATIVE_ERROR_OK;
}

PROP_SETTER(setColor)
int NativeControlObject::setColor(TiObject* obj)
{
Expand All @@ -74,6 +87,19 @@ int NativeControlObject::setLabel(TiObject* obj)
return NATIVE_ERROR_NOTSUPPORTED;
}

PROP_SETTER(setLeft)
int NativeControlObject::setLeft(TiObject* obj)
{
float left;
int error = getFloat(obj, &left);
if (error != NATIVE_ERROR_OK)
{
return error;
}
((bb::cascades::Control*)getNativeHandle())->setLeftMargin(left);
return NATIVE_ERROR_OK;
}

PROP_SETTER(setMax)
int NativeControlObject::setMax(TiObject* obj)
{
Expand All @@ -86,6 +112,19 @@ int NativeControlObject::setMin(TiObject* obj)
return NATIVE_ERROR_NOTSUPPORTED;
}

PROP_SETTER(setRight)
int NativeControlObject::setRight(TiObject* obj)
{
float right;
int error = getFloat(obj, &right);
if (error != NATIVE_ERROR_OK)
{
return error;
}
((bb::cascades::Control*)getNativeHandle())->setRightMargin(right);
return NATIVE_ERROR_OK;
}

PROP_SETTER(setText)
int NativeControlObject::setText(TiObject* obj)
{
Expand Down Expand Up @@ -121,12 +160,6 @@ int NativeControlObject::setTop(TiObject* obj)
return NATIVE_ERROR_OK;
}

PROP_SETTER(setLeft)
int NativeControlObject::setLeft(TiObject* obj)
{
return NATIVE_ERROR_NOTSUPPORTED;
}

PROP_SETTER(setValue)
int NativeControlObject::setValue(TiObject* obj)
{
Expand Down Expand Up @@ -241,7 +274,7 @@ static vector<NATIVE_PROPSET_CALLBACK> initFunctionMap()
vect[N_PROP_BORDER_COLOR] = NULL;
vect[N_PROP_BORDER_RADIUS] = NULL;
vect[N_PROP_BORDER_WIDTH] = NULL;
vect[N_PROP_BOTTOM] = NULL;
vect[N_PROP_BOTTOM] = PROP_SETTING_FUNCTION(setBottom);
vect[N_PROP_CENTER] = NULL;
vect[N_PROP_CHILDREN] = NULL;
vect[N_PROP_COLOR] = PROP_SETTING_FUNCTION(setColor);
Expand Down
4 changes: 3 additions & 1 deletion blackberry/tibb/NativeControlObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ class NativeControlObject : public NativeObject
virtual int setPropertyValue(size_t propertyNumber, TiObject* obj);

virtual int setBackgroundColor(TiObject* obj);
virtual int setBottom(TiObject* obj);
virtual int setColor(TiObject* obj);
virtual int setLabel(TiObject* obj);
virtual int setLeft(TiObject* obj);
virtual int setMax(TiObject* obj);
virtual int setMin(TiObject* obj);
virtual int setRight(TiObject* obj);
virtual int setText(TiObject* obj);
virtual int setTextAlign(TiObject* obj);
virtual int setTop(TiObject* obj);
virtual int setLeft(TiObject* obj);
virtual int setTitle(TiObject* obj);
virtual int setValue(TiObject* obj);
virtual int setVisible(TiObject* obj);
Expand Down
40 changes: 37 additions & 3 deletions blackberry/tibb/TiObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,36 @@ TiObject::TiObject()
{
isInitialized_ = false;
parentObject_ = NULL;
name_ = "";
#ifdef _TI_DEBUG_
cstrName_ = name_.c_str();
debugMembers_ = "";
cstrdebugMembers_ = debugMembers_.c_str();
#endif // _TI_DEBUG_
}

TiObject::TiObject(const char* objectName)
: isInitialized_(false)
, parentObject_(NULL)
{
name_ = objectName;
#ifdef _TI_DEBUG_
cstrName_ = name_.c_str();
debugMembers_ = "";
cstrdebugMembers_ = debugMembers_.c_str();
#endif // _TI_DEBUG_
}

TiObject::TiObject(const char* objectName, Handle<Value> value)
{
name_ = objectName;
value_ = Persistent<Value>::New(value);
parentObject_ = NULL;
#ifdef _TI_DEBUG_
cstrName_ = name_.c_str();
debugMembers_ = "";
cstrdebugMembers_ = debugMembers_.c_str();
#endif // _TI_DEBUG_
}

TiObject::~TiObject()
Expand Down Expand Up @@ -153,6 +169,13 @@ void TiObject::addMember(TiObject* object, const char* name/*=NULL*/)
}
childObjectMap_[name] = entry;
object->initializeTiObject(this);
#ifdef _TI_DEBUG_
// This debug code will create a string containing a list of properties and
// functions. This may be required for Titanium debugging.
debugMembers_ += "\n";
debugMembers_ += name;
cstrdebugMembers_ = debugMembers_.c_str();
#endif
}

Handle<Value> TiObject::getValue() const
Expand Down Expand Up @@ -284,7 +307,17 @@ Handle<Value> TiObject::propGetter_(Local<String> prop, const AccessorInfo& info
TiObject* propObject = obj->onLookupMember(propString);
if (propObject == NULL)
{
// TODO: lookup
// TODO: Fix the following block of commented out code. Currently it breaks
// Titanium runtime.
/*
if(obj->canAddMembers())
{
// If we're allowed to add members, return an "empty" result
// so V8 will handle it. V8 will set the value internally so
// we can ignore non-Titanium objects.
return result;
}
*/
return Undefined();
}
Handle<Value> ret = propObject->getValue();
Expand Down Expand Up @@ -314,8 +347,9 @@ Handle<Value> TiObject::propSetter_(Local<String> prop, Local<Value> value, cons
TiObject* obj = getTiObjectFromJsObject(info.Holder());
if (obj == NULL)
{
obj = new TiObject("", info.Holder());
setTiObjectToJsObject(info.Holder(), obj);
// We are not tracking this object so let V8 handle it.
info.Holder()->ForceSet(prop, value);
return value;
}
String::Utf8Value propName(prop);
const char* propString = (const char*)(*propName);
Expand Down
5 changes: 5 additions & 0 deletions blackberry/tibb/TiObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ class TiObject : public TiBase
bool isInitialized_;
TiObject* parentObject_;
map<string, ObjectEntry> childObjectMap_;
#ifdef _TI_DEBUG_
const char* cstrName_;
string debugMembers_;
const char* cstrdebugMembers_;
#endif // _TI_DEBUG_
};

#endif /* TIOBJECT_H_ */
2 changes: 1 addition & 1 deletion blackberry/tibb/TiUIActivityIndicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TiUIActivityIndicator::~TiUIActivityIndicator()
{
}

TiUIActivityIndicator* TiUIActivityIndicator::createActivityIndicator(NativeObjectFactory* nativeObjectFactory)
TiUIBase* TiUIActivityIndicator::createActivityIndicator(NativeObjectFactory* nativeObjectFactory)
{
TiUIActivityIndicator* obj = new TiUIActivityIndicator(nativeObjectFactory);
obj->initializeTiObject(NULL);
Expand Down
2 changes: 1 addition & 1 deletion blackberry/tibb/TiUIActivityIndicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class TiUIActivityIndicator : public TiUIBase
{
public:
static TiUIActivityIndicator* createActivityIndicator(NativeObjectFactory* nativeObjectFactory);
static TiUIBase* createActivityIndicator(NativeObjectFactory* nativeObjectFactory);

protected:
virtual ~TiUIActivityIndicator();
Expand Down
23 changes: 18 additions & 5 deletions blackberry/tibb/TiUIBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ const static TiProperty g_tiProperties[] =
N_PROP_BACKGROUND_COLOR
},

{
"bottom", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE,
N_PROP_BOTTOM
},

{
"color", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE,
N_PROP_COLOR
Expand Down Expand Up @@ -71,6 +76,11 @@ const static TiProperty g_tiProperties[] =
N_PROP_LABEL
},

{
"left", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE,
N_PROP_LEFT
},

{
"max", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE,
N_PROP_MAX
Expand All @@ -86,6 +96,11 @@ const static TiProperty g_tiProperties[] =
N_PROP_OPTIONS
},

{
"right", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE,
N_PROP_RIGHT
},

{
"selectedIndex", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE,
N_PROP_SELECTED_INDEX
Expand Down Expand Up @@ -250,16 +265,14 @@ void TiUIBase::setParametersFromObject(Local<Object> obj)
Handle<Array> propNames = obj->GetPropertyNames();
uint32_t props = propNames->Length();
Local<Value> propValue;
Handle<String> propString;
TiObject* foundProp;
for (uint32_t i = 0; i < props; i++)
{
propString = Handle<String>::Cast(propNames->Get(Integer::New(i)));
Handle<String> propString = Handle<String>::Cast(propNames->Get(Integer::New(i)));
String::Utf8Value propNameUTF(propString);
foundProp = onLookupMember(*propNameUTF);
TiObject* foundProp = onLookupMember(*propNameUTF);
if (foundProp != NULL)
{
propValue = obj->Get(propString);
Local<Value> propValue = obj->Get(propString);
foundProp->setValue(propValue);
}
}
Expand Down
4 changes: 2 additions & 2 deletions blackberry/tibb/TiUIBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class TiCascadesApp;

/*
* TiCascadesApp
* TiUIBase
*
* Titanium base class for all UI objects such as windows, labels, buttons, etc...
*/
Expand All @@ -30,7 +30,7 @@ class TiUIBase : public TiObject
virtual bool isUIObject() const;
virtual NativeObjectFactory* getNativeObjectFactory() const;
virtual NativeObject* getNativeObject() const;
virtual void setTiMappingProperties(const TiProperty* prop, int propertyCount);
virtual void setTiMappingProperties(const TiProperty* props, int propertyCount);

protected:
TiUIBase(NativeObjectFactory* nativeObjectFactory, const char* name);
Expand Down
2 changes: 1 addition & 1 deletion blackberry/tibb/TiUIButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TiUIButton::~TiUIButton()
{
}

TiUIButton* TiUIButton::createButton(NativeObjectFactory* nativeObjectFactory)
TiUIBase* TiUIButton::createButton(NativeObjectFactory* nativeObjectFactory)
{
TiUIButton* obj = new TiUIButton(nativeObjectFactory);
obj->initializeTiObject(NULL);
Expand Down
2 changes: 1 addition & 1 deletion blackberry/tibb/TiUIButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class TiUIButton : public TiUIBase
{
public:
static TiUIButton* createButton(NativeObjectFactory* nativeObjectFactory);
static TiUIBase* createButton(NativeObjectFactory* nativeObjectFactory);

protected:
virtual ~TiUIButton();
Expand Down
2 changes: 1 addition & 1 deletion blackberry/tibb/TiUIImageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TiUIImageView::~TiUIImageView()
{
}

TiUIImageView* TiUIImageView::createImageView(NativeObjectFactory* nativeObjectFactory)
TiUIBase* TiUIImageView::createImageView(NativeObjectFactory* nativeObjectFactory)
{
TiUIImageView* obj = new TiUIImageView(nativeObjectFactory);
obj->initializeTiObject(NULL);
Expand Down
2 changes: 1 addition & 1 deletion blackberry/tibb/TiUIImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class TiUIImageView : public TiUIBase
{
public:
static TiUIImageView* createImageView(NativeObjectFactory* nativeObjectFactory);
static TiUIBase* createImageView(NativeObjectFactory* nativeObjectFactory);

protected:
virtual ~TiUIImageView();
Expand Down
2 changes: 1 addition & 1 deletion blackberry/tibb/TiUILabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TiUILabel::~TiUILabel()
{
}

TiUILabel* TiUILabel::createLabel(NativeObjectFactory* nativeObjectFactory)
TiUIBase* TiUILabel::createLabel(NativeObjectFactory* nativeObjectFactory)
{
TiUILabel* obj = new TiUILabel(nativeObjectFactory);
obj->initializeTiObject(NULL);
Expand Down
2 changes: 1 addition & 1 deletion blackberry/tibb/TiUILabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class TiUILabel : public TiUIBase
{
public:
static TiUILabel* createLabel(NativeObjectFactory* nativeObjectFactory);
static TiUIBase* createLabel(NativeObjectFactory* nativeObjectFactory);

protected:
virtual ~TiUILabel();
Expand Down

0 comments on commit b733e5c

Please sign in to comment.