From b36a4f1df0d11169f6c5ecfad9f73c181e0ba9a0 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 25 Jul 2013 23:09:18 +0800 Subject: [PATCH] issue #2430:use upper letters for enum item in Image --- cocos2dx/platform/CCImage.h | 38 +++++++++++++++++---------- cocos2dx/platform/android/CCImage.cpp | 8 +++--- cocos2dx/platform/ios/CCImage.mm | 6 ++--- cocos2dx/platform/linux/CCImage.cpp | 16 +++++------ cocos2dx/platform/mac/CCImage.mm | 2 +- cocos2dx/platform/nacl/CCImage.cpp | 22 ++++++++-------- cocos2dx/platform/tizen/CCImage.cpp | 14 +++++----- cocos2dx/textures/CCTexture2D.cpp | 14 +++++----- 8 files changed, 65 insertions(+), 55 deletions(-) diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index d67e96bb60..420e9cc75b 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -50,7 +50,7 @@ public: Image(); virtual ~Image(); - enum Format + typedef enum Format { FORMAT_JPG, FORMAT_PNG, @@ -66,19 +66,29 @@ public: kFmtWebp = FORMAT_WEBP, kFmtRawData = FORMAT_RAW_DATA, kFmtUnKnown = FORMAT_UNKOWN - }; + }EImageFormat; - typedef enum + typedef enum TextAlign { - kAlignCenter = 0x33, ///< Horizontal center and vertical center. - kAlignTop = 0x13, ///< Horizontal center and vertical top. - kAlignTopRight = 0x12, ///< Horizontal right and vertical top. - kAlignRight = 0x32, ///< Horizontal right and vertical center. - kAlignBottomRight = 0x22, ///< Horizontal right and vertical bottom. - kAlignBottom = 0x23, ///< Horizontal center and vertical bottom. - kAlignBottomLeft = 0x21, ///< Horizontal left and vertical bottom. - kAlignLeft = 0x31, ///< Horizontal left and vertical center. - kAlignTopLeft = 0x11, ///< Horizontal left and vertical top. + TEXT_ALIGN_CENTER = 0x33, ///< Horizontal center and vertical center. + TEXT_ALIGN_TOP = 0x13, ///< Horizontal center and vertical top. + TEXT_ALIGN_TOP_RIGHT = 0x12, ///< Horizontal right and vertical top. + TEXT_ALIGN_RIGHT = 0x32, ///< Horizontal right and vertical center. + TEXT_ALIGN_BOTTOM_RIGHT = 0x22, ///< Horizontal right and vertical bottom. + TEXT_ALIGN_BOTTOM = 0x23, ///< Horizontal center and vertical bottom. + TEXT_ALIGN_BOTTOM_LEFT = 0x21, ///< Horizontal left and vertical bottom. + TEXT_ALIGN_LEFT = 0x31, ///< Horizontal left and vertical center. + TEXT_ALIGN_TOP_LEFT = 0x11, ///< Horizontal left and vertical top. + + kAlignCenter = TEXT_ALIGN_CENTER, + kAlignTop = TEXT_ALIGN_TOP, + kAlignTopRight = TEXT_ALIGN_TOP_RIGHT, + kAlignRight = TEXT_ALIGN_RIGHT, + kAlignBottomRight = TEXT_ALIGN_BOTTOM_RIGHT, + kAlignBottom = TEXT_ALIGN_BOTTOM, + kAlignBottomLeft = TEXT_ALIGN_BOTTOM_LEFT, + kAlignLeft = TEXT_ALIGN_LEFT, + kAlignTopLeft = TEXT_ALIGN_TOP_LEFT, }ETextAlign; /** @@ -121,7 +131,7 @@ public: const char * pText, int nWidth = 0, int nHeight = 0, - ETextAlign eAlignMask = kAlignCenter, + TextAlign eAlignMask = TEXT_ALIGN_CENTER, const char * pFontName = 0, int nSize = 0); @@ -131,7 +141,7 @@ public: const char * pText, int nWidth = 0, int nHeight = 0, - ETextAlign eAlignMask = kAlignCenter, + TextAlign eAlignMask = TEXT_ALIGN_CENTER, const char * pFontName = 0, int nSize = 0, float textTintR = 1, diff --git a/cocos2dx/platform/android/CCImage.cpp b/cocos2dx/platform/android/CCImage.cpp index 42878d1ae3..d0668b24c6 100644 --- a/cocos2dx/platform/android/CCImage.cpp +++ b/cocos2dx/platform/android/CCImage.cpp @@ -62,7 +62,7 @@ public: bool getBitmapFromJavaShadowStroke( const char *text, int nWidth, int nHeight, - Image::ETextAlign eAlignMask, + Image::TextAlign eAlignMask, const char * pFontName, float fontSize, float textTintR = 1.0, @@ -120,7 +120,7 @@ public: } - bool getBitmapFromJava(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) + bool getBitmapFromJava(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { return getBitmapFromJavaShadowStroke( text, nWidth, nHeight, eAlignMask, pFontName, fontSize ); } @@ -148,7 +148,7 @@ bool Image::initWithString( const char * pText, int nWidth/* = 0*/, int nHeight/* = 0*/, - ETextAlign eAlignMask/* = kAlignCenter*/, + TextAlign eAlignMask/* = kAlignCenter*/, const char * pFontName/* = nil*/, int nSize/* = 0*/) { @@ -182,7 +182,7 @@ bool Image::initWithStringShadowStroke( const char * pText, int nWidth , int nHeight , - ETextAlign eAlignMask , + TextAlign eAlignMask , const char * pFontName , int nSize , float textTintR, diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index 6a96a2987f..ea7118f75b 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -172,7 +172,7 @@ static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize #define ALIGN_CENTER 3 #define ALIGN_BOTTOM 2 -static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo) +static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo) { bool bRet = false; do @@ -543,7 +543,7 @@ bool Image::initWithString( const char * pText, int nWidth /* = 0 */, int nHeight /* = 0 */, - ETextAlign eAlignMask /* = kAlignCenter */, + TextAlign eAlignMask /* = kAlignCenter */, const char * pFontName /* = nil */, int nSize /* = 0 */) { @@ -554,7 +554,7 @@ bool Image::initWithStringShadowStroke( const char * pText, int nWidth , int nHeight , - ETextAlign eAlignMask , + TextAlign eAlignMask , const char * pFontName , int nSize , float textTintR, diff --git a/cocos2dx/platform/linux/CCImage.cpp b/cocos2dx/platform/linux/CCImage.cpp index fb2146ed30..c0af46dba2 100644 --- a/cocos2dx/platform/linux/CCImage.cpp +++ b/cocos2dx/platform/linux/CCImage.cpp @@ -240,11 +240,11 @@ public: /** * compute the start pos of every line */ - int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, int line) { + int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) { int lineWidth = textLines.at(line).lineWidth; - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) { + if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_TOP || eAlignMask == Image::TEXT_ALIGN_BOTTOM) { return (iMaxLineWidth - lineWidth) / 2; - } else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) { + } else if (eAlignMask == Image::TEXT_ALIGN_RIGHT || eAlignMask == Image::TEXT_ALIGN_TOP_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT) { return (iMaxLineWidth - lineWidth); } @@ -252,12 +252,12 @@ public: return 0; } - int computeLineStartY( FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight ){ + int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){ int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f); - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) { + if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_LEFT || eAlignMask == Image::TEXT_ALIGN_RIGHT) { //vertical center return (borderHeight - txtHeight) / 2 + baseLinePos; - } else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) { + } else if (eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM || eAlignMask == Image::TEXT_ALIGN_BOTTOM_LEFT) { //vertical bottom return borderHeight - txtHeight + baseLinePos; } @@ -313,7 +313,7 @@ public: return family_name; } - bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) { + bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { if (libError) { return false; } @@ -428,7 +428,7 @@ bool Image::initWithString( const char * pText, int nWidth/* = 0*/, int nHeight/* = 0*/, - ETextAlign eAlignMask/* = kAlignCenter*/, + TextAlign eAlignMask/* = kAlignCenter*/, const char * pFontName/* = nil*/, int nSize/* = 0*/) { diff --git a/cocos2dx/platform/mac/CCImage.mm b/cocos2dx/platform/mac/CCImage.mm index 720f195561..cf7f8894bf 100644 --- a/cocos2dx/platform/mac/CCImage.mm +++ b/cocos2dx/platform/mac/CCImage.mm @@ -859,7 +859,7 @@ bool Image::initWithString( const char * pText, int nWidth, int nHeight, - ETextAlign eAlignMask, + TextAlign eAlignMask, const char * pFontName, int nSize) { diff --git a/cocos2dx/platform/nacl/CCImage.cpp b/cocos2dx/platform/nacl/CCImage.cpp index 81eb6538f3..14ee649563 100644 --- a/cocos2dx/platform/nacl/CCImage.cpp +++ b/cocos2dx/platform/nacl/CCImage.cpp @@ -214,7 +214,7 @@ public: * while -1 means fail * */ - int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, FT_UInt unicode, + int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, FT_UInt unicode, int iLineIndex) { int iRet; @@ -223,11 +223,11 @@ public: return -1; } - if (eAlignMask == Image::kAlignCenter) { + if (eAlignMask == Image::TEXT_ALIGN_CENTER) { iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) / 2 - SHIFT6(face->glyph->metrics.horiBearingX ); - } else if (eAlignMask == Image::kAlignRight) { + } else if (eAlignMask == Image::TEXT_ALIGN_RIGHT) { iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) - SHIFT6(face->glyph->metrics.horiBearingX ); } else { @@ -237,17 +237,17 @@ public: return iRet; } - int computeLineStartY(FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight) + int computeLineStartY(FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight) { int iRet = 0; - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || - eAlignMask == Image::kAlignRight ) { + if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_LEFT || + eAlignMask == Image::TEXT_ALIGN_RIGHT ) { //vertical center iRet = (borderHeight - txtHeight)/2; - } else if (eAlignMask == Image::kAlignBottomRight || - eAlignMask == Image::kAlignBottom || - eAlignMask == Image::kAlignBottomLeft ) { + } else if (eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT || + eAlignMask == Image::TEXT_ALIGN_BOTTOM || + eAlignMask == Image::TEXT_ALIGN_BOTTOM_LEFT ) { //vertical bottom iRet = borderHeight - txtHeight; } @@ -310,7 +310,7 @@ public: return true; } - bool renderLines(FT_Face face, Image::ETextAlign eAlignMask, int iCurYCursor) + bool renderLines(FT_Face face, Image::TextAlign eAlignMask, int iCurYCursor) { size_t lines = vLines.size(); for (size_t i = 0; i < lines; i++) @@ -328,7 +328,7 @@ public: return true; } - bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) + bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { FT_Error iError; if (libError) diff --git a/cocos2dx/platform/tizen/CCImage.cpp b/cocos2dx/platform/tizen/CCImage.cpp index 5dcb778522..3c8776be33 100644 --- a/cocos2dx/platform/tizen/CCImage.cpp +++ b/cocos2dx/platform/tizen/CCImage.cpp @@ -240,11 +240,11 @@ public: /** * compute the start pos of every line */ - int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, int line) { + int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) { int lineWidth = textLines.at(line).lineWidth; - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) { + if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_TOP || eAlignMask == Image::TEXT_ALIGN_BOTTOM) { return (iMaxLineWidth - lineWidth) / 2; - } else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) { + } else if (eAlignMask == Image::TEXT_ALIGN_RIGHT || eAlignMask == Image::TEXT_ALIGN_TOP_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT) { return (iMaxLineWidth - lineWidth); } @@ -252,12 +252,12 @@ public: return 0; } - int computeLineStartY( FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight ){ + int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){ int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f); - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) { + if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_LEFT || eAlignMask == Image::TEXT_ALIGN_RIGHT) { //vertical center return (borderHeight - txtHeight) / 2 + baseLinePos; - } else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) { + } else if (eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM || eAlignMask == Image::TEXT_ALIGN_BOTTOM_LEFT) { //vertical bottom return borderHeight - txtHeight + baseLinePos; } @@ -313,7 +313,7 @@ public: return family_name; } - bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) { + bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { if (libError) { return false; } diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index a9e7b790aa..f712467ae4 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -459,22 +459,22 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin #endif bool bRet = false; - Image::ETextAlign eAlign; + Image::TextAlign eAlign; if (Label::VERTICAL_TEXT_ALIGNMENT_TOP == textDefinition._vertAlignment) { - eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignTop - : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; + eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::TEXT_ALIGN_TOP + : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::TEXT_ALIGN_TOP_LEFT : Image::TEXT_ALIGN_TOP_RIGHT; } else if (Label::VERTICAL_TEXT_ALIGNMENT_CENTER == textDefinition._vertAlignment) { - eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignCenter - : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight; + eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::TEXT_ALIGN_CENTER + : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::TEXT_ALIGN_LEFT : Image::TEXT_ALIGN_RIGHT; } else if (Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM == textDefinition._vertAlignment) { - eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignBottom - : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; + eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::TEXT_ALIGN_BOTTOM + : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::TEXT_ALIGN_BOTTOM_LEFT : Image::TEXT_ALIGN_BOTTOM_RIGHT; } else {