ScummVM API documentation
edit_widget.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef ULTIMA8_GUMPS_WIDGETS_EDITWIDGET_H
23#define ULTIMA8_GUMPS_WIDGETS_EDITWIDGET_H
24
25//
26// EditWidget. Widget for text input (single or multi-line)
27//
28
29#include "ultima/ultima8/gumps/gump.h"
30
31#include "ultima/ultima8/gfx/fonts/font.h"
32#include "ultima/ultima8/misc/classtype.h"
33
34namespace Ultima {
35namespace Ultima8 {
36
37class RenderedText;
38
39class EditWidget : public Gump {
40public:
41 ENABLE_RUNTIME_CLASSTYPE()
42
43 EditWidget(int x, int y, Common::String txt, bool gamefont, int fontnum,
44 int width, int height, unsigned int maxlength = 0,
45 bool multiline = false);
46 ~EditWidget() override;
47
48 void InitGump(Gump *newparent, bool take_focus = true) override;
49
50 void PaintThis(RenderSurface *, int32 lerp_factor, bool scaled) override;
51 void PaintComposited(RenderSurface *surf, int32 lerp_factor, int32 sx, int32 sy) override;
52
53 Gump *onMouseMotion(int32 mx, int32 my) override;
54 bool OnKeyDown(int key, int mod) override;
55 bool OnKeyUp(int key) override;
56 bool OnTextInput(int unicode) override;
57
58 void OnFocus(bool gain) override;
59
62 return _text;
63 }
64 void setText(const Common::String &t);
65
66 enum Message {
67 EDIT_ENTER = 16,
68 EDIT_ESCAPE = 17
69 };
70
71
72protected:
73 Common::String _text;
74 Common::String::size_type _cursor;
75 bool _gameFont;
76 int _fontNum;
77 unsigned int _maxLength;
78 bool _multiLine;
79
80 uint32 _cursorChanged;
81 bool _cursorVisible;
82
83 void ensureCursorVisible();
84 bool textFits(Common::String &t);
85 void renderText();
86 Font *getFont() const;
87
88 RenderedText *_cachedText;
89
90};
91
92} // End of namespace Ultima8
93} // End of namespace Ultima
94
95#endif
Definition: str.h:59
Definition: edit_widget.h:39
Common::String getText() const
get the current text
Definition: edit_widget.h:61
void PaintComposited(RenderSurface *surf, int32 lerp_factor, int32 sx, int32 sy) override
Overloadable method to Paint just this gumps unscaled components that require compositing (RenderSurf...
void PaintThis(RenderSurface *, int32 lerp_factor, bool scaled) override
Overloadable method to Paint just this Gump (RenderSurface is relative to this)
void InitGump(Gump *newparent, bool take_focus=true) override
Definition: gump.h:46
Definition: render_surface.h:37