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
00030
00031
00032 #ifndef KYRA_TEXTWIDGET_INCLUDED
00033 #define KYRA_TEXTWIDGET_INCLUDED
00034
00035 #include "../gui/widget.h"
00036
00046 class KrTextWidget : public KrWidget
00047 {
00048 public:
00055 KrTextWidget( int capacity, int width, int height,
00056 bool drawBorder,
00057 bool drawBackground,
00058 bool editable,
00059 const KrScheme& scheme
00060 );
00061
00062 KrTextWidget( int width, int height,
00063 bool drawBorder,
00064 bool drawBackground,
00065 bool editable,
00066 const KrScheme& scheme
00067 );
00068
00069 ~KrTextWidget();
00070
00071 virtual const char* WidgetType() { return "TextWidget"; }
00072
00073 virtual int IsMouseListener() { return LEFT_MOUSE; }
00074 virtual void MouseIn( bool down, bool in );
00075 virtual void MouseMove( bool down, int x, int y ) {}
00076 virtual bool MouseClick( int down, int x, int y );
00077
00078 virtual bool IsKeyListener() { return editable; }
00079 virtual void KeyFocus( bool focus );
00080 virtual bool KeyEvent( const SDL_Event& key );
00081
00083 void SetTextChar( const std::string& );
00085 void GetTextChar( std::string* buffer );
00086 int Width() { return width; }
00087 int Height() { return height; }
00088
00089
00090 virtual void AddedtoTree();
00091
00092 private:
00093 enum
00094 {
00095 CURSOR_WIDTH = 2
00096 };
00097
00098 void PositionCursor();
00099
00100 int width, height;
00101 bool drawBorder;
00102 bool drawBackground;
00103 bool editable;
00104
00105 int cursorPos, maxSpaces;
00106
00107 KrImNode* holder;
00108 KrBevelElement* bevel;
00109 KrBoxResource *plateRes, *cursorRes;
00110 KrBox *plate, *cursor;
00111 KrTextBox *textBox;
00112 };
00113
00114
00115 #endif