- Main Page
- Classes
- Files

- File List

# C:/Documents and Settings/Administrator/Desktop/woopsi-src-0.39/Woopsi/woopsi/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 char* text, u16 width);
    00027
    00032                 virtual void setText(const char* text);
    00033
    00038                 virtual void setText(const char text);
    00039
    00044                 virtual void append(const char* text);
    00045
    00050                 virtual void append(const char text);
    00051
    00057                 virtual void insert(const char* text, const u32 index);
    00058
    00064                 virtual void insert(const char text, const u32 index);
    00065
    00070                 virtual void remove(const u32 startIndex);
    00071
    00077                 virtual void remove(const u32 startIndex, const u32 count);
    00078
    00083                 void setLineSpacing(u8 lineSpacing);
    00084
    00090                 void setWidth(u16 width);
    00091
    00096                 void setFont(FontBase* font);
    00097
    00103                 const u8 getLineLength(const s32 lineNumber) const;
    00104
    00111                 const u8 getLineTrimmedLength(const s32 lineNumber) const;
    00112
    00118                 const u8 getLinePixelLength(const s32 lineNumber) const;
    00119
    00126                 const u8 getLineTrimmedPixelLength(const s32 lineNumber) const;
    00127
    00133                 inline const char* getLinePointer(const s32 lineNumber) const { return getCharArray() + _linePositions[lineNumber]; };
    00134
    00139                 inline const s32 getPixelHeight() const { return _textPixelHeight; };
    00140
    00145                 inline const u8 getPixelWidth() const { return _textPixelWidth; };
    00146
    00151                 inline const u8 getLineSpacing() const { return _lineSpacing; };
    00152
    00158                 inline const u8 getLineHeight() const { return _font->getHeight() + _lineSpacing; };
    00159
    00164                 inline const s32 getLineCount() const { return _linePositions.size() - 1; };
    00165
    00170                 FontBase* getFont() const;
    00171
    00176                 void stripTopLines(const s32 lines);
    00177
    00181                 void wrap();
    00182
    00188                 void wrap(u32 charIndex);
    00189
    00197                 const u32 getLineContainingCharIndex(const u32 index) const;
    00198
    00205                 const u32 getLineStartIndex(const u32 line) const { return _linePositions[line]; };
    00206
    00207         private:
    00212                 typedef struct {
    00213                         u32 index;
    00214                         u8 width;
    00215                 } LongestLine;
    00216
    00217                 FontBase* _font;
    00218                 WoopsiArray<u32> _linePositions;
    00219                 WoopsiArray<LongestLine> _longestLines;
    00220                 u8 _lineSpacing;
    00221                 s32 _textPixelHeight;
    00222                 u8 _textPixelWidth;
    00223                 u16 _width;
    00224         };
    00225 }
    00226
    00227 #endif

All Classes Functions Variables Enumerations Enumerator