textwidget.h

00001 /*--License:
00002         Kyra Sprite Engine
00003         Copyright Lee Thomason (Grinning Lizard Software) 2001-2005
00004         www.grinninglizard.com/kyra
00005         www.sourceforge.net/projects/kyra
00006 
00007         Kyra is provided under the LGPL. 
00008         
00009         I kindly request you display a splash screen (provided in the HTML documentation)
00010         to promote Kyra and acknowledge the software and everyone who has contributed to it, 
00011         but it is not required by the license.
00012 
00013 --- LGPL License --
00014 
00015     This library is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU Lesser General Public
00017     License as published by the Free Software Foundation; either
00018     version 2.1 of the License, or (at your option) any later version.
00019 
00020     This library is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023     Lesser General Public License for more details.
00024 
00025     You should have received a copy of the GNU Lesser General Public
00026     License along with this library; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 
00029         The full text of the license can be found in lgpl.txt
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         // Used to initialize the widget.
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

Generated on Thu Jul 20 20:45:32 2006 for Kyra by  doxygen 1.4.7