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 class FluidScroller;
37 
38 /* RichTextWidget */
39 class RichTextWidget : public Widget, public CommandSender {
40 protected:
41  Graphics::ManagedSurface *_cachedTextSurface = nullptr;
42  Graphics::MacText *_txtWnd = nullptr;
43  Graphics::ManagedSurface *_surface = nullptr;
44  Common::U32String _text;
45 
46  ScrollBarWidget *_verticalScroll;
47  int16 _scrolledX, _scrolledY;
48  int _mouseDownY = 0;
49  int _mouseDownStartY = 0;
50  int _innerMargin;
51  int _scrollbarWidth;
52  uint16 _limitH;
53  int _textWidth;
54  int _textHeight;
55 
56  float _scrollPos;
57  FluidScroller *_fluidScroller;
58  bool _isDragging;
59 
60  Common::Path _imageArchive;
61 
62 public:
63  RichTextWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &text, const Common::U32String &tooltip = Common::U32String());
64  RichTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &text, const Common::U32String &tooltip = Common::U32String());
65  RichTextWidget(GuiObject *boss, const Common::String &name, const Common::U32String &text, const Common::U32String &tooltip = Common::U32String());
66 
67  ~RichTextWidget();
68 
69  void reflowLayout() override;
70  void draw() override;
71 
72  void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
73  void handleMouseWheel(int x, int y, int direction) override;
74  void handleMouseDown(int x, int y, int button, int clickCount) override;
75  void handleMouseUp(int x, int y, int button, int clickCount) override;
76  void handleMouseMoved(int x, int y, int button) override;
77  void handleTickle() override;
78  void handleTooltipUpdate(int x, int y) override;
79 
80  void markAsDirty() override;
81 
82  bool containsWidget(Widget *) const override;
83  bool wantsFocus() override { return true; }
84 
85  void setImageArchive(const Common::Path &fname) { _imageArchive = fname; }
86 
87 protected:
88  void init();
89  void recalc();
90  void applyScrollPos();
91  void drawWidget() override;
92  void createWidget();
93  void ensureWidget();
94  Widget *findWidget(int x, int y) override;
95 };
96 
97 } // End of namespace GUI
98 
99 #endif
Definition: managed_surface.h:51
Definition: str.h:59
Definition: mactext.h:47
Definition: FluidScroll.h:34
Definition: path.h:52
Definition: scrollbar.h:34
Definition: richtext.h:39
Definition: printman.h:30
Definition: object.h:60
Definition: ustr.h:57
Definition: formatinfo.h:28
Definition: widget.h:101
Definition: object.h:40