ScummVM API documentation
mactextwindow.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 GRAPHICS_MACGUI_MACTEXTWINDOW_H
23#define GRAPHICS_MACGUI_MACTEXTWINDOW_H
24
25#include "graphics/macgui/macfontmanager.h"
26#include "graphics/macgui/mactext.h"
27
28namespace Graphics {
29
30class MacTextWindow : public MacWindow {
31public:
32 MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, MacMenu *menu, int padding = 0);
33 MacTextWindow(MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, MacMenu *menu, int padding = 0);
34 virtual ~MacTextWindow();
35
36 void resize(int w, int h) override;
37 void setDimensions(const Common::Rect &r) override;
38
39 bool processEvent(Common::Event &event) override;
40
41 bool draw(ManagedSurface *g, bool forceRedraw = false) override;
42 bool draw(bool forceRedraw = false) override;
43 void blit(ManagedSurface *g, Common::Rect &dest) override;
44
45 void setTextWindowFont(const MacFont *macFont);
46 const MacFont *getTextWindowFont();
47
48 void appendText(const Common::U32String &str, const MacFont *macFont = nullptr, bool skipAdd = false);
49 void appendText(const Common::String &str, const MacFont *macFont = nullptr, bool skipAdd = false);
50 void clearText();
51 void setMarkdownText(const Common::U32String &str);
52
53 void scrollToBottom() { _mactext->_scrollPos = MAX<int>(0, _mactext->getTextHeight() - getInnerDimensions().height()); }
54 void scrollTo(int pos) { _mactext->_scrollPos = CLIP<int>(pos, 0, MAX<int>(0, _mactext->getTextHeight() - getInnerDimensions().height())); _mactext->setDirty(true); }
55
56 void setEditable(bool editable) { _editable = editable; _mactext->setEditable(editable); }
57 void setActive(bool active) override { MacWindow::setActive(active); if (_editable) _mactext->setActive(active); }
58 void setSelectable(bool selectable) { _selectable = selectable; }
59
60 const Common::U32String &getInput() { return _inputText; }
61 void clearInput();
62 void appendInput(const Common::U32String &str);
63 void appendInput(const Common::String &str);
64
65 Common::U32String getSelection(bool formatted = false, bool newlines = true);
66 void clearSelection() { _mactext->clearSelection(); }
67 Common::U32String cutSelection() { return _mactext->cutSelection(); }
68 const SelectedText *getSelectedText() { return _mactext->getSelectedText(); }
69 uint32 getTextColor() { return _mactext->getTextColor(); }
70 uint32 getTextColor(int start, int end) { return _mactext->getTextColor(start, end); }
71 void setTextColor(uint32 color, int start, int end) { return _mactext->setTextColor(color, start, end); }
72 int getTextFont() { return _mactext->getTextFont(); }
73 int getTextFont(int start, int end) { return _mactext->getTextFont(start, end); }
74 int getTextSlant() { return _mactext->getTextSlant(); }
75 int getTextSlant(int start, int end) { return _mactext->getTextSlant(start, end); }
76 int getTextHeight() { return _mactext->getTextHeight(); }
77 int getLineHeight(int line) { return _mactext->getLineHeight(line); }
78 Common::U32String getTextChunk(int startRow, int startCol, int endRow, int endCol, bool formatted = false, bool newlines = true) { return _mactext->getTextChunk(startRow, startCol, endRow, endCol, formatted, newlines); }
79 Common::U32String getPlainText() { return _mactext->getPlainText(); }
80 Common::U32String getEditedString() { return _mactext->getEditedString(); };
81 void enforceTextFont(uint16 fontId) { return _mactext->enforceTextFont(fontId); }
82 void setTextFont(uint16 fontId, int start, int end) { return _mactext->setTextFont(fontId, start, end); }
83 void enforceTextSlant(int textSlant) { return _mactext->enforceTextSlant(textSlant); }
84 void setTextSlant(int textSlant, int start, int end) { return _mactext->setTextSlant(textSlant, start, end); }
85 int getRowCount() { return _mactext->getRowCount(); }
86 int getLineSpacing() { return _mactext->getLineSpacing(); }
87 int getTextSize() { return _mactext->getTextSize(); }
88 int getTextSize(int start, int end) { return _mactext->getTextSize(start, end); }
89 void setTextSize(int textSize) { return _mactext->setTextSize(textSize); }
90 void setTextSize(int textSize, int start, int end) { return _mactext->setTextSize(textSize, start, end); }
91
92 int getMouseLine(int x, int y);
93
94 void setBorderColor(uint32 color) override { _mactext->setBorderColor(color); }
99 void setTextColorRGB (uint32 rgb) { _textColorRGB = rgb; }
100
101private:
102 void init();
103
104 void calcScrollBar();
105
106 void undrawInput();
107 void drawInput();
108 void drawSelection();
109
110 void calcWin95Scroll(int &scrollAreaTop, int &scrollAreaHeight, int &barY, int &barHeight);
111
112public:
113 bool _editable;
114 bool _selectable;
115
116private:
117 MacText *_mactext;
118 const MacFont *_font;
119 const Font *_fontRef;
120
121 int _maxWidth;
122 Common::U32String _inputText;
123 uint _inputTextHeight;
124 bool _inputIsDirty;
125
126 WindowClick _scrollDirection;
127 uint32 _nextScrollTime;
128 uint32 _scrollDelay;
129 uint32 _nextWheelEventTime;
130 WindowClick _clickedScrollPart;
131
132 // dragging bar for win95
133 bool _isDragging;
134 int _dragStartY;
135 int _dragStartScrollPos;
136
137 MacMenu *_menu;
138
139 int _bgcolor;
140 int _textColorRGB;
141};
142
143} // End of namespace Graphics
144
145#endif
Definition: str.h:59
Definition: ustr.h:57
Definition: font.h:83
Definition: macfontmanager.h:110
Definition: macmenu.h:95
Definition: mactext.h:47
void setActive(bool active) override
Definition: mactextwindow.h:30
bool draw(ManagedSurface *g, bool forceRedraw=false) override
bool draw(bool forceRedraw=false) override
bool processEvent(Common::Event &event) override
void setTextColorRGB(uint32 rgb)
Definition: mactextwindow.h:99
void setActive(bool active) override
Definition: mactextwindow.h:57
void setDirty(bool dirty)
Definition: macwidget.h:62
Definition: macwindow.h:205
void setActive(bool active) override
const Common::Rect & getInnerDimensions() override
Definition: macwindow.h:280
Definition: macwindowmanager.h:149
Definition: managed_surface.h:51
TextAlign
Definition: font.h:48
Definition: formatinfo.h:28
Definition: events.h:218
Definition: rect.h:536