ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
macgui_impl.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 SCUMM_MACGUI_MACGUI_IMPL_H
23 #define SCUMM_MACGUI_MACGUI_IMPL_H
24 
25 #define TEXT_END_MARKER { 0, 0, kStyleRegular, Graphics::kTextAlignLeft, nullptr }
26 
27 #include "common/events.h"
28 #include "common/hashmap.h"
29 #include "common/rect.h"
30 #include "common/str.h"
31 #include "common/str-array.h"
32 
33 #include "engines/engine.h"
34 
35 #include "graphics/font.h"
36 #include "graphics/surface.h"
37 
38 class OSystem;
39 
40 namespace Graphics {
41 struct Surface;
42 class Palette;
43 class MacWindowManager;
44 class MacMenu;
45 }
46 
47 namespace Scumm {
48 
49 class ScummEngine;
50 class Actor;
51 
52 class MacGuiImpl {
53 public:
54  class MacDialogWindow;
55 
56  enum MacStringIds {
57  kMSISkip = -1,
58  kMSIAboutGameName = 1,
59  kMSIRoughCommandMsg,
60  kMSIAreYouSureYouWantToQuit,
61  kMSIAreYouSureYouWantToRestart,
62  kMSIGameName,
63  kMSIOpenGameFile,
64  kMSISaveGameFileAs,
65  kMSIGameFile,
66  kMSIAboutString1,
67  kMSIAboutString2,
68  kMSIAboutString3,
69  kMSIAboutString4,
70  kMSIAboutString5,
71  kMSIAboutString6,
72  kMSIAboutString7,
73  kMSIAboutString8,
74  kMSIAboutString9,
75  kMSIAboutString10,
76  kMSIAboutString11,
77  kMSIAboutString12,
78  kMSIAboutString13,
79  kMSIAboutString14,
80  kMSIAboutString15,
81  kMSIAboutString16,
82  kMSIAboutString17,
83  kMSIAboutString18,
84  kMSIAboutString19,
85  kMSIAboutString20,
86  kMSIAboutString21,
87  kMSIAboutString22,
88  kMSIAboutString23,
89  kMSIAboutString24,
90  kMSIAboutString25,
91  kMSIAboutString26,
92  kMSIAboutString27,
93  kMSIAboutString28,
94  kMSIAboutString29,
95  kMSIAboutString30,
96  kMSIAboutString31,
97  kMSIAboutString32,
98  kMSIAboutString33,
99  kMSIAboutString34,
100  kMSIAboutString35,
101  kMSIAboutString36,
102  kMSIAboutString37,
103  kMSIAboutString38,
104  kMSIAboutString39,
105  kMSIAboutString40
106  };
107 
108  enum ParsingMethod {
109  kStrC,
110  kStrPascal,
111  };
112 
114  MacStringIds strId;
115  ParsingMethod parsingMethod;
116  int numStrings;
117  };
118 
119  enum MacWidgetType {
120  kWidgetUnknown,
121  kWidgetButton,
122  kWidgetCheckbox,
123  kWidgetStaticText,
124  kWidgetEditText,
125  kWidgetIcon,
126  kWidgetImage,
127  kWidgetSlider,
128  kWidgetListBox,
129  kWidgetImageSlider,
130  kWidgetPopUpMenu
131  };
132 
133  virtual void onMenuOpen();
134  virtual void onMenuClose();
135 
136 protected:
137  ScummEngine *_vm = nullptr;
138  OSystem *_system = nullptr;
139 
140  Graphics::Surface *_surface = nullptr;
141  MacGuiImpl::MacDialogWindow *_bannerWindow = nullptr;
142 
143  Common::Path _resourceFile;
144 
145  bool _paletteDirty = false;
146  bool _suspendPaletteUpdates = false;
147 
148  bool _menuIsActive = false;
149  bool _cursorWasVisible = false;
150 
152  Common::Array<Common::String> _strsStrings;
153 
154  int _gameFontId = -1;
155 
156  byte _unicodeToMacRoman[96];
157 
158  enum DelayStatus {
159  kDelayDone = 0,
160  kDelayInterrupted = 1,
161  kDelayAborted
162  };
163 
164  enum FontId {
165  kSystemFont,
166 
167  kAboutFontRegular,
168  kAboutFontBold,
169  kAboutFontBold2,
170  kAboutFontExtraBold,
171  kAboutFontHeaderInside,
172  kAboutFontHeaderOutside,
173  kAboutFontHeader,
174  kAboutFontHeaderSimple1,
175  kAboutFontHeaderSimple2,
176 
177  kIndy3FontSmall,
178  kIndy3FontMedium,
179  kIndy3VerbFontRegular,
180  kIndy3VerbFontBold,
181  kIndy3VerbFontOutline,
182 
183  kLoomFontSmall,
184  kLoomFontMedium,
185  kLoomFontLarge
186  };
187 
188  enum TextStyle {
189  kStyleHeader1,
190  kStyleHeader2,
191  kStyleHeaderSimple1,
192  kStyleHeaderSimple2,
193  kStyleBold,
194  kStyleBold2,
195  kStyleExtraBold,
196  kStyleRegular
197  };
198 
199  struct TextLine {
200  int x;
201  int y;
202  TextStyle style;
203  Graphics::TextAlign align;
204  const char *str;
205  };
206 
207  enum MacDialogWindowStyle {
208  kWindowStyleNormal,
209  kWindowStyleRounded
210  };
211 
212  enum MacDialogMenuStyle {
213  kMenuStyleNone,
214  kMenuStyleDisabled,
215  kMenuStyleApple
216  };
217 
218  MacGuiImpl::DelayStatus delay(uint32 ms = 0);
219 
220  virtual bool getFontParams(FontId fontId, int &id, int &size, int &slant) const;
221 
222  virtual bool handleMenu(int id, Common::String &name);
223 
224  // For older games, there is no problem with displaying the Mac GUI and
225  // the game at the same time. For newer, there is.
226  virtual void saveScreen() {}
227  virtual void restoreScreen() {}
228 
229  virtual void runAboutDialog() = 0;
230  virtual bool runOpenDialog(int &saveSlotToHandle);
231  virtual bool runSaveDialog(int &saveSlotToHandle, Common::String &saveName);
232  virtual bool runOptionsDialog() = 0;
233  void prepareSaveLoad(Common::StringArray &savegameNames, bool *availSlots, int *slotIds, int size);
234 
235  bool runOkCancelDialog(Common::String text);
236 
237  virtual bool readStrings();
238  void parseSTRSBlock(uint8 *strsData, const MacSTRSParsingEntry *parsingTable, int parsingTableSize);
239 
240  void addMenu(Graphics::MacMenu *menu, int menuId);
241 
242  // These are non interactable, no point in having them as widgets for now...
243  void drawFakePathList(MacDialogWindow *window, Common::Rect r, const char *text);
244  void drawFakeDriveLabel(MacDialogWindow *window, Common::Rect r, const char *text);
245 
246  Graphics::Surface *createRemappedSurface(const Graphics::Surface *surface, const byte *palette, int colorCount);
247 
248 public:
249  class MacGuiObject {
250  protected:
251  Common::Rect _bounds;
252  bool _redraw = false;
253  bool _enabled = false;
254  bool _visible = true;
255 
256  public:
257  MacGuiObject(Common::Rect bounds, bool enabled) : _bounds(bounds), _enabled(enabled) {}
258  virtual ~MacGuiObject() {}
259 
260  Common::Rect getBounds() const { return _bounds; }
261  bool getRedraw() const { return _redraw; }
262  bool isEnabled() const { return _enabled; }
263  bool isVisible() const { return _visible; }
264  };
265 
266  class MacWidget : public MacGuiObject {
267  protected:
269  uint32 _black;
270  uint32 _white;
271 
272  int _id = -1;
273  MacWidgetType _type = kWidgetUnknown;
274 
275  bool _fullRedraw = false;
276 
277  Common::String _text;
278  int _oldValue = 0;
279  int _value = 0;
280 
281  int drawText(Common::String text, int x, int y, int w, uint32 fg = 0, uint32 bg = 0, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wordWrap = false, int deltax = 0) const;
282  void drawBitmap(Common::Rect r, const uint16 *bitmap, uint32 color) const;
283 
284  public:
285  MacWidget(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled);
286  virtual ~MacWidget() {};
287 
288  void setId(int id) { _id = id; }
289  int getId() const { return _id; }
290 
291  void setType(MacWidgetType type) { _type = type; }
292  MacWidgetType getType() { return _type; }
293 
294  // Visibility never changes after initialization, so it does
295  // not trigger a redraw.
296  void setVisible(bool visible) { _visible = visible; }
297 
298  virtual void getFocus() { setRedraw(); }
299  virtual void loseFocus() { setRedraw(); }
300 
301  virtual void setRedraw(bool fullRedraw = false);
302 
303  void setEnabled(bool enabled);
304 
305  virtual void setValue(int value);
306  int getValue() const { return _value; }
307 
308  void rememberValue() {
309  _oldValue = _value;
310  }
311 
312  bool valueHasChanged() {
313  return _oldValue != _value;
314  }
315 
316  Common::String getText() const;
317 
318  virtual bool useBeamCursor() { return false; }
319  virtual bool findWidget(int x, int y) const;
320  virtual bool reactsToKeyDown() { return false; }
321 
322  virtual void draw(bool drawFocused = false) = 0;
323 
324  virtual void handleMouseDown(Common::Event &event) {}
325  virtual bool handleDoubleClick(Common::Event &event) { return false; }
326  virtual bool handleMouseUp(Common::Event &event) { return false; }
327  virtual void handleMouseMove(Common::Event &event) {}
328  virtual void handleMouseHeld() {}
329  virtual void handleWheelUp() {}
330  virtual void handleWheelDown() {}
331  virtual bool handleKeyDown(Common::Event &event) { return false; }
332  };
333 
334  class MacButton : public MacWidget {
335  private:
336  struct CornerLine {
337  int start;
338  int length;
339  };
340 
341  void hLine(int x0, int y0, int x1, bool enabled);
342  void vLine(int x0, int y0, int y1, bool enabled);
343  void drawCorners(Common::Rect r, CornerLine *corner, bool enabled);
344 
345  public:
346  MacButton(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled) : MacWidget(window, bounds, text, enabled) {}
347 
348  void draw(bool drawFocused = false) override;
349 
350  bool handleMouseUp(Common::Event &event) override { return true; }
351  };
352 
353  class MacCheckbox : public MacWidget {
354  private:
355  Common::Rect _hitBounds;
356 
357  public:
358  MacCheckbox(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled);
359 
360  bool findWidget(int x, int y) const override;
361  void draw(bool drawFocused = false) override;
362  bool handleMouseUp(Common::Event &event) override;
363  };
364 
365  // The dialogs add texts as disabled, but we don't want it to be drawn
366  // as disabled so we enable it and make it "disabled" by giving it a
367  // custom findWidget().
368 
369  class MacStaticText : public MacWidget {
370  private:
371  uint32 _fg;
372  uint32 _bg;
374  bool _wordWrap = true;
375 
376  public:
379  Common::Rect bounds, Common::String text,
380  bool enabled, Graphics::TextAlign alignment = Graphics::kTextAlignLeft) : MacWidget(window, bounds, text, true) {
381  _alignment = alignment;
382  _fg = _black;
383  _bg = _white;
384  }
385 
386  void getFocus() override {}
387  void loseFocus() override {}
388 
389  void setWordWrap(bool wordWrap) { _wordWrap = wordWrap; }
390 
391  void setText(Common::String text) {
392  if (text != _text) {
393  _text = text;
394  setRedraw();
395  }
396  }
397 
398  void setColor(uint32 fg, uint32 bg) {
399  if (fg != _fg || bg != _bg) {
400  _fg = fg;
401  _bg = bg;
402  setRedraw();
403  }
404  }
405 
406  void draw(bool drawFocused = false) override;
407  };
408 
409  class MacEditText : public MacWidget {
410  private:
411  // Max length of a SCUMM saved game name. We could make this
412  // configurable later, if needed.
413  uint _maxLength = 31;
414 
415  int _textPos = 1;
416  int _selectLen = 0;
417  int _caretPos = 0;
418  int _caretX = -1;
419 
420  uint32 _nextCaretBlink = 0;
421  bool _caretVisible = true;
422 
423  const Graphics::Font *_font;
424  Graphics::Surface _textSurface;
425 
426  int getTextPosFromMouse(int x, int y);
427 
428  void updateSelection(int x, int y);
429  void deleteSelection();
430 
431  public:
432  MacEditText(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled);
433 
434  void getFocus() override {}
435  void loseFocus() override {}
436 
437  void selectAll();
438 
439  bool useBeamCursor() override { return true; }
440  bool findWidget(int x, int y) const override;
441  bool reactsToKeyDown() override { return true; }
442 
443  void draw(bool drawFocused = false) override;
444 
445  void handleMouseDown(Common::Event &event) override;
446  bool handleDoubleClick(Common::Event &event) override;
447  bool handleKeyDown(Common::Event &event) override;
448  void handleMouseHeld() override;
449  void handleMouseMove(Common::Event &event) override;
450  };
451 
452  class MacImage : public MacWidget {
453  private:
454  Graphics::Surface *_image = nullptr;
455  Graphics::Surface *_mask = nullptr;
456 
457  public:
458  MacImage(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Graphics::Surface *surface, Graphics::Surface *mask, bool enabled);
459  ~MacImage();
460 
461  Graphics::Surface *getImage() const { return _image; }
462  Graphics::Surface *getMask() const { return _mask; }
463 
464  void draw(bool drawFocused = false) override;
465  };
466 
467  class MacSliderBase : public MacWidget {
468  protected:
469  int _minValue;
470  int _maxValue;
471  int _minPos;
472  int _maxPos;
473  int _handlePos = -1;
474  int _grabOffset = -1;
475 
476  Common::HashMap<int, int> _posToValue;
477  Common::HashMap<int, int> _valueToPos;
478 
479  int calculateValueFromPos(int pos) const;
480  int calculatePosFromValue(int value) const;
481  int calculateValueFromPos() const;
482  int calculatePosFromValue() const;
483 
484  public:
485  MacSliderBase(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, int minValue, int maxValue, int minPos, int maxPos, bool enabled)
486  : MacWidget(window, bounds, "SliderBase", enabled),
487  _minValue(minValue), _maxValue(maxValue),
488  _minPos(minPos), _maxPos(maxPos) {}
489 
490  virtual ~MacSliderBase() {
491  _posToValue.clear();
492  _valueToPos.clear();
493  }
494 
495  void getFocus() override {}
496  void loseFocus() override {}
497 
498  int getMinValue() const { return _minValue; }
499  int getMaxValue() const { return _maxValue; }
500  void setValue(int value) override;
501 
502  void addStop(int pos, int value) {
503  _posToValue[pos] = value;
504  _valueToPos[value] = pos;
505  }
506  };
507 
508  class MacSlider : public MacSliderBase {
509  private:
510  Common::Point _clickPos;
511  uint32 _nextRepeat = 0;
512 
513  int _pageSize = 0;
514  int _paging = 0;
515 
516  bool _upArrowPressed = false;
517  bool _downArrowPressed = false;
518 
519  Common::Rect _boundsButtonUp;
520  Common::Rect _boundsButtonDown;
521  Common::Rect _boundsBody;
522 
523  Common::Rect getHandleRect(int value);
524 
525  void fill(Common::Rect r, bool inverted = false);
526 
527  void drawUpArrow(bool markAsDirty);
528  void drawDownArrow(bool markAsDirty);
529  void drawArrow(Common::Rect r, const uint16 *bitmap, bool markAsDirty);
530 
531  void eraseDragHandle();
532  void drawHandle(Common::Rect r);
533 
534  public:
535  MacSlider(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, int minValue, int maxValue, int pageSize, bool enabled);
536 
537  bool isScrollable() const { return (_maxValue - _minValue) > 0; }
538  int getPageSize() const { return _pageSize; }
539 
540  bool findWidget(int x, int y) const override;
541  void draw(bool drawFocued = false) override;
542  void redrawHandle(int oldValue, int newValue);
543 
544  void handleMouseDown(Common::Event &event) override;
545  bool handleMouseUp(Common::Event &event) override;
546  void handleMouseMove(Common::Event &event) override;
547  void handleMouseHeld() override;
548  void handleWheelUp() override;
549  void handleWheelDown() override;
550  };
551 
552  class MacImageSlider : public MacSliderBase {
553  private:
554  Graphics::Surface *_background;
555  MacImage *_handle;
556  int _minX;
557  int _maxX;
558  bool _freeBackground = false;
559  bool _snapWhileDragging = false;
560 
561  void eraseHandle();
562  void drawHandle();
563 
564  public:
565  MacImageSlider(MacGuiImpl::MacDialogWindow *window, MacImage *background, MacImage *handle, bool enabled, int minX, int maxX, int minValue, int maxValue, int leftMargin, int rightMargin)
566  : MacSliderBase(window, background->getBounds(), minValue, maxValue, minX + leftMargin, maxX - rightMargin, enabled),
567  _background(background->getImage()), _handle(handle), _minX(minX), _maxX(maxX) {}
568  MacImageSlider(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, MacImage *handle, bool enabled, int minX, int maxX, int minValue, int maxValue);
569  ~MacImageSlider();
570 
571  void setValue(int value) override;
572 
573  bool findWidget(int x, int y) const override;
574  void draw(bool drawFocused = false) override;
575 
576  void setSnapWhileDragging(bool snap) { _snapWhileDragging = snap; }
577 
578  void handleMouseDown(Common::Event &event) override;
579  bool handleMouseUp(Common::Event &event) override;
580  void handleMouseMove(Common::Event &event) override;
581  void handleWheelUp() override;
582  void handleWheelDown() override;
583  };
584 
585  class MacListBox : public MacWidget {
586  private:
587  Common::StringArray _texts;
588  Common::Array<MacStaticText *> _textWidgets;
589  MacSlider *_slider;
590  bool _sliderFocused = false;
591 
592  void updateTexts();
593  void handleWheel(int distance);
594 
595  public:
596  MacListBox(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::StringArray texts, bool enabled, bool contentUntouchable = true);
597  ~MacListBox();
598 
599  void getFocus() override {}
600  void loseFocus() override {}
601 
602  void setValue(int value) override {
603  if (value != _value) {
604  _value = value;
605  updateTexts();
606  }
607  }
608 
609  bool findWidget(int x, int y) const override;
610  void setRedraw(bool fullRedraw = false) override;
611  void draw(bool drawFocused = false) override;
612 
613  void handleMouseDown(Common::Event &event) override;
614  bool handleDoubleClick(Common::Event &event) override;
615  bool handleMouseUp(Common::Event &event) override;
616  void handleMouseMove(Common::Event &event) override;
617  void handleMouseHeld() override;
618  void handleWheelUp() override;
619  void handleWheelDown() override;
620  bool handleKeyDown(Common::Event &event) override;
621  };
622 
623  class MacPopUpMenu : public MacWidget {
624  private:
625  Common::StringArray _texts;
626  int _textWidth;
627  bool _menuVisible = false;
628  int _selected;
629  Graphics::Surface _popUpBackground;
630  Common::Rect _popUpBounds;
631 
632  public:
633  MacPopUpMenu(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, int textWidth, Common::StringArray texts, bool enabled);
634  ~MacPopUpMenu();
635 
636  bool findWidget(int x, int y) const override;
637  void draw(bool drawFocused = false) override;
638 
639  void handleMouseDown(Common::Event &event) override;
640  bool handleMouseUp(Common::Event &event) override;
641  void handleMouseMove(Common::Event &event) override;
642  };
643 
644  enum MacDialogEventType {
645  kDialogClick,
646  kDialogValueChange,
647  kDialogKeyDown
648  };
649 
650  struct MacDialogEvent {
651  MacWidget *widget;
652  MacDialogEventType type;
653  };
654 
656  private:
657  Common::Queue<MacDialogEvent> _eventQueue;
658  uint32 _black;
659  uint32 _white;
660 
661  bool _shakeWasEnabled;
662 
663  Common::Rect _bounds;
664  int _margin;
665 
666  bool _visible = false;
667 
668  uint32 _lastClickTime = 0;
669  Common::Point _lastClickPos;
670 
671  Graphics::Surface *_beamCursor = nullptr;
672  Common::Point _beamCursorPos;
673  bool _cursorWasVisible = false;
674  bool _beamCursorVisible = false;
675  const int _beamCursorHotspotX = 3;
676  const int _beamCursorHotspotY = 4;
677 
678  void drawBeamCursor();
679  void undrawBeamCursor();
680 
681  PauseToken _pauseToken;
682 
683  Graphics::Surface *_from = nullptr;
684  Graphics::Surface *_backup = nullptr;
685  Graphics::Surface _surface;
686  Graphics::Surface _innerSurface;
687 
689 
690  MacWidget *_defaultWidget = nullptr;
691 
692  MacWidget *_focusedWidget = nullptr;
693  Common::Point _focusClick;
694  Common::Point _oldMousePos;
695  Common::Point _mousePos;
696  Common::Point _realMousePos;
697 
698  Common::StringArray _substitutions;
699  Common::Array<Common::Rect> _dirtyRects;
700  bool _dirtyPalette = false;
701 
702  void queueEvent(MacGuiImpl::MacWidget *widget, MacGuiImpl::MacDialogEventType type);
703 
704  void copyToScreen(Graphics::Surface *s = nullptr) const;
705 
706  void addWidget(MacWidget *widget, MacWidgetType type);
707 
708  public:
709  OSystem *_system;
710  MacGuiImpl *_gui;
711 
712  MacDialogWindow(MacGuiImpl *gui, OSystem *system, Graphics::Surface *from, Common::Rect bounds, MacDialogWindowStyle windowStyle = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
713  ~MacDialogWindow();
714 
715  Graphics::Surface *surface() { return &_surface; }
716  Graphics::Surface *innerSurface() { return &_innerSurface; }
717 
718  bool isVisible() const { return _visible; }
719 
720  void show();
721  bool runDialog(MacDialogEvent &dialogEvent);
722  void delayAndUpdate();
723  void updateCursor();
724 
725  uint getNumWidgets() const { return _widgets.size(); }
726 
727  MacWidget *getWidget(uint nr) const;
728  MacWidget *getWidget(MacWidgetType type, uint nr = 0) const;
729 
730  void setDefaultWidget(MacWidget *widget) { _defaultWidget = widget; }
731  MacWidget *getDefaultWidget() const { return _defaultWidget; }
732 
733  void setFocusedWidget(int x, int y);
734  void clearFocusedWidget();
735  MacWidget *getFocusedWidget() const { return _focusedWidget; }
736  Common::Point getFocusClick() const { return _focusClick; }
737  Common::Point getMousePos() const { return _mousePos; }
738 
739  int findWidget(int x, int y) const;
740 
741  MacGuiImpl::MacButton *addButton(Common::Rect bounds, Common::String text, bool enabled);
742  MacGuiImpl::MacCheckbox *addCheckbox(Common::Rect bounds, Common::String text, bool enabled);
743  MacGuiImpl::MacStaticText *addStaticText(Common::Rect bounds, Common::String text, bool enabled, Graphics::TextAlign alignment = Graphics::kTextAlignLeft);
744  MacGuiImpl::MacEditText *addEditText(Common::Rect bounds, Common::String text, bool enabled);
745  MacGuiImpl::MacImage *addIcon(int x, int y, int id, bool enabled);
746  MacGuiImpl::MacImage *addPicture(Common::Rect bounds, int id, bool enabled);
747  MacGuiImpl::
748  MacGuiImpl::MacSlider *addSlider(int x, int y, int h, int minValue, int maxValue, int pageSize, bool enabled);
749  MacGuiImpl::MacImageSlider *addImageSlider(int backgroundId, int handleId, bool enabled, int minX, int maxX, int minValue, int maxValue, int leftMargin = 0, int rightMargin = 0);
750  MacGuiImpl::MacImageSlider *addImageSlider(Common::Rect bounds, MacImage *handle, bool enabled, int minX, int maxX, int minValue, int maxValue);
751  MacGuiImpl::MacListBox *addListBox(Common::Rect bounds, Common::StringArray texts, bool enabled, bool contentUntouchable = false);
752  MacGuiImpl::MacPopUpMenu *addPopUpMenu(Common::Rect bounds, Common::String text, int textWidth, Common::StringArray texts, bool enabled);
753 
754  void addControl(Common::Rect bounds, uint16 controlId);
755 
756  void addSubstitution(Common::String text) { _substitutions.push_back(text); }
757  void replaceSubstitution(int nr, Common::String text) { _substitutions[nr] = text; }
758 
759  bool hasSubstitution(uint n) const { return n < _substitutions.size(); }
760  Common::String &getSubstitution(uint n) { return _substitutions[n]; }
761 
762  void markRectAsDirty(Common::Rect r);
763  void update(bool fullRedraw = false);
764 
765  void drawPatternRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled, bool darkenOnly);
766 
767  void drawDottedHLine(int x0, int y, int x1);
768  void fillPattern(Common::Rect r, uint16 pattern, bool fillBlack = true, bool fillWhite = true);
769  void drawSprite(const MacImage *image, int x, int y);
770  void drawSprite(const Graphics::Surface *sprite, int x, int y);
771  void drawSprite(const Graphics::Surface *sprite, int x, int y, Common::Rect clipRect);
772  void drawTexts(Common::Rect r, const TextLine *lines, bool inverse = false);
773  void drawTextBox(Common::Rect r, const TextLine *lines, bool inverse = false, int arc = 9);
774  };
775 
776  MacGuiImpl(ScummEngine *vm, const Common::Path &resourceFile);
777  virtual ~MacGuiImpl();
778 
779  Graphics::MacWindowManager *_windowManager = nullptr;
780 
781  virtual int getNumColors() const = 0;
782 
783  Graphics::Surface *surface() { return _surface; }
784  virtual uint32 getBlack() const;
785  virtual uint32 getWhite() const;
786 
787  uint32 _macWhite;
788  uint32 _macBlack;
789 
790  virtual const Common::String name() const = 0;
791 
792  Common::String readCString(uint8 *&data);
793  Common::String readPascalString(uint8 *&data);
794 
795  int toMacRoman(int unicode) const;
796 
797  void setPaletteDirty();
798  void updatePalette();
799 
800  virtual bool handleEvent(Common::Event event);
801 
802  static void menuCallback(int id, Common::String &name, void *data);
803  virtual bool initialize();
804  void updateWindowManager();
805  virtual void updateMenus();
806 
807  const Graphics::Font *getFont(FontId fontId);
808  virtual const Graphics::Font *getFontByScummId(int32 id) = 0;
809 
810  bool loadIcon(int id, Graphics::Surface **icon, Graphics::Surface **mask);
811  Graphics::Surface *loadPict(int id);
812 
813  virtual bool isVerbGuiActive() const { return false; }
814  virtual void reset() {}
815  virtual void resetAfterLoad() = 0;
816  virtual void update(int delta) = 0;
817 
818  virtual bool runQuitDialog();
819  virtual bool runRestartDialog();
820 
821  virtual void setupCursor(int &width, int &height, int &hotspotX, int &hotspotY, int &animate) = 0;
822 
823  virtual Graphics::Surface *textArea() { return nullptr; }
824  virtual void clearTextArea() {}
825  virtual void initTextAreaForActor(Actor *a, byte color) {}
826  virtual void printCharToTextArea(int chr, int x, int y, int color) {}
827 
828  void setMacGuiColors(Graphics::Palette &palette);
829 
830  MacDialogWindow *createWindow(Common::Rect bounds, MacDialogWindowStyle style = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
831  MacDialogWindow *createDialog(int dialogId);
832  MacDialogWindow *createDialog(int dialogId, Common::Rect bounds);
833  void drawBanner(char *message);
834  void undrawBanner();
835 
836  void drawBitmap(Graphics::Surface *s, Common::Rect r, const uint16 *bitmap, uint32 color) const;
837 };
838 
839 } // End of namespace Scumm
840 #endif
Definition: engine.h:103
void clear(bool shrinkArray=0)
Definition: hashmap.h:427
Definition: macgui_impl.h:52
Definition: macgui_impl.h:508
Definition: str.h:59
Definition: font.h:83
TextAlign
Definition: font.h:48
Definition: surface.h:67
Definition: macgui_impl.h:369
Definition: macgui_impl.h:353
Definition: macgui_impl.h:650
Definition: macgui_impl.h:552
Align the text to the left.
Definition: font.h:51
Definition: rect.h:144
Definition: path.h:52
Definition: macgui_impl.h:409
Definition: queue.h:42
Definition: macwindowmanager.h:147
Definition: macgui_impl.h:452
Definition: scumm.h:504
Definition: macgui_impl.h:334
Definition: macgui_impl.h:585
void push_back(const T &element)
Definition: array.h:180
Definition: hashmap.h:85
Definition: events.h:199
Definition: macgui_impl.h:655
Definition: formatinfo.h:28
Definition: rect.h:45
Definition: macmenu.h:94
size_type size() const
Definition: array.h:315
Definition: macgui_impl.h:249
Definition: macgui_impl.h:623
Definition: actor.h:97
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168
Definition: macgui_impl.h:113
Definition: system.h:161
Simple class for handling a palette data.
Definition: palette.h:51
Definition: macgui_impl.h:467
Definition: actor.h:30
Definition: macgui_impl.h:199
Definition: macgui_impl.h:266
Definition: atari-screen.h:44