- Main Page
- Classes
- Files

- File List

# label.h

    00001 #ifndef _LABEL_H_
    00002 #define _LABEL_H_
    00003
    00004 #include <nds.h>
    00005 #include "gadget.h"
    00006 #include "gadgetstyle.h"
    00007 #include "woopsistring.h"
    00008
    00009 namespace WoopsiUI {
    00010
    00015         class Label : public Gadget {
    00016         public:
    00017
    00021                 enum TextAlignmentHoriz {
    00022                         TEXT_ALIGNMENT_HORIZ_CENTRE = 0,
    00023                         TEXT_ALIGNMENT_HORIZ_LEFT = 1,
    00024                         TEXT_ALIGNMENT_HORIZ_RIGHT = 2
    00025                 };
    00026
    00030                 enum TextAlignmentVert {
    00031                         TEXT_ALIGNMENT_VERT_CENTRE = 0,
    00032                         TEXT_ALIGNMENT_VERT_TOP = 1,
    00033                         TEXT_ALIGNMENT_VERT_BOTTOM = 2
    00034                 };
    00035
    00048                 Label(s16 x, s16 y, u16 width, u16 height, const WoopsiString& text, GadgetStyle* style = NULL);
    00049
    00054                 virtual void setTextAlignmentHoriz(TextAlignmentHoriz alignment);
    00055
    00060                 virtual void setTextAlignmentVert(TextAlignmentVert alignment);
    00061
    00066                 virtual inline const WoopsiString& getText() const { return _text; };
    00067
    00072                 virtual void setText(const WoopsiString& text);
    00073
    00079                 virtual void appendText(const WoopsiString& text);
    00080
    00086                 virtual void insertText(const WoopsiString& text, const u32 index);
    00087
    00094                 virtual void getPreferredDimensions(Rect& rect) const;
    00095
    00100                 virtual void setFont(FontBase* font);
    00101
    00102         protected:
    00103                 WoopsiString _text;
    00104                 s32 _textX;
    00105                 s32 _textY;
    00106                 TextAlignmentHoriz _hAlignment;
    00107                 TextAlignmentVert _vAlignment;
    00115                 virtual void drawContents(GraphicsPort* port);
    00116
    00123                 virtual void drawBorder(GraphicsPort* port);
    00124
    00130                 virtual void onResize(u16 width, u16 height);
    00131
    00136                 virtual void calculateTextPositionVertical();
    00137
    00142                 virtual void calculateTextPositionHorizontal();
    00143
    00147                 virtual void onTextChange();
    00148
    00152                 virtual inline ~Label() { };
    00153
    00157                 inline Label(const Label& label) : Gadget(label) { };
    00158         };
    00159 }
    00160
    00161 #endif