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 
28 namespace Graphics {
29 
30 class MacTextWindow : public MacWindow {
31 public:
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  virtual void resize(int w, int h) override;
37  void setDimensions(const Common::Rect &r) override;
38 
39  virtual bool processEvent(Common::Event &event) override;
40 
41  virtual bool draw(ManagedSurface *g, bool forceRedraw = false) override;
42  virtual bool draw(bool forceRedraw = false) override;
43  virtual 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 setEditable(bool editable) { _editable = editable; _mactext->setEditable(editable); }
54  void setActive(bool active) override { MacWindow::setActive(active); if (_editable) _mactext->setActive(active); }
55  void setSelectable(bool selectable) { _selectable = selectable; }
56 
57  const Common::U32String &getInput() { return _inputText; }
58  void clearInput();
59  void appendInput(const Common::U32String &str);
60  void appendInput(const Common::String &str);
61 
62  Common::U32String getSelection(bool formatted = false, bool newlines = true);
63  void clearSelection() { _mactext->clearSelection(); }
64  Common::U32String cutSelection() { return _mactext->cutSelection(); }
65  const SelectedText *getSelectedText() { return _mactext->getSelectedText(); }
66  uint32 getTextColor() { return _mactext->getTextColor(); }
67  uint32 getTextColor(int start, int end) { return _mactext->getTextColor(start, end); }
68  void setTextColor(uint32 color, int start, int end) { return _mactext->setTextColor(color, start, end); }
69  int getTextFont() { return _mactext->getTextFont(); }
70  int getTextFont(int start, int end) { return _mactext->getTextFont(start, end); }
71  int getTextSlant() { return _mactext->getTextSlant(); }
72  int getTextSlant(int start, int end) { return _mactext->getTextSlant(start, end); }
73  int getTextHeight() { return _mactext->getTextHeight(); }
74  int getLineHeight(int line) { return _mactext->getLineHeight(line); }
75  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); }
76  Common::U32String getPlainText() { return _mactext->getPlainText(); }
77  Common::U32String getEditedString() { return _mactext->getEditedString(); };
78  void enforceTextFont(uint16 fontId) { return _mactext->enforceTextFont(fontId); }
79  void setTextFont(uint16 fontId, int start, int end) { return _mactext->setTextFont(fontId, start, end); }
80  void enforceTextSlant(int textSlant) { return _mactext->enforceTextSlant(textSlant); }
81  void setTextSlant(int textSlant, int start, int end) { return _mactext->setTextSlant(textSlant, start, end); }
82  int getRowCount() { return _mactext->getRowCount(); }
83  int getLineSpacing() { return _mactext->getLineSpacing(); }
84  int getTextSize() { return _mactext->getTextSize(); }
85  int getTextSize(int start, int end) { return _mactext->getTextSize(start, end); }
86  void setTextSize(int textSize) { return _mactext->setTextSize(textSize); }
87  void setTextSize(int textSize, int start, int end) { return _mactext->setTextSize(textSize, start, end); }
88 
89  int getMouseLine(int x, int y);
90 
91  virtual void setBorderColor(uint32 color) override { _mactext->setBorderColor(color); }
96  void setTextColorRGB (uint32 rgb) { _textColorRGB = rgb; }
97 
98 private:
99  void init();
100 
101  void calcScrollBar();
102 
103  void undrawInput();
104  void drawInput();
105  void drawSelection();
106 
107 public:
108  bool _editable;
109  bool _selectable;
110 
111 private:
112  MacText *_mactext;
113  const MacFont *_font;
114  const Font *_fontRef;
115 
116  int _maxWidth;
117  Common::U32String _inputText;
118  uint _inputTextHeight;
119  bool _inputIsDirty;
120 
121  MacMenu *_menu;
122 
123  int _bgcolor;
124  int _textColorRGB;
125 };
126 
127 } // End of namespace Graphics
128 
129 #endif
Definition: managed_surface.h:51
Definition: str.h:59
Definition: font.h:83
TextAlign
Definition: font.h:48
virtual bool draw(ManagedSurface *g, bool forceRedraw=false) override
Definition: mactext.h:47
Definition: macwindow.h:203
Definition: mactextwindow.h:30
Definition: rect.h:524
Definition: macwindowmanager.h:147
virtual bool processEvent(Common::Event &event) override
Definition: ustr.h:57
void setActive(bool active) override
Definition: mactextwindow.h:54
Definition: events.h:210
Definition: formatinfo.h:28
Definition: macmenu.h:94
Definition: mactext.h:29
Definition: macfontmanager.h:106
void setTextColorRGB(uint32 rgb)
Definition: mactextwindow.h:96
void setActive(bool active) override
void setActive(bool active) override