Woopsi 1.0 GUI Framework for Nintendo DS Homebrew

- 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 "document.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
    00064                 MultiLineTextBox(s16 x, s16 y, u16 width, u16 height, const WoopsiString& text, u32 flags, s16 maxRows = 0, GadgetStyle* style = NULL);
    00065
    00070                 virtual void setTextAlignmentHoriz(TextAlignmentHoriz alignment);
    00071
    00076                 virtual void setTextAlignmentVert(TextAlignmentVert alignment);
    00077
    00084                 virtual const u16 getPageCount() const;
    00085
    00091                 virtual const u16 getCurrentPage() const;
    00092
    00100                 virtual inline const Document* getDocument() const { return _document; };
    00101
    00106                 virtual void setText(const WoopsiString& text);
    00107
    00113                 virtual void appendText(const WoopsiString& text);
    00114
    00119                 virtual void removeText(const u32 startIndex);
    00120
    00127                 virtual void removeText(const u32 startIndex, const u32 count);
    00128
    00133                 virtual void setFont(FontBase* font);
    00134
    00139                 virtual const u32 getTextLength() const;
    00140
    00144                 virtual void showCursor();
    00145
    00149                 virtual void hideCursor();
    00150
    00157                 virtual void moveCursorToPosition(const s32 position);
    00158
    00164                 virtual inline const s32 getCursorPosition() const { return _cursorPos; };
    00165
    00171                 virtual void insertText(const WoopsiString& text, const u32 index);
    00172
    00177                 virtual void insertTextAtCursor(const WoopsiString& text);
    00178
    00183                 virtual void handleKeyboardPressEvent(const KeyboardEventArgs& e);
    00184
    00189                 virtual void handleKeyboardRepeatEvent(const KeyboardEventArgs& e);
    00190
    00195                 inline bool opensKeyboard() const { return _opensKeyboard; };
    00196
    00200                 inline void disableKeyboardPopup() { _opensKeyboard = false; };
    00201
    00205                 inline void enableKeyboardPopup() { _opensKeyboard = true; };
    00206
    00207         protected:
    00208                 Document* _document;
    00209                 u8 _visibleRows;
    00210                 s16 _maxRows;
    00211                 u32 _topRow;
    00212                 TextAlignmentHoriz _hAlignment;
    00213                 TextAlignmentVert _vAlignment;
    00214                 s32 _cursorPos;
    00215                 bool _showCursor;
    00216                 bool _opensKeyboard;
    00223                 virtual void getCursorCoordinates(s16& x, s16& y) const;
    00224
    00232                 virtual u32 getCharIndexAtCoordinate(s16 x, s32 rowIndex) const;
    00233
    00240                 virtual u32 getCharIndexAtCoordinates(s16 x, s16 y) const;
    00241
    00247                 s32 getRowContainingCoordinate(s16 y) const;
    00248
    00255                 virtual void drawContents(GraphicsPort* port);
    00256
    00263                 virtual void drawBorder(GraphicsPort* port);
    00264
    00268                 virtual void moveCursorLeft();
    00269
    00273                 virtual void moveCursorRight();
    00274
    00278                 virtual void moveCursorUp();
    00279
    00283                 virtual void moveCursorDown();
    00284
    00291                 virtual bool cullTopLines();
    00292
    00298                 virtual void limitCanvasHeight();
    00299
    00303                 virtual void limitCanvasY();
    00304
    00308                 void jumpToCursor();
    00309
    00313                 void jumpToTextBottom();
    00314
    00320                 virtual void onResize(u16 width, u16 height);
    00321
    00327                 virtual void onClick(s16 x, s16 y);
    00328
    00334                 virtual void onDoubleClick(s16 x, s16 y);
    00335
    00340                 virtual void onKeyPress(KeyCode keyCode);
    00341
    00346                 virtual void onKeyRepeat(KeyCode keyCode);
    00347
    00353                 void processPhysicalKey(KeyCode keyCode);
    00354
    00359                 virtual void processKey(const WoopsiKey* key);
    00360
    00367                 u8 getRowX(s32 row) const;
    00368
    00375                 s16 getRowY(s32 row) const;
    00376
    00381                 u32 getCursorCodePoint() const;
    00382
    00386                 void calculateVisibleRows();
    00387
    00392                 void drawText(GraphicsPort* port);
    00393
    00398                 void drawCursor(GraphicsPort* port);
    00399
    00405                 void drawRow(GraphicsPort* port, s32 row);
    00406
    00410                 inline virtual ~MultiLineTextBox() {
    00411                         delete _document;
    00412                         _document = NULL;
    00413                 }
    00414
    00418                 inline MultiLineTextBox(const MultiLineTextBox& multiLineTextBox) : ScrollingPanel(multiLineTextBox) { };
    00419         };
    00420 }
    00421
    00422 #endif