2013-07-19 04:13:41 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 Zynga 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-07-11 02:59:05 +08:00
|
|
|
|
2013-07-19 04:13:41 +08:00
|
|
|
#ifndef _CCLabelTextFormatProtocol_h_
|
|
|
|
#define _CCLabelTextFormatProtocol_h_
|
2013-10-29 20:25:03 +08:00
|
|
|
#include "CCFontAtlas.h"
|
|
|
|
#include <vector>
|
2013-07-11 02:59:05 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-10-29 20:25:03 +08:00
|
|
|
|
|
|
|
struct LetterInfo
|
|
|
|
{
|
|
|
|
FontLetterDefinition def;
|
|
|
|
|
|
|
|
Point position;
|
|
|
|
Size contentSize;
|
|
|
|
bool visible;
|
|
|
|
};
|
|
|
|
|
2013-07-11 02:59:05 +08:00
|
|
|
class CC_DLL LabelTextFormatProtocol
|
|
|
|
{
|
|
|
|
public:
|
2013-10-29 20:25:03 +08:00
|
|
|
virtual bool recordLetterInfo(const cocos2d::Point& point,unsigned short int theChar, int spriteIndex) = 0;
|
|
|
|
virtual bool recordPlaceholderInfo(int spriteIndex) = 0;
|
|
|
|
virtual std::vector<LetterInfo> *getLettersInfo() = 0;
|
|
|
|
virtual float getLetterPosXLeft(int index) const = 0;
|
|
|
|
virtual float getLetterPosXRight(int index) const = 0;
|
2013-07-11 02:59:05 +08:00
|
|
|
// sprite related stuff
|
2013-10-31 20:17:30 +08:00
|
|
|
virtual cocos2d::Sprite *getLetter(int ID) = 0;
|
2013-07-11 02:59:05 +08:00
|
|
|
|
|
|
|
// font related stuff
|
2013-09-13 11:46:46 +08:00
|
|
|
virtual int getCommonLineHeight() const = 0;
|
|
|
|
virtual int getKerningForCharsPair(unsigned short first, unsigned short second) const = 0;
|
|
|
|
virtual int getXOffsetForChar(unsigned short c) const = 0;
|
|
|
|
virtual int getYOffsetForChar(unsigned short c) const = 0;
|
|
|
|
virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) const = 0;
|
|
|
|
virtual cocos2d::Rect getRectForChar(unsigned short c) const = 0;
|
2013-07-11 02:59:05 +08:00
|
|
|
|
|
|
|
// string related stuff
|
2013-09-13 11:46:46 +08:00
|
|
|
virtual int getStringNumLines() const = 0;
|
|
|
|
virtual int getStringLenght() const = 0;
|
|
|
|
virtual unsigned short getCharAtStringPosition(int position) const = 0;
|
|
|
|
virtual unsigned short * getUTF8String() const = 0;
|
|
|
|
virtual void assignNewUTF8String(unsigned short *newString) = 0;
|
|
|
|
virtual TextHAlignment getTextAlignment() const = 0;
|
2013-07-11 02:59:05 +08:00
|
|
|
|
|
|
|
// label related stuff
|
2013-09-13 11:46:46 +08:00
|
|
|
virtual float getMaxLineWidth() const = 0;
|
|
|
|
virtual bool breakLineWithoutSpace() const = 0;
|
|
|
|
virtual cocos2d::Size getLabelContentSize() const = 0;
|
|
|
|
virtual void setLabelContentSize(const Size &newSize) = 0;
|
2013-07-11 02:59:05 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif
|