- Main Page
- Classes
- Files

- File List

# textbox.h

    00001 #ifndef _TEXTBOX_H_
    00002 #define _TEXTBOX_H_
    00003
    00004 #include <nds.h>
    00005 #include "label.h"
    00006 #include "woopsistring.h"
    00007 #include "gadgetstyle.h"
    00008 #include "keyboardeventhandler.h"
    00009 #include "gadgeteventargs.h"
    00010 #include "textboxbase.h"
    00011
    00012 namespace WoopsiUI {
    00013
    00014         class WoopsiTimer;
    00015         class WoopsiKey;
    00016
    00025         class TextBox : public TextBoxBase, public Label, public KeyboardEventHandler {
    00026         public:
    00027
    00040                 TextBox(s16 x, s16 y, u16 width, u16 height, const WoopsiString& text, GadgetStyle* style = NULL);
    00041
    00045                 virtual void showCursor();
    00046
    00050                 virtual void hideCursor();
    00051
    00056                 virtual void setText(const WoopsiString& text);
    00057
    00063                 virtual void appendText(const WoopsiString& text);
    00064
    00069                 virtual void removeText(const u32 startIndex);
    00070
    00077                 virtual void removeText(const u32 startIndex, const u32 count);
    00078
    00084                 virtual void insertText(const WoopsiString& text, const u32 index);
    00085
    00090                 virtual void insertTextAtCursor(const WoopsiString& text);
    00091
    00098                 virtual void moveCursorToPosition(const s32 position);
    00099
    00105                 virtual inline const s32 getCursorPosition() const { return _cursorPos; };
    00106
    00111                 virtual void handleKeyboardPressEvent(const KeyboardEventArgs& e);
    00112
    00117                 virtual void handleKeyboardRepeatEvent(const KeyboardEventArgs& e);
    00118
    00123                 virtual void handleKeyPressEvent(const GadgetEventArgs& e);
    00124
    00129                 virtual void handleKeyRepeatEvent(const GadgetEventArgs& e);
    00130
    00135                 inline bool opensKeyboard() const { return _opensKeyboard; };
    00136
    00140                 inline void disableKeyboardPopup() { _opensKeyboard = false; };
    00141
    00145                 inline void enableKeyboardPopup() { _opensKeyboard = true; };
    00146
    00147         protected:
    00148                 s32 _cursorPos;
    00149                 bool _showCursor;
    00150                 bool _opensKeyboard;
    00155                 inline void onBlur();
    00156
    00163                 virtual void drawContents(GraphicsPort* port);
    00164
    00169                 virtual void repositionCursor(const s32 position);
    00170
    00176                 void moveCursorToClickLocation(s16 x, s16 y);
    00177
    00184                 virtual void drawBorder(GraphicsPort* port);
    00185
    00191                 virtual void onClick(s16 x, s16 y);
    00192
    00198                 virtual void onDoubleClick(s16 x, s16 y);
    00199
    00204                 virtual void onKeyPress(KeyCode keyCode);
    00205
    00210                 virtual void onKeyRepeat(KeyCode keyCode);
    00211
    00216                 virtual void processKey(const WoopsiKey* key);
    00217
    00223                 virtual const u16 getCursorXPos() const;
    00224
    00229                 virtual const u16 getCursorWidth() const;
    00230
    00236                 virtual void calculateTextPositionHorizontal();
    00237
    00241                 inline TextBox(const TextBox& textbox) : Label(textbox) { };
    00242         };
    00243 }
    00244
    00245 #endif