Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

lineedit.h

00001 /*
00002   libwftk - Worldforge Toolkit - a widget library
00003   Copyright (C) 2002 Malcolm Walker <malcolm@worldforge.org>
00004   Based on code copyright  (C) 1999-2002  Karsten Laux
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Lesser General Public
00008   License as published by the Free Software Foundation; either
00009   version 2.1 of the License, or (at your option) any later version.
00010   
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Lesser General Public License for more details.
00015   
00016   You should have received a copy of the GNU Lesser General Public
00017   License along with this library; if not, write to the
00018   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019   Boston, MA  02111-1307, SA.
00020 */
00021 
00022 #ifndef _LINEDIT_H
00023 #define _LINEDIT_H
00024 
00025 #include <wftk/font.h>
00026 #include <wftk/widget.h>
00027 
00028 namespace wftk {
00029 
00037 class LineEdit : public Widget
00038 {
00039  public:
00043   explicit LineEdit(const std::string& text = "", const Font& font = Font());
00045   virtual ~LineEdit();
00046 
00048   const std::string& getText() {return text_;}
00050   void setTextColor(const Color& fontCol);
00051 
00053   virtual void setText(const std::string&);
00055   virtual void clearText() {setText("");}
00057   virtual void timer();
00058   
00060   SigC::Signal0<void> keyInput;
00062   SigC::Signal0<void> textChanged;
00064   SigC::Signal0<void> enterPressed;
00065   
00067   virtual bool keyEvent(const SDL_keysym&, bool pressed);
00069   virtual void gainedFocus() {invalidate(textCursor_);}
00071   virtual void lostFocus() {invalidate(textCursor_);}
00072 
00073  protected:
00075   virtual void draw(Surface&, const Point&, const Region&);
00077   virtual void setPackingInfo();
00079   void textUpdate() {updateText(); invalidate();}
00081   std::string text_;
00083   Font textFont_;
00084  private: /* see .cpp file for documentation of these methods */
00086   virtual Point drawText(Surface&, const Point&, const Region&);
00088   virtual void updateText();
00090   void drawCursor(Surface&, const Point&, const Region&);
00092   int cursorPos_;
00094   bool cursor_;
00096   bool drawCursor_;
00098   bool blockInput_;
00100   Rect textCursor_;
00102   int cursorCount_;
00104   Surface* textSurface_;
00105 };
00106 
00107 } // namespace wftk
00108 
00109 #endif // _LINEDIT_H

Generated Tue Apr 12 22:48:51 2005.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.