2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2005-01-29 16:30:51 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-01-29 16:30:51 +00:00
|
|
|
*
|
2006-02-11 10:08:56 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-01-29 16:30:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GUI_EDITABLE_H
|
|
|
|
#define GUI_EDITABLE_H
|
|
|
|
|
|
|
|
#include "common/str.h"
|
|
|
|
#include "common/rect.h"
|
|
|
|
#include "gui/widget.h"
|
2006-05-27 05:46:04 +00:00
|
|
|
#include "gui/newgui.h"
|
2005-01-29 16:30:51 +00:00
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
2005-01-29 18:04:34 +00:00
|
|
|
/**
|
|
|
|
* Base class for widgets which need to edit text, like ListWidget and
|
|
|
|
* EditTextWidget.
|
|
|
|
*/
|
2005-01-29 16:30:51 +00:00
|
|
|
class EditableWidget : public Widget {
|
|
|
|
public:
|
|
|
|
typedef Common::String String;
|
|
|
|
protected:
|
|
|
|
String _editString;
|
|
|
|
|
|
|
|
bool _caretVisible;
|
|
|
|
uint32 _caretTime;
|
|
|
|
int _caretPos;
|
|
|
|
|
|
|
|
bool _caretInverse;
|
|
|
|
|
|
|
|
int _editScrollOffset;
|
|
|
|
|
2006-06-05 12:22:51 +00:00
|
|
|
Theme::FontStyle _font;
|
2006-05-27 05:46:04 +00:00
|
|
|
|
2005-01-29 16:30:51 +00:00
|
|
|
public:
|
2006-05-31 12:09:00 +00:00
|
|
|
EditableWidget(GuiObject *boss, int x, int y, int w, int h);
|
2006-06-03 13:33:39 +00:00
|
|
|
EditableWidget(GuiObject *boss, const String &name);
|
2005-01-29 16:30:51 +00:00
|
|
|
virtual ~EditableWidget();
|
|
|
|
|
2006-03-07 05:39:52 +00:00
|
|
|
void init();
|
|
|
|
|
2005-01-29 18:04:34 +00:00
|
|
|
virtual void setEditString(const String &str);
|
|
|
|
virtual const String &getEditString() const { return _editString; }
|
|
|
|
|
2005-01-29 16:30:51 +00:00
|
|
|
virtual void handleTickle();
|
2005-01-29 18:04:34 +00:00
|
|
|
virtual bool handleKeyDown(uint16 ascii, int keycode, int modifiers);
|
2005-01-29 16:30:51 +00:00
|
|
|
|
2006-08-04 15:48:37 +00:00
|
|
|
virtual void reflowLayout();
|
|
|
|
|
2005-01-29 16:30:51 +00:00
|
|
|
protected:
|
|
|
|
virtual void startEditMode() = 0;
|
|
|
|
virtual void endEditMode() = 0;
|
|
|
|
virtual void abortEditMode() = 0;
|
|
|
|
|
|
|
|
virtual Common::Rect getEditRect() const = 0;
|
2005-01-29 18:04:34 +00:00
|
|
|
virtual int getCaretOffset() const;
|
2005-01-29 16:30:51 +00:00
|
|
|
void drawCaret(bool erase);
|
2005-01-29 18:04:34 +00:00
|
|
|
bool setCaretPos(int newPos);
|
|
|
|
bool adjustOffset();
|
2006-05-27 13:17:19 +00:00
|
|
|
void makeCaretVisible();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-06-05 12:22:51 +00:00
|
|
|
void setFontStyle(Theme::FontStyle font) { _font = font; }
|
2006-05-27 05:46:04 +00:00
|
|
|
|
2006-06-20 22:50:27 +00:00
|
|
|
virtual bool tryInsertChar(byte c, int pos);
|
2005-01-29 16:30:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace GUI
|
|
|
|
|
|
|
|
#endif
|