1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: lyt_TextBox.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: 26780 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_LYT_TEXTBOX_H_ 17 #define NW_LYT_TEXTBOX_H_ 18 19 #include <nw/ut/ut_Color.h> 20 #include <nw/ut/ut_RuntimeTypeInfo.h> 21 #include <nw/font/font_DispStringBuffer.h> 22 23 #include <nw/lyt/lyt_Config.h> 24 #include <nw/lyt/lyt_Pane.h> 25 26 namespace nw 27 { 28 namespace font 29 { 30 31 class Font; 32 33 template <typename CharType> 34 class TagProcessorBase; 35 36 template <typename CharType> 37 class TextWriterBase; 38 39 } // namespace nw::font 40 41 namespace lyt 42 { 43 44 class DrawInfo; 45 struct ResBlockSet; 46 47 //--------------------------------------------------------------------------- 48 //! :category 描画 49 //! 50 //! @brief テキストの表示を行うペインです。 51 //! 52 //! @since 2009/09/18 初版。 53 //--------------------------------------------------------------------------- 54 class TextBox : public Pane 55 { 56 typedef Pane Base; 57 58 public: 59 //! 実行時型情報です。 60 NW_UT_RUNTIME_TYPEINFO; 61 62 //! TextBox が使用するタグプロセッサの定義です。 63 typedef font::TagProcessorBase<wchar_t> TagProcessor; 64 65 //---------------------------------------- 66 //! @name コンストラクタ/デストラクタ 67 //@{ 68 69 //! @brief コンストラクタです。 70 //! 71 //! @details 72 //! 文字列用バッファを確保してオブジェクトを生成します。 73 //! allocStrLen に 0 を指定した場合は文字列用バッファを確保しません。 74 //! 75 //! @param allocStrLen 確保する文字列用バッファの文字数です。 76 //! 77 //! @since 2009/09/18 初版。 78 //! 79 explicit TextBox(u16 allocStrLen = 0); 80 81 //! @brief コンストラクタです。 82 //! 83 //! @details 84 //! str を初期の文字列として設定します。 85 //! 86 //! pFont で指定したフォントを描画用のフォントとして設定します。 87 //! 88 //! @param allocStrLen 確保する文字列用バッファの文字数です。 89 //! @param str テキスト文字列です。 90 //! @param pFont フォントへのポインタです。 91 //! 92 //! @since 2009/09/18 初版。 93 //! 94 TextBox( 95 u16 allocStrLen, 96 const wchar_t* str, 97 const font::Font* pFont); 98 99 //! @brief コンストラクタです。 100 //! 101 //! @details 102 //! 文字列用バッファを確保してオブジェクトを生成します。 103 //! allocStrLen に 0 を指定した場合は文字列用バッファを確保しません。 104 //! 105 //! str を初期の文字列として設定します。 106 //! 文字列の長さは必ず strLen で指定した値になります。終端文字(0000h)を判断しません。 107 //! 108 //! pFont で指定したフォントを描画用のフォントとして設定します。 109 //! 110 //! @param allocStrLen 確保する文字列用バッファの文字数です。 111 //! @param str テキスト文字列です。 112 //! @param strLen テキスト文字列長です。 113 //! @param pFont フォントへのポインタです。 114 //! 115 //! @since 2009/09/18 初版。 116 //! 117 TextBox( 118 u16 allocStrLen, 119 const wchar_t* str, 120 u16 strLen, 121 const font::Font* pFont); 122 123 //! @brief コンストラクタです。 124 //! 125 //! @details 126 //! リソースからオブジェクトを生成します。 127 //! 128 //! @param pBlock リソースへのポインタです。 129 //! @param resBlockSet ResBlockSet への参照です。 130 //! 131 //! @since 2009/09/18 初版。 132 //! 133 TextBox( 134 const res::TextBox* pBlock, 135 const ResBlockSet& resBlockSet); 136 137 //! @brief デストラクタです。 138 //! 139 //! @details 140 //! 設定されているフォントオブジェクトは破棄しません。 141 //! 142 //! @date 2010/01/26 フォントは破棄しない仕様に変更しました。 143 //! @since 2009/09/18 初版。 144 //! 145 virtual ~TextBox(); 146 147 //@} 148 149 //---------------------------------------- 150 //! @name 文字列操作 151 //@{ 152 153 //! @brief 格納している文字列を取得します。 154 //! 155 //! @return 156 //! 格納している文字列の先頭アドレスを返します。 157 //! 文字列用バッファが確保されていなければ NULL を返します。 158 //! 159 //! @sa SetString 160 //! @sa GetStringLength 161 //! 162 //! @since 2009/09/18 初版。 163 //! GetString()164 const wchar_t* GetString() const 165 { 166 return m_TextBuf; 167 } 168 169 //! @brief 文字列用バッファを取得します。 170 //! 171 //! @details 172 //! 文字列用バッファを確保するには AllocStringBuffer() を呼び出してください。 173 //! 174 //! @return 175 //! 文字列用バッファの先頭アドレスを返します。 176 //! 文字列用バッファが確保されていなければ NULL を返します。 177 //! 178 //! @sa GetStringBufferLength 179 //! @sa AllocStringBuffer 180 //! 181 //! @since 2009/09/18 初版。 182 //! GetStringBuffer()183 const wchar_t* GetStringBuffer() const 184 { 185 return m_TextBuf; 186 } 187 188 //! @brief 格納している文字列の文字数を取得します。 189 //! 190 //! @return 格納している文字列の長さ(文字数)を返します。 191 //! 192 //! @sa SetString 193 //! @sa GetString 194 //! 195 //! @since 2009/09/18 初版。 196 //! GetStringLength()197 u16 GetStringLength() const 198 { 199 return m_TextLen; 200 } 201 202 //! @brief 文字列用バッファの格納可能な文字数を取得します。 203 //! 204 //! @return 文字列用バッファの長さを返します。 205 //! 206 //! @sa GetStringBuffer 207 //! @sa AllocStringBuffer 208 //! 209 //! @since 2009/09/18 初版。 210 //! 211 u16 GetStringBufferLength() const; 212 213 //! @brief 文字列用バッファを確保します。 214 //! 215 //! @details 216 //! 既に確保しているバッファの長さが minLen で指定した 217 //! 長さより大きい場合は何もしません。 218 //! 219 //! @param minLen 確保する文字列用バッファの長さ(文字数)です。 220 //! 221 //! @sa FreeStringBuffer 222 //! 223 //! @date 2010/05/10 引数 isDoubleBuffer を削除しました。 224 //! @date 2010/02/19 引数 isDoubleBuffer を追加しました。 225 //! @since 2009/09/18 初版。 226 //! 227 virtual void AllocStringBuffer(u16 minLen); 228 229 //! @brief 文字列用バッファを解放します。 230 //! 231 //! @sa AllocStringBuffer 232 //! 233 //! @since 2009/09/18 初版。 234 //! 235 virtual void FreeStringBuffer(); 236 237 //! @brief 文字列バッファに文字列を格納します。 238 //! 239 //! @details 240 //! 指定した文字列の長さが文字列用バッファの長さを超える場合は、 241 //! 文字列用バッファの長さを超える分が切り捨てられます。 242 //! 243 //! @param str 格納する文字列です。 244 //! @param dstIdx 格納位置です。 245 //! 246 //! @return 格納した文字列の長さを返します。 247 //! 248 //! @sa GetString 249 //! @sa GetStringLength 250 //! 251 //! @since 2009/09/18 初版。 252 //! 253 virtual u16 SetString( 254 const wchar_t* str, 255 u16 dstIdx = 0); 256 257 //! @brief 文字列バッファに文字列を格納します。 258 //! 259 //! @details 260 //! 文字列の長さは strLen で指定された値です。終端文字を判断しません。 261 //! 262 //! 指定した文字列の長さが文字列用バッファの長さを超える場合は、 263 //! 文字列用バッファの長さを超える分が切り捨てられます。 264 //! 265 //! @param str 格納する文字列です。 266 //! @param dstIdx 格納位置です。 267 //! @param strLen 格納する文字列の長さです。 268 //! 269 //! @return 格納した文字列の長さを返します。 270 //! 271 //! @sa GetString 272 //! @sa GetStringLength 273 //! 274 //! @date 2010/04/09 strLen の値が 0 だった場合の記述に誤りがありました。値 0 は終端文字までを意味しません。 275 //! @since 2009/09/18 初版。 276 //! 277 virtual u16 SetString( 278 const wchar_t* str, 279 u16 dstIdx, 280 u16 strLen); 281 282 //@} 283 284 //---------------------------------------- 285 //! @name 設定/取得 286 //@{ 287 288 //! @brief テキストの表示色を取得します。 289 //! 290 //! @param type 表示色の種類です。 lyt::TextColor を指定します。 291 //! 292 //! @return 表示色を返します。 293 //! 294 //! @sa SetTextColor 295 //! @sa lyt::TextColor 296 //! 297 //! @since 2009/09/18 初版。 298 //! GetTextColor(u32 type)299 const ut::Color8 GetTextColor(u32 type) const 300 { 301 NW_ASSERT(type < TEXTCOLOR_MAX); return m_TextColors[type]; 302 } 303 304 //! @brief テキストの表示色を設定します。 305 //! 306 //! @details 307 //! 指定の表示色を設定します。 308 //! 309 //! @param type 表示色の種類です。 lyt::TextColor を指定します。 310 //! @param value 表示色です。 311 //! 312 //! @sa GetTextColor 313 //! @sa lyt::TextColor 314 //! 315 //! @since 2009/09/18 初版。 316 //! SetTextColor(u32 type,ut::Color8 value)317 void SetTextColor(u32 type, ut::Color8 value) 318 { 319 NW_ASSERT(type < TEXTCOLOR_MAX); 320 321 m_TextColors[type] = value; 322 } 323 324 //! @brief テキストの表示色を設定します。 325 //! 326 //! @details 327 //! テキストの表示色の上端と下端を同時に設定します。 328 //! 329 //! @param top 上端の表示色です。 330 //! @param bottom 下端の表示色です。 331 //! 332 //! @sa GetTextColor 333 //! 334 //! @since 2009/09/18 初版。 335 //! SetTextColor(ut::Color8 top,ut::Color8 bottom)336 void SetTextColor( 337 ut::Color8 top, 338 ut::Color8 bottom 339 ) 340 { 341 m_TextColors[TEXTCOLOR_TOP ] = top; 342 m_TextColors[TEXTCOLOR_BOTTOM] = bottom; 343 } 344 345 //! @brief テキストのフォントを取得します。 346 //! 347 //! @sa SetFont 348 //! 349 //! @date 2010/01/26 フォントは破棄しない仕様に変更しました。 350 //! @since 2009/09/18 初版。 351 //! 352 const font::Font* GetFont() const; 353 354 //! @brief テキストのフォントを設定します。 355 //! 356 //! @details 357 //! 同時に、フォントサイズを指定されたフォントオブジェクトのサイズに設定します。 358 //! 359 //! NULL を渡した場合はフォントの設定を解除します。 360 //! 361 //! @param pFont フォントオブジェクトへのポインタです。 362 //! 363 //! @sa GetFont 364 //! 365 //! @date 2010/01/26 フォントは破棄しない仕様に変更しました。 366 //! @since 2009/09/18 初版。 367 //! 368 void SetFont(const font::Font* pFont); 369 370 //! @brief テキストのフォントサイズを取得します。 371 //! 372 //! @return テキストのフォントサイズを返します。 373 //! 374 //! @sa SetFontSize 375 //! 376 //! @since 2009/09/18 初版。 377 //! GetFontSize()378 const Size& GetFontSize() const 379 { 380 return m_FontSize; 381 } 382 383 //! @brief テキストのフォントサイズを設定します。 384 //! 385 //! @param fontSize フォントサイズです。 386 //! 387 //! @sa GetFontSize 388 //! 389 //! @since 2009/09/18 初版。 390 //! SetFontSize(const Size & fontSize)391 void SetFontSize(const Size& fontSize) 392 { 393 if (UpdatePTDirty(!(m_FontSize == fontSize))) 394 { 395 m_FontSize = fontSize; 396 } 397 } 398 399 //! @brief テキストの行間隔を取得します。 400 //! 401 //! @return テキストの行間隔を返します。 402 //! 403 //! @sa SetLineSpace 404 //! 405 //! @since 2009/09/18 初版。 406 //! GetLineSpace()407 f32 GetLineSpace() const 408 { 409 return m_LineSpace; 410 } 411 412 //! @brief テキストの行間隔を設定します。 413 //! 414 //! @param space 行間です。 415 //! 416 //! @sa GetLineSpace 417 //! 418 //! @since 2009/09/18 初版。 419 //! SetLineSpace(f32 space)420 void SetLineSpace(f32 space) 421 { 422 if (UpdatePTDirty(m_LineSpace != space)) 423 { 424 m_LineSpace = space; 425 } 426 } 427 428 //! @brief テキストの文字間隔を取得します。 429 //! 430 //! @return テキストの文字間隔を返します。 431 //! 432 //! @sa SetCharSpace 433 //! 434 //! @since 2009/09/18 初版。 435 //! GetCharSpace()436 f32 GetCharSpace() const 437 { 438 return m_CharSpace; 439 } 440 441 //! @brief テキストの文字間隔を設定します。 442 //! 443 //! @param space 文字間隔です。 444 //! 445 //! @sa GetCharSpace 446 //! 447 //! @since 2009/09/18 初版。 448 //! SetCharSpace(f32 space)449 void SetCharSpace(f32 space) 450 { 451 if (UpdatePTDirty(m_CharSpace != space)) 452 { 453 m_CharSpace = space; 454 } 455 } 456 457 //! @brief テキスト表示基準位置設定の水平位置指定を取得します。 458 //! 459 //! @return テキスト表示基準位置設定の水平位置指定を返します。 460 //! 461 //! @sa SetTextPositionH 462 //! @sa GetTextPositionV 463 //! 464 //! @since 2009/09/18 初版。 465 //! GetTextPositionH()466 HorizontalPosition GetTextPositionH() const 467 { 468 return internal::GetHorizontalPosition(m_TextPosition); 469 } 470 471 //! @brief テキスト表示基準位置設定の水平位置指定を設定します。 472 //! 473 //! @param val テキスト表示基準位置指定です。 474 //! 475 //! @sa GetTextPositionH 476 //! @sa SetTextPositionV 477 //! 478 //! @since 2009/09/18 初版。 479 //! SetTextPositionH(HorizontalPosition val)480 void SetTextPositionH(HorizontalPosition val) 481 { 482 if (UpdatePTDirty(GetTextPositionH() != val)) 483 { 484 internal::SetHorizontalPosition(&m_TextPosition, u8(val)); 485 } 486 } 487 488 //! @brief テキスト表示基準位置設定の垂直位置指定を取得します。 489 //! 490 //! @return テキスト表示基準位置設定の垂直位置指定を返します。 491 //! 492 //! @sa SetTextPositionV 493 //! @sa GetTextPositionH 494 //! 495 //! @since 2009/09/18 初版。 496 //! GetTextPositionV()497 VerticalPosition GetTextPositionV() const 498 { 499 return internal::GetVerticalPosition(m_TextPosition); 500 } 501 502 //! @brief テキスト表示基準位置設定の垂直位置指定を設定します。 503 //! 504 //! @param val テキスト表示基準位置指定です。 505 //! 506 //! @sa GetTextPositionV 507 //! @sa SetTextPositionH 508 //! 509 //! @since 2009/09/18 初版。 510 //! SetTextPositionV(VerticalPosition val)511 void SetTextPositionV(VerticalPosition val) 512 { 513 if (UpdatePTDirty(GetTextPositionV() != val)) 514 { 515 internal::SetVerticalPosition(&m_TextPosition, u8(val)); 516 } 517 } 518 519 //! @brief 行そろえ指定を取得します。 520 //! 521 //! @return 行そろえ指定を返します。 522 //! 523 //! @sa SetTextAlignment 524 //! 525 //! @since 2009/09/18 初版。 526 //! GetTextAlignment()527 TextAlignment GetTextAlignment() const 528 { 529 return static_cast<TextAlignment>(m_Bits.textAlignment); 530 } 531 532 //! @brief 行そろえ指定を設定します。 533 //! 534 //! @param val 行そろえの指定です。 535 //! 536 //! @sa GetTextAlignment 537 //! 538 //! @since 2009/09/18 初版。 539 //! SetTextAlignment(TextAlignment val)540 void SetTextAlignment(TextAlignment val) 541 { 542 if (UpdatePTDirty(GetTextAlignment() != val)) 543 { 544 m_Bits.textAlignment = val; 545 } 546 } 547 548 //! @brief タグプロセッサを取得します。 549 //! 550 //! @return 551 //! タグプロセッサを返します。 552 //! タグプロセッサが設定されていない場合は NULL を返します。 553 //! 554 //! @sa SetTagProcessor 555 //! 556 //! @since 2009/09/18 初版。 557 //! GetTagProcessor()558 TagProcessor* GetTagProcessor() const 559 { 560 return m_pTagProcessor; 561 } 562 563 //! @brief タグプロセッサを設定します。 564 //! 565 //! @details 566 //! NULL を渡した場合はタグプロセッサの設定を解除します。 567 //! 568 //! @param pTagProcessor タグプロセッサへのポインタです。 569 //! 570 //! @sa GetTagProcessor 571 //! 572 //! @since 2009/09/18 初版。 573 //! SetTagProcessor(TagProcessor * pTagProcessor)574 void SetTagProcessor(TagProcessor* pTagProcessor) 575 { 576 if (UpdatePTDirty(m_pTagProcessor != pTagProcessor)) 577 { 578 m_pTagProcessor = pTagProcessor; 579 } 580 } 581 582 //! @brief テキストの表示色(頂点カラー)を取得します。 583 //! 584 //! @details 585 //! idx が lyt::VERTEXCOLOR_LT のときは上端の色、 586 //! idx が lyt::VERTEXCOLOR_LB のときは下端の色を返します。 587 //! 588 //! idx が lyt::VERTEXCOLOR_RT または lyt::VERTEXCOLOR_RB のときは 589 //! 対応する頂点カラーを返しますが表示には使用されていません。 590 //! 591 //! @param idx インデックスです。 lyt::VertexColor を指定します。 592 //! 593 //! @return テキストの表示色を返します。 594 //! 595 //! @sa SetVtxColor 596 //! @sa GetVtxColorElement 597 //! @sa lyt::VertexColor 598 //! 599 //! @since 2009/09/18 初版。 600 //! 601 virtual const ut::Color8 GetVtxColor(u32 idx) const; 602 603 //! @brief テキストの表示色(頂点カラー)を設定します。 604 //! 605 //! @details 606 //! idx が lyt::VERTEXCOLOR_LT のときは上端の色を、 607 //! idx が lyt::VERTEXCOLOR_LB のときは下端の色を変更します。 608 //! 609 //! idx が lyt::VERTEXCOLOR_RT、 lyt::VERTEXCOLOR_RB のときは 610 //! 対応する頂点カラーを変更しますが表示には使用されていません。 611 //! 612 //! @param idx インデックスです。 lyt::VertexColor を指定します。 613 //! @param value テキストの表示色です。 614 //! 615 //! @sa GetVtxColor 616 //! @sa SetVtxColorElement 617 //! @sa lyt::VertexColor 618 //! 619 //! @since 2009/09/18 初版。 620 //! 621 virtual void SetVtxColor(u32 idx, ut::Color8 value); 622 623 //! @brief テキストの表示色(頂点カラー)の成分を取得します。 624 //! 625 //! @details 626 //! idx が lyt::ANIMTARGET_VERTEXCOLOR_LT_* のときは上端の色、 627 //! idx が lyt::ANIMTARGET_VERTEXCOLOR_LB_* のときは下端の色の各成分を返します。 628 //! 629 //! idx が lyt::ANIMTARGET_VERTEXCOLOR_RT_*、 lyt::ANIMTARGET_VERTEXCOLOR_RB_* のときは 630 //! 対応する頂点カラーの各成分を返しますが表示には使用されていません。 631 //! 632 //! @param idx インデックスです。 lyt::AnimTargetPaneColor を指定します。 633 //! 634 //! @return テキストの表示色の成分を返します。 635 //! 636 //! @sa SetVtxColorElement 637 //! @sa GetVtxColor 638 //! @sa lyt::AnimTargetPaneColor 639 //! 640 //! @since 2009/09/18 初版。 641 //! 642 virtual u8 GetVtxColorElement(u32 idx) const; 643 644 //! @brief テキストの表示色(頂点カラー)の成分を設定します。 645 //! 646 //! @details 647 //! idx が lyt::ANIMTARGET_VERTEXCOLOR_LT_* のときは上端の色、 648 //! idx が lyt::ANIMTARGET_VERTEXCOLOR_LB_* のときは下端の色の各成分を変更します。 649 //! 650 //! idx が lyt::ANIMTARGET_VERTEXCOLOR_RT_*、 lyt::ANIMTARGET_VERTEXCOLOR_RB_* のときは 651 //! 対応する頂点カラーの各成分を変更しますが表示には使用されていません。 652 //! 653 //! @param idx インデックスです。 lyt::AnimTargetPaneColor を指定します。 654 //! @param value カラーの成分値です。 655 //! 656 //! @sa GetVtxColorElement 657 //! @sa SetVtxColor 658 //! @sa lyt::AnimTargetPaneColor 659 //! 660 //! @since 2009/09/18 初版。 661 //! 662 virtual void SetVtxColorElement(u32 idx, u8 value); 663 664 #ifdef NW_LYT_DRAWER_ENABLE 665 //! @brief テキストの描画用データを作成します。(Drawer::Draw()関数用) 666 //! 667 //! @details 668 //! テキストの個々の文字に依存する描画データを作成します。 669 //! 既に作成済みで再生成する必要がない場合は、何も行われません。 670 //! また、明示的に呼び出さない場合でも Drawer::Draw() を通じて、 671 //! このペインの MakeUniformData() の中で呼びだされます。 672 //! 673 //! ※ Drawer::Draw()関数を使用してレイアウトデータを描画する場合に使用します。 674 //! 675 //! 次の関数を呼び出した場合は再生成が行われます。 676 //! 677 //! SetFont 678 //! SetFontSize 679 //! SetLineSpace 680 //! SetCharSpace 681 //! SetTextPositionH 682 //! SetTextPositionV 683 //! SetTextAlignment 684 //! SetTagProcessor 685 //! SetString 686 //! 687 //! @param pDrawer Drawerオブジェクトへのポインタです。 688 //! 689 //! @sa Drawer::Draw 690 //! 691 //! @since 2010/05/20 初版。 692 //! UpdateDrawCharData(Drawer * pDrawer)693 void UpdateDrawCharData(Drawer* pDrawer) 694 { 695 if (m_TextLen <= 0 || !m_pFont) 696 { 697 return; 698 } 699 700 UpdateDrawCharDataImpl(pDrawer); 701 } 702 #endif 703 704 //! @brief テキストが描画される矩形を取得します。 705 //! 706 //! @return 矩形を返します。 707 //! 708 //! @since 2009/09/18 初版。 709 //! 710 const ut::Rect GetTextDrawRect() const; 711 712 using Base::GetMaterial; 713 714 //! @brief ペインが持つマテリアルの数を取得します。 715 //! 716 //! @return マテリアルの数を返します。 717 //! 718 //! @since 2010/01/26 初版。 719 //! 720 virtual u8 GetMaterialNum() const; 721 722 //! @brief ペインのマテリアルを取得します。 723 //! 724 //! @details 725 //! idx には 0 のみ指定できます。 726 //! 727 //! @param idx インデックスです。 728 //! 729 //! @return マテリアルへのポインタを返します。 730 //! 731 //! @sa SetMaterial 732 //! 733 //! @since 2010/01/26 初版。 734 //! 735 virtual Material* GetMaterial(u32 idx) const; 736 737 //! @brief マテリアルを設定します。 738 //! 739 //! @details 740 //! 現在設定されているマテリアルが TextBox オブジェクトの 741 //! 生成時に同時に生成されたものだった場合には、 742 //! そのマテリアルは破棄されます。 743 //! 744 //! @param pMaterial マテリアルへのポインタです。 745 //! 746 //! @sa GetMaterial 747 //! 748 //! @since 2010/01/26 初版。 749 //! 750 void SetMaterial(Material* pMaterial); 751 752 //@} 753 754 //! @details :private GetDispStringBuffer()755 font::DispStringBuffer* GetDispStringBuffer() const 756 { 757 return m_pDispStringBuf; 758 } 759 760 //! @details :private 761 void GetTextGlobalMtx(nw::math::MTX34* pMtx) const; 762 763 #ifdef NW_LYT_DRAWER_ENABLE 764 virtual void MakeUniformDataSelf( DrawInfo* pDrawInfo, Drawer* pDrawer ) const; 765 #endif 766 767 protected: 768 #ifdef NW_LYT_DMPGL_ENABLED 769 virtual void DrawSelf(const DrawInfo& drawInfo); 770 virtual void LoadMtx(const DrawInfo& drawInfo); 771 #endif 772 773 protected: 774 //! @details :private 775 void SetFontInfo(font::WideTextWriter* pWriter) const; 776 777 //! @details :private 778 void SetTextPos(font::WideTextWriter* pWriter) const; 779 780 //! @details :private 781 math::VEC2 AdjustTextPos( 782 const Size& size, 783 bool isCeil 784 ) const; 785 786 //! @details :private 787 void Init(u16 allocStrLen); 788 789 //! @details :private 790 void InitMaterial(); 791 792 //! @details :private 793 u16 SetStringImpl( 794 const wchar_t* str, 795 u16 dstIdx, 796 u32 strLen); 797 798 //! :private 799 //! @brief 文字の位置・テクスチャが変更になったかどうかの状態を更新します。 UpdatePTDirty(bool isChanged)800 bool UpdatePTDirty(bool isChanged) 801 { 802 m_Bits.isPTDirty |= isChanged ? 1: 0; 803 return isChanged; 804 } 805 806 #ifdef NW_LYT_DRAWER_ENABLE 807 //! :private 808 //! @brief テキストの描画用データを更新します。(Drawer::Draw()用) UpdateDrawCharDataImpl(Drawer * pDrawer)809 void UpdateDrawCharDataImpl(Drawer* pDrawer) 810 { 811 if (m_Bits.isPTDirty || (! m_pDispStringBuf->IsGeneratedCommand() && pDrawer)) 812 { 813 SetupDrawCharData(pDrawer); 814 } 815 } 816 #endif 817 818 #ifdef NW_LYT_DRAWER_ENABLE 819 //! :private 820 //! @brief テキストの描画用データを作成します。(Drawer::Draw()用) 821 void SetupDrawCharData(Drawer* pDrawer); 822 #endif 823 824 //! @details :private 825 void SetupTextWriter(font::WideTextWriter* pWriter); 826 827 private: 828 //! @details :private 829 wchar_t* m_TextBuf; 830 831 //! @details :private 832 ut::Color8 m_TextColors[TEXTCOLOR_MAX]; 833 834 //! @details :private 835 const font::Font* m_pFont; 836 837 //! @details :private 838 Size m_FontSize; 839 840 //! @details :private 841 f32 m_LineSpace; 842 843 //! @details :private 844 f32 m_CharSpace; 845 846 //! @details :private 847 TagProcessor* m_pTagProcessor; 848 849 //! @details :private 850 u16 m_TextBufBytes; 851 852 //! @details :private 853 u16 m_TextLen; 854 855 //! @details :private 856 u8 m_TextPosition; 857 858 //! @details :private 859 struct Bits 860 { 861 u8 textAlignment: 2; 862 u8 isPTDirty : 1; // 位置・テクスチャが変更になったら真 863 }; 864 865 //! @details :private 866 Bits m_Bits; 867 868 //! @details :private 869 Material* m_pMaterial; 870 871 //! @details :private 872 font::DispStringBuffer* m_pDispStringBuf; 873 }; 874 875 } // namespace nw::lyt 876 } // namespace nw 877 878 #endif // NW_LYT_TEXTBOX_H_ 879 880