- Main Page
- Classes
- Files

- File List

# multilinetextbox.h

    00001 #ifndef _MULTILINE_TEXTBOX_H_
    00002 #define _MULTILINE_TEXTBOX_H_
    00003
    00004 #include <nds.h>
    00005 #include "scrollingpanel.h"
    00006 #include "gadgetstyle.h"
    00007 #include "woopsistring.h"
    00008 #include "text.h"
    00009 #include "keyboardeventhandler.h"
    00010 #include "textboxbase.h"
    00011
    00012 namespace WoopsiUI {
    00013
    00014         class WoopsiTimer;
    00015         class WoopsiKey;
    00016
    00024         class MultiLineTextBox : public TextBoxBase, public ScrollingPanel, public KeyboardEventHandler  {
    00025         public:
    00026
    00030                 enum TextAlignmentHoriz {
    00031                         TEXT_ALIGNMENT_HORIZ_CENTRE = 0,
    00032                         TEXT_ALIGNMENT_HORIZ_LEFT = 1,
    00033                         TEXT_ALIGNMENT_HORIZ_RIGHT = 2
    00034                 };
    00035
    00039                 enum TextAlignmentVert {
    00040                         TEXT_ALIGNMENT_VERT_CENTRE = 0,
    00041                         TEXT_ALIGNMENT_VERT_TOP = 1,
    00042                         TEXT_ALIGNMENT_VERT_BOTTOM = 2
    00043                 };
    00044
    00063                 MultiLineTextBox(s16 x, s16 y, u16 width, u16 height, const WoopsiString& text, u32 flags, s16 maxRows = 0, GadgetStyle* style = NULL);
    00064
    00069                 virtual void setTextAlignmentHoriz(TextAlignmentHoriz alignment);
    00070
    00075                 virtual void setTextAlignmentVert(TextAlignmentVert alignment);
    00076
    00083                 virtual const u16 getPageCount() const;
    00084
    00090                 virtual const u16 getCurrentPage() const;
    00091
    00099                 virtual inline const Text* getText() const { return _text; };
    00100
    00105                 virtual void setText(const WoopsiString& text);
    00106
    00112                 virtual void appendText(const WoopsiString& text);
    00113
    00118                 virtual void removeText(const u32 startIndex);
    00119
    00126                 virtual void removeText(const u32 startIndex, const u32 count);
    00127
    00132                 virtual void setFont(FontBase* font);
    00133
    00138                 virtual const u32 getTextLength() const;
    00139
    00143                 virtual void showCursor();
    00144
    00148                 virtual void hideCursor();
    00149
    00156                 virtual void moveCursorToPosition(const s32 position);
    00157
    00163                 virtual inline const s32 getCursorPosition() const { return _cursorPos; };
    00164
    00170                 virtual void insertText(const WoopsiString& text, const u32 index);
    00171
    00176                 virtual void insertTextAtCursor(const WoopsiString& text);
    00177
    00182                 virtual void handleKeyboardPressEvent(const KeyboardEventArgs& e);
    00183
    00188                 virtual void handleKeyboardRepeatEvent(const KeyboardEventArgs& e);
    00189
    00194                 inline bool opensKeyboard() const { return _opensKeyboard; };
    00195
    00199                 inline void disableKeyboardPopup() { _opensKeyboard = false; };
    00200
    00204                 inline void enableKeyboardPopup() { _opensKeyboard = true; };
    00205
    00206         protected:
    00207                 Text* _text;
    00208                 u8 _visibleRows;
    00209                 s16 _maxRows;
    00210                 u32 _topRow;
    00211                 TextAlignmentHoriz _hAlignment;
    00212                 TextAlignmentVert _vAlignment;
    00213                 s32 _cursorPos;
    00214                 bool _showCursor;
    00215                 bool _opensKeyboard;
    00222                 virtual void getCursorCoordinates(s16& x, s16& y) const;
    00223
    00231                 virtual u32 getCharIndexAtCoordinate(s16 x, s32 rowIndex) const;
    00232
    00239                 virtual u32 getCharIndexAtCoordinates(s16 x, s16 y) const;
    00240
    00246                 s32 getRowContainingCoordinate(s16 y) const;
    00247
    00254                 virtual void drawContents(GraphicsPort* port);
    00255
    00262                 virtual void drawBorder(GraphicsPort* port);
    00263
    00267                 virtual void moveCursorLeft();
    00268
    00272                 virtual void moveCursorRight();
    00273
    00277                 virtual void moveCursorUp();
    00278
    00282                 virtual void moveCursorDown();
    00283
    00290                 virtual bool cullTopLines();
    00291
    00297                 virtual void limitCanvasHeight();
    00298
    00302                 virtual void limitCanvasY();
    00303
    00307                 void jumpToCursor();
    00308
    00312                 void jumpToTextBottom();
    00313
    00319                 virtual void onResize(u16 width, u16 height);
    00320
    00326                 virtual void onClick(s16 x, s16 y);
    00327
    00333                 virtual void onDoubleClick(s16 x, s16 y);
    00334
    00339                 virtual void onKeyPress(KeyCode keyCode);
    00340
    00345                 virtual void onKeyRepeat(KeyCode keyCode);
    00346
    00352                 void processPhysicalKey(KeyCode keyCode);
    00353
    00358                 virtual void processKey(const WoopsiKey* key);
    00359
    00366                 u8 getRowX(s32 row) const;
    00367
    00374                 s16 getRowY(s32 row) const;
    00375
    00380                 u32 getCursorCodePoint() const;
    00381
    00385                 void calculateVisibleRows();
    00386
    00391                 void drawText(GraphicsPort* port);
    00392
    00397                 void drawCursor(GraphicsPort* port);
    00398
    00404                 void drawRow(GraphicsPort* port, s32 row);
    00405
    00409                 inline virtual ~MultiLineTextBox() {
    00410                         delete _text;
    00411                         _text = NULL;
    00412                 }
    00413
    00417                 inline MultiLineTextBox(const MultiLineTextBox& multiLineTextBox) : ScrollingPanel(multiLineTextBox) { };
    00418         };
    00419 }
    00420
    00421 #endif