- Main Page
- Classes
- Files

- File List

# text.h

    00001 #ifndef _TEXT_H_
    00002 #define _TEXT_H_
    00003
    00004 #include <nds.h>
    00005 #include "fontbase.h"
    00006 #include "woopsiarray.h"
    00007 #include "woopsistring.h"
    00008
    00009 namespace WoopsiUI {
    00010
    00016         class Text : public WoopsiString {
    00017
    00018         public:
    00019
    00026                 Text(FontBase* font, const WoopsiString& text, u16 width);
    00027
    00032                 virtual void setText(const WoopsiString& text);
    00033
    00038                 virtual void setText(const char* text);
    00039
    00044                 virtual void setText(const u32 text);
    00045
    00050                 virtual void append(const WoopsiString& text);
    00051
    00057                 virtual void insert(const WoopsiString& text, const s32 index);
    00058
    00063                 virtual void remove(const s32 startIndex);
    00064
    00070                 virtual void remove(const s32 startIndex, const s32 count);
    00071
    00076                 void setLineSpacing(u8 lineSpacing);
    00077
    00083                 void setWidth(u16 width);
    00084
    00089                 void setFont(FontBase* font);
    00090
    00096                 const u8 getLineLength(const s32 lineNumber) const;
    00097
    00104                 const s16 getLineTrimmedLength(const s32 lineNumber) const;
    00105
    00111                 const s16 getLinePixelLength(const s32 lineNumber) const;
    00112
    00119                 const s16 getLineTrimmedPixelLength(const s32 lineNumber) const;
    00120
    00125                 inline const s32 getPixelHeight() const { return _textPixelHeight; };
    00126
    00131                 inline const u8 getPixelWidth() const { return _textPixelWidth; };
    00132
    00137                 inline const u8 getLineSpacing() const { return _lineSpacing; };
    00138
    00144                 inline const u8 getLineHeight() const { return _font->getHeight() + _lineSpacing; };
    00145
    00150                 inline const s32 getLineCount() const { return _linePositions.size() - 1; };
    00151
    00156                 FontBase* getFont() const;
    00157
    00162                 void stripTopLines(const s32 lines);
    00163
    00167                 void wrap();
    00168
    00174                 void wrap(s32 charIndex);
    00175
    00183                 const s32 getLineContainingCharIndex(const s32 index) const;
    00184
    00191                 const s32 getLineStartIndex(const s32 line) const { return _linePositions[line]; };
    00192
    00193         private:
    00198                 typedef struct {
    00199                         s32 index;
    00200                         u8 width;
    00201                 } LongestLine;
    00202
    00203                 FontBase* _font;
    00204                 WoopsiArray<s32> _linePositions;
    00205                 WoopsiArray<LongestLine> _longestLines;
    00206                 u8 _lineSpacing;
    00207                 s32 _textPixelHeight;
    00208                 u8 _textPixelWidth;
    00209                 u16 _width;
    00210         };
    00211 }
    00212
    00213 #endif