1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: font_TagProcessorBase.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 18822 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_FONT_TAGPROCESSORBASE_H_ 17 #define NW_FONT_TAGPROCESSORBASE_H_ 18 19 #include <nn/types.h> 20 #include <nw/ut/ut_Rect.h> 21 22 namespace nw { 23 namespace font { 24 25 26 27 template <typename CharType> 28 class TextWriterBase; 29 30 31 template <typename CharType> 32 struct PrintContext 33 { 34 TextWriterBase<CharType>* writer; //!< 文字列描画に使用しているTextWriterへのポインタ。 35 const CharType* str; //!< 描画中の文字列へのポインタ。 36 const f32 xOrigin; //!< 描画開始X座標。 37 const f32 yOrigin; //!< 描画開始Y座標。 38 u32 flags; //!< TextWriter::ContextFlag のOR。 39 PrintContextPrintContext40 PrintContext( 41 TextWriterBase<CharType>* aWriter, 42 const CharType* aStr, 43 const f32 aXOrigin, 44 const f32 aYOrigin, 45 u32 aFlags 46 ) 47 : writer(aWriter), 48 str(aStr), 49 xOrigin(aXOrigin), 50 yOrigin(aYOrigin), 51 flags(aFlags) 52 {} 53 }; 54 55 #if defined( __CC_ARM ) || defined( __ARMCC_VERSION ) 56 #pragma push 57 #pragma diag_suppress 2819 // class XXX has an implicitly instantiated key function YYY 58 #endif 59 60 //--------------------------------------------------------------------------- 61 //! @brief グリフグループが定義されているフォントリソースを扱うクラスです。 62 //! 63 //! @tparam CharType 文字の型。 64 //--------------------------------------------------------------------------- 65 template <typename CharType> 66 class TagProcessorBase 67 { 68 public: 69 /* ------------------------------------------------------------------------ 70 型 71 ------------------------------------------------------------------------ */ 72 73 //! 呼び出し元 (TextWriter) が行うべき処理の列挙子です。 74 enum Operation 75 { 76 //! @brief 行頭では次の文字との間に文字間を開けません。 77 //! 行頭以外の位置では次の文字との間に文字間を開けます。 78 //! 79 OPERATION_DEFAULT, 80 81 //! @brief 行頭以外の位置でタグ処理が行われた場合、 82 //! デフォルトでは次の文字との間に文字間を空けますが、 83 //! これを空けないようにします。 84 //! 85 OPERATION_NO_CHAR_SPACE, 86 87 //! @brief 行頭でタグ処理が行われた場合、 88 //! デフォルトでは次の文字との間に文字間を空けませんが、 89 //! これを空けるようにします。 90 //! 91 OPERATION_CHAR_SPACE, 92 93 //! @brief 改行時に必要な処理のうち X 座標の調整のみを行います。 94 //! Y 座標の調整は行いません。 95 //! また、次の文字との間に文字間を開けません。 96 //! 97 OPERATION_NEXT_LINE, 98 99 //! @brief 文字列の途中で文字列描画を終了する場合に使用します。 100 //! 101 OPERATION_END_DRAW, 102 103 //! @details :private 104 NUM_OF_OPERATION 105 }; 106 107 /* ------------------------------------------------------------------------ 108 関数 109 ------------------------------------------------------------------------ */ 110 111 //! @name コンストラクタ / デストラクタ 112 //@{ 113 114 //! コンストラクタです。 115 TagProcessorBase(); 116 117 //! デストラクタです。 118 virtual ~TagProcessorBase(); 119 120 //@} 121 122 123 //! @name タグ処理 124 //@{ 125 126 //! @brief タグに従って処理を行います。 127 //! 128 //! @param[in] code タグ処理の起点となった制御文字コード。(0x0000 ~ 0x001F) 129 //! @param[in,out] pContext 文字列の描画状態情報へのポインタ。 130 //! 131 //! @return 呼び出し元 (TextWriter) が行うべき処理を返します。 132 //! 133 virtual Operation Process( 134 u16 code, 135 PrintContext<CharType>* pContext); 136 137 //! @brief タグの影響範囲を計算します。 138 //! 139 //! @param[out] pRect タグの影響範囲を格納する矩形構造体へのポインタ。 140 //! @param[in] code タグ処理の起点となった制御文字コード。(0x0000 ~ 0x001F) 141 //! @param[in,out] pContext 文字列の描画状態情報へのポインタ。 142 //! 143 //! @return 呼び出し元 (TextWriter) が行うべき処理を返します。 144 //! 同じタグに対して Process() 関数が返す値と同じ値を返すべきです。 145 //! 146 virtual Operation CalcRect( 147 ut::Rect* pRect, 148 u16 code, 149 PrintContext<CharType>* pContext); 150 151 //@} 152 153 private: 154 /* ------------------------------------------------------------------------ 155 型 156 ------------------------------------------------------------------------ */ 157 typedef PrintContext<CharType> ContextType; 158 159 void ProcessLinefeed(ContextType* pContext); 160 void ProcessTab(ContextType* pContext); 161 }; 162 163 #if defined( __CC_ARM ) || defined( __ARMCC_VERSION ) 164 #pragma pop 165 #endif 166 167 } // namespace font 168 } // namespace nw 169 170 #endif // NW_FONT_TAGPROCESSORBASE_H_ 171