Woopsi 1.0 GUI Framework for Nintendo DS Homebrew

- 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
    00153                 virtual void getPreferredDimensions(Rect& rect) const;
    00154
    00155         protected:
    00156                 s32 _cursorPos;
    00157                 bool _showCursor;
    00158                 bool _opensKeyboard;
    00163                 inline void onBlur();
    00164
    00171                 virtual void drawContents(GraphicsPort* port);
    00172
    00177                 virtual void repositionCursor(const s32 position);
    00178
    00184                 void moveCursorToClickLocation(s16 x, s16 y);
    00185
    00192                 virtual void drawBorder(GraphicsPort* port);
    00193
    00199                 virtual void onClick(s16 x, s16 y);
    00200
    00206                 virtual void onDoubleClick(s16 x, s16 y);
    00207
    00212                 virtual void onKeyPress(KeyCode keyCode);
    00213
    00218                 virtual void onKeyRepeat(KeyCode keyCode);
    00219
    00224                 virtual void processKey(const WoopsiKey* key);
    00225
    00231                 virtual const u16 getCursorXPos() const;
    00232
    00237                 virtual const u16 getCursorWidth() const;
    00238
    00244                 virtual void calculateTextPositionHorizontal();
    00245
    00249                 inline TextBox(const TextBox& textbox) : Label(textbox) { };
    00250         };
    00251 }
    00252
    00253 #endif