summaryrefslogtreecommitdiff
path: root/include/nw4r/lyt/lyt_textBox.h
blob: f4d5bff9cad66e84e5824972e71be2e6a59b573b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef LYT_TEXT_BOX_H
#define LYT_TEXT_BOX_H

#include "nw4r/lyt/lyt_pane.h"

namespace nw4r {

namespace lyt {
class TextBox : public Pane {
public:
    TextBox(u16 allocStrLen);
    TextBox(const wchar_t *str, const ut::Font *pFont);
    TextBox(u16, const wchar_t *str, u16, const ut::Font *pFont);
    TextBox(const res::TextBox *pBlock, const ResBlockSet &resBlockSet);

    void Init(u16 allocStrLen);

    ut::Rect GetTextDrawRect() const;
    ut::Rect GetTextDrawRect(const DrawInfo &drawInfo) const;
    u16 GetStringBufferLength() const;
    u16 SetStringImpl(const wchar_t *str, u16 dstIdx, u32 strLen);
    const ut::Font *GetFont() const;
    void SetFont(const ut::Font *pFont);
    ut::Rect GetTextDrawRect(ut::TextWriterBase<wchar_t> *pWriter) const;
    f32 GetTextMagH() const;
    f32 GetTextMagV() const;
    f32 GetTextAlignMag() const;
    UNKTYPE MakeDrawFlag() const;

    ut::Color GetTextColor(u32 type) const {
        return mTextColors[type / 2];
    }
    void SetTextColor(u32 type, ut::Color value) {
        mTextColors[type] = value;
    }
    u8 GetTextPositionH() const {
        return detail::GetHorizontalPosition(mTextPosition);
    }
    void SetTextPositionH(u8 val) {
        detail::SetHorizontalPosition(&mTextPosition, val);
    }
    u8 GetTextPositionV() const {
        return detail::GetVerticalPosition(mTextPosition);
    }
    void SetTextPositionV(u8 val) {
        detail::SetVerticalPosition(&mTextPosition, val);
    }

    const Size &GetFontSize() const {
        return mFontSize;
    }

    void SetFontSize(const Size &fontSize) {
        mFontSize = fontSize;
    }

    f32 GetCharSpace() const {
        return mCharSpace;
    }

    void SetCharSpace(f32 charSpace) {
        mCharSpace = charSpace;
    }

    f32 GetLineSpace() const {
        return mLineSpace;
    }

    void SetLineSpace(f32 lineSpace) {
        mLineSpace = lineSpace;
    }

    ut::TagProcessorBase<wchar_t> *GetTagProcessor() const {
        return mpTagProcessor;
    }
    void SetTagProcessor(ut::TagProcessorBase<wchar_t> *pTagProcessor) {
        mpTagProcessor = pTagProcessor;
    }

    const wchar_t *GetString() const {
        return mTextBuf;
    }

    virtual ~TextBox();
    NW4R_UT_RTTI_DECL(TextBox);
    virtual void DrawSelf(const DrawInfo &drawInfo);                   // at 0x18
    virtual ut::Color GetVtxColor(u32 idx) const;                      // at 0x24
    virtual void SetVtxColor(u32 idx, ut::Color value);                // at 0x28
    virtual u8 GetVtxColorElement(u32 idx) const;                      // at 0x34
    virtual void SetVtxColorElement(u32 idx, u8 value);                // at 0x38
    virtual void LoadMtx(const DrawInfo &drawInfo);                    // at 0x70
    virtual void AllocStringBuffer(u16 minLen);                        // at 0x
    virtual void FreeStringBuffer();                                   // at 0x
    virtual u16 SetString(const wchar_t *str, u16 dstIdx);             // at 0x
    virtual u16 SetString(const wchar_t *str, u16 dstIdx, u16 strLen); // at 0x

protected:
    wchar_t *mTextBuf;                             // at 0xD8 // ptr to is Guess
    ut::Color mTextColors[2];                      // at 0xDC
    const ut::Font *mpFont;                        // at 0xE4
    Size mFontSize;                                // at 0xE8
    f32 mLineSpace;                                // at 0xF0
    f32 mCharSpace;                                // at 0xF4
    ut::TagProcessorBase<wchar_t> *mpTagProcessor; // at 0xF8
    u16 mTextBufBytes;                             // at 0xFC
    u16 mTextLen;                                  // at 0xFE
    u8 mTextPosition;                              // at 0x100
    struct {                                       //
        u8 bAllocFont : 1;                         //
        u8 textAlignment : 2;                      //
    } mBits;                                       // at 0x101
};

} // namespace lyt
} // namespace nw4r
#endif