ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

editable.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GUI_WIDGETS_EDITABLE_H
00024 #define GUI_WIDGETS_EDITABLE_H
00025 
00026 #include "common/keyboard.h"
00027 #include "common/str.h"
00028 #include "gui/widget.h"
00029 #include "gui/ThemeEngine.h"
00030 #include "gui/object.h"
00031 
00032 namespace Common {
00033 struct Rect;
00034 }
00035 
00036 namespace GUI {
00037 
00042 class EditableWidget : public Widget, public CommandSender {
00043 public:
00044     typedef Common::String String;
00045 protected:
00046     String      _editString;
00047 
00048     uint32      _cmd;
00049 
00050     bool        _caretVisible;
00051     uint32      _caretTime;
00052     int         _caretPos;
00053 
00054     bool        _caretInverse;
00055 
00056     int         _editScrollOffset;
00057 
00058     ThemeEngine::FontStyle  _font;
00059 
00060     ThemeEngine::TextInversionState  _inversion;
00061 
00062 public:
00063     EditableWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip = 0, uint32 cmd = 0);
00064     EditableWidget(GuiObject *boss, const String &name, const char *tooltip = 0, uint32 cmd = 0);
00065     virtual ~EditableWidget();
00066 
00067     void init();
00068 
00069     virtual void setEditString(const String &str);
00070     virtual const String &getEditString() const     { return _editString; }
00071 
00072     virtual void handleTickle();
00073     virtual bool handleKeyDown(Common::KeyState state);
00074     virtual void reflowLayout();
00075 
00076     bool setCaretPos(int newPos);
00077 
00078 protected:
00079     virtual void startEditMode() = 0;
00080     virtual void endEditMode() = 0;
00081     virtual void abortEditMode() = 0;
00087     virtual Common::Rect getEditRect() const = 0;
00088     virtual int getCaretOffset() const;
00089     void drawCaret(bool erase);
00090     bool adjustOffset();
00091     void makeCaretVisible();
00092 
00093     void defaultKeyDownHandler(Common::KeyState &state, bool &dirty, bool &forcecaret, bool &handled);
00094 
00095     void setFontStyle(ThemeEngine::FontStyle font) { _font = font; }
00096 
00097     virtual bool tryInsertChar(byte c, int pos);
00098 };
00099 
00100 } // End of namespace GUI
00101 
00102 #endif


Generated on Sat Feb 16 2019 05:00:49 for ResidualVM by doxygen 1.7.1
curved edge   curved edge