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