00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TEXTFIELD_H
00020 #define TEXTFIELD_H
00021
00022 #include "../constants.h"
00023 #include "widget.h"
00024 #include "window.h"
00025 #include "label.h"
00026
00031 class TextField : public Widget {
00032 private:
00033 int numChars;
00034 bool inside;
00035 char *text;
00036 int pos, maxPos;
00037 int eventType;
00038
00039 public:
00040
00041 enum {
00042 EVENT_KEYPRESS=0,
00043 EVENT_ACTION
00044 };
00045
00046 TextField(int x, int y, int numChars);
00047 ~TextField();
00048 bool handleEvent(Widget *parent, SDL_Event *event, int x, int y);
00049 void drawWidget(Widget *parent);
00050 inline char *getText() { text[maxPos] = '\0'; return text; }
00051 inline void setFocus(bool b) { Widget::setFocus(b); inside = b; }
00052 inline void clearText() { pos = maxPos = 0; }
00053 inline int getEventType() { return eventType; }
00054
00055 virtual inline bool hasSound() { return false; }
00056 };
00057
00058 #endif
00059