00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SDL_LINEEDIT
00030 #define SDL_LINEEDIT
00031
00032 #ifdef SWIG
00033 %include "swigcommon.h"
00034 %module sdllineedit
00035 %{
00036 #include "sdllineedit.h"
00037 %}
00038 #endif
00039
00040 #include "sdlgradientwidget.h"
00041
00053 class DECLSPEC SDLLineEdit : public SDLGradientWidget {
00054 public:
00055
00057 SDLLineEdit(SDLWidget* parent, SDL_Rect& r);
00058
00060 ~SDLLineEdit();
00061
00062 void LoadThemeStyle(const char* widgettype);
00063
00065 void LoadThemeStyle(const char* widgettype, const char* objectname);
00066
00068 void EditBegin();
00069
00071 void EditEnd();
00072
00074 void SetCursorPos(int p);
00075
00077 int GetCursorPos();
00078
00080 char* GetText();
00081
00083 void SetText(char* new_text);
00084
00085 #ifndef SWIG
00086
00087 void SetTextFormat(char* text, ...);
00088 #endif
00089
00091 bool IsCursorVisible();
00092
00098 void SendChar(char c);
00099
00103 void SendDel();
00104
00108 void SendBackspace();
00109
00115 void SetValidKeys(char* keys);
00116
00117 protected:
00118
00120 virtual void eventEditBegin(int id, SDLWidget* widget, unsigned long data, void *clientdata);
00121
00123 virtual void eventEditEnd(int id, SDLWidget* widget, unsigned long data, void *clientdata);
00124
00126 void eventDraw(SDL_Surface* surface, SDL_Rect* rect);
00127
00129 bool eventKeyDown(const SDL_KeyboardEvent* key);
00130
00132 bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00133
00135 void eventInputFocusLost(SDLMessageObject* newfocus);
00136
00138 bool eventFilterKey(const SDL_KeyboardEvent* key);
00139
00140 private:
00141
00142 SDLLineEdit(const SDLLineEdit&);
00143 SDLLineEdit& operator=(SDLLineEdit&);
00144
00145 void DrawText(SDL_Surface* surface, SDL_Rect* rect);
00146 void DrawTextCursor(SDL_Surface* surface, SDL_Rect* rect);
00147 int GetCursorXPos();
00148 char* GetDrawText();
00149 int GetCursorPosFromScreen(int x, int y);
00150
00151 void InsertChar(char* c);
00152 void DeleteChar(Uint16 pos);
00153
00154 void FreeValidKeys();
00155 bool IsValidKey(char c);
00156
00157 char my_text[256];
00158 int my_cursorPosition;
00159 bool my_isCursorVisible;
00160 int my_offsetX;
00161 char* my_validkeys;
00162
00163 SDL_Surface* my_srfTextCursor;
00164
00165
00166 };
00167
00168 #endif // SDL_LINEEDIT