2013-09-13 22:20:20 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:47:11 +08:00
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
#include "gui/UILayoutParameter.h"
|
|
|
|
#include "gui/UILayout.h"
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace gui {
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
LayoutParameter* LayoutParameter::create()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-12-23 15:02:52 +08:00
|
|
|
LayoutParameter* parameter = new LayoutParameter();
|
2013-09-13 22:20:20 +08:00
|
|
|
if (parameter)
|
|
|
|
{
|
|
|
|
parameter->autorelease();
|
|
|
|
return parameter;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(parameter);
|
2013-11-14 11:37:46 +08:00
|
|
|
return nullptr;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
void LayoutParameter::setMargin(const Margin &margin)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 20:54:13 +08:00
|
|
|
_margin = margin;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
const Margin& LayoutParameter::getMargin() const
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 20:54:13 +08:00
|
|
|
return _margin;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
LayoutParameterType LayoutParameter::getLayoutType() const
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-16 20:54:13 +08:00
|
|
|
return _layoutParameterType;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
LinearLayoutParameter* LinearLayoutParameter::create()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-12-23 15:02:52 +08:00
|
|
|
LinearLayoutParameter* parameter = new LinearLayoutParameter();
|
2013-09-13 22:20:20 +08:00
|
|
|
if (parameter)
|
|
|
|
{
|
|
|
|
parameter->autorelease();
|
|
|
|
return parameter;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(parameter);
|
2013-11-14 11:37:46 +08:00
|
|
|
return nullptr;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
void LinearLayoutParameter::setGravity(LinearGravity gravity)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-25 19:04:37 +08:00
|
|
|
_linearGravity = gravity;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
LinearGravity LinearLayoutParameter::getGravity() const
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-25 19:04:37 +08:00
|
|
|
return _linearGravity;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
RelativeLayoutParameter* RelativeLayoutParameter::create()
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-12-23 15:02:52 +08:00
|
|
|
RelativeLayoutParameter* parameter = new RelativeLayoutParameter();
|
2013-09-13 22:20:20 +08:00
|
|
|
if (parameter)
|
|
|
|
{
|
|
|
|
parameter->autorelease();
|
|
|
|
return parameter;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(parameter);
|
2013-11-14 11:37:46 +08:00
|
|
|
return nullptr;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
void RelativeLayoutParameter::setAlign(RelativeAlign align)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-25 19:04:37 +08:00
|
|
|
_relativeAlign = align;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
RelativeAlign RelativeLayoutParameter::getAlign() const
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-25 19:04:37 +08:00
|
|
|
return _relativeAlign;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
void RelativeLayoutParameter::setRelativeToWidgetName(const char *name)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-25 19:04:37 +08:00
|
|
|
_relativeWidgetName = name;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
const char* RelativeLayoutParameter::getRelativeToWidgetName() const
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-25 19:04:37 +08:00
|
|
|
return _relativeWidgetName.c_str();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
void RelativeLayoutParameter::setRelativeName(const char* name)
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-25 19:04:37 +08:00
|
|
|
_relativeLayoutName = name;
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
const char* RelativeLayoutParameter::getRelativeName() const
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
2013-09-25 19:04:37 +08:00
|
|
|
return _relativeLayoutName.c_str();
|
2013-09-13 22:20:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_END
|