00001
00006 #ifndef PG_MULTI_LINE_EDIT
00007 #define PG_MULTI_LINE_EDIT
00008
00009 #include "pglineedit.h"
00010 #include "pgscrollbar.h"
00011 #include "pgtheme.h"
00012 #include "pgstring.h"
00013
00014 class DECLSPEC PG_MultiLineEdit : public PG_LineEdit {
00015 public:
00016
00017 PG_MultiLineEdit(PG_Widget* parent, const PG_Rect& r, const std::string& style="LineEdit", int maximumLength = 1000000);
00018 virtual void SetText(const std::string& new_text);
00019
00020 void SetCursorPos(int p);
00021
00022 void SetVPosition(int line);
00023
00024 void InsertText(const std::string& c);
00025
00026 protected:
00027
00028 void eventBlit(SDL_Surface* surface, const PG_Rect& src, const PG_Rect& dst);
00029
00030 bool eventKeyDown(const SDL_KeyboardEvent* key);
00031
00032 bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00033
00034 bool eventMouseMotion(const SDL_MouseMotionEvent* motion);
00035
00036 bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00037
00038 virtual void InsertChar(const PG_Char& c);
00039
00040 virtual void DeleteChar(Uint16 pos);
00041
00042 bool handleScroll(PG_ScrollBar* widget, long data);
00043
00044 private:
00045
00046 DLLLOCAL void FindWordRight();
00047
00048 DLLLOCAL void FindWordLeft();
00049
00050 DLLLOCAL void DeleteSelection();
00051
00052 DLLLOCAL void GetCursorTextPosFromScreen(int x, int y, unsigned int& horzOffset, unsigned int& lineOffset);
00053
00054 DLLLOCAL void GetCursorTextPos(unsigned int& horzOffset, unsigned int& lineOffset);
00055
00056 DLLLOCAL void SetCursorTextPos(unsigned int offset, unsigned int line);
00057
00058 DLLLOCAL int ConvertCursorPos(unsigned int offset, unsigned int line);
00059
00060 DLLLOCAL void GetCursorPos(int& x, int& y);
00061
00062 DLLLOCAL void DrawText(const PG_Rect& dst);
00063
00064 DLLLOCAL void DrawTextCursor();
00065
00066 DLLLOCAL void CreateTextVector(bool bSetupVScroll = true);
00067
00068 DLLLOCAL void SetupVScroll();
00069
00070 std::vector<PG_String> my_textdata;
00071
00072 PG_ScrollBar* my_vscroll;
00073
00074 int my_firstLine;
00075
00076 int my_mark;
00077
00078 bool my_isCursorAtEOL;
00079
00080 bool my_allowHiddenCursor;
00081 };
00082
00083 #endif // PG_MULTI_LINE_EDIT