ScummVM API documentation
richtext.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 GUI_WIDGETS_RICHTEXT_H
23 #define GUI_WIDGETS_RICHTEXT_H
24 
25 #include "common/str.h"
26 #include "gui/widget.h"
27 
28 namespace Graphics {
29 class MacText;
30 class ManagedSurface;
31 }
32 
33 namespace GUI {
34 
35 class ScrollBarWidget;
36 
37 /* RichTextWidget */
38 class RichTextWidget : public Widget, public CommandSender {
39 protected:
40  Graphics::MacText *_txtWnd = nullptr;
41  Graphics::ManagedSurface *_surface = nullptr;
42  Common::U32String _text;
43 
44  ScrollBarWidget *_verticalScroll;
45  int16 _scrolledX, _scrolledY;
46  int _mouseDownY = 0;
47  int _mouseDownStartY = 0;
48  int _innerMargin;
49  int _scrollbarWidth;
50  uint16 _limitH;
51  int _textWidth;
52  int _textHeight;
53 
54  Common::Path _imageArchive;
55 
56 public:
57  RichTextWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &text, const Common::U32String &tooltip = Common::U32String());
58  RichTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &text, const Common::U32String &tooltip = Common::U32String());
59  RichTextWidget(GuiObject *boss, const Common::String &name, const Common::U32String &text, const Common::U32String &tooltip = Common::U32String());
60 
61  ~RichTextWidget();
62 
63  void reflowLayout() override;
64  void draw() override;
65 
66  void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
67  void handleMouseWheel(int x, int y, int direction) override;
68  void handleMouseDown(int x, int y, int button, int clickCount) override;
69  void handleMouseUp(int x, int y, int button, int clickCount) override;
70  void handleMouseMoved(int x, int y, int button) override;
71  void handleTooltipUpdate(int x, int y) override;
72 
73  void markAsDirty() override;
74 
75  bool containsWidget(Widget *) const override;
76 
77  void setImageArchive(const Common::Path &fname) { _imageArchive = fname; }
78 
79 protected:
80  void init();
81  void recalc();
82  void drawWidget() override;
83  void createWidget();
84  Widget *findWidget(int x, int y) override;
85 };
86 
87 } // End of namespace GUI
88 
89 #endif
Definition: managed_surface.h:51
Definition: str.h:59
Definition: mactext.h:47
Definition: path.h:52
Definition: scrollbar.h:34
Definition: richtext.h:38
Definition: system.h:46
Definition: object.h:60
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: ustr.h:57
Definition: formatinfo.h:28
Definition: widget.h:101
Definition: object.h:40