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