1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ZVISION_INPUT_CONTROL_H
24 #define ZVISION_INPUT_CONTROL_H
25 
26 #include "zvision/scripting/control.h"
27 #include "zvision/text/text.h"
28 #include "zvision/text/string_manager.h"
29 
30 #include "common/rect.h"
31 
32 namespace Video {
33 	class VideoDecoder;
34 }
35 
36 namespace ZVision {
37 
38 class InputControl : public Control {
39 public:
40 	InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
41 	~InputControl();
42 
43 private:
44 	Graphics::Surface *_background;
45 	Common::Rect _textRectangle;
46 	Common::Rect _headerRectangle;
47 	TextStyleState _stringInit;
48 	TextStyleState _stringChooserInit;
49 	uint32 _nextTabstop;
50 	bool _focused;
51 
52 	Common::String _currentInputText;
53 	bool _textChanged;
54 	bool _enterPressed;
55 	bool _readOnly;
56 
57 	int16 _txtWidth;
58 	int16 _maxTxtWidth;
59 	Video::VideoDecoder *_animation;
60 
61 public:
focus()62 	void focus() {
63 		_focused = true;
64 		_textChanged = true;
65 	}
unfocus()66 	void unfocus() {
67 		_focused = false;
68 		_textChanged = true;
69 	}
70 	bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
71 	bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
72 	bool onKeyDown(Common::KeyState keyState);
73 	bool process(uint32 deltaTimeInMillis);
74 	void setText(const Common::String &_str);
75 	const Common::String getText();
76 	bool enterPress();
77 	void setReadOnly(bool);
78 };
79 
80 } // End of namespace ZVision
81 
82 #endif
83