1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     TextWriter.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  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   $Rev: 46365 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_COMMON_SCENE_TEXTWRITER_H_
17 #define NN_COMMON_SCENE_TEXTWRITER_H_
18 
19 #include <nn.h>
20 #include <nn/pl.h>
21 #include <nn/font.h>
22 
23 namespace scene
24 {
25 
26 /* Please see man pages for details
27 
28 */
29 class TextWriter
30 {
31 public:
32     /* Please see man pages for details
33 
34     */
35     TextWriter();
36 
37     /* Please see man pages for details
38 
39     */
40     virtual ~TextWriter();
41 
42     /* Please see man pages for details
43 
44 
45 
46 
47 
48     */
49     void Initialize(nn::fnd::ExpHeap* pExpHeap);
50 
51     /* Please see man pages for details
52 
53     */
54     void Finalize();
55 
56     /* Please see man pages for details
57 
58 
59 
60 
61     */
62     void BeginRender(GLenum targetDisplay);
63 
64     /* Please see man pages for details
65 
66     */
67     void EndRender();
68 
69     /* Please see man pages for details
70 
71 
72 
73 
74 
75 
76     */
77     void Printf(f32 x, f32 y, const wchar_t* pFormat, ...);
78 
79     /* Please see man pages for details
80 
81 
82 
83 
84 
85     */
86     void PutString(f32 x, f32 y, const wchar_t* pString);
87 
88     /* Please see man pages for details
89 
90 
91 
92 
93 
94 
95     */
96     void SetTextColor(u8 red, u8 green, u8 blue, u8 alpha = 255);
97 
98     /* Please see man pages for details
99 
100 
101 
102     */
103     f32 GetFontSize();
104 
105     /* Please see man pages for details
106 
107 
108 
109     */
110     void SetFontSize(f32 size);
111 
112     /* Please see man pages for details
113 
114 
115 
116     */
117     f32 GetFontScale();
118 
119     /* Please see man pages for details
120 
121 
122 
123     */
124     void SetFontScale(f32 scale);
125 
126     /* Please see man pages for details
127 
128 
129 
130     */
131     f32 GetCharSpace();
132 
133     /* Please see man pages for details
134 
135 
136 
137     */
138     void SetCharSpace(f32 charSpace);
139 
140     /* Please see man pages for details
141 
142 
143 
144     */
145     f32 CalculateStringWidth(const wchar_t* pString);
146 
147     /* Please see man pages for details
148 
149 
150 
151     */
152     f32 CalculateStringHeight(const wchar_t* pString);
153 
154 protected:
155     // Perform font initialization.
156     bool InitializeFont();
157     // Perform shader initialization.
158     bool InitializeShader();
159     // Allocate the string buffer.
160     nn::font::DispStringBuffer* AllocateStringBuffer(s32 charMax);
161 
162 protected:
163     // Heap
164     nn::fnd::ExpHeap* m_pExpHeap;
165     // Font
166     nn::font::ResFont m_font;
167     // Render object
168     nn::font::RectDrawer     m_drawer;
169     nn::font::WideTextWriter m_writer;
170     // String buffer.
171     nn::font::DispStringBuffer*m_pStringBuffer;
172     // Character color
173     nn::util::Color8 m_textColor;
174     // Shader buffer
175     void* m_pShaderBuffer;
176     // Render target
177     u32 m_targetDisplay;
178 };
179 
180 } // namespace scene
181 
182 #endif // NN_COMMON_SCENE_TEXTWRITER_H_
183